Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proto config files for feature and required class. #4869

Closed
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
f255fae
Add proto config files for feature and required class.
KevinGitonga Feb 6, 2023
f583167
Add Bazel config on profile Build.bazel.
KevinGitonga Feb 6, 2023
19564c4
Fix lint buildifier issue on profile Build.bazel.
KevinGitonga Feb 6, 2023
d89f05d
Add profileId decorator to more Activities and refactor to use the same.
KevinGitonga Feb 7, 2023
ecd09ae
Remove redundant Kdoc exemption.
KevinGitonga Feb 7, 2023
e13b2c1
Add dependency on library to App module to resolve dependency issues.
KevinGitonga Feb 8, 2023
1cdbbb0
Refactor tests to use CurrentUserProfileIdIntentDecorator.kt instead …
KevinGitonga Feb 8, 2023
5866d69
Update to use ProfileId from protoExtra.
KevinGitonga Feb 8, 2023
31c1621
Add Activity tests for this enhancement and also make changes as advi…
KevinGitonga Feb 9, 2023
3b17968
Merge branch 'develop' into profile_id_provision_feature
KevinGitonga Feb 9, 2023
43141c9
Refactor to remove internalId usages to ProfileId directly.
KevinGitonga Feb 14, 2023
2f8de67
Merge branch 'oppia:develop' into profile_id_provision_feature
KevinGitonga Feb 14, 2023
9dcf79f
Merge remote-tracking branch 'origin/profile_id_provision_feature' in…
KevinGitonga Feb 14, 2023
b6f7820
Remove redundant exemptions and fix some failing tests.
KevinGitonga Feb 14, 2023
8076486
Fix some failing tests.
KevinGitonga Feb 15, 2023
c7c55b0
Fix some failing tests.
KevinGitonga Feb 15, 2023
7215556
Use getDefautInstance.
KevinGitonga Feb 15, 2023
e619ecb
Fix more failing tests.
KevinGitonga Feb 15, 2023
6797b06
Fix more failing tests.
KevinGitonga Feb 15, 2023
104c0c9
Fix more failing tests.
KevinGitonga Feb 15, 2023
7f8a9c9
More refactor PR per reviewer's comments.
KevinGitonga Feb 16, 2023
1d4539e
More refactor for feature.
KevinGitonga Feb 16, 2023
e3883b2
Fix some failing tests.
KevinGitonga Feb 17, 2023
e6a989d
Remove redundant Kdoc exemptions..
KevinGitonga Feb 17, 2023
b198b6e
Refactor Fragments to use similar pattern instead of independently de…
KevinGitonga Feb 20, 2023
a4d5ef2
Remove redundant kdoc exemptions.
KevinGitonga Feb 20, 2023
30c6013
Refactor CurrentUserProfileIdIntentDecorator.kt.
KevinGitonga Feb 20, 2023
0df8b14
Fix failing tests after refactor.
KevinGitonga Feb 20, 2023
c694de7
Merge branch 'develop' into profile_id_provision_feature
KevinGitonga Feb 20, 2023
6c875ee
Fix failing tests after refactor.
KevinGitonga Feb 20, 2023
1d2b73c
Add tests covering all fragments using this feature.
KevinGitonga Feb 21, 2023
91fba7c
Fix some failing tests.
KevinGitonga Feb 21, 2023
a77a7ac
Fix some failing tests.
KevinGitonga Feb 22, 2023
7c39d7f
Fix some failing tests.
KevinGitonga Feb 22, 2023
7cb44ab
Switch from allOf to anyOf, since no way to add ProfileId extra.
KevinGitonga Feb 22, 2023
ec70ac6
Merge branch 'oppia:develop' into profile_id_provision_feature
KevinGitonga Feb 27, 2023
9650c0a
Make changes per reviewer's comments also self review viewmodels and …
KevinGitonga Feb 27, 2023
76476f0
Fix failing tests.
KevinGitonga Feb 27, 2023
8dfe4cb
Update some files to new pattern.
KevinGitonga Feb 28, 2023
03601e0
Add omitted bazel config.
KevinGitonga Feb 28, 2023
e295d16
Merge branch 'develop' into profile_id_provision_feature
KevinGitonga Mar 24, 2023
9092288
Revert "Merge branch 'develop' into profile_id_provision_feature"
KevinGitonga Mar 24, 2023
1b83300
Revert "Merge branch 'develop' into profile_id_provision_feature"
KevinGitonga Mar 24, 2023
f08303d
Merge remote-tracking branch 'origin/profile_id_provision_feature' in…
KevinGitonga Mar 24, 2023
773044f
Revert "Revert "Merge branch 'develop' into profile_id_provision_feat…
KevinGitonga Mar 24, 2023
757c915
Revert and merge some files to align PR.
KevinGitonga Mar 24, 2023
3f00192
Fix some failing tests.
KevinGitonga Mar 24, 2023
e12ccbe
Fix some failing tests.
KevinGitonga Mar 24, 2023
d99ed4d
updates based on reviewer's comments.
KevinGitonga Mar 27, 2023
12ba091
Fix some failing tests.
KevinGitonga Mar 27, 2023
d79b0e8
Merge branch 'develop' into profile_id_provision_feature
KevinGitonga Mar 30, 2023
89e0a4a
Revert removed file after merge.
KevinGitonga Mar 30, 2023
09a4b06
Refactor RecentlyPlayedFragmentTest.kt file.
KevinGitonga Mar 30, 2023
1d05c38
Fix failing tests by reverting recently_played_fragment.xml file.
KevinGitonga Mar 30, 2023
d39ea1d
Merge branch 'oppia:develop' into profile_id_provision_feature
KevinGitonga Apr 3, 2023
22f058b
Integrate some changes from develop that were breaking this PR.
KevinGitonga Apr 3, 2023
76886d3
Fix failing tests.
KevinGitonga Apr 3, 2023
36f3b51
Resolve issues per reviewer's comments.
KevinGitonga Apr 3, 2023
1b7d505
Refactor default instance to use 0.
KevinGitonga Apr 3, 2023
cd41e49
Refactor default instance to use 0.
KevinGitonga Apr 3, 2023
69929a9
Add regex checks for ProfileId.
KevinGitonga Apr 4, 2023
1cffcad
Reformat activities to integrate with regex checks.
KevinGitonga Apr 4, 2023
7894473
Remove redundant Kdoc exemption.
KevinGitonga Apr 4, 2023
0426cb8
Remove redundant Kdoc exemption.
KevinGitonga Apr 4, 2023
dbe4740
Fix some failing tests after refactor.
KevinGitonga Apr 4, 2023
fbe0ce6
Fix some regex fail checks.
KevinGitonga Apr 5, 2023
b60732c
Update test's.
KevinGitonga Apr 5, 2023
3773844
Update test's.
KevinGitonga Apr 5, 2023
f28d12a
Merge branch 'develop' into profile_id_provision_feature
KevinGitonga Apr 20, 2023
4b282c0
Revert "Merge branch 'develop' into profile_id_provision_feature"
KevinGitonga Apr 20, 2023
54e3be5
Revert "Revert "Merge branch 'develop' into profile_id_provision_feat…
KevinGitonga Apr 20, 2023
2bc06d6
Revert "Merge branch 'develop' into profile_id_provision_feature"
KevinGitonga Apr 20, 2023
f1bfd4b
Revert "Revert "Merge branch 'develop' into profile_id_provision_feat…
KevinGitonga Apr 20, 2023
308465f
Merge remote-tracking branch 'origin/profile_id_provision_feature' in…
KevinGitonga Apr 20, 2023
c93eab4
Merge branch 'develop' into profile_id_provision_feature
KevinGitonga May 2, 2023
0fc52e2
Inline conflicting files during merge.
KevinGitonga May 2, 2023
efe957b
Update some tests to prevent breaking tests after adding regex checks.
KevinGitonga May 2, 2023
a5864fc
Merge branch 'oppia:develop' into profile_id_provision_feature
KevinGitonga May 9, 2023
de21bd7
Merge branch 'develop' into profile_id_provision_feature
KevinGitonga May 11, 2023
ae52607
Fix pending failing test's.
KevinGitonga May 11, 2023
3848a78
Merge branch 'oppia:develop' into profile_id_provision_feature
KevinGitonga May 16, 2023
598f25b
Merge branch 'oppia:develop' into profile_id_provision_feature
KevinGitonga May 29, 2023
dc65274
Merge branch 'develop' into profile_id_provision_feature
KevinGitonga Jun 15, 2023
6474ed2
Merge changes and clean PR after merge conflicts.
KevinGitonga Jun 15, 2023
172773a
Fix some failing tests.
KevinGitonga Jun 19, 2023
9c328fb
Merge branch 'oppia:develop' into profile_id_provision_feature
KevinGitonga Jun 19, 2023
ffffacf
Fix Kdoc issues.
KevinGitonga Jun 19, 2023
3c9fb79
Merge remote-tracking branch 'origin/profile_id_provision_feature' in…
KevinGitonga Jun 19, 2023
e774bf0
Merge branch 'oppia:develop' into profile_id_provision_feature
KevinGitonga Jun 20, 2023
3f9753c
Fix more failing tests.
KevinGitonga Jun 20, 2023
dfbbc20
Merge branch 'develop' into profile_id_provision_feature
KevinGitonga Jun 21, 2023
3a0dce0
Merge branch 'develop' into profile_id_provision_feature
KevinGitonga Jun 26, 2023
8c7aaa7
Update ExplorationActiveTimeControllerTest.kt to invoke startPlayinhN…
KevinGitonga Jun 26, 2023
0eb896c
Merge branch 'develop' into profile_id_provision_feature
KevinGitonga Aug 23, 2023
ef34293
Minor updates per reviewer's comments.
KevinGitonga Aug 23, 2023
c42f1d8
Merge branch 'develop' into profile_id_provision_feature
adhiamboperes Sep 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ kt_android_library(
"//utility/src/main/java/org/oppia/android/util/extensions:bundle_extensions",
"//utility/src/main/java/org/oppia/android/util/parser/image:image_loader",
"//utility/src/main/java/org/oppia/android/util/parser/image:image_parsing_annonations",
"//utility/src/main/java/org/oppia/android/util/profile:current_user_profile_id_intent_decorator",
"//utility/src/main/java/org/oppia/android/util/statusbar:status_bar_color",
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import org.oppia.android.app.activity.ActivityComponentImpl
import org.oppia.android.app.activity.InjectableAppCompatActivity
import org.oppia.android.app.administratorcontrols.appversion.AppVersionActivity
import org.oppia.android.app.administratorcontrols.learneranalytics.ProfileAndDeviceIdActivity
import org.oppia.android.app.drawer.NAVIGATION_PROFILE_ID_ARGUMENT_KEY
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.ScreenName.ADMINISTRATOR_CONTROLS_ACTIVITY
import org.oppia.android.app.settings.profile.ProfileEditFragment
import org.oppia.android.app.settings.profile.ProfileListActivity
import org.oppia.android.app.settings.profile.ProfileListFragment
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.util.extensions.getStringFromBundle
import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.decorateWithScreenName
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.decorateWithUserProfileId
import javax.inject.Inject

/** Argument key for of title for selected controls in [AdministratorControlsActivity]. */
Expand Down Expand Up @@ -114,15 +115,13 @@ class AdministratorControlsActivity :
/** Returns an [Intent] to start this activity. */
fun createAdministratorControlsActivityIntent(context: Context, profileId: Int?): Intent {
val intent = Intent(context, AdministratorControlsActivity::class.java)
intent.putExtra(NAVIGATION_PROFILE_ID_ARGUMENT_KEY, profileId)
intent.decorateWithScreenName(ADMINISTRATOR_CONTROLS_ACTIVITY)
intent.decorateWithUserProfileId(
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
ProfileId.newBuilder().apply { internalId = profileId!! }
.build()
)
return intent
}

/** Returns the argument key used to specify the user's internal profile ID. */
fun getIntentKey(): String {
return NAVIGATION_PROFILE_ID_ARGUMENT_KEY
}
}

