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 93 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 @@ -799,6 +799,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,16 @@ import org.oppia.android.app.activity.ActivityComponentImpl
import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity
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 org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.extractCurrentUserProfileId
import javax.inject.Inject

/** Argument key for of title for selected controls in [AdministratorControlsActivity]. */
Expand Down Expand Up @@ -64,6 +66,7 @@ class AdministratorControlsActivity :
lateinit var resourceHandler: AppLanguageResourceHandler
private lateinit var lastLoadedFragment: String
private var isProfileDeletionDialogVisible: Boolean = false
private lateinit var profileId: ProfileId

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -78,29 +81,30 @@ class AdministratorControlsActivity :
// TODO(#661): Change the default fragment in the right hand side to be EditAccount fragment in the case of multipane controls.
PROFILE_LIST_FRAGMENT
}
val selectedProfileId = savedInstanceState?.getInt(SELECTED_PROFILE_ID_SAVED_KEY) ?: -1
profileId = savedInstanceState?.extractCurrentUserProfileId()
?: ProfileId.newBuilder().apply { internalId = -1 }.build()
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
administratorControlsActivityPresenter.handleOnCreate(
extraControlsTitle,
lastLoadedFragment,
selectedProfileId,
profileId,
isProfileDeletionDialogVisible
)
title = resourceHandler.getStringInLocale(R.string.administrator_controls)
}

override fun routeToAppVersion() {
startActivity(AppVersionActivity.createAppVersionActivityIntent(this))
startActivity(AppVersionActivity.createAppVersionActivityIntent(this, profileId))
}

override fun routeToProfileList() {
startActivity(ProfileListActivity.createProfileListActivityIntent(this))
startActivity(ProfileListActivity.createProfileListActivityIntent(this, profileId))
}

override fun routeToLearnerAnalytics() {
startActivity(ProfileAndDeviceIdActivity.createIntent(this))
startActivity(ProfileAndDeviceIdActivity.createIntent(this, profileId))
}

