From b87275c2126a1b0247d35c08e0fe336a6d89ce10 Mon Sep 17 00:00:00 2001 From: NikM3 Date: Sun, 23 Apr 2023 15:15:08 -0400 Subject: [PATCH] Bugfixes and stuff --- .idea/misc.xml | 3 +- ...nActivityTest.kt => ALoginActivityTest.kt} | 6 ++-- .../symphony/mrfit/ui/RegisterActivityTest.kt | 9 +++-- ...ityTest.kt => YUserProfileActivityTest.kt} | 17 +++++---- ...alityTest.kt => ZCoreFunctionalityTest.kt} | 12 +++---- .../mrfit/data/exercise/ExerciseRepository.kt | 36 ++++++++++--------- .../symphony/mrfit/ui/UserProfileActivity.kt | 7 ++-- .../mrfit/ui/WorkoutRoutineActivity.kt | 15 ++++---- .../mrfit/ui/WorkoutTemplateActivity.kt | 19 ++++------ .../main/res/layout/activity_user_profile.xml | 15 ++++---- .../res/layout/activity_workout_template.xml | 7 ++-- app/src/main/res/layout/card_exercise.xml | 6 ++-- 12 files changed, 78 insertions(+), 74 deletions(-) rename app/src/androidTest/java/com/symphony/mrfit/ui/{LoginActivityTest.kt => ALoginActivityTest.kt} (96%) rename app/src/androidTest/java/com/symphony/mrfit/ui/{UserProfileActivityTest.kt => YUserProfileActivityTest.kt} (95%) rename app/src/androidTest/java/com/symphony/mrfit/ui/{CoreFunctionalityTest.kt => ZCoreFunctionalityTest.kt} (96%) diff --git a/.idea/misc.xml b/.idea/misc.xml index 0ad17cb..773fe0f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,6 @@ - - + diff --git a/app/src/androidTest/java/com/symphony/mrfit/ui/LoginActivityTest.kt b/app/src/androidTest/java/com/symphony/mrfit/ui/ALoginActivityTest.kt similarity index 96% rename from app/src/androidTest/java/com/symphony/mrfit/ui/LoginActivityTest.kt rename to app/src/androidTest/java/com/symphony/mrfit/ui/ALoginActivityTest.kt index 696df75..e87018e 100644 --- a/app/src/androidTest/java/com/symphony/mrfit/ui/LoginActivityTest.kt +++ b/app/src/androidTest/java/com/symphony/mrfit/ui/ALoginActivityTest.kt @@ -1,7 +1,7 @@ /* - * Created by Team Symphony on 4/23/23, 3:46 AM + * Created by Team Symphony on 4/23/23, 3:14 PM * Copyright (c) 2023 . All rights reserved. - * Last modified 4/23/23, 3:46 AM + * Last modified 4/23/23, 1:53 PM */ package com.symphony.mrfit.ui @@ -18,7 +18,7 @@ import com.symphony.mrfit.R import org.junit.Rule import org.junit.Test -class LoginActivityTest { +class ALoginActivityTest { @get:Rule var activityScenarioRule = activityScenarioRule() diff --git a/app/src/androidTest/java/com/symphony/mrfit/ui/RegisterActivityTest.kt b/app/src/androidTest/java/com/symphony/mrfit/ui/RegisterActivityTest.kt index 7a0793b..09e317c 100644 --- a/app/src/androidTest/java/com/symphony/mrfit/ui/RegisterActivityTest.kt +++ b/app/src/androidTest/java/com/symphony/mrfit/ui/RegisterActivityTest.kt @@ -1,7 +1,7 @@ /* - * Created by Team Symphony on 4/23/23, 3:46 AM + * Created by Team Symphony on 4/23/23, 3:14 PM * Copyright (c) 2023 . All rights reserved. - * Last modified 4/23/23, 3:46 AM + * Last modified 4/23/23, 3:14 PM */ package com.symphony.mrfit.ui @@ -25,7 +25,10 @@ class RegisterActivityTest { onView(withId(R.id.registerEmail)) .perform(ViewActions.typeText(REAL_EMAIL)) onView(withId(R.id.registerPassword)) - .perform(ViewActions.typeText(LoginActivityTest.REAL_PASS), ViewActions.closeSoftKeyboard()) + .perform( + ViewActions.typeText(ALoginActivityTest.REAL_PASS), + ViewActions.closeSoftKeyboard() + ) onView(withId(R.id.registerButton)) .perform(ViewActions.click()) } diff --git a/app/src/androidTest/java/com/symphony/mrfit/ui/UserProfileActivityTest.kt b/app/src/androidTest/java/com/symphony/mrfit/ui/YUserProfileActivityTest.kt similarity index 95% rename from app/src/androidTest/java/com/symphony/mrfit/ui/UserProfileActivityTest.kt rename to app/src/androidTest/java/com/symphony/mrfit/ui/YUserProfileActivityTest.kt index 3f56c66..e541902 100644 --- a/app/src/androidTest/java/com/symphony/mrfit/ui/UserProfileActivityTest.kt +++ b/app/src/androidTest/java/com/symphony/mrfit/ui/YUserProfileActivityTest.kt @@ -1,7 +1,7 @@ /* - * Created by Team Symphony on 4/23/23, 3:46 AM + * Created by Team Symphony on 4/23/23, 3:14 PM * Copyright (c) 2023 . All rights reserved. - * Last modified 4/23/23, 3:46 AM + * Last modified 4/23/23, 2:02 PM */ package com.symphony.mrfit.ui @@ -14,10 +14,12 @@ import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.ext.junit.rules.activityScenarioRule import com.symphony.mrfit.R import org.hamcrest.CoreMatchers.not +import org.junit.FixMethodOrder import org.junit.Rule import org.junit.Test -class UserProfileActivityTest { +@FixMethodOrder +class YUserProfileActivityTest { @get:Rule var activityScenarioRule = activityScenarioRule() @@ -94,12 +96,12 @@ class UserProfileActivityTest { */ @Test fun notificationsButtonTest() { + Thread.sleep(500) Espresso.onView(withId(R.id.notificationsButton)) .perform(click()) Espresso.onView(withId(R.id.layout_notificationLogActivity)) .check(matches(isDisplayed())) Espresso.pressBack() - Thread.sleep(500) } /** @@ -107,12 +109,12 @@ class UserProfileActivityTest { */ @Test fun goalsButtonTest() { + Thread.sleep(500) Espresso.onView(withId(R.id.goalsButton)) .perform(click()) Espresso.onView(withId(R.id.layout_goalsActivity)) .check(matches(isDisplayed())) Espresso.pressBack() - Thread.sleep(500) } /** @@ -120,12 +122,12 @@ class UserProfileActivityTest { */ @Test fun historyButtonTest() { + Thread.sleep(500) Espresso.onView(withId(R.id.historyButton)) .perform(click()) Espresso.onView(withId(R.id.layout_workoutHistoryActivity)) .check(matches(isDisplayed())) Espresso.pressBack() - Thread.sleep(500) } /** @@ -133,12 +135,12 @@ class UserProfileActivityTest { */ @Test fun exerciseButtonTest() { + Thread.sleep(500) Espresso.onView(withId(R.id.customExercisesButton)) .perform(click()) Espresso.onView(withId(R.id.layout_customExerciseActivity)) .check(matches(isDisplayed())) Espresso.pressBack() - Thread.sleep(500) } /** @@ -146,6 +148,7 @@ class UserProfileActivityTest { */ @Test fun logoutButtonTest() { + Thread.sleep(500) Espresso.onView(withId(R.id.logoutButton)) .perform(click()) Espresso.onView(withId(R.id.layout_loginActivity)) diff --git a/app/src/androidTest/java/com/symphony/mrfit/ui/CoreFunctionalityTest.kt b/app/src/androidTest/java/com/symphony/mrfit/ui/ZCoreFunctionalityTest.kt similarity index 96% rename from app/src/androidTest/java/com/symphony/mrfit/ui/CoreFunctionalityTest.kt rename to app/src/androidTest/java/com/symphony/mrfit/ui/ZCoreFunctionalityTest.kt index 6aa60e6..32906e1 100644 --- a/app/src/androidTest/java/com/symphony/mrfit/ui/CoreFunctionalityTest.kt +++ b/app/src/androidTest/java/com/symphony/mrfit/ui/ZCoreFunctionalityTest.kt @@ -1,7 +1,7 @@ /* - * Created by Team Symphony on 4/22/23, 6:21 AM + * Created by Team Symphony on 4/23/23, 3:14 PM * Copyright (c) 2023 . All rights reserved. - * Last modified 4/22/23, 6:05 AM + * Last modified 4/23/23, 2:37 PM */ package com.symphony.mrfit.ui @@ -22,7 +22,7 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4ClassRunner::class) @LargeTest -class CoreFunctionalityTest { +class ZCoreFunctionalityTest { @get:Rule var activityScenarioRule = activityScenarioRule() @@ -81,7 +81,7 @@ class CoreFunctionalityTest { Thread.sleep(500) Espresso.onView(withId(R.id.exerciseListView)) .perform(actionOnItemAtPosition(0, click())) - Thread.sleep(500) + Thread.sleep(1000) Espresso.onView(withId(R.id.saveTemplateButton)) .perform(click()) Thread.sleep(1000) @@ -91,7 +91,7 @@ class CoreFunctionalityTest { Thread.sleep(500) Espresso.onView(withId(R.id.exerciseListView)) .perform(actionOnItemAtPosition(1, click())) - Thread.sleep(500) + Thread.sleep(1000) Espresso.onView(withId(R.id.saveTemplateButton)) .perform(click()) Thread.sleep(1000) @@ -101,7 +101,7 @@ class CoreFunctionalityTest { Thread.sleep(500) Espresso.onView(withId(R.id.exerciseListView)) .perform(actionOnItemAtPosition(2, click())) - Thread.sleep(500) + Thread.sleep(1000) Espresso.onView(withId(R.id.saveTemplateButton)) .perform(click()) Thread.sleep(1000) diff --git a/app/src/main/java/com/symphony/mrfit/data/exercise/ExerciseRepository.kt b/app/src/main/java/com/symphony/mrfit/data/exercise/ExerciseRepository.kt index 178542e..73fcb99 100644 --- a/app/src/main/java/com/symphony/mrfit/data/exercise/ExerciseRepository.kt +++ b/app/src/main/java/com/symphony/mrfit/data/exercise/ExerciseRepository.kt @@ -1,7 +1,7 @@ /* - * Created by Team Symphony on 4/22/23, 7:14 PM + * Created by Team Symphony on 4/23/23, 3:14 PM * Copyright (c) 2023 . All rights reserved. - * Last modified 4/22/23, 7:09 PM + * Last modified 4/23/23, 2:34 PM */ package com.symphony.mrfit.data.exercise @@ -123,24 +123,28 @@ class ExerciseRepository { * Retrieve an array list of exercises belonging to the current User */ suspend fun getExerciseList(): ArrayList { - val user = auth.currentUser!! val exeList = ArrayList() - Log.d(TAG, "Getting exercises belonging to ${user.uid}") - try { - val result = database.collection(EXERCISE_COLLECTION) - .whereEqualTo(OWNER_FIELD, user.uid) - .get() - .await() + val user = auth.currentUser + if (user != null) { + Log.d(TAG, "Getting exercises belonging to ${user.uid}") + try { + val result = database.collection(EXERCISE_COLLECTION) + .whereEqualTo(OWNER_FIELD, user.uid) + .get() + .await() - for (document in result) { - Log.d(TAG, "${document.id} => ${document.data}") - val t = document.toObject() - exeList.add(t) + for (document in result) { + Log.d(TAG, "${document.id} => ${document.data}") + val t = document.toObject() + exeList.add(t) + } + } catch (e: java.lang.Exception) { + Log.d(TAG, "Error getting documents: ", e) } - } catch (e: java.lang.Exception) { - Log.d(TAG, "Error getting documents: ", e) + return exeList + } else { + return exeList } - return exeList } /** diff --git a/app/src/main/java/com/symphony/mrfit/ui/UserProfileActivity.kt b/app/src/main/java/com/symphony/mrfit/ui/UserProfileActivity.kt index 3188ea2..6f1c259 100644 --- a/app/src/main/java/com/symphony/mrfit/ui/UserProfileActivity.kt +++ b/app/src/main/java/com/symphony/mrfit/ui/UserProfileActivity.kt @@ -1,7 +1,7 @@ /* - * Created by Team Symphony on 4/19/23, 7:07 PM + * Created by Team Symphony on 4/23/23, 3:14 PM * Copyright (c) 2023 . All rights reserved. - * Last modified 4/19/23, 7:07 PM + * Last modified 4/23/23, 2:31 PM */ package com.symphony.mrfit.ui @@ -119,8 +119,6 @@ class UserProfileActivity : AppCompatActivity() { } } - // Hide the screen till loading is done - screen.visibility = View.GONE spinner.visibility = View.VISIBLE // Get data of current User and populate the page @@ -148,7 +146,6 @@ class UserProfileActivity : AppCompatActivity() { weightText.text = getString(R.string.weight_value, weightText.text) } - screen.visibility = View.VISIBLE spinner.visibility = View.GONE }) diff --git a/app/src/main/java/com/symphony/mrfit/ui/WorkoutRoutineActivity.kt b/app/src/main/java/com/symphony/mrfit/ui/WorkoutRoutineActivity.kt index f3842e8..e806377 100644 --- a/app/src/main/java/com/symphony/mrfit/ui/WorkoutRoutineActivity.kt +++ b/app/src/main/java/com/symphony/mrfit/ui/WorkoutRoutineActivity.kt @@ -1,7 +1,7 @@ /* - * Created by Team Symphony on 4/22/23, 5:12 PM + * Created by Team Symphony on 4/23/23, 3:14 PM * Copyright (c) 2023 . All rights reserved. - * Last modified 4/22/23, 5:12 PM + * Last modified 4/23/23, 3:14 PM */ package com.symphony.mrfit.ui @@ -49,7 +49,7 @@ class WorkoutRoutineActivity : AppCompatActivity() { private lateinit var passedRoutineID: String private var routineName: String? = null private var playlist: String? = null - private var exercises: ArrayList? = null + private var exercises: ArrayList = ArrayList() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -120,16 +120,19 @@ class WorkoutRoutineActivity : AppCompatActivity() { routinePlaylist.setText(BLANK) } if (routine.workoutList != null) { - if (routine.workoutList.isNotEmpty()) { + if (routine.workoutList.isEmpty()) { + exercises = routine.workoutList + placeholderText.visibility = View.VISIBLE + } else { spinner.visibility = View.VISIBLE exercises = routine.workoutList - exerciseViewModel.getWorkouts(exercises!!) + exerciseViewModel.getWorkouts(exercises) } } }) exerciseViewModel.workoutList.observe(this, Observer { val workList = it ?: return@Observer - workoutList.adapter = WorkoutAdapter(this, workList, passedRoutineID, exercises!!) + workoutList.adapter = WorkoutAdapter(this, workList, passedRoutineID, exercises) placeholderText.visibility = View.GONE workoutList.visibility = View.VISIBLE spinner.visibility = View.GONE diff --git a/app/src/main/java/com/symphony/mrfit/ui/WorkoutTemplateActivity.kt b/app/src/main/java/com/symphony/mrfit/ui/WorkoutTemplateActivity.kt index 08e8108..e26af70 100644 --- a/app/src/main/java/com/symphony/mrfit/ui/WorkoutTemplateActivity.kt +++ b/app/src/main/java/com/symphony/mrfit/ui/WorkoutTemplateActivity.kt @@ -1,7 +1,7 @@ /* - * Created by Team Symphony on 4/22/23, 7:14 PM + * Created by Team Symphony on 4/23/23, 3:14 PM * Copyright (c) 2023 . All rights reserved. - * Last modified 4/22/23, 7:14 PM + * Last modified 4/23/23, 3:14 PM */ package com.symphony.mrfit.ui @@ -62,16 +62,12 @@ class WorkoutTemplateActivity : AppCompatActivity() { this, ExerciseViewModelFactory() )[ExerciseViewModel::class.java] - val home = binding.BackButton - home.setOnClickListener { - val intent = Intent(this, Workout::class.java) - startActivity(intent) + val home = binding.BackButton + home.setOnClickListener { + val intent = Intent(this, Workout::class.java) + startActivity(intent) - } - } - - override fun onStart() { - super.onStart() + } val storage: FirebaseStorage = Firebase.storage @@ -255,7 +251,6 @@ class WorkoutTemplateActivity : AppCompatActivity() { } setResult(Activity.RESULT_OK) }) - } private fun gotoExerciseScreen() { diff --git a/app/src/main/res/layout/activity_user_profile.xml b/app/src/main/res/layout/activity_user_profile.xml index 0adfb7d..f40d87c 100644 --- a/app/src/main/res/layout/activity_user_profile.xml +++ b/app/src/main/res/layout/activity_user_profile.xml @@ -1,8 +1,8 @@ @@ -88,8 +87,8 @@ android:id="@+id/heightValueTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:textColor="@color/black" - android:text="@string/PLACEHOLDER_NUMBER" /> + android:text="--" + android:textColor="@color/black" /> + android:text="--" + android:textColor="@color/black" />