diff --git a/app/build.gradle b/app/build.gradle index a86e27e60a98c4c55022980556826e76a6b9ff6b..c13d8b2f403b344bf54ecda1d4f34f9fd14492f9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -28,6 +28,7 @@ dependencies { androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' compile 'com.squareup.okhttp3:okhttp:3.8.1' compile 'com.android.support:cardview-v7:26.1.0' + compile 'com.android.support:design:26.1.0' compile 'com.android.support:recyclerview-v7:26.1.0' compile 'com.github.bumptech.glide:glide:4.2.0' } diff --git a/app/src/main/java/com/example/leo/fitnessdiy/ExerciseFragment.java b/app/src/main/java/com/example/leo/fitnessdiy/ExerciseFragment.java index 41f289e5f3fc6a8d51a006d08df760d32338c62c..ec8becc82eb7128d60c7efcd4f1786aa34cc03aa 100644 --- a/app/src/main/java/com/example/leo/fitnessdiy/ExerciseFragment.java +++ b/app/src/main/java/com/example/leo/fitnessdiy/ExerciseFragment.java @@ -1,12 +1,14 @@ package com.example.leo.fitnessdiy; import android.content.Context; +import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; /** @@ -64,7 +66,16 @@ public class ExerciseFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_exercise, container, false); + View view = inflater.inflate(R.layout.fragment_exercise, container, false); + Button plankButton = (Button)view.findViewById(R.id.plank_button); + plankButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent i = new Intent(getActivity(), PlankActivity.class); + startActivity(i); + } + }); + return view; } // TODO: Rename method, update argument and hook method into UI event @@ -105,4 +116,10 @@ public class ExerciseFragment extends Fragment { // TODO: Update argument type and name void onFragmentInteraction(Uri uri); } + + + + + + } diff --git a/app/src/main/java/com/example/leo/fitnessdiy/HomeActivity.java b/app/src/main/java/com/example/leo/fitnessdiy/HomeActivity.java index 11bedcf53226f31e3f73e2321a2c8f512e650919..ea1a0671b61f969a1549e00b74a26a46593adbac 100644 --- a/app/src/main/java/com/example/leo/fitnessdiy/HomeActivity.java +++ b/app/src/main/java/com/example/leo/fitnessdiy/HomeActivity.java @@ -2,6 +2,7 @@ package com.example.leo.fitnessdiy; import android.content.Intent; import android.net.Uri; +import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; @@ -13,6 +14,7 @@ public class HomeActivity extends AppCompatActivity implements ExerciseFragment.OnFragmentInteractionListener, HistoryFragment.OnFragmentInteractionListener{ + private FloatingActionButton chatButton; @Override public void onFragmentInteraction(Uri uri) { @@ -23,6 +25,8 @@ public class HomeActivity extends AppCompatActivity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); + chatButton = findViewById(R.id.chat_button); + chatButton.setImageResource(R.drawable.chat_icon); } public void openHistory(View view) { @@ -30,10 +34,7 @@ public class HomeActivity extends AppCompatActivity startActivity(i); } - public void startExcercise(View view) { - Intent i = new Intent(getApplicationContext(), ExerciseActivity.class); - startActivity(i); - } + public void changeFragment(View view){ Fragment fragment; @@ -45,7 +46,7 @@ public class HomeActivity extends AppCompatActivity ft.replace(R.id.home_fragment, fragment); ft.commit(); } - if(view == findViewById(R.id.exercise_button)){ + else if(view == findViewById(R.id.exercise_button)){ fragment = new ExerciseFragment(); FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); @@ -54,4 +55,7 @@ public class HomeActivity extends AppCompatActivity } } + public void goToChat(View view) { + + } } diff --git a/app/src/main/res/drawable/chat_icon.png b/app/src/main/res/drawable/chat_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3f8679dc97ac5fe57e9b22b6ba79c76e2c8792db Binary files /dev/null and b/app/src/main/res/drawable/chat_icon.png differ diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml index 47a494b687e61427a45fdde798eca0211f7bf127..8f7f8fa2c90587ce8a1431d5409694bc5b4f8689 100644 --- a/app/src/main/res/layout/activity_home.xml +++ b/app/src/main/res/layout/activity_home.xml @@ -27,12 +27,19 @@ android:text="@string/exercise" android:onClick="changeFragment"/> </LinearLayout> + <fragment - android:name="com.example.leo.fitnessdiy.ExerciseFragment" android:id="@+id/home_fragment" + android:name="com.example.leo.fitnessdiy.ExerciseFragment" android:layout_width="match_parent" - android:layout_height="match_parent" - /> + android:layout_height="471dp" /> + + <android.support.design.widget.FloatingActionButton + android:id="@+id/chat_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="right" + android:onClick="goToChat"/> diff --git a/app/src/main/res/layout/fragment_exercise.xml b/app/src/main/res/layout/fragment_exercise.xml index 83fbd4042372fea4a797d9d2c8b08814da1dbb1b..c28ca5dda596664c6ae265ce6576e3dc626c7533 100644 --- a/app/src/main/res/layout/fragment_exercise.xml +++ b/app/src/main/res/layout/fragment_exercise.xml @@ -4,10 +4,11 @@ android:layout_height="match_parent" tools:context="com.example.leo.fitnessdiy.ExerciseFragment"> - <!-- TODO: Update blank fragment layout --> - <TextView - android:layout_width="match_parent" - android:layout_height="match_parent" - android:text="EXERCISE" /> + <Button + android:id="@+id/plank_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Plank" + /> </FrameLayout>