Skip to content

Commit

Permalink
Address general comments
Browse files Browse the repository at this point in the history
  • Loading branch information
adhiamboperes committed Sep 9, 2024
1 parent 0397de7 commit 063b97a
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ class ClassroomListFragmentPresenter @Inject constructor(
private fun handleProfileOnboardingState(profile: Profile) {
// App onboarding is completed by the first profile on the app(SOLE_LEARNER or SUPERVISOR),
// while profile onboarding is completed by each profile.
if (!profile.completedProfileOboarding) {
if (!profile.completedProfileOnboarding) {
markProfileOnboardingEnded(profileId)
if (profile.profileType == ProfileType.SOLE_LEARNER ||
profile.profileType == ProfileType.SUPERVISOR
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package org.oppia.android.app.home

import org.oppia.android.app.model.ProfileType

/** Listener for when a user wishes to exit their profile. */
interface ExitProfileListener {

/**
* Called when back press is clicked on the HomeScreen.
*
* A SOLE_LEARNER exits the app completely while other [ProfileType]s are routed to the
* [ProfileChooserActivity].
* Routing behaviour may change based on [ProfileType]
*/
fun exitProfile(profileType: ProfileType)
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class HomeFragmentPresenter @Inject constructor(
private fun handleProfileOnboardingState(profile: Profile) {
// App onboarding is completed by the first profile on the app(SOLE_LEARNER or SUPERVISOR),
// while profile onboarding is completed by each profile.
if (!profile.completedProfileOboarding) {
if (!profile.completedProfileOnboarding) {
markProfileOnboardingEnded(profileId)
if (profile.profileType == ProfileType.SOLE_LEARNER ||
profile.profileType == ProfileType.SUPERVISOR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class AudioLanguageFragmentPresenter @Inject constructor(

binding.onboardingNavigationContinue.setOnClickListener {
updateSelectedAudioLanguage(selectedLanguage, profileId).also {
loginToProfile(profileId)
logInToProfile(profileId)
}
}

Expand Down Expand Up @@ -159,7 +159,7 @@ class AudioLanguageFragmentPresenter @Inject constructor(
}
}

private fun loginToProfile(profileId: ProfileId) {
private fun logInToProfile(profileId: ProfileId) {
profileManagementController.loginToProfile(profileId).toLiveData().observe(
fragment,
{ result ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class ProfileChooserActivityPresenter @Inject constructor(
isAdmin = true
)
} else {
// TODO(#482): Ensures that an admin profile is present. Remove when there is proper admin account creation.
// TODO(#482): Ensures that an admin profile is present.
// This can be removed once the new onboarding flow is finalized, as it will handle the creation of an admin profile.
profileManagementController.addProfile(
name = "Admin",
pin = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class ProfileChooserFragmentPresenter @Inject constructor(
if (enableOnboardingFlowV2.value) {
ensureProfileOnboarded(model.profile)
} else {
loginToProfile(model.profile)
logInToProfile(model.profile)
}
}
}
Expand Down Expand Up @@ -256,8 +256,8 @@ class ProfileChooserFragmentPresenter @Inject constructor(
}

private fun ensureProfileOnboarded(profile: Profile) {
if (profile.profileType == ProfileType.SUPERVISOR || profile.completedProfileOboarding) {
loginToProfile(profile)
if (profile.profileType == ProfileType.SUPERVISOR || profile.completedProfileOnboarding) {
logInToProfile(profile)
} else {
launchOnboardingScreen(profile.id, profile.name)
}
Expand All @@ -277,7 +277,7 @@ class ProfileChooserFragmentPresenter @Inject constructor(
activity.startActivity(intent)
}

private fun loginToProfile(profile: Profile) {
private fun logInToProfile(profile: Profile) {
if (profile.pin.isNullOrBlank()) {
profileManagementController.loginToProfile(profile.id).toLiveData().observe(
fragment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,10 @@ class SplashActivityPresenter @Inject constructor(

private fun proceedBasedOnProfileState(profile: Profile) {
when {
profile.startedProfileOboarding && !profile.completedProfileOboarding -> {
profile.startedProfileOnboarding && !profile.completedProfileOnboarding -> {
resumeOnboarding(profile.id, profile.name)
}
profile.startedProfileOboarding && profile.completedProfileOboarding -> {
profile.startedProfileOnboarding && profile.completedProfileOnboarding -> {
loginToProfile(profile.id)
}
else -> launchOnboardingActivity()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ class ProfileManagementController @Inject constructor(
it,
ProfileActionStatus.PROFILE_NOT_FOUND
)
val updatedProfile = profile.toBuilder().setStartedProfileOboarding(true).build()
val updatedProfile = profile.toBuilder().setStartedProfileOnboarding(true).build()
val profileDatabaseBuilder = it.toBuilder().putProfiles(
profileId.internalId,
updatedProfile
Expand Down Expand Up @@ -392,7 +392,7 @@ class ProfileManagementController @Inject constructor(
it,
ProfileActionStatus.PROFILE_NOT_FOUND
)
val updatedProfile = profile.toBuilder().setCompletedProfileOboarding(true).build()
val updatedProfile = profile.toBuilder().setCompletedProfileOnboarding(true).build()
val profileDatabaseBuilder = it.toBuilder().putProfiles(
profileId.internalId,
updatedProfile
Expand Down
9 changes: 0 additions & 9 deletions model/src/main/proto/arguments.proto
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,6 @@ message ReadingTextSizeFragmentStateBundle {
message AudioLanguageActivityParams {
// The default audio language previously selected by the user (upon opening the activity).
AudioLanguage audio_language = 1;

// The internal Id associated with the profile.
int32 profile_id = 2;
}

// The bundle of properties that are saved upon configuration changes in AudioLanguageActivity.
Expand All @@ -281,9 +278,6 @@ message AudioLanguageActivityResultBundle {
message AudioLanguageFragmentArguments {
// The default audio language previously selected by the user (upon opening the fragment).
AudioLanguage audio_language = 1;

// The internal Id associated with the profile.
int32 profile_id = 2;
}

// The bundle of properties that are saved upon configuration changes in AudioLanguageFragment.
Expand Down Expand Up @@ -897,9 +891,6 @@ message WalkthroughFinalFragmentArguments {
message IntroActivityParams {
// The nickname associated with a newly created profile.
string profile_nickname = 1;

// The internal Id associated with the newly created profile.
int32 profile_id = 2;
}

// Arguments required when creating a new IntroFragment.
Expand Down
8 changes: 4 additions & 4 deletions model/src/main/proto/profile.proto
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ message Profile {
// Represents the type of user which informs the configuration options available to them.
ProfileType profile_type = 20;

// Indicates whether this profile has started the onboarding flow.
bool started_profile_oboarding = 21;
// Indicates that this profile has viewed the relevant onboarding introduction screen.
bool started_profile_onboarding = 21;

// Indicates whether this profile has completed the onboarding flow.
bool completed_profile_oboarding = 22;
// Indicates that this profile has reached the home screen for the first time.
bool completed_profile_onboarding = 22;
}

// Represents the type of user using the app.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.google.common.truth.IntegerSubject
import com.google.common.truth.IterableSubject
import com.google.common.truth.LongSubject
import com.google.common.truth.StringSubject
import com.google.common.truth.Subject
import com.google.common.truth.Truth.assertAbout
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.extensions.proto.LiteProtoSubject
Expand Down Expand Up @@ -2473,7 +2472,7 @@ class EventLogSubject private constructor(
* This method never fails since the underlying property defaults to empty string if it's not
* defined in the context.
*/
fun hasProfileIdThat(): Subject = assertThat(actual.profileId)
fun hasProfileIdThat(): LiteProtoSubject = assertThat(actual.profileId)

companion object {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class ProfileTestHelperTest {
}

@Test
fun testUpdateProfile_updateProfileType_checkIsSuccessful() {
fun testUpdateProfile_updateProfileType_profileTypeShouldBeUpdated() {
profileTestHelper.addOnlyAdminProfile()
val profileId = profileManagementController.getCurrentProfileId()
val updateProvider = profileTestHelper.updateProfileType(profileId!!, ProfileType.SUPERVISOR)
Expand Down

0 comments on commit 063b97a

Please sign in to comment.