override fun onBackPressed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import org.oppia.android.app.administratorcontrols.administratorcontrolsitemview
import org.oppia.android.app.administratorcontrols.administratorcontrolsitemviewmodel.AdministratorControlsItemViewModel
import org.oppia.android.app.administratorcontrols.administratorcontrolsitemviewmodel.AdministratorControlsProfileAndDeviceIdViewModel
import org.oppia.android.app.administratorcontrols.administratorcontrolsitemviewmodel.AdministratorControlsProfileViewModel
import org.oppia.android.app.drawer.NAVIGATION_PROFILE_ID_ARGUMENT_KEY
import org.oppia.android.app.fragment.FragmentScope
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.recyclerview.BindableAdapter
Expand All @@ -24,6 +23,7 @@ import org.oppia.android.databinding.AdministratorControlsFragmentBinding
import org.oppia.android.databinding.AdministratorControlsGeneralViewBinding
import org.oppia.android.databinding.AdministratorControlsLearnerAnalyticsViewBinding
import org.oppia.android.databinding.AdministratorControlsProfileViewBinding
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.extractCurrentUserProfileId
import java.security.InvalidParameterException
import javax.inject.Inject

Expand Down Expand Up @@ -56,8 +56,7 @@ class AdministratorControlsFragmentPresenter @Inject constructor(
/* attachToRoot= */ false
)

