Skip to content

Commit

Permalink
Bugfixes and stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
NikM3 committed Apr 23, 2023
1 parent 422637f commit b87275c
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 74 deletions.
3 changes: 1 addition & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<LoginActivity>()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<UserProfileActivity>()
Expand Down Expand Up @@ -94,58 +96,59 @@ 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)
}

/**
* Test if the Goals button navigates properly
*/
@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)
}

/**
* Test if the History button navigates properly
*/
@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)
}

/**
* Test if the Exercises button navigates properly
*/
@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)
}

/**
* Test if the Logout button navigates properly
*/
@Test
fun logoutButtonTest() {
Thread.sleep(500)
Espresso.onView(withId(R.id.logoutButton))
.perform(click())
Espresso.onView(withId(R.id.layout_loginActivity))
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -22,7 +22,7 @@ import org.junit.runner.RunWith

@RunWith(AndroidJUnit4ClassRunner::class)
@LargeTest
class CoreFunctionalityTest {
class ZCoreFunctionalityTest {

@get:Rule
var activityScenarioRule = activityScenarioRule<MainActivity>()
Expand Down Expand Up @@ -81,7 +81,7 @@ class CoreFunctionalityTest {
Thread.sleep(500)
Espresso.onView(withId(R.id.exerciseListView))
.perform(actionOnItemAtPosition<RecyclerView.ViewHolder>(0, click()))
Thread.sleep(500)
Thread.sleep(1000)
Espresso.onView(withId(R.id.saveTemplateButton))
.perform(click())
Thread.sleep(1000)
Expand All @@ -91,7 +91,7 @@ class CoreFunctionalityTest {
Thread.sleep(500)
Espresso.onView(withId(R.id.exerciseListView))
.perform(actionOnItemAtPosition<RecyclerView.ViewHolder>(1, click()))
Thread.sleep(500)
Thread.sleep(1000)
Espresso.onView(withId(R.id.saveTemplateButton))
.perform(click())
Thread.sleep(1000)
Expand All @@ -101,7 +101,7 @@ class CoreFunctionalityTest {
Thread.sleep(500)
Espresso.onView(withId(R.id.exerciseListView))
.perform(actionOnItemAtPosition<RecyclerView.ViewHolder>(2, click()))
Thread.sleep(500)
Thread.sleep(1000)
Espresso.onView(withId(R.id.saveTemplateButton))
.perform(click())
Thread.sleep(1000)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -123,24 +123,28 @@ class ExerciseRepository {
* Retrieve an array list of exercises belonging to the current User
*/
suspend fun getExerciseList(): ArrayList<Exercise> {
val user = auth.currentUser!!
val exeList = ArrayList<Exercise>()
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<Exercise>()
exeList.add(t)
for (document in result) {
Log.d(TAG, "${document.id} => ${document.data}")
val t = document.toObject<Exercise>()
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
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -148,7 +146,6 @@ class UserProfileActivity : AppCompatActivity() {
weightText.text = getString(R.string.weight_value, weightText.text)
}

screen.visibility = View.VISIBLE
spinner.visibility = View.GONE
})

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<String>? = null
private var exercises: ArrayList<String> = ArrayList()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -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
Expand Down
19 changes: 7 additions & 12 deletions app/src/main/java/com/symphony/mrfit/ui/WorkoutTemplateActivity.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -255,7 +251,6 @@ class WorkoutTemplateActivity : AppCompatActivity() {
}
setResult(Activity.RESULT_OK)
})

}

private fun gotoExerciseScreen() {
Expand Down
15 changes: 7 additions & 8 deletions app/src/main/res/layout/activity_user_profile.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Created by Team Symphony on 4/21/23, 10:18 PM
~ Created by Team Symphony on 4/23/23, 3:14 PM
~ Copyright (c) 2023 . All rights reserved.
~ Last modified 4/21/23, 8:40 PM
~ Last modified 4/23/23, 2:31 PM
-->

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
Expand Down Expand Up @@ -47,7 +47,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="@string/PLACEHOLDER_TEXT"
android:textColor="@color/black"
android:textSize="20sp"
android:textStyle="bold" />
Expand Down Expand Up @@ -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" />

<TextView
android:id="@+id/heightLabelTextView"
Expand All @@ -115,8 +114,8 @@
android:id="@+id/weightValueTextView"
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" />

<TextView
android:id="@+id/weightLabelTextView"
Expand All @@ -142,7 +141,7 @@
android:id="@+id/ageValueTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/PLACEHOLDER_NUMBER"
android:text="--"
android:textColor="@color/black" />

<TextView
Expand Down
Loading

0 comments on commit b87275c

Please sign in to comment.