override fun loadProfileEdit(profileId: Int, profileName: String) {
override fun loadProfileEdit(profileId: ProfileId, profileName: String) {
lastLoadedFragment = PROFILE_EDIT_FRAGMENT
administratorControlsActivityPresenter.loadProfileEdit(profileId, profileName)
}
Expand All @@ -112,17 +116,12 @@ class AdministratorControlsActivity :

companion object {
/** Returns an [Intent] to start this activity. */
fun createAdministratorControlsActivityIntent(context: Context, profileId: Int?): Intent {
fun createAdministratorControlsActivityIntent(context: Context, profileId: ProfileId): Intent {
val intent = Intent(context, AdministratorControlsActivity::class.java)
intent.putExtra(NAVIGATION_PROFILE_ID_ARGUMENT_KEY, profileId)
intent.decorateWithScreenName(ADMINISTRATOR_CONTROLS_ACTIVITY)
intent.decorateWithUserProfileId(profileId)
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 @@ -10,11 +10,13 @@ import org.oppia.android.app.activity.ActivityScope
import org.oppia.android.app.administratorcontrols.appversion.AppVersionFragment
import org.oppia.android.app.administratorcontrols.learneranalytics.ProfileAndDeviceIdFragment
import org.oppia.android.app.drawer.NavigationDrawerFragment
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.settings.profile.LoadProfileEditDeletionDialogListener
import org.oppia.android.app.settings.profile.ProfileEditFragment
import org.oppia.android.app.settings.profile.ProfileListFragment
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.databinding.AdministratorControlsActivityBinding
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.decorateWithUserProfileId
import javax.inject.Inject

/** The presenter for [AdministratorControlsActivity]. */
Expand All @@ -28,15 +30,15 @@ class AdministratorControlsActivityPresenter @Inject constructor(
private lateinit var binding: AdministratorControlsActivityBinding

private lateinit var lastLoadedFragment: String
private var selectedProfileId: Int = -1
private lateinit var selectedProfileId: ProfileId
private lateinit var extraControlsTitle: String
private var isProfileDeletionDialogVisible: Boolean = false

/** Initializes the [AdministratorControlsActivity] and sets the navigation drawer. */
fun handleOnCreate(
extraControlsTitle: String?,
lastLoadedFragment: String,
selectedProfileId: Int,
selectedProfileId: ProfileId,
isProfileDeletionDialogVisible: Boolean
) {
binding = DataBindingUtil.setContentView(
Expand Down Expand Up @@ -70,7 +72,7 @@ class AdministratorControlsActivityPresenter @Inject constructor(
profileId = profileId,
profileName = extraControlsTitle
)
if (isProfileDeletionDialogVisible && profileId != 0) {
if (isProfileDeletionDialogVisible && profileId.internalId != 0) {
val fragment = activity.supportFragmentManager.findFragmentById(
R.id.administrator_controls_fragment_multipane_placeholder
)
Expand Down Expand Up @@ -144,7 +146,7 @@ class AdministratorControlsActivityPresenter @Inject constructor(
}

/** Loads the [ProfileEditFragment] when the user clicks on a profile in tablet multipane mode. */
fun loadProfileEdit(profileId: Int, profileName: String) {
fun loadProfileEdit(profileId: ProfileId, profileName: String) {
lastLoadedFragment = PROFILE_EDIT_FRAGMENT
selectedProfileId = profileId
extraControlsTitle = profileName
Expand Down Expand Up @@ -209,6 +211,6 @@ class AdministratorControlsActivityPresenter @Inject constructor(
isProfileDeletionDialogVisible?.let {
outState.putBoolean(IS_PROFILE_DELETION_DIALOG_VISIBLE_KEY, it)
}
selectedProfileId?.let { outState.putInt(SELECTED_PROFILE_ID_SAVED_KEY, it) }
selectedProfileId?.let { outState.decorateWithUserProfileId(it) }
}
}
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 All @@ -36,7 +36,6 @@ class AdministratorControlsFragmentPresenter @Inject constructor(
) {
private lateinit var binding: AdministratorControlsFragmentBinding
private lateinit var linearLayoutManager: LinearLayoutManager
private var internalProfileId: Int = -1
private lateinit var profileId: ProfileId

@Inject
Expand All @@ -56,8 +55,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
@@ -1,7 +1,9 @@
package org.oppia.android.app.administratorcontrols

import org.oppia.android.app.model.ProfileId

/** Listener for when an activity should load [ProfileEditFragment]. */
interface LoadProfileEditListener {
/** Inflates [ProfileEditFragment] as part of a tablet mode a multipane fragment. */
fun loadProfileEdit(profileId: Int, profileName: String)
fun loadProfileEdit(profileId: ProfileId, profileName: String)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import android.os.Bundle
import android.view.MenuItem
import org.oppia.android.app.activity.ActivityComponentImpl
import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.ScreenName.APP_VERSION_ACTIVITY
import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.decorateWithScreenName
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.decorateWithUserProfileId
import javax.inject.Inject

/** Activity for App Version. */
Expand All @@ -30,9 +32,10 @@ class AppVersionActivity : InjectableAutoLocalizedAppCompatActivity() {

companion object {
/** Returns an [Intent] to start this activity. */
fun createAppVersionActivityIntent(context: Context): Intent {
fun createAppVersionActivityIntent(context: Context, profileId: ProfileId): Intent {
return Intent(context, AppVersionActivity::class.java).apply {
decorateWithScreenName(APP_VERSION_ACTIVITY)
decorateWithUserProfileId(profileId)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import android.os.Bundle
import android.view.MenuItem
import org.oppia.android.app.activity.ActivityComponentImpl
import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.ScreenName.PROFILE_AND_DEVICE_ID_ACTIVITY
import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.decorateWithScreenName
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.decorateWithUserProfileId
import javax.inject.Inject

/**
Expand Down Expand Up @@ -35,9 +37,10 @@ class ProfileAndDeviceIdActivity : InjectableAutoLocalizedAppCompatActivity() {

companion object {
/** Returns an [Intent] to launch [ProfileAndDeviceIdActivity]. */
fun createIntent(context: Context): Intent {
fun createIntent(context: Context, profileId: ProfileId): Intent {
return Intent(context, ProfileAndDeviceIdActivity::class.java).apply {
decorateWithScreenName(PROFILE_AND_DEVICE_ID_ACTIVITY)
decorateWithUserProfileId(profileId)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package org.oppia.android.app.completedstorylist
import androidx.appcompat.app.AppCompatActivity
import org.oppia.android.app.home.RouteToTopicPlayStoryListener
import org.oppia.android.app.model.CompletedStory
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.shim.IntentFactoryShim
import org.oppia.android.app.viewmodel.ObservableViewModel
import org.oppia.android.domain.translation.TranslationController

/** Completed story view model for the recycler view in [CompletedStoryListFragment]. */
class CompletedStoryItemViewModel(
private val activity: AppCompatActivity,
private val internalProfileId: Int,
private val profileId: ProfileId,
val completedStory: CompletedStory,
val entityType: String,
private val intentFactoryShim: IntentFactoryShim,
Expand All @@ -31,13 +32,13 @@ class CompletedStoryItemViewModel(

/** Called when user clicks on CompletedStoryItem. */
fun onCompletedStoryItemClicked() {
routeToTopicPlayStory(internalProfileId, completedStory.topicId, completedStory.storyId)
routeToTopicPlayStory(profileId, completedStory.topicId, completedStory.storyId)
}

override fun routeToTopicPlayStory(internalProfileId: Int, topicId: String, storyId: String) {
override fun routeToTopicPlayStory(profileId: ProfileId, topicId: String, storyId: String) {
val intent = intentFactoryShim.createTopicPlayStoryActivityIntent(
activity.applicationContext,
internalProfileId,
profileId,
topicId,
storyId
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import android.content.Intent
import android.os.Bundle
import org.oppia.android.app.activity.ActivityComponentImpl
import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.ScreenName.COMPLETED_STORY_LIST_ACTIVITY
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 completed stories. */
Expand All @@ -17,21 +20,18 @@ class CompletedStoryListActivity : InjectableAutoLocalizedAppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
(activityComponent as ActivityComponentImpl).inject(this)
val internalProfileId: Int =
intent.getIntExtra(PROFILE_ID_EXTRA_KEY, -1)
completedStoryListActivityPresenter.handleOnCreate(internalProfileId)
val profileId: ProfileId = intent.extractCurrentUserProfileId()
completedStoryListActivityPresenter.handleOnCreate(profileId)
}

companion object {
// TODO(#1655): Re-restrict access to fields in tests post-Gradle.
const val PROFILE_ID_EXTRA_KEY =
"CompletedStoryListActivity.profile_id"

/** Returns a new [Intent] to route to [CompletedStoryListActivity] for a specified profile ID. */
fun createCompletedStoryListActivityIntent(context: Context, internalProfileId: Int): Intent {
fun createCompletedStoryListActivityIntent(context: Context, profileId: ProfileId): Intent {
val intent = Intent(context, CompletedStoryListActivity::class.java)
intent.putExtra(PROFILE_ID_EXTRA_KEY, internalProfileId)
intent.decorateWithScreenName(COMPLETED_STORY_LIST_ACTIVITY)
intent.decorateWithUserProfileId(profileId)
return intent
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ package org.oppia.android.app.completedstorylist
import androidx.appcompat.app.AppCompatActivity
import org.oppia.android.R
import org.oppia.android.app.activity.ActivityScope
import org.oppia.android.app.model.ProfileId
import javax.inject.Inject

/** The presenter for [CompletedStoryListActivity]. */
@ActivityScope
class CompletedStoryListActivityPresenter @Inject constructor(
private val activity: AppCompatActivity
) {

/** Initializes views for [CompletedStoryListActivity] and binds [CompletedStoryListFragment]. */
fun handleOnCreate(internalProfileId: Int) {
fun handleOnCreate(profileId: ProfileId) {
activity.setContentView(R.layout.completed_story_list_activity)
if (getCompletedStoryListFragment() == null) {
activity
.supportFragmentManager
.beginTransaction()
.add(
R.id.completed_story_list_fragment_placeholder,
CompletedStoryListFragment.newInstance(internalProfileId),
CompletedStoryListFragment.newInstance(profileId),
CompletedStoryListFragment.COMPLETED_STORY_LIST_FRAGMENT_TAG
).commitNow()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import android.view.View
import android.view.ViewGroup
import org.oppia.android.app.fragment.FragmentComponentImpl
import org.oppia.android.app.fragment.InjectableFragment
import org.oppia.android.app.model.ProfileId
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.decorateWithUserProfileId
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.extractCurrentUserProfileId
import javax.inject.Inject

/** Fragment for displaying completed stories. */
Expand All @@ -20,10 +23,10 @@ class CompletedStoryListFragment : InjectableFragment() {
"CompletedStoryListFragment.profile_id"

/** Returns a new [CompletedStoryListFragment] to display corresponding to the specified profile ID. */
fun newInstance(internalProfileId: Int): CompletedStoryListFragment {
fun newInstance(profileId: ProfileId): CompletedStoryListFragment {
val completedStoryListFragment = CompletedStoryListFragment()
val args = Bundle()
args.putInt(COMPLETED_STORY_LIST_FRAGMENT_PROFILE_ID_KEY, internalProfileId)
args.decorateWithUserProfileId(profileId)
completedStoryListFragment.arguments = args
return completedStoryListFragment
}
Expand All @@ -45,13 +48,11 @@ class CompletedStoryListFragment : InjectableFragment() {
val args = checkNotNull(arguments) {
"Expected arguments to be passed to CompletedStoryListFragment"
}
val internalProfileId = args.getInt(
COMPLETED_STORY_LIST_FRAGMENT_PROFILE_ID_KEY, -1
)
val profileId = args.extractCurrentUserProfileId()
return completedStoryListFragmentPresenter.handleCreateView(
inflater,
container,
internalProfileId
profileId
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ 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.model.ProfileId
import org.oppia.android.app.recyclerview.BindableAdapter
import org.oppia.android.app.viewmodel.ViewModelProvider
import org.oppia.android.databinding.CompletedStoryItemBinding
Expand All @@ -27,10 +28,10 @@ class CompletedStoryListFragmentPresenter @Inject constructor(
fun handleCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
internalProfileId: Int
profileId: ProfileId
): View? {
val viewModel = getCompletedStoryListViewModel()
viewModel.setProfileId(internalProfileId)
viewModel.setProfileId(profileId)

binding = CompletedStoryListFragmentBinding
.inflate(
Expand Down
Loading