internalProfileId = activity.intent.getIntExtra(NAVIGATION_PROFILE_ID_ARGUMENT_KEY, -1)
profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build()
profileId = activity.intent.extractCurrentUserProfileId()
administratorControlsViewModel.setProfileId(profileId)

linearLayoutManager = LinearLayoutManager(activity.applicationContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import org.oppia.android.app.devoptions.markstoriescompleted.MarkStoriesComplete
import org.oppia.android.app.devoptions.marktopicscompleted.MarkTopicsCompletedActivity
import org.oppia.android.app.devoptions.mathexpressionparser.MathExpressionParserActivity
import org.oppia.android.app.devoptions.vieweventlogs.ViewEventLogsActivity
import org.oppia.android.app.drawer.NAVIGATION_PROFILE_ID_ARGUMENT_KEY
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.ScreenName.DEVELOPER_OPTIONS_ACTIVITY
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.decorateWithScreenName
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.decorateWithUserProfileId
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.extractCurrentUserProfileId
import javax.inject.Inject

/** Activity for Developer Options. */
Expand All @@ -35,34 +37,34 @@ class DeveloperOptionsActivity :
@Inject
lateinit var resourceHandler: AppLanguageResourceHandler

private var internalProfileId = -1
private lateinit var profileId: ProfileId

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
(activityComponent as ActivityComponentImpl).inject(this)
internalProfileId = intent.getIntExtra(NAVIGATION_PROFILE_ID_ARGUMENT_KEY, -1)
profileId = intent.extractCurrentUserProfileId()
developerOptionsActivityPresenter.handleOnCreate()
title = resourceHandler.getStringInLocale(R.string.developer_options_activity_title)
}

override fun routeToMarkChaptersCompleted() {
startActivity(
MarkChaptersCompletedActivity
.createMarkChaptersCompletedIntent(this, internalProfileId)
.createMarkChaptersCompletedIntent(this, profileId.internalId)
)
}

override fun routeToMarkStoriesCompleted() {
startActivity(
MarkStoriesCompletedActivity
.createMarkStoriesCompletedIntent(this, internalProfileId)
.createMarkStoriesCompletedIntent(this, profileId.internalId)
)
}

override fun routeToMarkTopicsCompleted() {
startActivity(
MarkTopicsCompletedActivity
.createMarkTopicsCompletedIntent(this, internalProfileId)
.createMarkTopicsCompletedIntent(this, profileId.internalId)
)
}

Expand All @@ -82,14 +84,14 @@ class DeveloperOptionsActivity :
/** Function to create intent for DeveloperOptionsActivity */
fun createDeveloperOptionsActivityIntent(context: Context, internalProfileId: Int): Intent {
return Intent(context, DeveloperOptionsActivity::class.java).apply {
putExtra(NAVIGATION_PROFILE_ID_ARGUMENT_KEY, internalProfileId)
decorateWithScreenName(DEVELOPER_OPTIONS_ACTIVITY)
decorateWithUserProfileId(
ProfileId.newBuilder().apply {
internalId = internalProfileId
}.build()
)
}
}

fun getIntentKey(): String {
return NAVIGATION_PROFILE_ID_ARGUMENT_KEY
}
}

override fun forceCrash() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ import org.oppia.android.domain.profile.ProfileManagementController
import org.oppia.android.domain.topic.TopicController
import org.oppia.android.util.data.AsyncResult
import org.oppia.android.util.data.DataProviders.Companion.toLiveData
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.extractCurrentUserProfileId
import org.oppia.android.util.statusbar.StatusBarColor
import javax.inject.Inject

const val NAVIGATION_PROFILE_ID_ARGUMENT_KEY =
"NavigationDrawerFragmentPresenter.navigation_profile_id"
const val TAG_SWITCH_PROFILE_DIALOG = "SWITCH_PROFILE_DIALOG"

/** The presenter for [NavigationDrawerFragment]. */
Expand All @@ -63,16 +62,14 @@ class NavigationDrawerFragmentPresenter @Inject constructor(
private lateinit var binding: DrawerFragmentBinding
private lateinit var profileId: ProfileId
private var previousMenuItemId: Int? = null
private var internalProfileId: Int = -1

fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View? {
binding = DrawerFragmentBinding.inflate(inflater, container, /* attachToRoot= */ false)
binding.fragmentDrawerNavView.setNavigationItemSelectedListener(this)

fragment.setHasOptionsMenu(true)

internalProfileId = activity.intent.getIntExtra(NAVIGATION_PROFILE_ID_ARGUMENT_KEY, -1)
profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build()
profileId = activity.intent.extractCurrentUserProfileId()

val headerBinding =
NavHeaderNavigationDrawerBinding.inflate(
Expand Down Expand Up @@ -107,7 +104,7 @@ class NavigationDrawerFragmentPresenter @Inject constructor(
uncheckAllMenuItemsWhenAdministratorControlsOrDeveloperOptionsIsSelected()
drawerLayout.closeDrawers()
getFooterViewModel().isDeveloperOptionsSelected.set(true)
val intent = starter.createIntent(activity, internalProfileId)
val intent = starter.createIntent(activity, profileId.internalId)
fragment.activity!!.startActivity(intent)
if (previousMenuItemId == 0) fragment.activity!!.finish()
else if (previousMenuItemId != null &&
Expand Down Expand Up @@ -147,7 +144,7 @@ class NavigationDrawerFragmentPresenter @Inject constructor(
val intent =
AdministratorControlsActivity.createAdministratorControlsActivityIntent(
activity,
internalProfileId
profileId.internalId
)
fragment.activity!!.startActivity(intent)
if (previousMenuItemId == -1) fragment.activity!!.finish()
Expand Down Expand Up @@ -244,13 +241,13 @@ class NavigationDrawerFragmentPresenter @Inject constructor(
if (previousMenuItemId != menuItemId) {
when (NavigationDrawerItem.valueFromNavId(menuItemId)) {
NavigationDrawerItem.HOME -> {
val intent = HomeActivity.createHomeActivity(activity, internalProfileId)
val intent = HomeActivity.createHomeActivity(activity, profileId.internalId)
fragment.activity!!.startActivity(intent)
drawerLayout.closeDrawers()
}
NavigationDrawerItem.OPTIONS -> {
val intent = OptionsActivity.createOptionsActivity(
activity, internalProfileId,
activity, profileId.internalId,
/* isFromNavigationDrawer= */ true
)
fragment.activity!!.startActivity(intent)
Expand All @@ -261,7 +258,7 @@ class NavigationDrawerFragmentPresenter @Inject constructor(
}
NavigationDrawerItem.HELP -> {
val intent = HelpActivity.createHelpActivityIntent(
activity, internalProfileId,
activity, profileId.internalId,
/* isFromNavigationDrawer= */ true
)
fragment.activity!!.startActivity(intent)
Expand All @@ -272,7 +269,7 @@ class NavigationDrawerFragmentPresenter @Inject constructor(
}
NavigationDrawerItem.DOWNLOADS -> {
val intent =
MyDownloadsActivity.createMyDownloadsActivityIntent(activity, internalProfileId)
MyDownloadsActivity.createMyDownloadsActivityIntent(activity, profileId.internalId)
fragment.activity!!.startActivity(intent)
if (checkIfPreviousActivityShouldGetFinished(menuItemId)) {
fragment.activity!!.finish()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ import android.os.Bundle
import org.oppia.android.R
import org.oppia.android.app.activity.ActivityComponentImpl
import org.oppia.android.app.activity.InjectableAppCompatActivity
import org.oppia.android.app.drawer.NAVIGATION_PROFILE_ID_ARGUMENT_KEY
import org.oppia.android.app.help.faq.FAQListActivity
import org.oppia.android.app.help.faq.RouteToFAQSingleListener
import org.oppia.android.app.help.faq.faqsingle.FAQSingleActivity
import org.oppia.android.app.help.thirdparty.ThirdPartyDependencyListActivity
import org.oppia.android.app.model.PoliciesActivityParams
import org.oppia.android.app.model.PolicyPage
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.ScreenName.HELP_ACTIVITY
import org.oppia.android.app.policies.PoliciesActivity
import org.oppia.android.app.policies.RouteToPoliciesListener
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.util.extensions.getProto
import org.oppia.android.util.extensions.getStringFromBundle
import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.decorateWithScreenName
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.decorateWithUserProfileId
import javax.inject.Inject

const val HELP_OPTIONS_TITLE_SAVED_KEY = "HelpActivity.help_options_title"
Expand Down Expand Up @@ -96,9 +97,13 @@ class HelpActivity :
isFromNavigationDrawer: Boolean
): Intent {
val intent = Intent(context, HelpActivity::class.java)
intent.putExtra(NAVIGATION_PROFILE_ID_ARGUMENT_KEY, profileId)
intent.putExtra(BOOL_IS_FROM_NAVIGATION_DRAWER_EXTRA_KEY, isFromNavigationDrawer)
intent.decorateWithScreenName(HELP_ACTIVITY)
intent.decorateWithUserProfileId(
ProfileId.newBuilder().apply {
internalId = profileId!!
}.build()
)
return intent
}
}
Expand Down
17 changes: 11 additions & 6 deletions app/src/main/java/org/oppia/android/app/home/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.oppia.android.app.activity.ActivityComponentImpl
import org.oppia.android.app.activity.InjectableAppCompatActivity
import org.oppia.android.app.activity.route.ActivityRouter
import org.oppia.android.app.drawer.ExitProfileDialogFragment
import org.oppia.android.app.drawer.NAVIGATION_PROFILE_ID_ARGUMENT_KEY
import org.oppia.android.app.drawer.TAG_SWITCH_PROFILE_DIALOG
import org.oppia.android.app.model.DestinationScreen
import org.oppia.android.app.model.ExitProfileDialogArguments
Expand All @@ -20,6 +19,8 @@ import org.oppia.android.app.model.ScreenName.HOME_ACTIVITY
import org.oppia.android.app.topic.TopicActivity
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.decorateWithScreenName
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.decorateWithUserProfileId
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.extractCurrentUserProfileId
import javax.inject.Inject

/** The central activity for all users entering the app. */
Expand All @@ -37,22 +38,26 @@ class HomeActivity :
@Inject
lateinit var activityRouter: ActivityRouter

private var internalProfileId: Int = -1
private lateinit var profileId: ProfileId

companion object {
fun createHomeActivity(context: Context, profileId: Int?): Intent {
return Intent(context, HomeActivity::class.java).apply {
putExtra(NAVIGATION_PROFILE_ID_ARGUMENT_KEY, profileId)
decorateWithScreenName(HOME_ACTIVITY)
decorateWithUserProfileId(
ProfileId.newBuilder().apply {
internalId = profileId!!
}.build()
)
}
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
(activityComponent as ActivityComponentImpl).inject(this)
internalProfileId = intent?.getIntExtra(NAVIGATION_PROFILE_ID_ARGUMENT_KEY, -1)!!
homeActivityPresenter.handleOnCreate(internalProfileId)
profileId = intent.extractCurrentUserProfileId()
homeActivityPresenter.handleOnCreate(profileId.internalId)
title = resourceHandler.getStringInLocale(R.string.home_activity_title)
}

Expand Down Expand Up @@ -96,7 +101,7 @@ class HomeActivity :
val recentlyPlayedActivityParams =
RecentlyPlayedActivityParams
.newBuilder()
.setProfileId(ProfileId.newBuilder().setInternalId(internalProfileId).build())
.setProfileId(ProfileId.newBuilder().setInternalId(profileId.internalId).build())
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
.setActivityTitle(recentlyPlayedActivityTitle).build()

activityRouter.routeToScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.GridLayoutManager
import org.oppia.android.R
import org.oppia.android.app.drawer.NAVIGATION_PROFILE_ID_ARGUMENT_KEY
import org.oppia.android.app.fragment.FragmentScope
import org.oppia.android.app.home.promotedlist.ComingSoonTopicListViewModel
import org.oppia.android.app.home.promotedlist.PromotedStoryListViewModel
import org.oppia.android.app.home.topiclist.AllTopicsViewModel
import org.oppia.android.app.home.topiclist.TopicSummaryViewModel
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.TopicSummary
import org.oppia.android.app.recyclerview.BindableAdapter
import org.oppia.android.app.translation.AppLanguageResourceHandler
Expand All @@ -29,6 +29,7 @@ import org.oppia.android.domain.topic.TopicListController
import org.oppia.android.domain.translation.TranslationController
import org.oppia.android.util.parser.html.StoryHtmlParserEntityType
import org.oppia.android.util.parser.html.TopicHtmlParserEntityType
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.extractCurrentUserProfileId
import javax.inject.Inject

/** The presenter for [HomeFragment]. */
Expand All @@ -48,21 +49,21 @@ class HomeFragmentPresenter @Inject constructor(
) {
private val routeToTopicPlayStoryListener = activity as RouteToTopicPlayStoryListener
private lateinit var binding: HomeFragmentBinding
private var internalProfileId: Int = -1
private lateinit var profileId: ProfileId

fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View? {
binding = HomeFragmentBinding.inflate(inflater, container, /* attachToRoot= */ false)
// NB: Both the view model and lifecycle owner must be set in order to correctly bind LiveData elements to
// data-bound view models.

internalProfileId = activity.intent.getIntExtra(NAVIGATION_PROFILE_ID_ARGUMENT_KEY, -1)
profileId = activity.intent.extractCurrentUserProfileId()
logHomeActivityEvent()

val homeViewModel = HomeViewModel(
activity,
fragment,
oppiaLogger,
internalProfileId,
profileId.internalId,
profileManagementController,
topicListController,
topicEntityType,
Expand Down Expand Up @@ -150,7 +151,7 @@ class HomeFragmentPresenter @Inject constructor(

fun onTopicSummaryClicked(topicSummary: TopicSummary) {
routeToTopicPlayStoryListener.routeToTopicPlayStory(
internalProfileId,
profileId.internalId,
topicSummary.topicId,
topicSummary.firstStoryId
)
Expand Down
Loading