diff --git a/app/src/main/java/org/oppia/android/app/administratorcontrols/AdministratorControlsFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/administratorcontrols/AdministratorControlsFragmentPresenter.kt index 843b1dbc2fe..0b88aea5bfd 100644 --- a/app/src/main/java/org/oppia/android/app/administratorcontrols/AdministratorControlsFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/administratorcontrols/AdministratorControlsFragmentPresenter.kt @@ -56,8 +56,7 @@ class AdministratorControlsFragmentPresenter @Inject constructor( /* attachToRoot= */ false ) - internalProfileId = activity.intent.extractCurrentUserProfileId().internalId - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = activity.intent.extractCurrentUserProfileId() administratorControlsViewModel.setProfileId(profileId) linearLayoutManager = LinearLayoutManager(activity.applicationContext) diff --git a/app/src/main/java/org/oppia/android/app/classroom/ClassroomListActivity.kt b/app/src/main/java/org/oppia/android/app/classroom/ClassroomListActivity.kt index c8f075f10bf..4edf64dc884 100644 --- a/app/src/main/java/org/oppia/android/app/classroom/ClassroomListActivity.kt +++ b/app/src/main/java/org/oppia/android/app/classroom/ClassroomListActivity.kt @@ -42,7 +42,7 @@ class ClassroomListActivity : @Inject lateinit var activityRouter: ActivityRouter - private var internalProfileId: Int = -1 + private lateinit var profileId: ProfileId companion object { /** Returns a new [Intent] to route to [ClassroomListActivity] for a specified [profileId]. */ @@ -58,7 +58,7 @@ class ClassroomListActivity : super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - internalProfileId = intent.extractCurrentUserProfileId().internalId + profileId = intent.extractCurrentUserProfileId() classroomListActivityPresenter.handleOnCreate() title = resourceHandler.getStringInLocale(R.string.classroom_list_activity_title) } @@ -88,7 +88,7 @@ class ClassroomListActivity : val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId(ProfileId.newBuilder().setInternalId(internalProfileId).build()) + .setProfileId(profileId) .setActivityTitle(recentlyPlayedActivityTitle).build() activityRouter.routeToScreen( diff --git a/app/src/main/java/org/oppia/android/app/classroom/ClassroomListFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/classroom/ClassroomListFragmentPresenter.kt index 19da63a9d68..b6cb9f55824 100644 --- a/app/src/main/java/org/oppia/android/app/classroom/ClassroomListFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/classroom/ClassroomListFragmentPresenter.kt @@ -103,7 +103,7 @@ class ClassroomListFragmentPresenter @Inject constructor( /* attachToRoot= */ false ) - internalProfileId = profileId.internalId + internalProfileId = profileId.loggedInInternalProfileId logHomeActivityEvent() diff --git a/app/src/main/java/org/oppia/android/app/classroom/ClassroomListViewModel.kt b/app/src/main/java/org/oppia/android/app/classroom/ClassroomListViewModel.kt index 8211e52529b..04b55a33b22 100644 --- a/app/src/main/java/org/oppia/android/app/classroom/ClassroomListViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/classroom/ClassroomListViewModel.kt @@ -63,7 +63,8 @@ class ClassroomListViewModel( private val dateTimeUtil: DateTimeUtil, private val translationController: TranslationController ) : ObservableViewModel() { - private val profileId: ProfileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + private val profileId: ProfileId = + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() private val promotedStoryListLimit = activity.resources.getInteger( R.integer.promoted_story_list_limit ) diff --git a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivity.kt b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivity.kt index fe2d803f0a7..d956e069bf6 100644 --- a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivity.kt +++ b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivity.kt @@ -21,7 +21,8 @@ class CompletedStoryListActivity : InjectableAutoLocalizedAppCompatActivity() { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - val internalProfileId: Int = intent?.extractCurrentUserProfileId()?.internalId ?: -1 + val internalProfileId: Int = + intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 completedStoryListActivityPresenter.handleOnCreate(internalProfileId) } @@ -30,7 +31,7 @@ class CompletedStoryListActivity : InjectableAutoLocalizedAppCompatActivity() { /** Returns a new [Intent] to route to [CompletedStoryListActivity] for a specified profile ID. */ fun createCompletedStoryListActivityIntent(context: Context, internalProfileId: Int): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val intent = Intent(context, CompletedStoryListActivity::class.java).apply { decorateWithUserProfileId(profileId) decorateWithScreenName(COMPLETED_STORY_LIST_ACTIVITY) diff --git a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListFragment.kt b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListFragment.kt index 4f11f4df5e1..36cb8405bff 100644 --- a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListFragment.kt +++ b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListFragment.kt @@ -21,7 +21,7 @@ class CompletedStoryListFragment : InjectableFragment() { /** Returns a new [CompletedStoryListFragment] to display corresponding to the specified profile ID. */ fun newInstance(internalProfileId: Int): CompletedStoryListFragment { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return CompletedStoryListFragment().apply { arguments = Bundle().apply { decorateWithUserProfileId(profileId) @@ -47,11 +47,10 @@ class CompletedStoryListFragment : InjectableFragment() { "Expected arguments to be passed to CompletedStoryListFragment" } val profileId = arguments.extractCurrentUserProfileId() - val internalProfileId = profileId.internalId return completedStoryListFragmentPresenter.handleCreateView( inflater, container, - internalProfileId + profileId ) } } diff --git a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListFragmentPresenter.kt index ed1a566d4de..02b2ae9cd68 100644 --- a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListFragmentPresenter.kt @@ -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.databinding.CompletedStoryItemBinding import org.oppia.android.databinding.CompletedStoryListFragmentBinding @@ -26,9 +27,9 @@ class CompletedStoryListFragmentPresenter @Inject constructor( fun handleCreateView( inflater: LayoutInflater, container: ViewGroup?, - internalProfileId: Int + profileId: ProfileId ): View? { - viewModel.setProfileId(internalProfileId) + viewModel.setProfileId(profileId) binding = CompletedStoryListFragmentBinding .inflate( diff --git a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListViewModel.kt b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListViewModel.kt index 678d91b02ce..4750308cfb2 100644 --- a/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryListViewModel.kt @@ -26,13 +26,11 @@ class CompletedStoryListViewModel @Inject constructor( private val translationController: TranslationController, @StoryHtmlParserEntityType private val entityType: String ) : ObservableViewModel() { - /** [internalProfileId] needs to be set before any of the live data members can be accessed. */ - private var internalProfileId: Int = -1 + /** [profileId] needs to be set before any of the live data members can be accessed. */ + private var profileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() private val completedStoryListResultLiveData: LiveData> by lazy { - topicController.getCompletedStoryList( - ProfileId.newBuilder().setInternalId(internalProfileId).build() - ).toLiveData() + topicController.getCompletedStoryList(profileId).toLiveData() } private val completedStoryLiveData: LiveData by lazy { @@ -44,9 +42,9 @@ class CompletedStoryListViewModel @Inject constructor( Transformations.map(completedStoryLiveData, ::processCompletedStoryList) } - /** Sets internalProfileId to this ViewModel. */ - fun setProfileId(internalProfileId: Int) { - this.internalProfileId = internalProfileId + /** Sets profileId to this ViewModel. */ + fun setProfileId(profileId: ProfileId) { + this.profileId = profileId } private fun processCompletedStoryListResult( @@ -74,7 +72,7 @@ class CompletedStoryListViewModel @Inject constructor( completedStoryList.completedStoryList.map { completedStory -> CompletedStoryItemViewModel( activity, - internalProfileId, + profileId.loggedInInternalProfileId, // Use the loggedInInternalProfileId completedStory, entityType, intentFactoryShim, diff --git a/app/src/main/java/org/oppia/android/app/devoptions/DeveloperOptionsActivity.kt b/app/src/main/java/org/oppia/android/app/devoptions/DeveloperOptionsActivity.kt index eda9f03bc9a..7a2393e7aa5 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/DeveloperOptionsActivity.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/DeveloperOptionsActivity.kt @@ -37,35 +37,37 @@ 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.extractCurrentUserProfileId().internalId + profileId = intent.extractCurrentUserProfileId() developerOptionsActivityPresenter.handleOnCreate() title = resourceHandler.getStringInLocale(R.string.developer_options_activity_title) } override fun routeToMarkChaptersCompleted() { - startActivity( - MarkChaptersCompletedActivity.createMarkChaptersCompletedIntent( - context = this, internalProfileId, showConfirmationNotice = false + if (!profileId.loggedOut) { + startActivity( + MarkChaptersCompletedActivity.createMarkChaptersCompletedIntent( + context = this, profileId.loggedInInternalProfileId, showConfirmationNotice = false + ) ) - ) + } } override fun routeToMarkStoriesCompleted() { startActivity( MarkStoriesCompletedActivity - .createMarkStoriesCompletedIntent(this, internalProfileId) + .createMarkStoriesCompletedIntent(this, profileId.loggedInInternalProfileId) ) } override fun routeToMarkTopicsCompleted() { startActivity( MarkTopicsCompletedActivity - .createMarkTopicsCompletedIntent(this, internalProfileId) + .createMarkTopicsCompletedIntent(this, profileId.loggedInInternalProfileId) ) } diff --git a/app/src/main/java/org/oppia/android/app/devoptions/markchapterscompleted/MarkChaptersCompletedFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/devoptions/markchapterscompleted/MarkChaptersCompletedFragmentPresenter.kt index 98a5d8f35fc..d076b194109 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/markchapterscompleted/MarkChaptersCompletedFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/markchapterscompleted/MarkChaptersCompletedFragmentPresenter.kt @@ -68,7 +68,7 @@ class MarkChaptersCompletedFragmentPresenter @Inject constructor( this.selectedExplorationIds += selectedExplorationIds this.selectedExplorationTitles += selectedExplorationTitles - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() viewModel.setProfileId(profileId) linearLayoutManager = LinearLayoutManager(activity.applicationContext) diff --git a/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedActivity.kt b/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedActivity.kt index e3373fc7df6..8099f1f0914 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedActivity.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedActivity.kt @@ -24,15 +24,17 @@ class MarkStoriesCompletedActivity : InjectableAutoLocalizedAppCompatActivity() @Inject lateinit var resourceHandler: AppLanguageResourceHandler - private var internalProfileId = -1 + private var profileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - val profileId = intent?.extractCurrentUserProfileId() - internalProfileId = profileId?.internalId ?: -1 - markStoriesCompletedActivityPresenter.handleOnCreate(internalProfileId) + val currentProfileId = intent?.extractCurrentUserProfileId() + profileId = currentProfileId ?: ProfileId.newBuilder().setLoggedOut(true).build() + markStoriesCompletedActivityPresenter.handleOnCreate( + profileId.loggedInInternalProfileId + ) title = resourceHandler.getStringInLocale(R.string.mark_stories_completed_activity_title) } @@ -48,7 +50,7 @@ class MarkStoriesCompletedActivity : InjectableAutoLocalizedAppCompatActivity() /** Returns an [Intent] to start this activity. */ fun createMarkStoriesCompletedIntent(context: Context, internalProfileId: Int): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return Intent(context, MarkStoriesCompletedActivity::class.java).apply { decorateWithUserProfileId(profileId) decorateWithScreenName(MARK_STORIES_COMPLETED_ACTIVITY) diff --git a/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedFragment.kt b/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedFragment.kt index 460c6e1dd7b..a6504468bc3 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedFragment.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedFragment.kt @@ -28,7 +28,7 @@ class MarkStoriesCompletedFragment : InjectableFragment() { /** Returns a new [MarkStoriesCompletedFragment]. */ fun newInstance(internalProfileId: Int): MarkStoriesCompletedFragment { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return MarkStoriesCompletedFragment().apply { arguments = Bundle().apply { decorateWithUserProfileId(profileId) @@ -51,7 +51,7 @@ class MarkStoriesCompletedFragment : InjectableFragment() { checkNotNull(arguments) { "Expected arguments to be passed to MarkStoriesCompletedFragment" } val profileId = arguments.extractCurrentUserProfileId() - val internalProfileId = profileId.internalId + val internalProfileId = profileId.loggedInInternalProfileId var selectedStoryIdList = ArrayList() if (savedInstanceState != null) { diff --git a/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedFragmentPresenter.kt index a7514fa682b..fe358b8b7fc 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedFragmentPresenter.kt @@ -52,7 +52,7 @@ class MarkStoriesCompletedFragmentPresenter @Inject constructor( this.selectedStoryIdList = selectedStoryIdList - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() viewModel.setProfileId(profileId) linearLayoutManager = LinearLayoutManager(activity.applicationContext) diff --git a/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/testing/MarkStoriesCompletedTestActivity.kt b/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/testing/MarkStoriesCompletedTestActivity.kt index f128ade5049..e88a7f10a71 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/testing/MarkStoriesCompletedTestActivity.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/testing/MarkStoriesCompletedTestActivity.kt @@ -24,7 +24,7 @@ class MarkStoriesCompletedTestActivity : InjectableAutoLocalizedAppCompatActivit setContentView(R.layout.mark_stories_completed_activity) val profileId = intent?.extractCurrentUserProfileId() - internalProfileId = profileId?.internalId ?: -1 + internalProfileId = profileId?.loggedInInternalProfileId ?: -1 if (getMarkStoriesCompletedFragment() == null) { val markStoriesCompletedFragment = MarkStoriesCompletedFragment.newInstance(internalProfileId) @@ -44,7 +44,7 @@ class MarkStoriesCompletedTestActivity : InjectableAutoLocalizedAppCompatActivit /** Returns an [Intent] for [MarkStoriesCompletedTestActivity]. */ fun createMarkStoriesCompletedTestIntent(context: Context, internalProfileId: Int): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val intent = Intent(context, MarkStoriesCompletedTestActivity::class.java) intent.decorateWithUserProfileId(profileId) return intent diff --git a/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedActivity.kt b/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedActivity.kt index a891de3a059..1f1b24e6fda 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedActivity.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedActivity.kt @@ -25,14 +25,16 @@ class MarkTopicsCompletedActivity : InjectableAutoLocalizedAppCompatActivity() { @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) - val profileId = intent?.extractCurrentUserProfileId() - internalProfileId = profileId?.internalId ?: -1 - markTopicsCompletedActivityPresenter.handleOnCreate(internalProfileId) + profileId = + intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() + if (!profileId.loggedOut) { + markTopicsCompletedActivityPresenter.handleOnCreate(profileId.loggedInInternalProfileId) + } title = resourceHandler.getStringInLocale(R.string.mark_topics_completed_activity_title) } @@ -47,7 +49,7 @@ class MarkTopicsCompletedActivity : InjectableAutoLocalizedAppCompatActivity() { companion object { /** Returns an [Intent] for [MarkStoriesCompletedTestActivity]. */ fun createMarkTopicsCompletedIntent(context: Context, internalProfileId: Int): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return Intent(context, MarkTopicsCompletedActivity::class.java).apply { decorateWithUserProfileId(profileId) decorateWithScreenName(MARK_TOPICS_COMPLETED_ACTIVITY) diff --git a/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedFragment.kt b/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedFragment.kt index 1b5f6dc5543..034de917e62 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedFragment.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedFragment.kt @@ -28,7 +28,7 @@ class MarkTopicsCompletedFragment : InjectableFragment() { /** Returns a new [MarkTopicsCompletedFragment]. */ fun newInstance(internalProfileId: Int): MarkTopicsCompletedFragment { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return MarkTopicsCompletedFragment().apply { arguments = Bundle().apply { decorateWithUserProfileId(profileId) @@ -50,7 +50,7 @@ class MarkTopicsCompletedFragment : InjectableFragment() { val arguments = checkNotNull(arguments) { "Expected arguments to be passed to MarkTopicsCompletedFragment" } - val internalProfileId = arguments.extractCurrentUserProfileId().internalId + val internalProfileId = arguments.extractCurrentUserProfileId().loggedInInternalProfileId var selectedTopicIdList = ArrayList() if (savedInstanceState != null) { diff --git a/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedFragmentPresenter.kt index ad7451d7eff..b78f5abb293 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedFragmentPresenter.kt @@ -52,7 +52,7 @@ class MarkTopicsCompletedFragmentPresenter @Inject constructor( this.selectedTopicIdList = selectedTopicIdList - this.profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + this.profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() viewModel.setProfileId(profileId) linearLayoutManager = LinearLayoutManager(activity.applicationContext) diff --git a/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/testing/MarkTopicsCompletedTestActivity.kt b/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/testing/MarkTopicsCompletedTestActivity.kt index 5e6242271be..899fe979a97 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/testing/MarkTopicsCompletedTestActivity.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/testing/MarkTopicsCompletedTestActivity.kt @@ -14,7 +14,7 @@ import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.extrac /** The activity for testing [MarkTopicsCompletedFragment]. */ class MarkTopicsCompletedTestActivity : InjectableAutoLocalizedAppCompatActivity() { - private var internalProfileId = -1 + private var profileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -22,10 +22,12 @@ class MarkTopicsCompletedTestActivity : InjectableAutoLocalizedAppCompatActivity supportActionBar?.setDisplayHomeAsUpEnabled(true) supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_arrow_back_white_24dp) setContentView(R.layout.mark_topics_completed_activity) - val profileId = intent?.extractCurrentUserProfileId() - internalProfileId = profileId?.internalId ?: -1 + val currentProfileId = intent?.extractCurrentUserProfileId() + profileId = currentProfileId ?: ProfileId.newBuilder().setLoggedOut(true).build() if (getMarkTopicsCompletedFragment() == null) { - val markTopicsCompletedFragment = MarkTopicsCompletedFragment.newInstance(internalProfileId) + val markTopicsCompletedFragment = MarkTopicsCompletedFragment.newInstance( + profileId.loggedInInternalProfileId + ) supportFragmentManager.beginTransaction().add( R.id.mark_topics_completed_container, markTopicsCompletedFragment @@ -41,7 +43,7 @@ class MarkTopicsCompletedTestActivity : InjectableAutoLocalizedAppCompatActivity companion object { /** Returns an [Intent] for [MarkTopicsCompletedTestActivity]. */ fun createMarkTopicsCompletedTestIntent(context: Context, internalProfileId: Int): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val intent = Intent(context, MarkTopicsCompletedTestActivity::class.java).apply { decorateWithUserProfileId(profileId) } diff --git a/app/src/main/java/org/oppia/android/app/devoptions/testing/DeveloperOptionsTestActivity.kt b/app/src/main/java/org/oppia/android/app/devoptions/testing/DeveloperOptionsTestActivity.kt index 7e1565c276d..6c101af7b87 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/testing/DeveloperOptionsTestActivity.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/testing/DeveloperOptionsTestActivity.kt @@ -30,15 +30,15 @@ class DeveloperOptionsTestActivity : RouteToMarkTopicsCompletedListener, RouteToViewEventLogsListener { - private var internalProfileId = -1 + private var profileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) setContentView(R.layout.developer_options_activity) - val profileId = intent?.extractCurrentUserProfileId() - internalProfileId = profileId?.internalId ?: -1 + profileId = + intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() if (getDeveloperOptionsFragment() == null) { supportFragmentManager.beginTransaction().add( @@ -57,7 +57,7 @@ class DeveloperOptionsTestActivity : override fun routeToMarkChaptersCompleted() { startActivity( MarkChaptersCompletedActivity.createMarkChaptersCompletedIntent( - context = this, internalProfileId, showConfirmationNotice = false + context = this, profileId.loggedInInternalProfileId, showConfirmationNotice = false ) ) } @@ -65,14 +65,14 @@ class DeveloperOptionsTestActivity : override fun routeToMarkStoriesCompleted() { startActivity( MarkStoriesCompletedActivity - .createMarkStoriesCompletedIntent(this, internalProfileId) + .createMarkStoriesCompletedIntent(this, profileId.loggedInInternalProfileId) ) } override fun routeToMarkTopicsCompleted() { startActivity( MarkTopicsCompletedActivity - .createMarkTopicsCompletedIntent(this, internalProfileId) + .createMarkTopicsCompletedIntent(this, profileId.loggedInInternalProfileId) ) } @@ -87,7 +87,7 @@ class DeveloperOptionsTestActivity : companion object { /** Returns [Intent] for [DeveloperOptionsTestActivity]. */ fun createDeveloperOptionsTestIntent(context: Context, internalProfileId: Int): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val intent = Intent(context, DeveloperOptionsActivity::class.java) intent.decorateWithUserProfileId(profileId) return intent diff --git a/app/src/main/java/org/oppia/android/app/drawer/ExitProfileDialogFragment.kt b/app/src/main/java/org/oppia/android/app/drawer/ExitProfileDialogFragment.kt index 7900163e9a5..820294ccd50 100644 --- a/app/src/main/java/org/oppia/android/app/drawer/ExitProfileDialogFragment.kt +++ b/app/src/main/java/org/oppia/android/app/drawer/ExitProfileDialogFragment.kt @@ -13,6 +13,7 @@ import org.oppia.android.app.fragment.FragmentComponentImpl import org.oppia.android.app.fragment.InjectableDialogFragment import org.oppia.android.app.model.ExitProfileDialogArguments import org.oppia.android.app.model.HighlightItem +import org.oppia.android.app.model.ProfileId import org.oppia.android.app.profile.ProfileChooserActivity import org.oppia.android.util.extensions.getProto import org.oppia.android.util.extensions.putProto @@ -70,6 +71,10 @@ class ExitProfileDialogFragment : InjectableDialogFragment() { dialog.dismiss() } .setPositiveButton(R.string.home_activity_back_dialog_exit) { _, _ -> + ProfileId.newBuilder() + .setLoggedInInternalProfileId(0) + .setLoggedOut(true) + .build() // TODO(#3641): Investigate on using finish instead of intent. val intent = ProfileChooserActivity.createProfileChooserActivity(activity!!) if (!restoreLastCheckedItem) { diff --git a/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerFragmentPresenter.kt index f606bafca88..7f9acde08fd 100644 --- a/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerFragmentPresenter.kt @@ -64,7 +64,7 @@ class NavigationDrawerFragmentPresenter @Inject constructor( private lateinit var binding: DrawerFragmentBinding private lateinit var profileId: ProfileId private var previousMenuItemId: Int? = null - private var internalProfileId: Int = -1 + private var internalProfileId: Int = 0 fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View? { binding = DrawerFragmentBinding.inflate(inflater, container, /* attachToRoot= */ false) @@ -73,7 +73,7 @@ class NavigationDrawerFragmentPresenter @Inject constructor( fragment.setHasOptionsMenu(true) profileId = activity.intent.extractCurrentUserProfileId() - internalProfileId = profileId.internalId + internalProfileId = profileId.loggedInInternalProfileId val headerBinding = NavHeaderNavigationDrawerBinding.inflate( diff --git a/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerHeaderViewModel.kt b/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerHeaderViewModel.kt index d75c0d03287..2b5940de62c 100644 --- a/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerHeaderViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerHeaderViewModel.kt @@ -28,7 +28,9 @@ class NavigationDrawerHeaderViewModel @Inject constructor( ObservableField(computeProfileStoryProgressText()) fun onHeaderClicked() { - routeToProfileProgressListener.routeToProfileProgress(profile.get()!!.id.internalId) + routeToProfileProgressListener.routeToProfileProgress( + profile.get()!!.id.loggedInInternalProfileId + ) } fun setOngoingTopicProgress(ongoingTopicCount: Int) { diff --git a/app/src/main/java/org/oppia/android/app/home/HomeActivity.kt b/app/src/main/java/org/oppia/android/app/home/HomeActivity.kt index 34885717a33..77ba6f1e84b 100644 --- a/app/src/main/java/org/oppia/android/app/home/HomeActivity.kt +++ b/app/src/main/java/org/oppia/android/app/home/HomeActivity.kt @@ -57,7 +57,7 @@ class HomeActivity : super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - internalProfileId = intent.extractCurrentUserProfileId().internalId + internalProfileId = intent.extractCurrentUserProfileId().loggedInInternalProfileId homeActivityPresenter.handleOnCreate(internalProfileId) title = resourceHandler.getStringInLocale(R.string.home_activity_title) } @@ -110,7 +110,9 @@ class HomeActivity : val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId(ProfileId.newBuilder().setInternalId(internalProfileId).build()) + .setProfileId( + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + ) .setActivityTitle(recentlyPlayedActivityTitle).build() activityRouter.routeToScreen( diff --git a/app/src/main/java/org/oppia/android/app/home/HomeFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/home/HomeFragmentPresenter.kt index b3ef5d04e3f..6cd6d2ce35c 100644 --- a/app/src/main/java/org/oppia/android/app/home/HomeFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/home/HomeFragmentPresenter.kt @@ -64,7 +64,7 @@ class HomeFragmentPresenter @Inject constructor( // 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.extractCurrentUserProfileId().internalId + internalProfileId = activity.intent.extractCurrentUserProfileId().loggedInInternalProfileId logHomeActivityEvent() @@ -126,7 +126,7 @@ class HomeFragmentPresenter @Inject constructor( AppStartupState.StartupMode.USER_NOT_YET_ONBOARDED ) { analyticsController.logAppOnboardedEvent( - ProfileId.newBuilder().setInternalId(internalProfileId).build() + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() ) } } @@ -206,7 +206,7 @@ class HomeFragmentPresenter @Inject constructor( private fun logHomeActivityEvent() { analyticsController.logImportantEvent( oppiaLogger.createOpenHomeContext(), - ProfileId.newBuilder().apply { internalId = internalProfileId }.build() + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() ) } } diff --git a/app/src/main/java/org/oppia/android/app/home/HomeViewModel.kt b/app/src/main/java/org/oppia/android/app/home/HomeViewModel.kt index 1696cf74ca9..ec2920a052b 100644 --- a/app/src/main/java/org/oppia/android/app/home/HomeViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/home/HomeViewModel.kt @@ -54,7 +54,8 @@ class HomeViewModel( private val translationController: TranslationController ) : ObservableViewModel() { - private val profileId: ProfileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + private val profileId: ProfileId = + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() private val promotedStoryListLimit = activity.resources.getInteger( R.integer.promoted_story_list_limit ) diff --git a/app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedActivityPresenter.kt index 9eef029e29b..4eb143fe8a0 100644 --- a/app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedActivityPresenter.kt @@ -32,7 +32,9 @@ class RecentlyPlayedActivityPresenter @Inject constructor( if (getRecentlyPlayedFragment() == null) { activity.supportFragmentManager.beginTransaction().add( R.id.recently_played_fragment_placeholder, - RecentlyPlayedFragment.newInstance(recentlyPlayedActivityParams.profileId.internalId), + RecentlyPlayedFragment.newInstance( + recentlyPlayedActivityParams.profileId.loggedInInternalProfileId + ), RecentlyPlayedFragment.TAG_RECENTLY_PLAYED_FRAGMENT ).commitNow() } diff --git a/app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedFragment.kt b/app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedFragment.kt index f599f9150e5..7d3f0016b19 100644 --- a/app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedFragment.kt +++ b/app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedFragment.kt @@ -20,7 +20,7 @@ class RecentlyPlayedFragment : InjectableFragment(), PromotedStoryClickListener /** Returns a new [RecentlyPlayedFragment] to display recently played stories. */ fun newInstance(internalProfileId: Int): RecentlyPlayedFragment { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return RecentlyPlayedFragment().apply { arguments = Bundle().apply { decorateWithUserProfileId(profileId) @@ -47,7 +47,7 @@ class RecentlyPlayedFragment : InjectableFragment(), PromotedStoryClickListener val profileId = arguments.extractCurrentUserProfileId() - val internalProfileId = profileId.internalId + val internalProfileId = profileId.loggedInInternalProfileId return recentlyPlayedFragmentPresenter.handleCreateView(inflater, container, internalProfileId) } diff --git a/app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedFragmentPresenter.kt index 98b7617e0eb..c7fac97425e 100755 --- a/app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedFragmentPresenter.kt @@ -51,7 +51,7 @@ class RecentlyPlayedFragmentPresenter @Inject constructor( container: ViewGroup?, internalProfileId: Int ): View? { - this.profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + this.profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val recentlyPlayedViewModel = recentlyPlayedViewModelFactory.create( fragment as PromotedStoryClickListener, this.profileId @@ -178,13 +178,13 @@ class RecentlyPlayedFragmentPresenter @Inject constructor( // cases, lessons played from this fragment are known to be in progress, and that progress // can't be resumed here (hence the restart). explorationDataController.restartExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId.loggedInInternalProfileId, classroomId, topicId, storyId, explorationId ) } else { // The only lessons that can't have their progress saved are those that were already // completed. explorationDataController.replayExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId.loggedInInternalProfileId, classroomId, topicId, storyId, explorationId ) } startPlayingProvider.toLiveData().observe(fragment) { result -> diff --git a/app/src/main/java/org/oppia/android/app/mydownloads/MyDownloadsActivity.kt b/app/src/main/java/org/oppia/android/app/mydownloads/MyDownloadsActivity.kt index 7d6be2cf97d..172d7f8c45f 100644 --- a/app/src/main/java/org/oppia/android/app/mydownloads/MyDownloadsActivity.kt +++ b/app/src/main/java/org/oppia/android/app/mydownloads/MyDownloadsActivity.kt @@ -31,12 +31,14 @@ class MyDownloadsActivity : InjectableAutoLocalizedAppCompatActivity() { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) myDownloadsActivityPresenter.handleOnCreate() - internalProfileId = intent?.extractCurrentUserProfileId()?.internalId ?: -1 + internalProfileId = intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 } companion object { fun createMyDownloadsActivityIntent(context: Context, internalProfileId: Int?): Intent { - val profileId = internalProfileId?.let { ProfileId.newBuilder().setInternalId(it).build() } + val profileId = internalProfileId?.let { + ProfileId.newBuilder().setLoggedInInternalProfileId(it).build() + } val intent = Intent(context, MyDownloadsActivity::class.java) if (profileId != null) { intent.decorateWithUserProfileId(profileId) @@ -47,7 +49,7 @@ class MyDownloadsActivity : InjectableAutoLocalizedAppCompatActivity() { } override fun onBackPressed() { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val intent = if (enableMultipleClassrooms.value) ClassroomListActivity.createClassroomListActivity(this, profileId) else diff --git a/app/src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListActivity.kt b/app/src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListActivity.kt index 92a96385275..7302c8639f0 100644 --- a/app/src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListActivity.kt +++ b/app/src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListActivity.kt @@ -20,7 +20,8 @@ class OngoingTopicListActivity : InjectableAutoLocalizedAppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - val internalProfileId: Int = intent?.extractCurrentUserProfileId()?.internalId ?: -1 + val internalProfileId: Int = + intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 ongoingTopicListActivityPresenter.handleOnCreate(internalProfileId) } @@ -28,7 +29,7 @@ class OngoingTopicListActivity : InjectableAutoLocalizedAppCompatActivity() { // TODO(#1655): Re-restrict access to fields in tests post-Gradle. /** Returns a new [Intent] to route to [OngoingTopicListActivity] for a specified profile ID. */ fun createOngoingTopicListActivityIntent(context: Context, internalProfileId: Int): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return Intent(context, OngoingTopicListActivity::class.java).apply { decorateWithUserProfileId(profileId) decorateWithScreenName(ONGOING_TOPIC_LIST_ACTIVITY) diff --git a/app/src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListFragment.kt b/app/src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListFragment.kt index df42a578654..297c885656b 100644 --- a/app/src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListFragment.kt +++ b/app/src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListFragment.kt @@ -23,7 +23,7 @@ class OngoingTopicListFragment : InjectableFragment() { fun newInstance(internalProfileId: Int): OngoingTopicListFragment { val ongoingTopicListFragment = OngoingTopicListFragment() val args = Bundle() - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() args.decorateWithUserProfileId(profileId) ongoingTopicListFragment.arguments = args return ongoingTopicListFragment @@ -45,7 +45,7 @@ class OngoingTopicListFragment : InjectableFragment() { ): View? { val args = checkNotNull(arguments) { "Expected arguments to be passed to OngoingTopicListFragment" } - val internalProfileId = args.extractCurrentUserProfileId().internalId + val internalProfileId = args.extractCurrentUserProfileId().loggedInInternalProfileId return ongoingTopicListFragmentPresenter.handleCreateView( inflater, container, diff --git a/app/src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListViewModel.kt b/app/src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListViewModel.kt index 37ecd2369ad..9132d5250b6 100644 --- a/app/src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListViewModel.kt @@ -33,7 +33,7 @@ class OngoingTopicListViewModel @Inject constructor( private val ongoingTopicListResultLiveData: LiveData> by lazy { topicController.getOngoingTopicList( - ProfileId.newBuilder().setInternalId(internalProfileId).build() + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() ).toLiveData() } diff --git a/app/src/main/java/org/oppia/android/app/options/AppLanguageActivity.kt b/app/src/main/java/org/oppia/android/app/options/AppLanguageActivity.kt index 961113c101f..abb447ace5c 100644 --- a/app/src/main/java/org/oppia/android/app/options/AppLanguageActivity.kt +++ b/app/src/main/java/org/oppia/android/app/options/AppLanguageActivity.kt @@ -23,15 +23,16 @@ import javax.inject.Inject class AppLanguageActivity : InjectableAutoLocalizedAppCompatActivity() { @Inject lateinit var appLanguageActivityPresenter: AppLanguageActivityPresenter - private var profileId: Int? = -1 + private var profileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - profileId = intent?.extractCurrentUserProfileId()?.internalId ?: -1 + profileId = + intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() appLanguageActivityPresenter.handleOnCreate( savedInstanceState?.retrieveLanguageFromSavedState() ?: intent.retrieveLanguageFromParams(), - profileId!! + profileId.loggedInInternalProfileId ) } @@ -45,7 +46,8 @@ class AppLanguageActivity : InjectableAutoLocalizedAppCompatActivity() { oppiaLanguage: OppiaLanguage, internalProfileId: Int? ): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId!!).build() + val profileId = + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId!!).build() return Intent(context, AppLanguageActivity::class.java).apply { val arguments = AppLanguageActivityParams.newBuilder().apply { this.oppiaLanguage = oppiaLanguage diff --git a/app/src/main/java/org/oppia/android/app/options/AppLanguageFragment.kt b/app/src/main/java/org/oppia/android/app/options/AppLanguageFragment.kt index b946c93555b..d53e62766d5 100644 --- a/app/src/main/java/org/oppia/android/app/options/AppLanguageFragment.kt +++ b/app/src/main/java/org/oppia/android/app/options/AppLanguageFragment.kt @@ -22,7 +22,7 @@ class AppLanguageFragment : InjectableFragment(), AppLanguageRadioButtonListener @Inject lateinit var appLanguageFragmentPresenter: AppLanguageFragmentPresenter - private var profileId: Int? = -1 + private var profileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() companion object { private const val FRAGMENT_ARGUMENTS_KEY = "AppLanguageFragment.arguments" @@ -30,7 +30,7 @@ class AppLanguageFragment : InjectableFragment(), AppLanguageRadioButtonListener /** Returns a new [AppLanguageFragment] instance. */ fun newInstance(oppiaLanguage: OppiaLanguage, internalProfileId: Int): AppLanguageFragment { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return AppLanguageFragment().apply { arguments = Bundle().apply { val args = AppLanguageFragmentArguments.newBuilder().apply { @@ -70,13 +70,14 @@ class AppLanguageFragment : InjectableFragment(), AppLanguageRadioButtonListener savedInstanceState?.retrieveLanguageFromSavedState() ?: arguments?.retrieveLanguageFromArguments() ) { "Expected arguments to be passed to AppLanguageFragment" } - profileId = arguments?.extractCurrentUserProfileId()?.internalId ?: -1 + profileId = + arguments?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() return appLanguageFragmentPresenter.handleOnCreateView( inflater, container, oppiaLanguage, - profileId!! + profileId.loggedInInternalProfileId ) } diff --git a/app/src/main/java/org/oppia/android/app/options/AppLanguageFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/options/AppLanguageFragmentPresenter.kt index a7a550583b3..a12dbb118d7 100644 --- a/app/src/main/java/org/oppia/android/app/options/AppLanguageFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/options/AppLanguageFragmentPresenter.kt @@ -40,7 +40,7 @@ class AppLanguageFragmentPresenter @Inject constructor( /* attachToRoot= */ false ) this.appLanguage = prefSummaryValue - this.profileId = ProfileId.newBuilder().apply { internalId = profileId }.build() + this.profileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = profileId }.build() appLanguageSelectionViewModel.selectedLanguage.value = prefSummaryValue binding.viewModel = appLanguageSelectionViewModel binding.lifecycleOwner = fragment diff --git a/app/src/main/java/org/oppia/android/app/options/OptionsActivity.kt b/app/src/main/java/org/oppia/android/app/options/OptionsActivity.kt index 52a993a52f6..6aae80a0931 100644 --- a/app/src/main/java/org/oppia/android/app/options/OptionsActivity.kt +++ b/app/src/main/java/org/oppia/android/app/options/OptionsActivity.kt @@ -94,7 +94,7 @@ class OptionsActivity : OptionsActivityParams.getDefaultInstance() ) val isFromNavigationDrawer = args?.isFromNavigationDrawer ?: false - profileId = intent.extractCurrentUserProfileId().internalId + profileId = intent.extractCurrentUserProfileId().loggedInInternalProfileId if (savedInstanceState != null) { isFirstOpen = false } diff --git a/app/src/main/java/org/oppia/android/app/options/OptionsFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/options/OptionsFragmentPresenter.kt index b13cf402a8e..cd7fcbabcef 100644 --- a/app/src/main/java/org/oppia/android/app/options/OptionsFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/options/OptionsFragmentPresenter.kt @@ -70,8 +70,9 @@ class OptionsFragmentPresenter @Inject constructor( /* attachToRoot= */ false ) - internalProfileId = activity.intent?.extractCurrentUserProfileId()?.internalId ?: -1 - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + internalProfileId = + activity.intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() optionControlsViewModel.setProfileId(profileId) val optionsRecyclerViewAdapter = createRecyclerViewAdapter(isMultipane) diff --git a/app/src/main/java/org/oppia/android/app/player/audio/AudioFragment.kt b/app/src/main/java/org/oppia/android/app/player/audio/AudioFragment.kt index a4fc2738f49..7aec567d051 100755 --- a/app/src/main/java/org/oppia/android/app/player/audio/AudioFragment.kt +++ b/app/src/main/java/org/oppia/android/app/player/audio/AudioFragment.kt @@ -30,7 +30,7 @@ class AudioFragment : */ fun newInstance(internalProfileId: Int): AudioFragment { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val audioFragment = AudioFragment() val args = Bundle() args.decorateWithUserProfileId(profileId) @@ -51,7 +51,7 @@ class AudioFragment : ): View? { super.onCreateView(inflater, container, savedInstanceState) val internalProfileId = - arguments?.extractCurrentUserProfileId()?.internalId ?: -1 + arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 return audioFragmentPresenter.handleCreateView(inflater, container, internalProfileId) } diff --git a/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt index 60f4214458e..099459986bf 100644 --- a/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt @@ -71,7 +71,7 @@ class AudioFragmentPresenter @Inject constructor( container: ViewGroup?, internalProfileId: Int ): View? { - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() cellularAudioDialogController.getCellularDataPreference().toLiveData() .observe( fragment, diff --git a/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivityPresenter.kt index 9d1c50ec2ea..e763ffd1cb7 100644 --- a/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivityPresenter.kt @@ -150,7 +150,7 @@ class ExplorationActivityPresenter @Inject constructor( if (getSpotlightManager() == null) { activity.supportFragmentManager.beginTransaction().add( R.id.exploration_spotlight_fragment_placeholder, - SpotlightFragment.newInstance(profileId.internalId), + SpotlightFragment.newInstance(profileId.loggedInInternalProfileId), SpotlightManager.SPOTLIGHT_FRAGMENT_TAG ).commitNow() } @@ -392,7 +392,7 @@ class ExplorationActivityPresenter @Inject constructor( activity.startActivity( TopicActivity.createTopicActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, classroomId, topicId ) diff --git a/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationFragmentPresenter.kt index 151f2456f53..531b5c6701a 100755 --- a/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationFragmentPresenter.kt @@ -53,10 +53,10 @@ class ExplorationFragmentPresenter @Inject constructor( val args = retrieveArguments() val binding = ExplorationFragmentBinding.inflate(inflater, container, /* attachToRoot= */ false).root - internalProfileId = args.profileId.internalId + internalProfileId = args.profileId.loggedInInternalProfileId val stateFragment = StateFragment.newInstance( - args.profileId.internalId, args.topicId, args.storyId, args.explorationId + args.profileId.loggedInInternalProfileId, args.topicId, args.storyId, args.explorationId ) logPracticeFragmentEvent(args.classroomId, args.topicId, args.storyId, args.explorationId) if (getStateFragment() == null) { @@ -163,7 +163,7 @@ class ExplorationFragmentPresenter @Inject constructor( oppiaLogger.createOpenExplorationActivityContext( classroomId, topicId, storyId, explorationId ), - ProfileId.newBuilder().apply { internalId = internalProfileId }.build() + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() ) } diff --git a/app/src/main/java/org/oppia/android/app/player/state/StateFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/player/state/StateFragmentPresenter.kt index 672595d81ef..c6c9bb09a03 100755 --- a/app/src/main/java/org/oppia/android/app/player/state/StateFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/player/state/StateFragmentPresenter.kt @@ -115,7 +115,7 @@ class StateFragmentPresenter @Inject constructor( explorationId: String, userAnswerState: UserAnswerState ): View? { - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() this.topicId = topicId this.storyId = storyId this.explorationId = explorationId @@ -288,7 +288,8 @@ class StateFragmentPresenter @Inject constructor( private fun getAudioUiManager(): AudioUiManager? { if (getAudioFragment() == null) { - val audioFragment: AudioFragment = AudioFragment.newInstance(profileId.internalId) + val audioFragment: AudioFragment = + AudioFragment.newInstance(profileId.loggedInInternalProfileId) fragment.childFragmentManager.beginTransaction() .add(R.id.audio_fragment_placeholder, audioFragment, TAG_AUDIO_FRAGMENT).commitNow() } diff --git a/app/src/main/java/org/oppia/android/app/player/state/testing/StateFragmentTestActivity.kt b/app/src/main/java/org/oppia/android/app/player/state/testing/StateFragmentTestActivity.kt index 2fc44ad11f5..35048f39e79 100644 --- a/app/src/main/java/org/oppia/android/app/player/state/testing/StateFragmentTestActivity.kt +++ b/app/src/main/java/org/oppia/android/app/player/state/testing/StateFragmentTestActivity.kt @@ -50,7 +50,7 @@ class StateFragmentTestActivity : ) profileId = ProfileId.newBuilder().apply { - internalId = args?.internalProfileId ?: -1 + loggedInInternalProfileId = args?.internalProfileId ?: -1 }.build() stateFragmentTestActivityPresenter.handleOnCreate() } diff --git a/app/src/main/java/org/oppia/android/app/player/state/testing/StateFragmentTestActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/player/state/testing/StateFragmentTestActivityPresenter.kt index 6beed9aaf21..6eb32af5bf0 100644 --- a/app/src/main/java/org/oppia/android/app/player/state/testing/StateFragmentTestActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/player/state/testing/StateFragmentTestActivityPresenter.kt @@ -87,7 +87,7 @@ class StateFragmentTestActivityPresenter @Inject constructor( fun deleteCurrentProgressAndStopExploration(isCompletion: Boolean) { explorationDataController.deleteExplorationProgressById( - ProfileId.newBuilder().setInternalId(profileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(profileId).build(), explorationId ) stopExploration(isCompletion) diff --git a/app/src/main/java/org/oppia/android/app/profile/AdminAuthActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/profile/AdminAuthActivityPresenter.kt index d93df994351..f206f5371be 100644 --- a/app/src/main/java/org/oppia/android/app/profile/AdminAuthActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/profile/AdminAuthActivityPresenter.kt @@ -84,14 +84,19 @@ class AdminAuthActivityPresenter @Inject constructor( if (inputPin == adminPin) { when (args?.adminPinEnum ?: 0) { AdminAuthEnum.PROFILE_ADMIN_CONTROLS.value -> { - val internalId = args?.internalProfileId ?: -1 - val profileId = ProfileId.newBuilder().setInternalId(internalId).build() + val profileId = args?.internalProfileId?.let { internalId -> + if (internalId == -1) { + ProfileId.newBuilder().setLoggedOut(true).build() + } else { + ProfileId.newBuilder().setLoggedInInternalProfileId(internalId).build() + } + } ?: ProfileId.newBuilder().setLoggedOut(true).build() + activity.startActivity( AdministratorControlsActivity.createAdministratorControlsActivityIntent( context, profileId ) ) - activity.finish() } AdminAuthEnum.PROFILE_ADD_PROFILE.value -> { diff --git a/app/src/main/java/org/oppia/android/app/profile/AdminPinActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/profile/AdminPinActivityPresenter.kt index d00d9e72dcc..ab133eeae64 100644 --- a/app/src/main/java/org/oppia/android/app/profile/AdminPinActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/profile/AdminPinActivityPresenter.kt @@ -115,10 +115,11 @@ class AdminPinActivityPresenter @Inject constructor( if (failed) { return@setOnClickListener } - val profileId = - ProfileId.newBuilder() - .setInternalId(args?.internalProfileId ?: -1) - .build() + val profileId = if (args?.internalProfileId != null && args.internalProfileId != -1) { + ProfileId.newBuilder().setLoggedInInternalProfileId(args.internalProfileId).build() + } else { + ProfileId.newBuilder().setLoggedOut(true).build() + } profileManagementController.updatePin(profileId, inputPin).toLiveData().observe( activity, diff --git a/app/src/main/java/org/oppia/android/app/profile/PinPasswordActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/profile/PinPasswordActivityPresenter.kt index 266a88636fa..97db4294aa9 100644 --- a/app/src/main/java/org/oppia/android/app/profile/PinPasswordActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/profile/PinPasswordActivityPresenter.kt @@ -39,7 +39,8 @@ class PinPasswordActivityPresenter @Inject constructor( private val accessibilityService: AccessibilityService, @EnableMultipleClassrooms private val enableMultipleClassrooms: PlatformParameterValue, ) { - private var internalProfileId = -1 + private var internalProfileId = + ProfileId.newBuilder().setLoggedOut(true).build().loggedInInternalProfileId private var profileId = ProfileId.getDefaultInstance() private lateinit var alertDialog: AlertDialog private var confirmedDeletion = false @@ -51,8 +52,9 @@ class PinPasswordActivityPresenter @Inject constructor( ) val adminPin = args?.adminPin - internalProfileId = args?.internalProfileId ?: -1 - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + internalProfileId = args?.internalProfileId ?: ProfileId.newBuilder().setLoggedOut(true) + .build().loggedInInternalProfileId + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val binding = DataBindingUtil.setContentView( activity, diff --git a/app/src/main/java/org/oppia/android/app/profile/PinPasswordViewModel.kt b/app/src/main/java/org/oppia/android/app/profile/PinPasswordViewModel.kt index a448f9d67e8..55537c3ac2d 100644 --- a/app/src/main/java/org/oppia/android/app/profile/PinPasswordViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/profile/PinPasswordViewModel.kt @@ -44,7 +44,7 @@ class PinPasswordViewModel @Inject constructor( } fun setProfileId(id: Int) { - profileId = ProfileId.newBuilder().setInternalId(id).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(id).build() } private fun processGetProfileResult(profileResult: AsyncResult): Profile { diff --git a/app/src/main/java/org/oppia/android/app/profile/ProfileChooserFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/profile/ProfileChooserFragmentPresenter.kt index 371bdfc9037..9339f6f02c1 100644 --- a/app/src/main/java/org/oppia/android/app/profile/ProfileChooserFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/profile/ProfileChooserFragmentPresenter.kt @@ -195,7 +195,7 @@ class ProfileChooserFragmentPresenter @Inject constructor( val pinPasswordIntent = PinPasswordActivity.createPinPasswordActivityIntent( activity, chooserViewModel.adminPin, - model.profile.id.internalId + model.profile.id.loggedInInternalProfileId ) activity.startActivity(pinPasswordIntent) } @@ -212,7 +212,7 @@ class ProfileChooserFragmentPresenter @Inject constructor( activity.startActivity( AdminPinActivity.createAdminPinActivityIntent( activity, - chooserViewModel.adminProfileId.internalId, + chooserViewModel.adminProfileId.loggedInInternalProfileId, selectUniqueRandomColor(), AdminAuthEnum.PROFILE_ADD_PROFILE.value ) @@ -234,7 +234,9 @@ class ProfileChooserFragmentPresenter @Inject constructor( fun routeToAdminPin() { if (chooserViewModel.adminPin.isEmpty()) { val profileId = - ProfileId.newBuilder().setInternalId(chooserViewModel.adminProfileId.internalId).build() + ProfileId.newBuilder() + .setLoggedInInternalProfileId(chooserViewModel.adminProfileId.loggedInInternalProfileId) + .build() activity.startActivity( AdministratorControlsActivity.createAdministratorControlsActivityIntent( activity, @@ -246,7 +248,7 @@ class ProfileChooserFragmentPresenter @Inject constructor( AdminAuthActivity.createAdminAuthActivityIntent( activity, chooserViewModel.adminPin, - chooserViewModel.adminProfileId.internalId, + chooserViewModel.adminProfileId.loggedInInternalProfileId, selectUniqueRandomColor(), AdminAuthEnum.PROFILE_ADMIN_CONTROLS.value ) diff --git a/app/src/main/java/org/oppia/android/app/profile/ResetPinDialogFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/profile/ResetPinDialogFragmentPresenter.kt index a4105ee19e4..efea52ac7b0 100644 --- a/app/src/main/java/org/oppia/android/app/profile/ResetPinDialogFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/profile/ResetPinDialogFragmentPresenter.kt @@ -91,7 +91,10 @@ class ResetPinDialogFragmentPresenter @Inject constructor( } if (input.length == 3) { profileManagementController - .updatePin(ProfileId.newBuilder().setInternalId(profileId).build(), input).toLiveData() + .updatePin( + ProfileId.newBuilder().setLoggedInInternalProfileId(profileId).build(), + input + ).toLiveData() .observe( fragment, Observer { diff --git a/app/src/main/java/org/oppia/android/app/profileprogress/ProfilePictureActivity.kt b/app/src/main/java/org/oppia/android/app/profileprogress/ProfilePictureActivity.kt index 306ba0ea413..f93e9e1b7f5 100644 --- a/app/src/main/java/org/oppia/android/app/profileprogress/ProfilePictureActivity.kt +++ b/app/src/main/java/org/oppia/android/app/profileprogress/ProfilePictureActivity.kt @@ -21,13 +21,13 @@ class ProfilePictureActivity : InjectableAutoLocalizedAppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - val internalProfileId = intent?.extractCurrentUserProfileId()?.internalId ?: -1 + val internalProfileId = intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 profilePictureActivityPresenter.handleOnCreate(internalProfileId) } companion object { fun createProfilePictureActivityIntent(context: Context, internalProfileId: Int): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return Intent(context, ProfilePictureActivity::class.java).apply { decorateWithScreenName(PROFILE_PICTURE_ACTIVITY) decorateWithUserProfileId(profileId) diff --git a/app/src/main/java/org/oppia/android/app/profileprogress/ProfilePictureActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/profileprogress/ProfilePictureActivityPresenter.kt index cd9398374aa..b417570fa45 100644 --- a/app/src/main/java/org/oppia/android/app/profileprogress/ProfilePictureActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/profileprogress/ProfilePictureActivityPresenter.kt @@ -45,7 +45,7 @@ class ProfilePictureActivityPresenter @Inject constructor( viewModel = profilePictureActivityViewModel lifecycleOwner = activity } - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() subscribeToProfileLiveData() setUpToolbar() diff --git a/app/src/main/java/org/oppia/android/app/profileprogress/ProfileProgressActivity.kt b/app/src/main/java/org/oppia/android/app/profileprogress/ProfileProgressActivity.kt index b0066ad36f5..39251c63ced 100644 --- a/app/src/main/java/org/oppia/android/app/profileprogress/ProfileProgressActivity.kt +++ b/app/src/main/java/org/oppia/android/app/profileprogress/ProfileProgressActivity.kt @@ -45,7 +45,7 @@ class ProfileProgressActivity : override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - internalProfileId = intent?.extractCurrentUserProfileId()?.internalId ?: -1 + internalProfileId = intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 profileProgressActivityPresenter.handleOnCreate(internalProfileId) resultLauncher = registerForActivityResult( @@ -61,7 +61,9 @@ class ProfileProgressActivity : val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId(ProfileId.newBuilder().setInternalId(internalProfileId).build()) + .setProfileId( + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + ) .setActivityTitle(recentlyPlayedActivityTitle) .build() @@ -95,7 +97,7 @@ class ProfileProgressActivity : // TODO(#1655): Re-restrict access to fields in tests post-Gradle. fun createProfileProgressActivityIntent(context: Context, internalProfileId: Int): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return Intent(context, ProfileProgressActivity::class.java).apply { decorateWithUserProfileId(profileId) decorateWithScreenName(PROFILE_PROGRESS_ACTIVITY) diff --git a/app/src/main/java/org/oppia/android/app/profileprogress/ProfileProgressActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/profileprogress/ProfileProgressActivityPresenter.kt index 836f5cfc0d5..e50f7017858 100644 --- a/app/src/main/java/org/oppia/android/app/profileprogress/ProfileProgressActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/profileprogress/ProfileProgressActivityPresenter.kt @@ -19,7 +19,7 @@ class ProfileProgressActivityPresenter @Inject constructor( private lateinit var profileId: ProfileId fun handleOnCreate(internalProfileId: Int) { - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() activity.setContentView(R.layout.profile_progress_activity) if (getProfileProgressFragment() == null) { activity.supportFragmentManager.beginTransaction().add( diff --git a/app/src/main/java/org/oppia/android/app/profileprogress/ProfileProgressFragment.kt b/app/src/main/java/org/oppia/android/app/profileprogress/ProfileProgressFragment.kt index 5e0e3338be4..668749bbc5f 100644 --- a/app/src/main/java/org/oppia/android/app/profileprogress/ProfileProgressFragment.kt +++ b/app/src/main/java/org/oppia/android/app/profileprogress/ProfileProgressFragment.kt @@ -19,7 +19,7 @@ class ProfileProgressFragment : companion object { /** Returns a new [ProfileProgressFragment] to display the progress for a specified profile ID. */ fun newInstance(internalProfileId: Int): ProfileProgressFragment { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val profileProgressFragment = ProfileProgressFragment() val args = Bundle() args.decorateWithUserProfileId(profileId) @@ -43,7 +43,7 @@ class ProfileProgressFragment : ): View? { val args = checkNotNull(arguments) { "Expected arguments to be passed to ProfileProgressFragment" } - val internalProfileId = args.extractCurrentUserProfileId().internalId + val internalProfileId = args.extractCurrentUserProfileId().loggedInInternalProfileId return profileProgressFragmentPresenter.handleCreateView(inflater, container, internalProfileId) } diff --git a/app/src/main/java/org/oppia/android/app/profileprogress/ProfileProgressViewModel.kt b/app/src/main/java/org/oppia/android/app/profileprogress/ProfileProgressViewModel.kt index d3844e3ce10..0faa62af669 100644 --- a/app/src/main/java/org/oppia/android/app/profileprogress/ProfileProgressViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/profileprogress/ProfileProgressViewModel.kt @@ -52,7 +52,7 @@ class ProfileProgressViewModel @Inject constructor( ) fun setProfileId(internalProfileId: Int) { - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() this.internalProfileId = internalProfileId subscribeToProfileLiveData() diff --git a/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentPresenter.kt index 541cfa104ad..e8953a4bc8f 100644 --- a/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentPresenter.kt @@ -198,11 +198,16 @@ class ResumeLessonFragmentPresenter @Inject constructor( ) { val startPlayingProvider = if (checkpoint == ExplorationCheckpoint.getDefaultInstance()) { explorationDataController.restartExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId.loggedInInternalProfileId, classroomId, topicId, storyId, explorationId ) } else { explorationDataController.resumeExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId, checkpoint + profileId.loggedInInternalProfileId, + classroomId, + topicId, + storyId, + explorationId, + checkpoint ) } startPlayingProvider.toLiveData().observe(fragment) { result -> diff --git a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditDeletionDialogFragment.kt b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditDeletionDialogFragment.kt index 3f3a8a6c940..cd53cc639f8 100644 --- a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditDeletionDialogFragment.kt +++ b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditDeletionDialogFragment.kt @@ -23,7 +23,7 @@ class ProfileEditDeletionDialogFragment : InjectableDialogFragment() { /** Creates new instance of the fragment [ProfileEditFragment]. */ fun newInstance(internalProfileId: Int): ProfileEditDeletionDialogFragment { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val profileEditDeletionDialog = ProfileEditDeletionDialogFragment() val args = Bundle() args.decorateWithUserProfileId(profileId) @@ -46,7 +46,7 @@ class ProfileEditDeletionDialogFragment : InjectableDialogFragment() { "Expected arguments to be pass to ProfileEditDeletionDialogFragment" } - val internalProfileId = args.extractCurrentUserProfileId().internalId + val internalProfileId = args.extractCurrentUserProfileId().loggedInInternalProfileId profileEditDialogInterface = parentFragment as ProfileEditFragment diff --git a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditFragmentPresenter.kt index c5df7aa5439..b129becc197 100644 --- a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditFragmentPresenter.kt @@ -101,7 +101,7 @@ class ProfileEditFragmentPresenter @Inject constructor( val enableDownloads = !binding.profileEditAllowDownloadSwitch.isChecked binding.profileEditAllowDownloadSwitch.isChecked = enableDownloads profileManagementController.updateAllowDownloadAccess( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), enableDownloads ).toLiveData().observe(activity) { if (it is AsyncResult.Failure) { @@ -115,7 +115,7 @@ class ProfileEditFragmentPresenter @Inject constructor( val enableLangSwitching = !binding.profileEditEnableInLessonLanguageSwitchingSwitch.isChecked binding.profileEditEnableInLessonLanguageSwitchingSwitch.isChecked = enableLangSwitching profileManagementController.updateEnableInLessonQuickLanguageSwitching( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), enableLangSwitching ).toLiveData().observe(activity) { if (it is AsyncResult.Failure) { @@ -146,7 +146,8 @@ class ProfileEditFragmentPresenter @Inject constructor( */ fun deleteProfile(internalProfileId: Int) { profileManagementController - .deleteProfile(ProfileId.newBuilder().setInternalId(internalProfileId).build()).toLiveData() + .deleteProfile(ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build()) + .toLiveData() .observe( fragment, Observer { diff --git a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditViewModel.kt b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditViewModel.kt index 90f3d710703..d8c8680412c 100644 --- a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditViewModel.kt @@ -55,7 +55,7 @@ class ProfileEditViewModel @Inject constructor( /** Sets the identifier of the profile. */ fun setProfileId(id: Int) { - profileId = ProfileId.newBuilder().setInternalId(id).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(id).build() } /** Fetches the profile of a user asynchronously. */ @@ -64,7 +64,7 @@ class ProfileEditViewModel @Inject constructor( is AsyncResult.Failure -> { oppiaLogger.e( "ProfileEditViewModel", - "Failed to retrieve the profile with ID: ${profileId.internalId}", + "Failed to retrieve the profile with ID: ${profileId.loggedInInternalProfileId}", profileResult.error ) Profile.getDefaultInstance() diff --git a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileListFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileListFragmentPresenter.kt index 91fd34399d1..8930226eef3 100644 --- a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileListFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileListFragmentPresenter.kt @@ -69,10 +69,10 @@ class ProfileListFragmentPresenter @Inject constructor( if (!isMultipane) { val routeToProfileEditListener = (activity as RouteToProfileEditListener) - routeToProfileEditListener.routeToProfileEditActivity(profile.id.internalId) + routeToProfileEditListener.routeToProfileEditActivity(profile.id.loggedInInternalProfileId) } else { val loadProfileEditListener = (activity as LoadProfileEditListener) - loadProfileEditListener.loadProfileEdit(profile.id.internalId, profile.name) + loadProfileEditListener.loadProfileEdit(profile.id.loggedInInternalProfileId, profile.name) } } } diff --git a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileRenameActivity.kt b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileRenameActivity.kt index 8733738725d..242e45259a7 100644 --- a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileRenameActivity.kt +++ b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileRenameActivity.kt @@ -21,7 +21,7 @@ class ProfileRenameActivity : InjectableAutoLocalizedAppCompatActivity() { /** Returns an [Intent] for opening [ProfileRenameActivity]. */ fun createProfileRenameActivity(context: Context, internalProfileId: Int): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return Intent(context, ProfileRenameActivity::class.java).apply { decorateWithUserProfileId(profileId) decorateWithScreenName(PROFILE_RENAME_ACTIVITY) @@ -34,7 +34,7 @@ class ProfileRenameActivity : InjectableAutoLocalizedAppCompatActivity() { (activityComponent as ActivityComponentImpl).inject(this) profileRenameActivityPresenter.handleOnCreate( - intent?.extractCurrentUserProfileId()?.internalId ?: 0 + intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: 0 ) } diff --git a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileRenameFragment.kt b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileRenameFragment.kt index fe56faf9ddb..d97ea6361ed 100644 --- a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileRenameFragment.kt +++ b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileRenameFragment.kt @@ -22,7 +22,7 @@ class ProfileRenameFragment : InjectableFragment() { /** Returns the instance of [ProfileRenameFragment]. */ fun newInstance(internalProfileId: Int): ProfileRenameFragment { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return ProfileRenameFragment().apply { arguments = Bundle().apply { decorateWithUserProfileId(profileId) @@ -43,7 +43,7 @@ class ProfileRenameFragment : InjectableFragment() { ): View? { val args = checkNotNull(arguments) { "Expected arguments to be passed to ProfileRenameFragment" } - val profileId = args.extractCurrentUserProfileId().internalId + val profileId = args.extractCurrentUserProfileId().loggedInInternalProfileId return profileRenameFragmentPresenter.handleCreateView( inflater, diff --git a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileRenameFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileRenameFragmentPresenter.kt index 3ad5bcd4f68..e595b5af77d 100644 --- a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileRenameFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileRenameFragmentPresenter.kt @@ -59,7 +59,7 @@ class ProfileRenameFragmentPresenter @Inject constructor( } profileManagementController .updateName( - ProfileId.newBuilder().setInternalId(profileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(profileId).build(), binding.profileRenameInputEditText.text.toString() ).toLiveData() .observe( diff --git a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileResetPinFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileResetPinFragmentPresenter.kt index fb4e499fafd..f7585526f9f 100644 --- a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileResetPinFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileResetPinFragmentPresenter.kt @@ -126,7 +126,8 @@ class ProfileResetPinFragmentPresenter @Inject constructor( return@setOnClickListener } profileManagementController - .updatePin(ProfileId.newBuilder().setInternalId(profileId).build(), pin).toLiveData() + .updatePin(ProfileId.newBuilder().setLoggedInInternalProfileId(profileId).build(), pin) + .toLiveData() .observe( activity, Observer { diff --git a/app/src/main/java/org/oppia/android/app/shim/IntentFactoryShimImpl.kt b/app/src/main/java/org/oppia/android/app/shim/IntentFactoryShimImpl.kt index d07bd9c5cc6..db80983a079 100644 --- a/app/src/main/java/org/oppia/android/app/shim/IntentFactoryShimImpl.kt +++ b/app/src/main/java/org/oppia/android/app/shim/IntentFactoryShimImpl.kt @@ -34,7 +34,7 @@ class IntentFactoryShimImpl @Inject constructor( ): Intent { return topicActivityIntentFactory.createIntent( ProfileId.newBuilder().apply { - internalId = internalProfileId + loggedInInternalProfileId = internalProfileId }.build(), classroomId, topicId, @@ -53,7 +53,7 @@ class IntentFactoryShimImpl @Inject constructor( ): Intent { return topicActivityIntentFactory.createIntent( ProfileId.newBuilder().apply { - internalId = internalProfileId + loggedInInternalProfileId = internalProfileId }.build(), classroomId, topicId diff --git a/app/src/main/java/org/oppia/android/app/spotlight/SpotlightFragment.kt b/app/src/main/java/org/oppia/android/app/spotlight/SpotlightFragment.kt index 7ad89f58e2b..bd98bf5f9fa 100644 --- a/app/src/main/java/org/oppia/android/app/spotlight/SpotlightFragment.kt +++ b/app/src/main/java/org/oppia/android/app/spotlight/SpotlightFragment.kt @@ -63,7 +63,7 @@ class SpotlightFragment : InjectableFragment(), SpotlightNavigationListener, Spo private var screenHeight: Int = 0 private var screenWidth: Int = 0 private lateinit var overlayBinding: Any - private var internalProfileId: Int = -1 + private var profileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() private var isSpotlightActive = false private val isRtl by lazy { resourceHandler.getLayoutDirection() == ViewCompat.LAYOUT_DIRECTION_RTL @@ -73,7 +73,8 @@ class SpotlightFragment : InjectableFragment(), SpotlightNavigationListener, Spo override fun onAttach(context: Context) { super.onAttach(context) (fragmentComponent as FragmentComponentImpl).inject(this) - internalProfileId = arguments?.extractCurrentUserProfileId()?.internalId ?: -1 + profileId = + arguments?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() calculateScreenSize() } @@ -99,17 +100,13 @@ class SpotlightFragment : InjectableFragment(), SpotlightNavigationListener, Spo // When Talkback is turned on, do not show spotlights since they are visual tools and can // potentially make the app experience difficult for a non-sighted user. if (accessibilityService.isScreenReaderEnabled() || !enableSpotlightUi.value) return - val profileId = ProfileId.newBuilder() - .setInternalId(internalProfileId) - .build() - + val currentProfileId = profileId val featureViewStateLiveData = spotlightStateController.retrieveSpotlightViewState( - profileId, + currentProfileId, spotlightTarget.feature ).toLiveData() - // Use activity as observer because this fragment's view hasn't been created yet. featureViewStateLiveData.observe( activity, object : Observer> { @@ -139,9 +136,6 @@ class SpotlightFragment : InjectableFragment(), SpotlightNavigationListener, Spo override fun onEnded() { if (targetList.isNotEmpty()) targetList.removeFirst() - val profileId = ProfileId.newBuilder() - .setInternalId(internalProfileId) - .build() spotlightStateController.markSpotlightViewed(profileId, spotlightTarget.feature) } }) @@ -385,7 +379,7 @@ class SpotlightFragment : InjectableFragment(), SpotlightNavigationListener, Spo companion object { /** Returns a new [SpotlightFragment]. */ fun newInstance(internalProfileId: Int): SpotlightFragment { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return SpotlightFragment().apply { arguments = Bundle().apply { decorateWithUserProfileId(profileId) diff --git a/app/src/main/java/org/oppia/android/app/story/StoryActivity.kt b/app/src/main/java/org/oppia/android/app/story/StoryActivity.kt index 43e56fe01c0..817ecd80b19 100644 --- a/app/src/main/java/org/oppia/android/app/story/StoryActivity.kt +++ b/app/src/main/java/org/oppia/android/app/story/StoryActivity.kt @@ -28,7 +28,7 @@ class StoryActivity : RouteToResumeLessonListener { @Inject lateinit var storyActivityPresenter: StoryActivityPresenter - private var internalProfileId: Int = -1 + private lateinit var profileId: ProfileId private lateinit var classroomId: String private lateinit var topicId: String private lateinit var storyId: String @@ -40,7 +40,8 @@ class StoryActivity : STORY_ACTIVITY_PARAMS_KEY, StoryActivityParams.getDefaultInstance() ) - internalProfileId = intent?.extractCurrentUserProfileId()?.internalId ?: -1 + profileId = + intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() classroomId = checkNotNull(args.classroomId) { "Expected extra classroom ID to be included for StoryActivity." } @@ -50,7 +51,15 @@ class StoryActivity : storyId = checkNotNull(args.storyId) { "Expected extra story ID to be included for StoryActivity." } - storyActivityPresenter.handleOnCreate(internalProfileId, classroomId, topicId, storyId) + + if (!profileId.loggedOut) { + storyActivityPresenter.handleOnCreate( + profileId.loggedInInternalProfileId, + classroomId, + topicId, + storyId + ) + } } override fun routeToExploration( @@ -116,7 +125,7 @@ class StoryActivity : topicId: String, storyId: String ): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val args = StoryActivityParams.newBuilder().apply { this.classroomId = classroomId this.topicId = topicId diff --git a/app/src/main/java/org/oppia/android/app/story/StoryFragment.kt b/app/src/main/java/org/oppia/android/app/story/StoryFragment.kt index 2821248a6e0..b5ab485ccc3 100644 --- a/app/src/main/java/org/oppia/android/app/story/StoryFragment.kt +++ b/app/src/main/java/org/oppia/android/app/story/StoryFragment.kt @@ -31,7 +31,7 @@ class StoryFragment : InjectableFragment(), ExplorationSelectionListener, StoryF storyId: String ): StoryFragment { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val args = StoryFragmentArguments.newBuilder().apply { this.classroomId = classroomId this.topicId = topicId @@ -65,7 +65,7 @@ class StoryFragment : InjectableFragment(), ExplorationSelectionListener, StoryF val args = arguments.getProto(STORY_FRAGMENT_ARGUMENTS_KEY, StoryFragmentArguments.getDefaultInstance()) - val internalProfileId = arguments.extractCurrentUserProfileId().internalId + val internalProfileId = arguments.extractCurrentUserProfileId().loggedInInternalProfileId val classroomId = checkNotNull(args.classroomId) { "Expected classroomId to be passed to StoryFragment." diff --git a/app/src/main/java/org/oppia/android/app/story/StoryFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/story/StoryFragmentPresenter.kt index 1d9ff2372c8..f8e4aa4c58a 100644 --- a/app/src/main/java/org/oppia/android/app/story/StoryFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/story/StoryFragmentPresenter.kt @@ -82,8 +82,9 @@ class StoryFragmentPresenter @Inject constructor( container, /* attachToRoot= */ false ) - profileId = ProfileId.newBuilder().apply { internalId = internalProfileId }.build() - storyViewModel.setInternalProfileId(internalProfileId) + profileId = + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() + storyViewModel.setInternalProfileId(profileId) storyViewModel.setClassroomId(classroomId) storyViewModel.setTopicId(topicId) storyViewModel.setStoryId(storyId) @@ -282,7 +283,7 @@ class StoryFragmentPresenter @Inject constructor( // one. val startPlayingProvider = if (canHavePartialProgressSaved) { explorationDataController.startPlayingNewExploration( - profileId.internalId, + profileId.loggedInInternalProfileId, classroomId, topicId, storyId, @@ -290,7 +291,7 @@ class StoryFragmentPresenter @Inject constructor( ) } else { explorationDataController.replayExploration( - profileId.internalId, + profileId.loggedInInternalProfileId, classroomId, topicId, storyId, diff --git a/app/src/main/java/org/oppia/android/app/story/StoryViewModel.kt b/app/src/main/java/org/oppia/android/app/story/StoryViewModel.kt index 2acb48ce3fb..b29caae11f4 100644 --- a/app/src/main/java/org/oppia/android/app/story/StoryViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/story/StoryViewModel.kt @@ -31,7 +31,7 @@ class StoryViewModel @Inject constructor( private val resourceHandler: AppLanguageResourceHandler, private val translationController: TranslationController ) { - private var internalProfileId: Int = -1 + private var profileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() private lateinit var classroomId: String private lateinit var topicId: String @@ -41,7 +41,8 @@ class StoryViewModel @Inject constructor( private val storyResultLiveData: LiveData> by lazy { topicController.getStory( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder() + .setLoggedInInternalProfileId(profileId.loggedInInternalProfileId).build(), topicId, storyId ).toLiveData() @@ -59,8 +60,8 @@ class StoryViewModel @Inject constructor( Transformations.map(storyLiveData, ::processStoryChapterList) } - fun setInternalProfileId(internalProfileId: Int) { - this.internalProfileId = internalProfileId + fun setInternalProfileId(internalProfileId: ProfileId) { + this.profileId = internalProfileId } fun setClassroomId(classroomId: String) { @@ -125,7 +126,7 @@ class StoryViewModel @Inject constructor( fragment, explorationSelectionListener, explorationCheckpointController, - internalProfileId, + profileId.loggedInInternalProfileId, classroomId, topicId, storyId, diff --git a/app/src/main/java/org/oppia/android/app/story/storyitemviewmodel/StoryChapterSummaryViewModel.kt b/app/src/main/java/org/oppia/android/app/story/storyitemviewmodel/StoryChapterSummaryViewModel.kt index 90163342636..2f2f91a1919 100644 --- a/app/src/main/java/org/oppia/android/app/story/storyitemviewmodel/StoryChapterSummaryViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/story/storyitemviewmodel/StoryChapterSummaryViewModel.kt @@ -48,7 +48,7 @@ class StoryChapterSummaryViewModel( } val chapterPlayState: ChapterPlayState = chapterSummary.chapterPlayState private val profileId by lazy { - ProfileId.newBuilder().apply { internalId = internalProfileId }.build() + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() } fun onExplorationClicked() { @@ -64,7 +64,7 @@ class StoryChapterSummaryViewModel( val explorationCheckpointLiveData = explorationCheckpointController.retrieveExplorationCheckpoint( ProfileId.newBuilder().apply { - internalId = internalProfileId + loggedInInternalProfileId = internalProfileId }.build(), explorationId ).toLiveData() diff --git a/app/src/main/java/org/oppia/android/app/survey/SurveyActivity.kt b/app/src/main/java/org/oppia/android/app/survey/SurveyActivity.kt index 12d5b7220ee..bfd162be533 100644 --- a/app/src/main/java/org/oppia/android/app/survey/SurveyActivity.kt +++ b/app/src/main/java/org/oppia/android/app/survey/SurveyActivity.kt @@ -25,7 +25,8 @@ class SurveyActivity : InjectableAutoLocalizedAppCompatActivity() { (activityComponent as ActivityComponentImpl).inject(this) val params = intent.extractParams() - this.profileId = params.profileId ?: ProfileId.newBuilder().setInternalId(-1).build() + this.profileId = + params.profileId ?: ProfileId.newBuilder().setLoggedInInternalProfileId(-1).build() surveyActivityPresenter.handleOnCreate( profileId, diff --git a/app/src/main/java/org/oppia/android/app/survey/SurveyFragment.kt b/app/src/main/java/org/oppia/android/app/survey/SurveyFragment.kt index 28d1cfdfcdd..1f468fdbb08 100644 --- a/app/src/main/java/org/oppia/android/app/survey/SurveyFragment.kt +++ b/app/src/main/java/org/oppia/android/app/survey/SurveyFragment.kt @@ -37,7 +37,7 @@ class SurveyFragment : internalProfileId: Int, topicId: String ): SurveyFragment { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val args = SurveyFragmentArguments.newBuilder().apply { this.topicId = topicId }.build() @@ -69,7 +69,7 @@ class SurveyFragment : SurveyFragmentArguments.getDefaultInstance() ) - val internalProfileId = arguments!!.extractCurrentUserProfileId().internalId + val internalProfileId = arguments!!.extractCurrentUserProfileId().loggedInInternalProfileId val topicId = args.topicId!! val explorationId = args.explorationId!! diff --git a/app/src/main/java/org/oppia/android/app/survey/SurveyFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/survey/SurveyFragmentPresenter.kt index cbcfb397e0a..be13c910df5 100644 --- a/app/src/main/java/org/oppia/android/app/survey/SurveyFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/survey/SurveyFragmentPresenter.kt @@ -68,7 +68,7 @@ class SurveyFragmentPresenter @Inject constructor( topicId: String, fragment: SurveyFragment ): View? { - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() this.answerAvailabilityReceiver = fragment this.answerHandler = fragment diff --git a/app/src/main/java/org/oppia/android/app/testing/AdministratorControlsFragmentTestActivity.kt b/app/src/main/java/org/oppia/android/app/testing/AdministratorControlsFragmentTestActivity.kt index 6ddca1f95a0..7684cfcb04c 100644 --- a/app/src/main/java/org/oppia/android/app/testing/AdministratorControlsFragmentTestActivity.kt +++ b/app/src/main/java/org/oppia/android/app/testing/AdministratorControlsFragmentTestActivity.kt @@ -62,7 +62,8 @@ class AdministratorControlsFragmentTestActivity : context: Context, profileId: Int? ): Intent { - val profileIdBuilder = profileId?.let { ProfileId.newBuilder().setInternalId(it).build() } + val profileIdBuilder = + profileId?.let { ProfileId.newBuilder().setLoggedInInternalProfileId(it).build() } val intent = Intent(context, AdministratorControlsFragmentTestActivity::class.java) if (profileIdBuilder != null) { intent.decorateWithUserProfileId(profileIdBuilder) diff --git a/app/src/main/java/org/oppia/android/app/testing/AudioFragmentTestActivity.kt b/app/src/main/java/org/oppia/android/app/testing/AudioFragmentTestActivity.kt index fd9d1f5de42..185e9ad4bfd 100644 --- a/app/src/main/java/org/oppia/android/app/testing/AudioFragmentTestActivity.kt +++ b/app/src/main/java/org/oppia/android/app/testing/AudioFragmentTestActivity.kt @@ -20,13 +20,14 @@ class AudioFragmentTestActivity : InjectableAutoLocalizedAppCompatActivity() { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) val internalProfileId = - intent?.extractCurrentUserProfileId()?.internalId ?: -1 + intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 audioFragmentTestActivityController.handleOnCreate(internalProfileId) } companion object { fun createAudioFragmentTestActivity(context: Context, internalProfileId: Int?): Intent { - val profileId = internalProfileId?.let { ProfileId.newBuilder().setInternalId(it).build() } + val profileId = + internalProfileId?.let { ProfileId.newBuilder().setLoggedInInternalProfileId(it).build() } val intent = Intent(context, AudioFragmentTestActivity::class.java) if (profileId != null) { intent.decorateWithUserProfileId(profileId) diff --git a/app/src/main/java/org/oppia/android/app/testing/ExplorationTestActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/testing/ExplorationTestActivityPresenter.kt index 196785a2dea..98fdc934368 100644 --- a/app/src/main/java/org/oppia/android/app/testing/ExplorationTestActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/testing/ExplorationTestActivityPresenter.kt @@ -69,7 +69,8 @@ class ExplorationTestActivityPresenter @Inject constructor( is AsyncResult.Success -> { oppiaLogger.d(TAG_EXPLORATION_TEST_ACTIVITY, "Successfully loaded exploration") routeToExplorationListener.routeToExploration( - ProfileId.newBuilder().apply { internalId = INTERNAL_PROFILE_ID }.build(), + ProfileId.newBuilder().apply { loggedInInternalProfileId = INTERNAL_PROFILE_ID } + .build(), CLASSROOM_ID, TOPIC_ID, STORY_ID, @@ -88,7 +89,8 @@ class ExplorationTestActivityPresenter @Inject constructor( } class TestFragment : InjectableFragment() { - @Inject lateinit var splitScreenManager: SplitScreenManager + @Inject + lateinit var splitScreenManager: SplitScreenManager override fun onAttach(context: Context) { super.onAttach(context) diff --git a/app/src/main/java/org/oppia/android/app/testing/NavigationDrawerTestActivity.kt b/app/src/main/java/org/oppia/android/app/testing/NavigationDrawerTestActivity.kt index 6097b74d8b5..a426c2c847a 100644 --- a/app/src/main/java/org/oppia/android/app/testing/NavigationDrawerTestActivity.kt +++ b/app/src/main/java/org/oppia/android/app/testing/NavigationDrawerTestActivity.kt @@ -40,7 +40,8 @@ class NavigationDrawerTestActivity : companion object { fun createNavigationDrawerTestActivity(context: Context, internalProfileId: Int?): Intent { val intent = Intent(context, NavigationDrawerTestActivity::class.java) - val profileId = internalProfileId?.let { ProfileId.newBuilder().setInternalId(it).build() } + val profileId = + internalProfileId?.let { ProfileId.newBuilder().setLoggedInInternalProfileId(it).build() } if (profileId != null) { intent.decorateWithUserProfileId(profileId) } @@ -51,7 +52,7 @@ class NavigationDrawerTestActivity : override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - internalProfileId = intent?.extractCurrentUserProfileId()?.internalId ?: -1 + internalProfileId = intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 homeActivityPresenter.handleOnCreate(internalProfileId) title = resourceHandler.getStringInLocale(R.string.home_activity_title) } @@ -88,7 +89,9 @@ class NavigationDrawerTestActivity : val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId(ProfileId.newBuilder().setInternalId(internalProfileId).build()) + .setProfileId( + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + ) .setActivityTitle(recentlyPlayedActivityTitle) .build() diff --git a/app/src/main/java/org/oppia/android/app/testing/ProfileEditFragmentTestActivity.kt b/app/src/main/java/org/oppia/android/app/testing/ProfileEditFragmentTestActivity.kt index 2d59a856d4f..3d08415d41c 100644 --- a/app/src/main/java/org/oppia/android/app/testing/ProfileEditFragmentTestActivity.kt +++ b/app/src/main/java/org/oppia/android/app/testing/ProfileEditFragmentTestActivity.kt @@ -23,7 +23,8 @@ class ProfileEditFragmentTestActivity : TestActivity() { companion object { /** Returns an [Intent] for opening [ProfileEditFragmentTestActivity]. */ fun createProfileEditFragmentTestActivity(context: Context, internalProfileId: Int): Intent { - val profileId = internalProfileId.let { ProfileId.newBuilder().setInternalId(it).build() } + val profileId = + internalProfileId.let { ProfileId.newBuilder().setLoggedInInternalProfileId(it).build() } val intent = Intent(context, ProfileEditFragmentTestActivity::class.java) intent.decorateWithUserProfileId(profileId) diff --git a/app/src/main/java/org/oppia/android/app/testing/ProfileEditFragmentTestActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/testing/ProfileEditFragmentTestActivityPresenter.kt index 873da8af228..ce31b69ac5e 100644 --- a/app/src/main/java/org/oppia/android/app/testing/ProfileEditFragmentTestActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/testing/ProfileEditFragmentTestActivityPresenter.kt @@ -15,7 +15,7 @@ class ProfileEditFragmentTestActivityPresenter @Inject constructor( /** Handles onCreate function of [ProfileEditActivity]. */ fun handleOnCreate() { activity.setContentView(R.layout.profile_edit_activity) - val profileId = activity.intent?.extractCurrentUserProfileId()?.internalId ?: 0 + val profileId = activity.intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: 0 if (getProfileEditFragment() == null) { activity.supportFragmentManager.beginTransaction().replace( R.id.profile_edit_fragment_placeholder, diff --git a/app/src/main/java/org/oppia/android/app/testing/SpotlightFragmentTestActivity.kt b/app/src/main/java/org/oppia/android/app/testing/SpotlightFragmentTestActivity.kt index 5953c996147..91d5a342f5a 100644 --- a/app/src/main/java/org/oppia/android/app/testing/SpotlightFragmentTestActivity.kt +++ b/app/src/main/java/org/oppia/android/app/testing/SpotlightFragmentTestActivity.kt @@ -21,7 +21,7 @@ class SpotlightFragmentTestActivity : TestActivity() { (activityComponent as ActivityComponentImpl).inject(this) spotlightFragmentTestActivityPresenter.handleOnCreate( - intent?.extractCurrentUserProfileId()?.internalId ?: -1 + intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 ) } @@ -34,7 +34,7 @@ class SpotlightFragmentTestActivity : TestActivity() { companion object { /** Returns the [Intent] for opening [SpotlightFragmentTestActivity]. */ fun createSpotlightFragmentTestActivity(context: Context): Intent { - val profileId = ProfileId.newBuilder().setInternalId(0).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() return Intent(context, SpotlightFragmentTestActivity::class.java).also { it.decorateWithUserProfileId(profileId) } diff --git a/app/src/main/java/org/oppia/android/app/testing/SpotlightFragmentTestActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/testing/SpotlightFragmentTestActivityPresenter.kt index 7018fe02e6a..0d498549c9f 100644 --- a/app/src/main/java/org/oppia/android/app/testing/SpotlightFragmentTestActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/testing/SpotlightFragmentTestActivityPresenter.kt @@ -26,7 +26,8 @@ class SpotlightFragmentTestActivityPresenter @Inject constructor( if (getSpotlightFragment() == null) { val spotlightFragment = SpotlightFragment() - val profileId = internalProfileId.let { ProfileId.newBuilder().setInternalId(it).build() } + val profileId = + internalProfileId.let { ProfileId.newBuilder().setLoggedInInternalProfileId(it).build() } val args = Bundle() args.decorateWithUserProfileId(profileId) spotlightFragment.arguments = args diff --git a/app/src/main/java/org/oppia/android/app/topic/TopicActivity.kt b/app/src/main/java/org/oppia/android/app/topic/TopicActivity.kt index eafcf9156ae..fb79dcb2f9b 100755 --- a/app/src/main/java/org/oppia/android/app/topic/TopicActivity.kt +++ b/app/src/main/java/org/oppia/android/app/topic/TopicActivity.kt @@ -34,7 +34,7 @@ class TopicActivity : RouteToResumeLessonListener, RouteToRevisionCardListener { - private var internalProfileId: Int = -1 + private var profileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() private lateinit var topicId: String private lateinit var classroomId: String private var storyId: String? = null @@ -45,7 +45,8 @@ class TopicActivity : override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - internalProfileId = intent?.extractCurrentUserProfileId()?.internalId ?: -1 + profileId = + intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() val args = intent?.getProtoExtra( TOPIC_ACTIVITY_PARAMS_KEY, TopicActivityParams.getDefaultInstance() @@ -57,7 +58,12 @@ class TopicActivity : "Expected topic ID to be included in intent for TopicActivity." } storyId = args?.storyId - topicActivityPresenter.handleOnCreate(internalProfileId, classroomId, topicId, storyId) + topicActivityPresenter.handleOnCreate( + profileId.loggedInInternalProfileId, + classroomId, + topicId, + storyId + ) } override fun routeToQuestionPlayer(skillIdList: ArrayList) { @@ -65,7 +71,8 @@ class TopicActivity : QuestionPlayerActivity.createQuestionPlayerActivityIntent( this, skillIdList, - ProfileId.newBuilder().setInternalId(internalProfileId).build() + ProfileId.newBuilder() + .setLoggedInInternalProfileId(profileId.loggedInInternalProfileId).build() ) ) } @@ -158,7 +165,7 @@ class TopicActivity : private val activity: AppCompatActivity ) : ActivityIntentFactories.TopicActivityIntentFactory { override fun createIntent(profileId: ProfileId, classroomId: String, topicId: String): Intent = - createTopicActivityIntent(activity, profileId.internalId, classroomId, topicId) + createTopicActivityIntent(activity, profileId.loggedInInternalProfileId, classroomId, topicId) override fun createIntent( profileId: ProfileId, @@ -168,7 +175,7 @@ class TopicActivity : ): Intent = createTopicPlayStoryActivityIntent( activity, - profileId.internalId, + profileId.loggedInInternalProfileId, classroomId, topicId, storyId @@ -190,7 +197,7 @@ class TopicActivity : this.topicId = topicId this.classroomId = classroomId }.build() - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return Intent(context, TopicActivity::class.java).apply { putProtoExtra(TOPIC_ACTIVITY_PARAMS_KEY, args) decorateWithUserProfileId(profileId) diff --git a/app/src/main/java/org/oppia/android/app/topic/TopicActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/topic/TopicActivityPresenter.kt index 807e4d9f292..c5b796071ad 100755 --- a/app/src/main/java/org/oppia/android/app/topic/TopicActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/topic/TopicActivityPresenter.kt @@ -33,7 +33,7 @@ class TopicActivityPresenter @Inject constructor(private val activity: AppCompat this.topicId = topicId this.classroomId = classroomId activity.setContentView(R.layout.topic_activity) - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() if (getTopicFragment() == null) { val topicFragment = TopicFragment() val arguments = Bundle().apply { diff --git a/app/src/main/java/org/oppia/android/app/topic/TopicFragment.kt b/app/src/main/java/org/oppia/android/app/topic/TopicFragment.kt index 83b1190f2db..976e1714410 100644 --- a/app/src/main/java/org/oppia/android/app/topic/TopicFragment.kt +++ b/app/src/main/java/org/oppia/android/app/topic/TopicFragment.kt @@ -34,7 +34,12 @@ class TopicFragment : InjectableFragment() { TOPIC_FRAGMENT_ARGUMENTS_KEY, TopicFragmentArguments.getDefaultInstance() ) - val internalProfileId = arguments?.extractCurrentUserProfileId()?.internalId ?: -1 + val profileId = arguments?.extractCurrentUserProfileId() + val internalProfileId = if (profileId?.loggedOut == true) { + 0 + } else { + profileId?.loggedInInternalProfileId ?: 0 + } val classroomId = args?.classroomId ?: TEST_CLASSROOM_ID_0 val topicId = args?.topicId ?: TEST_TOPIC_ID_0 val storyId = args?.storyId ?: "" diff --git a/app/src/main/java/org/oppia/android/app/topic/TopicFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/topic/TopicFragmentPresenter.kt index a68bd187120..50f0cae3bbf 100644 --- a/app/src/main/java/org/oppia/android/app/topic/TopicFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/topic/TopicFragmentPresenter.kt @@ -40,7 +40,7 @@ class TopicFragmentPresenter @Inject constructor( lateinit var accessibilityService: AccessibilityService private lateinit var tabLayout: TabLayout - private var internalProfileId: Int = -1 + private var internalProfileId: Int = 0 private lateinit var topicId: String private lateinit var storyId: String private lateinit var viewPager: ViewPager2 @@ -170,7 +170,7 @@ class TopicFragmentPresenter @Inject constructor( } analyticsController.logImportantEvent( eventContext, - ProfileId.newBuilder().apply { internalId = internalProfileId }.build() + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() ) } } diff --git a/app/src/main/java/org/oppia/android/app/topic/TopicViewModel.kt b/app/src/main/java/org/oppia/android/app/topic/TopicViewModel.kt index 5febc7267c4..18689ffa5d0 100644 --- a/app/src/main/java/org/oppia/android/app/topic/TopicViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/topic/TopicViewModel.kt @@ -26,21 +26,16 @@ class TopicViewModel @Inject constructor( private val resourceHandler: AppLanguageResourceHandler, private val translationController: TranslationController ) : ObservableViewModel() { - private var internalProfileId: Int = -1 + private var profileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() private lateinit var topicId: String private val topicResultLiveData: LiveData> by lazy { - topicController.getTopic( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), - topicId - ).toLiveData() + topicController.getTopic(profileId, topicId).toLiveData() } private val topicListResultLiveData: LiveData> by lazy { // TODO(#4754): Replace with a mechanism that properly accounts for fully completed stories. - topicListController.getPromotedActivityList( - ProfileId.newBuilder().setInternalId(internalProfileId).build() - ).toLiveData() + topicListController.getPromotedActivityList(profileId).toLiveData() } val numberOfChaptersCompletedLiveData: LiveData by lazy { @@ -84,7 +79,8 @@ class TopicViewModel @Inject constructor( } fun setInternalProfileId(internalProfileId: Int) { - this.internalProfileId = internalProfileId + this.profileId = + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() } fun setTopicId(topicId: String) { diff --git a/app/src/main/java/org/oppia/android/app/topic/info/TopicInfoFragment.kt b/app/src/main/java/org/oppia/android/app/topic/info/TopicInfoFragment.kt index 8c6b7ff96ef..d46db2b3ee3 100644 --- a/app/src/main/java/org/oppia/android/app/topic/info/TopicInfoFragment.kt +++ b/app/src/main/java/org/oppia/android/app/topic/info/TopicInfoFragment.kt @@ -24,7 +24,7 @@ class TopicInfoFragment : InjectableFragment() { /** Returns a new [TopicInfoFragment]. */ fun newInstance(internalProfileId: Int, topicId: String): TopicInfoFragment { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val args = TopicInfoFragmentArguments.newBuilder().setTopicId(topicId).build() return TopicInfoFragment().apply { @@ -54,7 +54,9 @@ class TopicInfoFragment : InjectableFragment() { TopicInfoFragmentArguments.getDefaultInstance() ) - val internalProfileId = arguments?.extractCurrentUserProfileId()?.internalId ?: -1 + val internalProfileId = + arguments?.extractCurrentUserProfileId() + ?: ProfileId.newBuilder().setLoggedOut(true).build() val topicId = checkNotNull(args?.topicId) { "Expected topic ID to be included in arguments for TopicInfoFragment." } diff --git a/app/src/main/java/org/oppia/android/app/topic/info/TopicInfoFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/topic/info/TopicInfoFragmentPresenter.kt index a155d6498c2..bbceb3e6b4c 100644 --- a/app/src/main/java/org/oppia/android/app/topic/info/TopicInfoFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/topic/info/TopicInfoFragmentPresenter.kt @@ -30,16 +30,16 @@ class TopicInfoFragmentPresenter @Inject constructor( @DefaultResourceBucketName private val resourceBucketName: String ) { private lateinit var binding: TopicInfoFragmentBinding - private var internalProfileId: Int = -1 + private lateinit var profileId: ProfileId private lateinit var topicId: String fun handleCreateView( inflater: LayoutInflater, container: ViewGroup?, - internalProfileId: Int, + internalProfileId: ProfileId, topicId: String ): View? { - this.internalProfileId = internalProfileId + this.profileId = internalProfileId this.topicId = topicId binding = TopicInfoFragmentBinding.inflate( inflater, @@ -68,10 +68,7 @@ class TopicInfoFragmentPresenter @Inject constructor( } private val topicResultLiveData: LiveData> by lazy { - topicController.getTopic( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), - topicId - ).toLiveData() + topicController.getTopic(profileId, topicId).toLiveData() } private fun getTopicList(): LiveData { diff --git a/app/src/main/java/org/oppia/android/app/topic/lessons/TopicLessonViewModel.kt b/app/src/main/java/org/oppia/android/app/topic/lessons/TopicLessonViewModel.kt index 6e6cfc71789..f8375e7a9de 100644 --- a/app/src/main/java/org/oppia/android/app/topic/lessons/TopicLessonViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/topic/lessons/TopicLessonViewModel.kt @@ -25,7 +25,7 @@ class TopicLessonViewModel @Inject constructor( private val resourceHandler: AppLanguageResourceHandler, private val translationController: TranslationController ) { - private var internalProfileId: Int = -1 + private var internalProfileId: Int = 0 private lateinit var topicId: String private lateinit var storyId: String private lateinit var topicStoryList: List @@ -43,7 +43,7 @@ class TopicLessonViewModel @Inject constructor( private val topicResultLiveData: LiveData> by lazy { topicController.getTopic( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), topicId ).toLiveData() } diff --git a/app/src/main/java/org/oppia/android/app/topic/lessons/TopicLessonsFragment.kt b/app/src/main/java/org/oppia/android/app/topic/lessons/TopicLessonsFragment.kt index 8c3258e7344..41e3d472314 100644 --- a/app/src/main/java/org/oppia/android/app/topic/lessons/TopicLessonsFragment.kt +++ b/app/src/main/java/org/oppia/android/app/topic/lessons/TopicLessonsFragment.kt @@ -44,7 +44,7 @@ class TopicLessonsFragment : storyId: String ): TopicLessonsFragment { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val args = TopicLessonsFragmentArguments.newBuilder().apply { this.classroomId = classroomId this.topicId = topicId @@ -88,7 +88,12 @@ class TopicLessonsFragment : } isDefaultStoryExpanded = stateArgs?.isDefaultStoryExpanded ?: false } - val internalProfileId = arguments?.extractCurrentUserProfileId()?.internalId ?: -1 + val profileId = arguments?.extractCurrentUserProfileId() + val internalProfileId = if (profileId != null && profileId.loggedInInternalProfileId != 0) { + profileId.loggedInInternalProfileId + } else { + 0 + } val args = arguments?.getProto( TOPIC_LESSONS_FRAGMENT_ARGUMENTS_KEY, TopicLessonsFragmentArguments.getDefaultInstance() diff --git a/app/src/main/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentPresenter.kt index 66a5a32b2df..1a83e35894d 100644 --- a/app/src/main/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentPresenter.kt @@ -53,7 +53,7 @@ class TopicLessonsFragmentPresenter @Inject constructor( private var currentExpandedChapterListIndex: Int? = null private lateinit var binding: TopicLessonsFragmentBinding - private var internalProfileId: Int = -1 + private var internalProfileId: Int = 0 private lateinit var classroomId: String private lateinit var topicId: String private lateinit var storyId: String @@ -286,7 +286,7 @@ class TopicLessonsFragmentPresenter @Inject constructor( chapterPlayState: ChapterPlayState ) { val profileId = ProfileId.newBuilder().apply { - internalId = internalProfileId + loggedInInternalProfileId = internalProfileId }.build() val canHavePartialProgressSaved = when (chapterPlayState) { diff --git a/app/src/main/java/org/oppia/android/app/topic/practice/TopicPracticeFragment.kt b/app/src/main/java/org/oppia/android/app/topic/practice/TopicPracticeFragment.kt index fc56dc042bf..b4994960005 100644 --- a/app/src/main/java/org/oppia/android/app/topic/practice/TopicPracticeFragment.kt +++ b/app/src/main/java/org/oppia/android/app/topic/practice/TopicPracticeFragment.kt @@ -28,7 +28,12 @@ class TopicPracticeFragment : InjectableFragment() { /** Returns a new [TopicPracticeFragment]. */ fun newInstance(internalProfileId: Int, topicId: String): TopicPracticeFragment { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = if (internalProfileId != -1) { + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + } else { + ProfileId.newBuilder().setLoggedOut(true).build() + } + val args = TopicPracticeFragmentArguments.newBuilder().apply { this.topicId = topicId }.build() @@ -70,7 +75,13 @@ class TopicPracticeFragment : InjectableFragment() { TOPIC_PRACTICE_FRAGMENT_ARGUMENTS_KEY, TopicPracticeFragmentArguments.getDefaultInstance() ) - val internalProfileId = arguments?.extractCurrentUserProfileId()?.internalId ?: -1 + val profileId = arguments?.extractCurrentUserProfileId() + val internalProfileId = + profileId?.loggedInInternalProfileId ?: if (profileId?.loggedOut == true) { + 0 + } else { + -1 + } val topicId = checkNotNull(args?.topicId) { "Expected topic ID to be included in arguments for TopicPracticeFragment." } diff --git a/app/src/main/java/org/oppia/android/app/topic/practice/TopicPracticeViewModel.kt b/app/src/main/java/org/oppia/android/app/topic/practice/TopicPracticeViewModel.kt index bbb73a939ab..b3f4e64b1b5 100644 --- a/app/src/main/java/org/oppia/android/app/topic/practice/TopicPracticeViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/topic/practice/TopicPracticeViewModel.kt @@ -26,11 +26,11 @@ class TopicPracticeViewModel @Inject constructor( ) : ObservableViewModel() { private val itemViewModelList: MutableList = ArrayList() private lateinit var topicId: String - private var internalProfileId: Int = -1 + private var internalProfileId: Int = 0 private val topicResultLiveData: LiveData> by lazy { topicController.getTopic( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), topicId ).toLiveData() } diff --git a/app/src/main/java/org/oppia/android/app/topic/revision/TopicRevisionFragment.kt b/app/src/main/java/org/oppia/android/app/topic/revision/TopicRevisionFragment.kt index 5573ce83b54..ddd27ba2e7d 100755 --- a/app/src/main/java/org/oppia/android/app/topic/revision/TopicRevisionFragment.kt +++ b/app/src/main/java/org/oppia/android/app/topic/revision/TopicRevisionFragment.kt @@ -27,7 +27,7 @@ class TopicRevisionFragment : InjectableFragment(), RevisionSubtopicSelector { /** Returns a new [TopicRevisionFragment]. */ fun newInstance(internalProfileId: Int, topicId: String): TopicRevisionFragment { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val args = TopicRevisionFragmentArguments.newBuilder().setTopicId(topicId).build() return TopicRevisionFragment().apply { arguments = Bundle().apply { @@ -51,7 +51,8 @@ class TopicRevisionFragment : InjectableFragment(), RevisionSubtopicSelector { container: ViewGroup?, savedInstanceState: Bundle? ): View? { - val internalProfileId = arguments?.extractCurrentUserProfileId()?.internalId ?: -1 + val internalProfileId = + arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 val args = arguments?.getProto( TOPIC_REVISION_FRAGMENT_ARGUMENTS_KEY, TopicRevisionFragmentArguments.getDefaultInstance() diff --git a/app/src/main/java/org/oppia/android/app/topic/revision/TopicRevisionViewModel.kt b/app/src/main/java/org/oppia/android/app/topic/revision/TopicRevisionViewModel.kt index 9018a41ea9a..0b264fca87e 100755 --- a/app/src/main/java/org/oppia/android/app/topic/revision/TopicRevisionViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/topic/revision/TopicRevisionViewModel.kt @@ -73,6 +73,6 @@ class TopicRevisionViewModel @Inject constructor( } fun setInternalProfileId(internalProfileId: Int) { - this.profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + this.profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() } } diff --git a/app/src/main/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivity.kt b/app/src/main/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivity.kt index 7606c7ea5ad..91dd5eb7488 100644 --- a/app/src/main/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivity.kt +++ b/app/src/main/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivity.kt @@ -42,7 +42,7 @@ class RevisionCardActivity : RevisionCardActivityParams.getDefaultInstance() ) - val internalProfileId = intent.extractCurrentUserProfileId().internalId + val internalProfileId = intent.extractCurrentUserProfileId().loggedInInternalProfileId val topicId = checkNotNull(args.topicId) { "Expected topic ID to be included in intent for RevisionCardActivity." } @@ -74,7 +74,7 @@ class RevisionCardActivity : subtopicId: Int, subtopicListSize: Int ): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val args = RevisionCardActivityParams.newBuilder().apply { this.topicId = topicId this.subtopicId = subtopicId diff --git a/app/src/main/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityPresenter.kt index af41963e498..ffcab8973a1 100644 --- a/app/src/main/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityPresenter.kt @@ -60,7 +60,7 @@ class RevisionCardActivityPresenter @Inject constructor( activity, R.layout.revision_card_activity ) - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() this.topicId = topicId this.subtopicId = subtopicId this.subtopicListSize = subtopicListSize diff --git a/app/src/main/java/org/oppia/android/app/topic/revisioncard/RevisionCardViewModel.kt b/app/src/main/java/org/oppia/android/app/topic/revisioncard/RevisionCardViewModel.kt index 3f0ef5010d3..73a8467947b 100755 --- a/app/src/main/java/org/oppia/android/app/topic/revisioncard/RevisionCardViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/topic/revisioncard/RevisionCardViewModel.kt @@ -47,7 +47,7 @@ class RevisionCardViewModel private constructor( /** Called when the previous navigation card is clicked. */ fun onPreviousCardClicked() { routeToReviewListener.routeToRevisionCard( - profileId.internalId, + profileId.loggedInInternalProfileId, topicId, subtopicId - 1, subtopicListSize @@ -57,7 +57,7 @@ class RevisionCardViewModel private constructor( /** Called when the next navigation card is clicked. */ fun onNextCardClicked() { routeToReviewListener.routeToRevisionCard( - profileId.internalId, + profileId.loggedInInternalProfileId, topicId, subtopicId + 1, subtopicListSize diff --git a/app/src/main/java/org/oppia/android/app/walkthrough/WalkthroughActivity.kt b/app/src/main/java/org/oppia/android/app/walkthrough/WalkthroughActivity.kt index 083b293bad7..80b0518f7ba 100644 --- a/app/src/main/java/org/oppia/android/app/walkthrough/WalkthroughActivity.kt +++ b/app/src/main/java/org/oppia/android/app/walkthrough/WalkthroughActivity.kt @@ -40,7 +40,7 @@ class WalkthroughActivity : companion object { fun createWalkthroughActivityIntent(context: Context, internalProfileId: Int): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return Intent(context, WalkthroughActivity::class.java).apply { decorateWithUserProfileId(profileId) decorateWithScreenName(WALKTHROUGH_ACTIVITY) diff --git a/app/src/main/java/org/oppia/android/app/walkthrough/end/WalkthroughFinalFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/walkthrough/end/WalkthroughFinalFragmentPresenter.kt index abd286f77d8..e1c16f93cd4 100644 --- a/app/src/main/java/org/oppia/android/app/walkthrough/end/WalkthroughFinalFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/walkthrough/end/WalkthroughFinalFragmentPresenter.kt @@ -45,8 +45,9 @@ class WalkthroughFinalFragmentPresenter @Inject constructor( /* attachToRoot= */ false ) this.topicId = topicId - val internalProfileId = activity.intent?.extractCurrentUserProfileId()?.internalId ?: -1 - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val internalProfileId = + activity.intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() walkthroughFinalViewModel = WalkthroughFinalViewModel() diff --git a/app/src/main/java/org/oppia/android/app/walkthrough/welcome/WalkthroughWelcomeFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/walkthrough/welcome/WalkthroughWelcomeFragmentPresenter.kt index 6327a374eb7..7c104686d62 100644 --- a/app/src/main/java/org/oppia/android/app/walkthrough/welcome/WalkthroughWelcomeFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/walkthrough/welcome/WalkthroughWelcomeFragmentPresenter.kt @@ -36,7 +36,6 @@ class WalkthroughWelcomeFragmentPresenter @Inject constructor( private lateinit var binding: WalkthroughWelcomeFragmentBinding private val routeToNextPage = activity as WalkthroughFragmentChangeListener private lateinit var walkthroughWelcomeViewModel: WalkthroughWelcomeViewModel - private var internalProfileId: Int = -1 private lateinit var profileId: ProfileId private lateinit var profileName: String @@ -48,8 +47,9 @@ class WalkthroughWelcomeFragmentPresenter @Inject constructor( /* attachToRoot= */ false ) - internalProfileId = activity.intent?.extractCurrentUserProfileId()?.internalId ?: -1 - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = + activity.intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true) + .build() walkthroughWelcomeViewModel = WalkthroughWelcomeViewModel() binding.let { diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivityTest.kt index 96da1bb908e..81e66f6880d 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivityTest.kt @@ -150,7 +150,8 @@ class AdministratorControlsActivityTest { private val internalProfileId = 0 - private val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + private val profileId = + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() @Inject lateinit var profileTestHelper: ProfileTestHelper @@ -700,7 +701,7 @@ class AdministratorControlsActivityTest { @Test @Config(qualifiers = "sw600dp") fun testAdministratorControlsFragment_clickProfileDeletionButton_checkOpensDeletionDialog() { - val profileId = ProfileId.newBuilder().setInternalId(1).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() launch( createAdministratorControlsActivityIntent( @@ -726,7 +727,7 @@ class AdministratorControlsActivityTest { @Test @Config(qualifiers = "sw600dp") fun testAdministratorControlsFragment_configChange_checkOpensDeletionDialog() { - val profileId = ProfileId.newBuilder().setInternalId(1).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() launch( createAdministratorControlsActivityIntent( @@ -753,7 +754,7 @@ class AdministratorControlsActivityTest { @Test @Config(qualifiers = "sw600dp") fun testAdministratorControlsFragment_configChange_checkDeletionDialogIsVisible() { - val profileId = ProfileId.newBuilder().setInternalId(1).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() launch( createAdministratorControlsActivityIntent( @@ -780,7 +781,7 @@ class AdministratorControlsActivityTest { @Test fun testActivity_createIntent_verifyScreenNameInIntent() { - val profileId = ProfileId.newBuilder().setInternalId(1).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() val screenName = createAdministratorControlsActivityIntent(profileId) .extractCurrentAppScreenName() diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AppVersionActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AppVersionActivityTest.kt index 49a66d5c398..bd3cb68e404 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AppVersionActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AppVersionActivityTest.kt @@ -273,7 +273,7 @@ class AppVersionActivityTest { } private fun launchAdministratorControlsActivityIntent(internalProfileId: Int): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return AdministratorControlsActivity.createAdministratorControlsActivityIntent( ApplicationProvider.getApplicationContext(), profileId diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt index df161b770ae..d7ef2dcaf1a 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt @@ -1182,7 +1182,7 @@ class ProfileAndDeviceIdFragmentTest { private val LEARNER_PROFILE_ID_1 = createProfileId(internalProfileId = 2) private fun createProfileId(internalProfileId: Int) = ProfileId.newBuilder().apply { - internalId = internalProfileId + loggedInInternalProfileId = internalProfileId }.build() } } diff --git a/app/src/sharedTest/java/org/oppia/android/app/classroom/ClassroomListActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/classroom/ClassroomListActivityTest.kt index 845096edd39..5b363664ad4 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/classroom/ClassroomListActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/classroom/ClassroomListActivityTest.kt @@ -126,7 +126,7 @@ class ClassroomListActivityTest { val screenName = ClassroomListActivity .createClassroomListActivity( context, - ProfileId.newBuilder().setInternalId(0).build() + ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() ) .extractCurrentAppScreenName() assertThat(screenName).isEqualTo(ScreenName.CLASSROOM_LIST_ACTIVITY) @@ -147,7 +147,7 @@ class ClassroomListActivityTest { val scenario = ActivityScenario.launch( ClassroomListActivity.createClassroomListActivity( context, - ProfileId.newBuilder().setInternalId(0).build() + ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() ) ) testCoroutineDispatchers.runCurrent() diff --git a/app/src/sharedTest/java/org/oppia/android/app/classroom/ClassroomListFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/classroom/ClassroomListFragmentTest.kt index c7986a03eb5..7316f863e6a 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/classroom/ClassroomListFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/classroom/ClassroomListFragmentTest.kt @@ -181,7 +181,7 @@ class ClassroomListFragmentTest { fun setUp() { Intents.init() setUpTestApplicationComponent() - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() testCoroutineDispatchers.registerIdlingResource() profileTestHelper.initializeProfiles() } diff --git a/app/src/sharedTest/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityTest.kt index 2d7afaf5f53..b795f326866 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityTest.kt @@ -129,7 +129,8 @@ class CompletedStoryListActivityTest { val oppiaTestRule = OppiaTestRule() private val internalProfileId = 0 - private val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + private val profileId = + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() @get:Rule val activityTestRule = ActivityTestRule( diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsActivityTest.kt index 9210e687ffa..6ddb207b53c 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsActivityTest.kt @@ -230,7 +230,7 @@ class DeveloperOptionsActivityTest { } private fun createDeveloperOptionsActivityIntent(internalProfileId: Int): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return DeveloperOptionsActivity.createDeveloperOptionsActivityIntent(context, profileId) } diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedFragmentTest.kt index 8c79da699c3..5046ee63737 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedFragmentTest.kt @@ -133,7 +133,7 @@ class MarkChaptersCompletedFragmentTest { @Before fun setUp() { - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() setUpTestApplicationComponent() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) testCoroutineDispatchers.registerIdlingResource() diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedFragmentTest.kt index 19836a42087..8a33601aeed 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedFragmentTest.kt @@ -142,7 +142,7 @@ class MarkStoriesCompletedFragmentTest { @Before fun setUp() { - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() setUpTestApplicationComponent() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) testCoroutineDispatchers.registerIdlingResource() diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedFragmentTest.kt index dd17bbe74ba..ac11be0c8a6 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedFragmentTest.kt @@ -142,7 +142,7 @@ class MarkTopicsCompletedFragmentTest { @Before fun setUp() { - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() setUpTestApplicationComponent() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) testCoroutineDispatchers.registerIdlingResource() diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsFragmentTest.kt index f40406b79fd..c7107c5226c 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsFragmentTest.kt @@ -623,7 +623,7 @@ class ViewEventLogsFragmentTest { .setFeedbackAnswer(answer) .setSurveyDetails( EventLog.SurveyResponseContext.newBuilder() - .setProfileId(profileId?.internalId.toString()) + .setProfileId(profileId?.loggedInInternalProfileId.toString()) .setSurveyId(surveyId) .build() ) diff --git a/app/src/sharedTest/java/org/oppia/android/app/help/HelpActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/help/HelpActivityTest.kt index ca9cbf486ad..bcc02e72162 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/help/HelpActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/help/HelpActivityTest.kt @@ -133,7 +133,7 @@ class HelpActivityTest { } private fun createHelpActivityIntent(): Intent { - val profileId = ProfileId.newBuilder().setInternalId(0).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() return HelpActivity.createHelpActivityIntent( ApplicationProvider.getApplicationContext(), isFromNavigationDrawer = false, diff --git a/app/src/sharedTest/java/org/oppia/android/app/help/HelpFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/help/HelpFragmentTest.kt index 508d72bdb2a..4066db07948 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/help/HelpFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/help/HelpFragmentTest.kt @@ -150,7 +150,7 @@ class HelpFragmentTest { internalProfileId: Int, isFromNavigationDrawer: Boolean ): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return HelpActivity.createHelpActivityIntent( ApplicationProvider.getApplicationContext(), profileId, diff --git a/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt index b6962460974..f08d2f59438 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt @@ -227,8 +227,8 @@ class HomeActivityTest { fun setUp() { Intents.init() setUpTestApplicationComponent() - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() - profileId1 = ProfileId.newBuilder().setInternalId(internalProfileId1).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + profileId1 = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId1).build() testCoroutineDispatchers.registerIdlingResource() profileTestHelper.initializeProfiles() } @@ -1916,7 +1916,7 @@ class HomeActivityTest { } private fun createHomeActivityIntent(internalProfileId: Int): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return HomeActivity.createHomeActivity(context, profileId) } @@ -2023,7 +2023,7 @@ class HomeActivityTest { } private fun createProfileId(internalProfileId: Int): ProfileId { - return ProfileId.newBuilder().setInternalId(internalProfileId).build() + return ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() } private fun logIntoAdminTwice() { diff --git a/app/src/sharedTest/java/org/oppia/android/app/home/RecentlyPlayedFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/RecentlyPlayedFragmentTest.kt index 9cf3f4ebf3e..9bbe3a0639d 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/home/RecentlyPlayedFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/home/RecentlyPlayedFragmentTest.kt @@ -178,7 +178,7 @@ class RecentlyPlayedFragmentTest { setUpTestApplicationComponent() profileTestHelper.initializeProfiles() testCoroutineDispatchers.registerIdlingResource() - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) } @@ -200,7 +200,9 @@ class RecentlyPlayedFragmentTest { val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId(ProfileId.newBuilder().setInternalId(internalProfileId).build()) + .setProfileId( + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + ) .setActivityTitle(recentlyPlayedActivityTitle) .build() return RecentlyPlayedActivity.createRecentlyPlayedActivityIntent( @@ -531,7 +533,7 @@ class RecentlyPlayedFragmentTest { ) activityTestRule.launchActivity( createRecentlyPlayedActivityIntent( - internalProfileId = profileId.internalId + internalProfileId = profileId.loggedInInternalProfileId ) ) activityTestRule.activity.window.decorView.layoutDirection = ViewCompat.LAYOUT_DIRECTION_RTL @@ -572,7 +574,7 @@ class RecentlyPlayedFragmentTest { ) activityTestRule.launchActivity( createRecentlyPlayedActivityIntent( - internalProfileId = profileId.internalId + internalProfileId = profileId.loggedInInternalProfileId ) ) activityTestRule.activity.window.decorView.layoutDirection = ViewCompat.LAYOUT_DIRECTION_RTL @@ -620,7 +622,7 @@ class RecentlyPlayedFragmentTest { ) activityTestRule.launchActivity( createRecentlyPlayedActivityIntent( - internalProfileId = profileId.internalId + internalProfileId = profileId.loggedInInternalProfileId ) ) activityTestRule.activity.window.decorView.layoutDirection = ViewCompat.LAYOUT_DIRECTION_RTL @@ -674,7 +676,7 @@ class RecentlyPlayedFragmentTest { ) activityTestRule.launchActivity( createRecentlyPlayedActivityIntent( - internalProfileId = profileId.internalId + internalProfileId = profileId.loggedInInternalProfileId ) ) activityTestRule.activity.window.decorView.layoutDirection = ViewCompat.LAYOUT_DIRECTION_RTL @@ -725,7 +727,7 @@ class RecentlyPlayedFragmentTest { ) activityTestRule.launchActivity( createRecentlyPlayedActivityIntent( - internalProfileId = profileId.internalId + internalProfileId = profileId.loggedInInternalProfileId ) ) testCoroutineDispatchers.runCurrent() @@ -751,7 +753,7 @@ class RecentlyPlayedFragmentTest { activityTestRule.launchActivity( createRecentlyPlayedActivityIntent( - internalProfileId = profileId.internalId + internalProfileId = profileId.loggedInInternalProfileId ) ) activityTestRule.activity.window.decorView.layoutDirection = ViewCompat.LAYOUT_DIRECTION_RTL @@ -972,7 +974,8 @@ class RecentlyPlayedFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = ProfileId.newBuilder().apply { internalId = internalProfileId }.build() + profileId = + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() parentScreen = ExplorationActivityParams.ParentScreen.PARENT_SCREEN_UNSPECIFIED checkpoint = ExplorationCheckpoint.newBuilder().apply { explorationTitle = "What is a Fraction?" @@ -1030,7 +1033,8 @@ class RecentlyPlayedFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = ProfileId.newBuilder().apply { internalId = internalProfileId }.build() + profileId = + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() isCheckpointingEnabled = true parentScreen = ExplorationActivityParams.ParentScreen.PARENT_SCREEN_UNSPECIFIED }.build() @@ -1070,7 +1074,8 @@ class RecentlyPlayedFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = ProfileId.newBuilder().apply { internalId = internalProfileId }.build() + profileId = + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() isCheckpointingEnabled = true parentScreen = ExplorationActivityParams.ParentScreen.PARENT_SCREEN_UNSPECIFIED }.build() @@ -1115,7 +1120,8 @@ class RecentlyPlayedFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = ProfileId.newBuilder().apply { internalId = internalProfileId }.build() + profileId = + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() isCheckpointingEnabled = true parentScreen = ExplorationActivityParams.ParentScreen.PARENT_SCREEN_UNSPECIFIED }.build() diff --git a/app/src/sharedTest/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListActivityTest.kt index 7c6f16174d0..b6eb600e64e 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListActivityTest.kt @@ -171,7 +171,7 @@ class OngoingTopicListActivityTest { Intents.init() setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProfileTestHelper.markCompletedRatiosStory0( profileId = profileId, @@ -251,7 +251,7 @@ class OngoingTopicListActivityTest { classroomId = TEST_CLASSROOM_ID_1 topicId = RATIOS_TOPIC_ID }.build() - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() intended(hasComponent(TopicActivity::class.java.name)) intended(hasProtoExtra(TopicActivity.TOPIC_ACTIVITY_PARAMS_KEY, args)) intended(hasProtoExtra(PROFILE_ID_INTENT_DECORATOR, profileId)) @@ -284,7 +284,7 @@ class OngoingTopicListActivityTest { classroomId = TEST_CLASSROOM_ID_1 topicId = RATIOS_TOPIC_ID }.build() - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() intended(hasComponent(TopicActivity::class.java.name)) intended(hasProtoExtra(TopicActivity.TOPIC_ACTIVITY_PARAMS_KEY, args)) intended(hasProtoExtra(PROFILE_ID_INTENT_DECORATOR, profileId)) diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/OptionsActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/OptionsActivityTest.kt index 8a9b5e83586..9436fa245fc 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/OptionsActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/OptionsActivityTest.kt @@ -134,7 +134,7 @@ class OptionsActivityTest { } private fun createOptionsActivityIntent(): Intent { - val profileId = ProfileId.newBuilder().setInternalId(0).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() return OptionsActivity.createOptionsActivity( ApplicationProvider.getApplicationContext(), profileId = profileId, diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt index 5cb9b71ef75..c3ff7cb9198 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt @@ -168,7 +168,7 @@ class OptionsFragmentTest { internalProfileId: Int, isFromNavigationDrawer: Boolean ): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return OptionsActivity.createOptionsActivity( context = ApplicationProvider.getApplicationContext(), profileId = profileId, diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeFragmentTest.kt index 5e4b14be4aa..160f31fcf52 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeFragmentTest.kt @@ -201,7 +201,7 @@ class ReadingTextSizeFragmentTest { internalProfileId: Int, isFromNavigationDrawer: Boolean ): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return OptionsActivity.createOptionsActivity( ApplicationProvider.getApplicationContext(), profileId, diff --git a/app/src/sharedTest/java/org/oppia/android/app/player/audio/AudioFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/player/audio/AudioFragmentTest.kt index ed37473683f..599fd4ffef0 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/player/audio/AudioFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/player/audio/AudioFragmentTest.kt @@ -158,7 +158,8 @@ class AudioFragmentTest { "2mzzFVDLuAj8/assets/audio/content-hi-2hn6btuei5.mp3" private var internalProfileId = 0 - private var profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + private var profileId = + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() @Before fun setUp() { diff --git a/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt index ec53953d954..cefe4b48f66 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt @@ -1453,7 +1453,7 @@ class ExplorationActivityTest { fun testExpActivity_showUnsavedExpDialog_cancel_checkOldestProgressIsSaved() { markAllSpotlightsSeen() explorationCheckpointTestHelper.saveCheckpointForRatiosStory0Exploration0( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = RATIOS_STORY_0_EXPLORATION_0_CURRENT_VERSION ) setUpAudioForFractionLesson() @@ -1481,7 +1481,7 @@ class ExplorationActivityTest { .perform(click()) explorationCheckpointTestHelper.verifyExplorationProgressIsSaved( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), RATIOS_EXPLORATION_ID_0 ) } @@ -1491,11 +1491,11 @@ class ExplorationActivityTest { fun testExpActivity_showUnsavedExpDialog_leave_checkOldestProgressIsSaved() { markAllSpotlightsSeen() explorationCheckpointTestHelper.saveCheckpointForRatiosStory0Exploration0( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = RATIOS_STORY_0_EXPLORATION_0_CURRENT_VERSION ) explorationCheckpointTestHelper.saveCheckpointForFractionsStory0Exploration1( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = FRACTIONS_STORY_0_EXPLORATION_1_CURRENT_VERSION ) setUpAudioForFractionLesson() @@ -1523,7 +1523,7 @@ class ExplorationActivityTest { .perform(click()) explorationCheckpointTestHelper.verifyExplorationProgressIsSaved( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), RATIOS_EXPLORATION_ID_0 ) } @@ -1592,7 +1592,7 @@ class ExplorationActivityTest { fun testExpActivity_progressSaved_onBackPress_checkNoProgressDeleted() { markAllSpotlightsSeen() explorationCheckpointTestHelper.saveCheckpointForRatiosStory0Exploration0( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = RATIOS_STORY_0_EXPLORATION_0_CURRENT_VERSION ) setUpAudioForFractionLesson() @@ -1618,11 +1618,11 @@ class ExplorationActivityTest { pressBack() explorationCheckpointTestHelper.verifyExplorationProgressIsSaved( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), RATIOS_EXPLORATION_ID_0 ) explorationCheckpointTestHelper.verifyExplorationProgressIsSaved( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), FRACTIONS_EXPLORATION_ID_0 ) } @@ -1630,11 +1630,11 @@ class ExplorationActivityTest { @Test fun testExplorationActivity_databaseFull_onBackPressed_showsProgressDatabaseFullDialog() { explorationCheckpointTestHelper.saveCheckpointForRatiosStory0Exploration0( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = RATIOS_STORY_0_EXPLORATION_0_CURRENT_VERSION ) explorationCheckpointTestHelper.saveCheckpointForFractionsStory0Exploration1( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = FRACTIONS_STORY_0_EXPLORATION_1_CURRENT_VERSION ) setUpAudioForFractionLesson() @@ -1668,11 +1668,11 @@ class ExplorationActivityTest { fun testExplorationActivity_databaseFull_onToolbarClosePressed_showsProgressDatabaseFullDialog() { markAllSpotlightsSeen() explorationCheckpointTestHelper.saveCheckpointForRatiosStory0Exploration0( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = RATIOS_STORY_0_EXPLORATION_0_CURRENT_VERSION ) explorationCheckpointTestHelper.saveCheckpointForFractionsStory0Exploration1( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = FRACTIONS_STORY_0_EXPLORATION_1_CURRENT_VERSION ) setUpAudioForFractionLesson() @@ -1707,11 +1707,11 @@ class ExplorationActivityTest { fun testExplorationActivity_showProgressDatabaseFullDialog_backToLesson_checkDialogDismisses() { markAllSpotlightsSeen() explorationCheckpointTestHelper.saveCheckpointForRatiosStory0Exploration0( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = RATIOS_STORY_0_EXPLORATION_0_CURRENT_VERSION ) explorationCheckpointTestHelper.saveCheckpointForFractionsStory0Exploration1( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = FRACTIONS_STORY_0_EXPLORATION_1_CURRENT_VERSION ) setUpAudioForFractionLesson() @@ -1748,11 +1748,11 @@ class ExplorationActivityTest { @Ignore("The ExplorationActivity takes time to finish, needs to fixed in #89.") fun testExplorationActivity_showProgressDatabaseFullDialog_continue_closesExpActivity() { explorationCheckpointTestHelper.saveCheckpointForRatiosStory0Exploration0( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = RATIOS_STORY_0_EXPLORATION_0_CURRENT_VERSION ) explorationCheckpointTestHelper.saveCheckpointForFractionsStory0Exploration1( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = FRACTIONS_STORY_0_EXPLORATION_1_CURRENT_VERSION ) setUpAudioForFractionLesson() @@ -1790,11 +1790,11 @@ class ExplorationActivityTest { @Ignore("The ExplorationActivity takes time to finish, needs to fixed in #89.") fun testExpActivity_showProgressDatabaseFullDialog_leaveWithoutSaving_closesExpActivity() { explorationCheckpointTestHelper.saveCheckpointForRatiosStory0Exploration0( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = RATIOS_STORY_0_EXPLORATION_0_CURRENT_VERSION ) explorationCheckpointTestHelper.saveCheckpointForFractionsStory0Exploration1( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = FRACTIONS_STORY_0_EXPLORATION_1_CURRENT_VERSION ) setUpAudioForFractionLesson() @@ -1831,11 +1831,11 @@ class ExplorationActivityTest { @Test fun testExpActivity_showProgressDatabaseFullDialog_leaveWithoutSaving_correctProgressIsDeleted() { explorationCheckpointTestHelper.saveCheckpointForRatiosStory0Exploration0( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = RATIOS_STORY_0_EXPLORATION_0_CURRENT_VERSION ) explorationCheckpointTestHelper.saveCheckpointForFractionsStory0Exploration1( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = FRACTIONS_STORY_0_EXPLORATION_1_CURRENT_VERSION ) setUpAudioForFractionLesson() @@ -1866,15 +1866,15 @@ class ExplorationActivityTest { testCoroutineDispatchers.runCurrent() explorationCheckpointTestHelper.verifyExplorationProgressIsSaved( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), RATIOS_EXPLORATION_ID_0 ) explorationCheckpointTestHelper.verifyExplorationProgressIsSaved( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), FRACTIONS_EXPLORATION_ID_1 ) explorationCheckpointTestHelper.verifyExplorationProgressIsDeleted( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), FRACTIONS_EXPLORATION_ID_0 ) } @@ -1884,11 +1884,11 @@ class ExplorationActivityTest { @Test fun testExpActivity_showProgressDatabaseFullDialog_continue_correctProgressIsDeleted() { explorationCheckpointTestHelper.saveCheckpointForRatiosStory0Exploration0( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = RATIOS_STORY_0_EXPLORATION_0_CURRENT_VERSION ) explorationCheckpointTestHelper.saveCheckpointForFractionsStory0Exploration1( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = FRACTIONS_STORY_0_EXPLORATION_1_CURRENT_VERSION ) setUpAudioForFractionLesson() @@ -1919,16 +1919,16 @@ class ExplorationActivityTest { testCoroutineDispatchers.runCurrent() explorationCheckpointTestHelper.verifyExplorationProgressIsSaved( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), FRACTIONS_EXPLORATION_ID_0 ) explorationCheckpointTestHelper.verifyExplorationProgressIsSaved( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), FRACTIONS_EXPLORATION_ID_1 ) } explorationCheckpointTestHelper.verifyExplorationProgressIsDeleted( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), RATIOS_EXPLORATION_ID_0 ) explorationDataController.stopPlayingExploration(isCompletion = false) @@ -1937,11 +1937,11 @@ class ExplorationActivityTest { @Test fun testExpActivity_showProgressDatabaseFullDialog_backToLesson_noProgressIsDeleted() { explorationCheckpointTestHelper.saveCheckpointForRatiosStory0Exploration0( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = RATIOS_STORY_0_EXPLORATION_0_CURRENT_VERSION ) explorationCheckpointTestHelper.saveCheckpointForFractionsStory0Exploration1( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), version = FRACTIONS_STORY_0_EXPLORATION_1_CURRENT_VERSION ) setUpAudioForFractionLesson() @@ -1970,16 +1970,16 @@ class ExplorationActivityTest { .inRoot(isDialog()).perform(click()) explorationCheckpointTestHelper.verifyExplorationProgressIsSaved( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), FRACTIONS_EXPLORATION_ID_0 ) explorationCheckpointTestHelper.verifyExplorationProgressIsSaved( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), FRACTIONS_EXPLORATION_ID_1 ) } explorationCheckpointTestHelper.verifyExplorationProgressIsSaved( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), RATIOS_EXPLORATION_ID_0 ) explorationDataController.stopPlayingExploration(isCompletion = false) @@ -2154,7 +2154,7 @@ class ExplorationActivityTest { @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso. fun testExpActivity_englishContentLang_contentIsInEnglish() { updateContentLanguage( - ProfileId.newBuilder().apply { internalId = internalProfileId }.build(), + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build(), OppiaLanguage.ENGLISH ) launch( @@ -2186,7 +2186,7 @@ class ExplorationActivityTest { @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) fun testExpActivity_profileWithArabicContentLang_contentIsInArabic() { updateContentLanguage( - ProfileId.newBuilder().apply { internalId = internalProfileId }.build(), + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build(), OppiaLanguage.ARABIC ) launch( @@ -2218,7 +2218,7 @@ class ExplorationActivityTest { fun testExpActivity_englishContentLang_showHint_explanationInEnglish() { markAllSpotlightsSeen() updateContentLanguage( - ProfileId.newBuilder().apply { internalId = internalProfileId }.build(), + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build(), OppiaLanguage.ENGLISH ) launch( @@ -2384,7 +2384,7 @@ class ExplorationActivityTest { fun testExpActivity_profileWithArabicContentLang_showHint_explanationInArabic() { markAllSpotlightsSeen() updateContentLanguage( - ProfileId.newBuilder().apply { internalId = internalProfileId }.build(), + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build(), OppiaLanguage.ARABIC ) launch( @@ -2560,7 +2560,7 @@ class ExplorationActivityTest { } private fun markSpotlightSeen(feature: Spotlight.FeatureCase) { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() spotlightStateController.markSpotlightViewed(profileId, feature) testCoroutineDispatchers.runCurrent() } @@ -2589,7 +2589,7 @@ class ExplorationActivityTest { // typical route to playing an exploration. return ExplorationActivity.createExplorationActivityIntent( ApplicationProvider.getApplicationContext(), - ProfileId.newBuilder().apply { internalId = internalProfileId }.build(), + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build(), classroomId, topicId, storyId, diff --git a/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt index eb141d43015..e787ea12813 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt @@ -220,7 +220,7 @@ class StateFragmentTest { @Inject lateinit var fakeAnalyticsEventLogger: FakeAnalyticsEventLogger @Inject lateinit var oppiaClock: FakeOppiaClock - private val profileId = ProfileId.newBuilder().apply { internalId = 1 }.build() + private val profileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 1 }.build() @After fun tearDown() { @@ -4924,7 +4924,7 @@ class StateFragmentTest { return launch( StateFragmentTestActivity.createTestActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, diff --git a/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserFragmentTest.kt index 322f5e2855d..4a1b3d650a0 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserFragmentTest.kt @@ -380,7 +380,7 @@ class ProfileChooserFragmentTest { intended(hasComponent(AdministratorControlsActivity::class.java.name)) it.onActivity { activity -> assertThat( - activity.intent.extractCurrentUserProfileId().internalId + activity.intent.extractCurrentUserProfileId().loggedInInternalProfileId ).isEqualTo(0) } } diff --git a/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressFragmentTest.kt index a9015c415da..b2c9ee8edae 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressFragmentTest.kt @@ -179,7 +179,7 @@ class ProfileProgressFragmentTest { setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() profileTestHelper.initializeProfiles() - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) } @@ -672,7 +672,7 @@ class ProfileProgressFragmentTest { @Test fun testClickViewAll_withLessThanTwoStories_opensRecentlyPlayedActivityWithStoriesForYouTitle() { storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), timestampOlderThanOneWeek = false ) launch(createProfileProgressActivityIntent(internalProfileId)).use { @@ -684,7 +684,9 @@ class ProfileProgressFragmentTest { ) val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId(ProfileId.newBuilder().setInternalId(internalProfileId).build()) + .setProfileId( + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + ) .setActivityTitle(RecentlyPlayedActivityTitle.STORIES_FOR_YOU) .build() clickProfileProgressItem(itemPosition = 0, targetViewId = R.id.view_all_text_view) @@ -700,15 +702,15 @@ class ProfileProgressFragmentTest { @Test fun testClickViewAll_threeStoriesStarted_opensRecentlyPlayedActivityWithRecentlyPlayedTitle() { storyProgressTestHelper.markCompletedFractionsStory0( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), timestampOlderThanOneWeek = false ) storyProgressTestHelper.markCompletedRatiosStory0( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), timestampOlderThanOneWeek = false ) storyProgressTestHelper.markInProgressNotSavedTestTopic0Story0( - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(), + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), timestampOlderThanOneWeek = false ) launch(createProfileProgressActivityIntent(internalProfileId)).use { @@ -720,7 +722,9 @@ class ProfileProgressFragmentTest { ) val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId(ProfileId.newBuilder().setInternalId(internalProfileId).build()) + .setProfileId( + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + ) .setActivityTitle(RecentlyPlayedActivityTitle.RECENTLY_PLAYED_STORIES) .build() clickProfileProgressItem(itemPosition = 0, targetViewId = R.id.view_all_text_view) @@ -815,7 +819,7 @@ class ProfileProgressFragmentTest { launch(createProfileProgressActivityIntent(internalProfileId)).use { testCoroutineDispatchers.runCurrent() clickProfileProgressItem(itemPosition = 0, targetViewId = R.id.completed_stories_container) - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() intended(hasComponent(CompletedStoryListActivity::class.java.name)) intended( hasProtoExtra( diff --git a/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonActivityTest.kt index 40aeae59dcc..65511a65b8c 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonActivityTest.kt @@ -204,7 +204,7 @@ class ResumeLessonActivityTest { private fun createResumeLessonActivityIntent(): Intent { return ResumeLessonActivity.createResumeLessonActivityIntent( context, - ProfileId.newBuilder().apply { internalId = 1 }.build(), + ProfileId.newBuilder().apply { loggedInInternalProfileId = 1 }.build(), TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID, FRACTIONS_STORY_ID_0, diff --git a/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentTest.kt index 1a28e628594..47f2f5f2f59 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentTest.kt @@ -276,7 +276,7 @@ class ResumeLessonFragmentTest { private fun createResumeLessonActivityIntent(): Intent { return ResumeLessonActivity.createResumeLessonActivityIntent( context, - ProfileId.newBuilder().apply { internalId = 1 }.build(), + ProfileId.newBuilder().apply { loggedInInternalProfileId = 1 }.build(), TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID, FRACTIONS_STORY_ID_0, @@ -289,7 +289,7 @@ class ResumeLessonFragmentTest { private fun createResumeRatiosLessonActivityIntent(): Intent { return ResumeLessonActivity.createResumeLessonActivityIntent( context, - ProfileId.newBuilder().apply { internalId = 1 }.build(), + ProfileId.newBuilder().apply { loggedInInternalProfileId = 1 }.build(), TEST_CLASSROOM_ID_1, RATIOS_TOPIC_ID, RATIOS_STORY_ID_0, diff --git a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditFragmentTest.kt index 37992371629..68ed8e618a6 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditFragmentTest.kt @@ -426,7 +426,7 @@ class ProfileEditFragmentTest { TestPlatformParameterModule.forceEnableFastLanguageSwitchingInLesson(true) val updateLangProvider = profileManagementController.updateEnableInLessonQuickLanguageSwitching( - profileId = ProfileId.newBuilder().apply { internalId = 0 }.build(), + profileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 0 }.build(), allowInLessonQuickLanguageSwitching = true ) monitorFactory.waitForNextSuccessfulResult(updateLangProvider) @@ -447,7 +447,7 @@ class ProfileEditFragmentTest { // The user should not have permission to switch languages (since the switch wasn't toggled). val profileProvider = profileManagementController.getProfile( - ProfileId.newBuilder().apply { internalId = 0 }.build() + ProfileId.newBuilder().apply { loggedInInternalProfileId = 0 }.build() ) val profile = monitorFactory.waitForNextSuccessfulResult(profileProvider) @@ -467,7 +467,7 @@ class ProfileEditFragmentTest { // The user should have permission to switch languages (since the switch was toggled). val profileProvider = profileManagementController.getProfile( - ProfileId.newBuilder().apply { internalId = 0 }.build() + ProfileId.newBuilder().apply { loggedInInternalProfileId = 0 }.build() ) val profile = monitorFactory.waitForNextSuccessfulResult(profileProvider) assertThat(profile.allowInLessonQuickLanguageSwitching).isTrue() diff --git a/app/src/sharedTest/java/org/oppia/android/app/story/StoryActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/story/StoryActivityTest.kt index 733b0efc911..6b05aa008ca 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/story/StoryActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/story/StoryActivityTest.kt @@ -208,7 +208,8 @@ class StoryActivityTest { storyId = TEST_STORY_ID_0 topicId = TEST_TOPIC_ID_0 classroomId = TEST_CLASSROOM_ID_0 - profileId = ProfileId.newBuilder().apply { internalId = internalProfileId }.build() + profileId = + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() parentScreen = ExplorationActivityParams.ParentScreen.STORY_SCREEN isCheckpointingEnabled = true }.build() diff --git a/app/src/sharedTest/java/org/oppia/android/app/story/StoryFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/story/StoryFragmentTest.kt index c93e0f8460a..c558b528b34 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/story/StoryFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/story/StoryFragmentTest.kt @@ -202,7 +202,7 @@ class StoryFragmentTest { setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() profileTestHelper.initializeProfiles() - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) } diff --git a/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyActivityTest.kt index 3634f6f4a24..e0965a4c96a 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyActivityTest.kt @@ -107,7 +107,7 @@ class SurveyActivityTest { @get:Rule val oppiaTestRule = OppiaTestRule() - private val profileId = ProfileId.newBuilder().setInternalId(0).build() + private val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyFragmentTest.kt index b600558c0da..a668ce47c77 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyFragmentTest.kt @@ -154,7 +154,7 @@ class SurveyFragmentTest { @Inject lateinit var surveyController: SurveyController - private val profileId = ProfileId.newBuilder().setInternalId(0).build() + private val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() @Before fun setup() { @@ -573,7 +573,7 @@ class SurveyFragmentTest { SurveyQuestionName.MARKET_FIT, SurveyQuestionName.NPS ) - val profileId = ProfileId.newBuilder().setInternalId(1).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() surveyController.startSurveySession(questions, profileId = profileId) testCoroutineDispatchers.runCurrent() } diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityDebugTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityDebugTest.kt index e367b50c81a..95032d61723 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityDebugTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityDebugTest.kt @@ -330,7 +330,7 @@ class NavigationDrawerActivityDebugTest { it.openNavigationDrawer() onView(withId(R.id.developer_options_linear_layout)).perform(nestedScrollTo()) .check(matches(isDisplayed())).perform(click()) - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() intended(hasComponent(DeveloperOptionsActivity::class.java.name)) intended( hasProtoExtra(PROFILE_ID_INTENT_DECORATOR, profileId) diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityProdTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityProdTest.kt index c5a79951ef5..ca7318a6e71 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityProdTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityProdTest.kt @@ -178,7 +178,7 @@ class NavigationDrawerActivityProdTest { testCoroutineDispatchers.registerIdlingResource() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProfileTestHelper.markCompletedRatiosStory0( - ProfileId.newBuilder().setInternalId( + ProfileId.newBuilder().setLoggedInInternalProfileId( internalProfileId ).build(), timestampOlderThanOneWeek = false @@ -260,7 +260,7 @@ class NavigationDrawerActivityProdTest { @Test fun testNavDrawer_openNavDrawer_oneTopicInProgress_profileStoryProgressIsDisplayedCorrectly() { storyProfileTestHelper.markCompletedRatiosStory1Exp0( - ProfileId.newBuilder().setInternalId( + ProfileId.newBuilder().setLoggedInInternalProfileId( internalProfileId ).build(), timestampOlderThanOneWeek = false @@ -282,7 +282,7 @@ class NavigationDrawerActivityProdTest { @Test fun testNavDrawer_openNavDrawer_oneTopicInProgress_profileTopicProgressIsDisplayedCorrectly() { storyProfileTestHelper.markCompletedRatiosStory1Exp0( - ProfileId.newBuilder().setInternalId( + ProfileId.newBuilder().setLoggedInInternalProfileId( internalProfileId ).build(), timestampOlderThanOneWeek = false @@ -326,7 +326,7 @@ class NavigationDrawerActivityProdTest { it.openNavigationDrawer() onView(withId(R.id.nav_header_profile_name)).perform(click()) testCoroutineDispatchers.runCurrent() - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() intended(hasComponent(ProfileProgressActivity::class.java.name)) intended( hasProtoExtra( @@ -782,7 +782,7 @@ class NavigationDrawerActivityProdTest { it.openNavigationDrawer() onView(withId(R.id.administrator_controls_linear_layout)).perform(nestedScrollTo()) .check(matches(isDisplayed())).perform(click()) - val profileId = ProfileId.newBuilder().setInternalId(0).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() intended(hasComponent(AdministratorControlsActivity::class.java.name)) intended(hasProtoExtra(PROFILE_ID_INTENT_DECORATOR, profileId)) } diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/TopicActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/TopicActivityTest.kt index debec65d207..2184ab417e8 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/TopicActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/TopicActivityTest.kt @@ -201,7 +201,8 @@ class TopicActivityTest { testCoroutineDispatchers.runCurrent() // Verify that the question activity is started with the correct profile ID. - val profileId = ProfileId.newBuilder().apply { internalId = internalProfileId }.build() + val profileId = + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() intended(hasComponent(QuestionPlayerActivity::class.java.name)) intended(hasProtoExtra(PROFILE_ID_INTENT_DECORATOR, profileId)) } @@ -221,7 +222,7 @@ class TopicActivityTest { } private fun markAllSpotlightsSeen() { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() spotlightStateController.markSpotlightViewed(profileId, TOPIC_LESSON_TAB) testCoroutineDispatchers.runCurrent() spotlightStateController.markSpotlightViewed(profileId, TOPIC_REVISION_TAB) diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/TopicFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/TopicFragmentTest.kt index dc00a9ca748..8cfcd1bfa5d 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/TopicFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/TopicFragmentTest.kt @@ -294,7 +294,7 @@ class TopicFragmentTest { initializeApplicationComponent(false) markSpotlightSeen(FIRST_CHAPTER) markSpotlightSeen(TOPIC_LESSON_TAB) - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() storyProgressTestHelper.markCompletedFractionsStory0Exp0(profileId, false) storyProgressTestHelper.markCompletedRatiosStory0Exp0(profileId, false) storyProgressTestHelper.markCompletedRatiosStory1Exp0(profileId, false) @@ -330,7 +330,7 @@ class TopicFragmentTest { initializeApplicationComponent(false) markSpotlightSeen(TOPIC_LESSON_TAB) markSpotlightSeen(FIRST_CHAPTER) - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markCompletedFractionsStory0Exp0(profileId, false) storyProgressTestHelper.markCompletedRatiosStory0Exp0(profileId, false) @@ -1026,7 +1026,7 @@ class TopicFragmentTest { private fun markSpotlightSeen(feature: Spotlight.FeatureCase) { val profileId = ProfileId.newBuilder() - .setInternalId(internalProfileId) + .setloggedInInternalProfileId(internalProfileId) .build() spotlightStateController.markSpotlightViewed(profileId, feature) testCoroutineDispatchers.runCurrent() diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/conceptcard/ConceptCardFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/conceptcard/ConceptCardFragmentTest.kt index c8ec2292371..81d1e6d4f27 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/conceptcard/ConceptCardFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/conceptcard/ConceptCardFragmentTest.kt @@ -158,7 +158,7 @@ class ConceptCardFragmentTest { @Inject lateinit var monitorFactory: DataProviderTestMonitor.Factory - private val profileId = ProfileId.newBuilder().apply { internalId = 1 }.build() + private val profileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 1 }.build() @Before fun setUp() { diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentTest.kt index 075b49e8ac0..68a23a1b1ac 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentTest.kt @@ -189,7 +189,7 @@ class TopicLessonsFragmentTest { Intents.init() setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) markAllSpotlightsSeen() } @@ -731,7 +731,8 @@ class TopicLessonsFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = ProfileId.newBuilder().apply { internalId = internalProfileId }.build() + profileId = + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() parentScreen = ExplorationActivityParams.ParentScreen.TOPIC_SCREEN_LESSONS_TAB checkpoint = ExplorationCheckpoint.newBuilder().apply { explorationTitle = "What is a Fraction?" @@ -787,7 +788,8 @@ class TopicLessonsFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = ProfileId.newBuilder().apply { internalId = internalProfileId }.build() + profileId = + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() isCheckpointingEnabled = true parentScreen = ExplorationActivityParams.ParentScreen.TOPIC_SCREEN_LESSONS_TAB }.build() @@ -825,7 +827,8 @@ class TopicLessonsFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = ProfileId.newBuilder().apply { internalId = internalProfileId }.build() + profileId = + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() isCheckpointingEnabled = true parentScreen = ExplorationActivityParams.ParentScreen.TOPIC_SCREEN_LESSONS_TAB }.build() @@ -868,7 +871,8 @@ class TopicLessonsFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = ProfileId.newBuilder().apply { internalId = internalProfileId }.build() + profileId = + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() isCheckpointingEnabled = true parentScreen = ExplorationActivityParams.ParentScreen.TOPIC_SCREEN_LESSONS_TAB }.build() @@ -910,7 +914,8 @@ class TopicLessonsFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = ProfileId.newBuilder().apply { internalId = internalProfileId }.build() + profileId = + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() isCheckpointingEnabled = false parentScreen = ExplorationActivityParams.ParentScreen.TOPIC_SCREEN_LESSONS_TAB }.build() diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/practice/TopicPracticeFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/practice/TopicPracticeFragmentTest.kt index fd5c8f4117f..f04bf1eba23 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/practice/TopicPracticeFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/practice/TopicPracticeFragmentTest.kt @@ -430,7 +430,7 @@ class TopicPracticeFragmentTest { } private fun markAllSpotlightsSeen() { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() spotlightStateController.markSpotlightViewed(profileId, TOPIC_LESSON_TAB) testCoroutineDispatchers.runCurrent() spotlightStateController.markSpotlightViewed(profileId, TOPIC_REVISION_TAB) diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityTest.kt index e612dacc954..ae5cec0a2fe 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityTest.kt @@ -209,7 +209,7 @@ class QuestionPlayerActivityTest { @Inject lateinit var fakeAccessibilityService: FakeAccessibilityService - private val profileId = ProfileId.newBuilder().apply { internalId = 1 }.build() + private val profileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 1 }.build() @Before fun setUp() { diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/revision/TopicRevisionFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/revision/TopicRevisionFragmentTest.kt index dec1050be90..79f05b91fd8 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/revision/TopicRevisionFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/revision/TopicRevisionFragmentTest.kt @@ -287,7 +287,7 @@ class TopicRevisionFragmentTest { } private fun markAllSpotlightsSeen() { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() spotlightStateController.markSpotlightViewed(profileId, TOPIC_LESSON_TAB) testCoroutineDispatchers.runCurrent() spotlightStateController.markSpotlightViewed(profileId, TOPIC_REVISION_TAB) diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityTest.kt index c73b3c86579..a9088123670 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityTest.kt @@ -148,7 +148,7 @@ class RevisionCardActivityTest { @Inject lateinit var fakeAccessibilityService: FakeAccessibilityService - private val profileId = ProfileId.newBuilder().apply { internalId = 1 }.build() + private val profileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 1 }.build() @Before fun setUp() { @@ -425,7 +425,7 @@ class RevisionCardActivityTest { subtopicId: Int ): ActivityScenario { val scenario = ActivityScenario.launch( - createRevisionCardActivityIntent(profileId.internalId, topicId, subtopicId) + createRevisionCardActivityIntent(profileId.loggedInInternalProfileId, topicId, subtopicId) ) testCoroutineDispatchers.runCurrent() return scenario diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardFragmentTest.kt index 29dde65b725..5deb8c944d8 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardFragmentTest.kt @@ -170,7 +170,7 @@ class RevisionCardFragmentTest { @Inject lateinit var monitorFactory: DataProviderTestMonitor.Factory - private val profileId = ProfileId.newBuilder().apply { internalId = 1 }.build() + private val profileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 1 }.build() private val SUBTOPIC_ID_EXTRA_KEY = "RevisionCardActivity.subtopic_id" @@ -192,7 +192,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, subtopicId = 2, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -214,7 +214,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, subtopicId = 2, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -237,7 +237,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, subtopicId = 2, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -259,7 +259,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, subtopicId = 2, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -281,7 +281,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, subtopicId = 2, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -305,7 +305,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, subtopicId = 2, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -326,7 +326,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, SUBTOPIC_TOPIC_ID, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -347,7 +347,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, TEST_TOPIC_ID_0, SUBTOPIC_TOPIC_ID, 1 @@ -363,7 +363,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, SUBTOPIC_TOPIC_ID, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -380,7 +380,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, SUBTOPIC_TOPIC_ID, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -410,7 +410,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, SUBTOPIC_TOPIC_ID, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -440,7 +440,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, SUBTOPIC_TOPIC_ID, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -463,7 +463,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, SUBTOPIC_TOPIC_ID, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -481,7 +481,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, SUBTOPIC_TOPIC_ID_2, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -501,7 +501,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, FRACTIONS_SUBTOPIC_TOPIC_ID_0, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -521,7 +521,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, FRACTIONS_SUBTOPIC_TOPIC_ID_1, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -541,7 +541,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, FRACTIONS_SUBTOPIC_TOPIC_ID_3, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -562,7 +562,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, FRACTIONS_SUBTOPIC_TOPIC_ID_1, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -588,7 +588,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, FRACTIONS_SUBTOPIC_TOPIC_ID_1, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -614,7 +614,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, SUBTOPIC_TOPIC_ID, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -635,7 +635,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, SUBTOPIC_TOPIC_ID_2, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -656,7 +656,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, subtopicId = 2, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -675,7 +675,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, subtopicId = 2, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -697,7 +697,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, subtopicId = 2, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -722,7 +722,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, FRACTIONS_TOPIC_ID, subtopicId = 2, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -751,7 +751,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, "test_topic_id_0", subtopicId = 1, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -772,7 +772,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, "test_topic_id_0", subtopicId = 1, FRACTIONS_SUBTOPIC_LIST_SIZE @@ -797,7 +797,7 @@ class RevisionCardFragmentTest { launch( createRevisionCardActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, "test_topic_id_0", subtopicId = 1, FRACTIONS_SUBTOPIC_LIST_SIZE diff --git a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughWelcomeFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughWelcomeFragmentTest.kt index 34437e03bc7..226bd3019c4 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughWelcomeFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughWelcomeFragmentTest.kt @@ -129,7 +129,7 @@ class WalkthroughWelcomeFragmentTest { setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() profileTestHelper.initializeProfiles() - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() } @After diff --git a/app/src/test/java/org/oppia/android/app/activity/ActivityIntentFactoriesTest.kt b/app/src/test/java/org/oppia/android/app/activity/ActivityIntentFactoriesTest.kt index 4a75e8d367a..49d98864df5 100644 --- a/app/src/test/java/org/oppia/android/app/activity/ActivityIntentFactoriesTest.kt +++ b/app/src/test/java/org/oppia/android/app/activity/ActivityIntentFactoriesTest.kt @@ -125,7 +125,7 @@ class ActivityIntentFactoriesTest { ) assertThat(intent).hasComponentClass(TopicActivity::class.java) - assertThat(intent.extractCurrentUserProfileId().internalId).isEqualTo(0) + assertThat(intent.extractCurrentUserProfileId().loggedInInternalProfileId).isEqualTo(0) assertThat(args.topicId).isEqualTo("test_topic_id") assertThat(args.storyId).isEmpty() } @@ -144,7 +144,7 @@ class ActivityIntentFactoriesTest { TopicActivityParams.getDefaultInstance() ) assertThat(intent).hasComponentClass(TopicActivity::class.java) - assertThat(intent.extractCurrentUserProfileId().internalId).isEqualTo(0) + assertThat(intent.extractCurrentUserProfileId().loggedInInternalProfileId).isEqualTo(0) assertThat(args.topicId).isEqualTo("test_topic_id") assertThat(args.storyId).isEqualTo("test_story_id") } diff --git a/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterTest.kt b/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterTest.kt index e493e5a6120..cf957bfebec 100644 --- a/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterTest.kt +++ b/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterTest.kt @@ -130,7 +130,9 @@ class ActivityRouterTest { val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId(ProfileId.newBuilder().setInternalId(internalProfileId).build()) + .setProfileId( + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + ) .setActivityTitle(RecentlyPlayedActivityTitle.RECENTLY_PLAYED_STORIES).build() activityRouter.routeToScreen( DestinationScreen diff --git a/app/src/test/java/org/oppia/android/app/home/HomeActivityLocalTest.kt b/app/src/test/java/org/oppia/android/app/home/HomeActivityLocalTest.kt index 3f69bfff0d6..a8c52968511 100644 --- a/app/src/test/java/org/oppia/android/app/home/HomeActivityLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/home/HomeActivityLocalTest.kt @@ -116,7 +116,7 @@ class HomeActivityLocalTest { @Inject lateinit var monitorFactory: DataProviderTestMonitor.Factory - private val profileId: ProfileId = ProfileId.newBuilder().setInternalId(1).build() + private val profileId: ProfileId = ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() @Before fun setUp() { diff --git a/app/src/test/java/org/oppia/android/app/player/exploration/ExplorationActivityLocalTest.kt b/app/src/test/java/org/oppia/android/app/player/exploration/ExplorationActivityLocalTest.kt index c62ba27d2a0..40ed79351c3 100644 --- a/app/src/test/java/org/oppia/android/app/player/exploration/ExplorationActivityLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/player/exploration/ExplorationActivityLocalTest.kt @@ -326,7 +326,7 @@ class ExplorationActivityLocalTest { // Update the SurveyLastShownTimestamp to trigger an update in the data provider and notify // subscribers of an update. profileManagementController.updateSurveyLastShownTimestamp( - ProfileId.newBuilder().setInternalId(internalProfileId).build() + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() ) onView(withText(R.string.survey_onboarding_title_text)) @@ -350,7 +350,7 @@ class ExplorationActivityLocalTest { } private fun markSpotlightSeen(feature: Spotlight.FeatureCase) { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() spotlightStateController.markSpotlightViewed(profileId, feature) testCoroutineDispatchers.runCurrent() } @@ -386,7 +386,7 @@ class ExplorationActivityLocalTest { ): Intent { return ExplorationActivity.createExplorationActivityIntent( ApplicationProvider.getApplicationContext(), - ProfileId.newBuilder().apply { internalId = internalProfileId }.build(), + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build(), classroomId, topicId, storyId, diff --git a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt index b40a46e7ce4..948b9b16a23 100644 --- a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt @@ -208,7 +208,7 @@ class StateFragmentLocalTest { @Inject lateinit var fakeAccessibilityService: FakeAccessibilityService @Inject lateinit var testGlideImageLoader: TestGlideImageLoader - private val profileId = ProfileId.newBuilder().apply { internalId = 1 }.build() + private val profileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 1 }.build() private val solutionIndex: Int = 4 @Before @@ -2231,7 +2231,7 @@ class StateFragmentLocalTest { return ActivityScenario.launch( StateFragmentTestActivity.createTestActivityIntent( context, - profileId.internalId, + profileId.loggedInInternalProfileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, diff --git a/app/src/test/java/org/oppia/android/app/testing/HomeSpanTest.kt b/app/src/test/java/org/oppia/android/app/testing/HomeSpanTest.kt index f3dd5643520..a4cd7018d73 100644 --- a/app/src/test/java/org/oppia/android/app/testing/HomeSpanTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/HomeSpanTest.kt @@ -167,7 +167,7 @@ class HomeSpanTest { } private fun createHomeActivityIntent(internalProfileId: Int): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return HomeActivity.createHomeActivity(context, profileId) } diff --git a/app/src/test/java/org/oppia/android/app/testing/RecentlyPlayedSpanTest.kt b/app/src/test/java/org/oppia/android/app/testing/RecentlyPlayedSpanTest.kt index c348c55fe90..6187cdece41 100644 --- a/app/src/test/java/org/oppia/android/app/testing/RecentlyPlayedSpanTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/RecentlyPlayedSpanTest.kt @@ -120,7 +120,7 @@ class RecentlyPlayedSpanTest { fun setUp() { setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( profileId, @@ -285,7 +285,7 @@ class RecentlyPlayedSpanTest { val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId(ProfileId.newBuilder().setInternalId(profileId).build()) + .setProfileId(ProfileId.newBuilder().setLoggedInInternalProfileId(profileId).build()) .build() return RecentlyPlayedActivity.createRecentlyPlayedActivityIntent( context, diff --git a/app/src/test/java/org/oppia/android/app/testing/administratorcontrols/AdministratorControlsFragmentTest.kt b/app/src/test/java/org/oppia/android/app/testing/administratorcontrols/AdministratorControlsFragmentTest.kt index 2145dab63cb..75ab563fb38 100644 --- a/app/src/test/java/org/oppia/android/app/testing/administratorcontrols/AdministratorControlsFragmentTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/administratorcontrols/AdministratorControlsFragmentTest.kt @@ -172,7 +172,7 @@ class AdministratorControlsFragmentTest { } private fun createAdministratorControlsActivityIntent(internalProifleId: Int): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProifleId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProifleId).build() return AdministratorControlsActivity.createAdministratorControlsActivityIntent( context, profileId diff --git a/app/src/test/java/org/oppia/android/app/testing/options/OptionsFragmentTest.kt b/app/src/test/java/org/oppia/android/app/testing/options/OptionsFragmentTest.kt index ee9b8cbbc5c..c38c706bf4d 100644 --- a/app/src/test/java/org/oppia/android/app/testing/options/OptionsFragmentTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/options/OptionsFragmentTest.kt @@ -202,7 +202,7 @@ class OptionsFragmentTest { internalProfileId: Int, isFromNavigationDrawer: Boolean ): Intent { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() return OptionsActivity.createOptionsActivity( ApplicationProvider.getApplicationContext(), diff --git a/data/src/main/java/org/oppia/android/data/persistence/PersistentCacheStore.kt b/data/src/main/java/org/oppia/android/data/persistence/PersistentCacheStore.kt index ba97ab106b6..b2a48834366 100644 --- a/data/src/main/java/org/oppia/android/data/persistence/PersistentCacheStore.kt +++ b/data/src/main/java/org/oppia/android/data/persistence/PersistentCacheStore.kt @@ -413,7 +413,8 @@ class PersistentCacheStore private constructor( initialValue: T, profileId: ProfileId ): PersistentCacheStore { - val profileDirectory = directoryManagementUtil.getOrCreateDir(profileId.internalId.toString()) + val profileDirectory = + directoryManagementUtil.getOrCreateDir(profileId.loggedInInternalProfileId.toString()) return PersistentCacheStore( application, cacheFactory, diff --git a/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationDataController.kt b/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationDataController.kt index 2cd658000a2..d6694b98922 100644 --- a/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationDataController.kt +++ b/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationDataController.kt @@ -223,7 +223,7 @@ class ExplorationDataController @Inject constructor( isRestart: Boolean ): DataProvider { return explorationProgressController.beginExplorationAsync( - ProfileId.newBuilder().apply { internalId = internalProfileId }.build(), + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build(), classroomId, topicId, storyId, diff --git a/domain/src/main/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointController.kt b/domain/src/main/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointController.kt index 1c2b7bc9c27..ca3aac2a0fc 100644 --- a/domain/src/main/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointController.kt +++ b/domain/src/main/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointController.kt @@ -178,7 +178,7 @@ class ExplorationCheckpointController @Inject constructor( AsyncResult.Failure( ExplorationCheckpointNotFoundException( "Checkpoint with the explorationId $explorationId was not found " + - "for profileId ${profileId.internalId}." + "for profileId ${profileId.loggedInInternalProfileId}." ) ) } @@ -259,7 +259,7 @@ class ExplorationCheckpointController @Inject constructor( AsyncResult.Failure( ExplorationCheckpointNotFoundException( "No saved checkpoint with explorationId ${explorationId!!} found for " + - "the profileId ${profileId!!.internalId}." + "the profileId ${profileId!!.loggedInInternalProfileId}." ) ) ExplorationCheckpointActionStatus.SUCCESS -> AsyncResult.Success(null) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/survey/SurveyEventsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/survey/SurveyEventsLogger.kt index b79f75fa081..2b9146989ef 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/survey/SurveyEventsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/survey/SurveyEventsLogger.kt @@ -101,7 +101,7 @@ class SurveyEventsLogger @Inject constructor( profileId: ProfileId? ): EventLog.SurveyResponseContext { return EventLog.SurveyResponseContext.newBuilder() - .setProfileId(profileId?.internalId.toString()) + .setProfileId(profileId?.loggedInInternalProfileId.toString()) .setSurveyId(surveyId) .build() } diff --git a/domain/src/main/java/org/oppia/android/domain/profile/ProfileManagementController.kt b/domain/src/main/java/org/oppia/android/domain/profile/ProfileManagementController.kt index 983caebf6db..0f4f6f757d4 100644 --- a/domain/src/main/java/org/oppia/android/domain/profile/ProfileManagementController.kt +++ b/domain/src/main/java/org/oppia/android/domain/profile/ProfileManagementController.kt @@ -42,7 +42,7 @@ import java.io.FileOutputStream import javax.inject.Inject import javax.inject.Singleton -private const val DEFAULT_LOGGED_OUT_INTERNAL_PROFILE_ID = -1 +private val LOGGED_OUT_PROFILE_ID = ProfileId.newBuilder().setLoggedOut(true).build() private const val GET_PROFILES_PROVIDER_ID = "get_profiles_provider_id" private const val GET_PROFILE_PROVIDER_ID = "get_profile_provider_id" private const val GET_WAS_PROFILE_EVER_ADDED_PROVIDER_ID = @@ -99,7 +99,7 @@ class ProfileManagementController @Inject constructor( private val profileNameValidator: ProfileNameValidator, private val translationController: TranslationController ) { - private var currentProfileId: Int = DEFAULT_LOGGED_OUT_INTERNAL_PROFILE_ID + private var currentProfileId: ProfileId = LOGGED_OUT_PROFILE_ID private val profileDataStore = cacheStoreFactory.create("profile_database", ProfileDatabase.getDefaultInstance()) @@ -198,13 +198,13 @@ class ProfileManagementController @Inject constructor( /** Returns a single profile, specified by profiledId. */ fun getProfile(profileId: ProfileId): DataProvider { return profileDataStore.transformAsync(GET_PROFILE_PROVIDER_ID) { - val profile = it.profilesMap[profileId.internalId] + val profile = it.profilesMap[profileId.loggedInInternalProfileId] if (profile != null) { AsyncResult.Success(profile) } else { AsyncResult.Failure( ProfileNotFoundException( - "ProfileId ${profileId.internalId} does" + + "ProfileId ${profileId.loggedInInternalProfileId} does" + " not match an existing Profile" ) ) @@ -275,7 +275,7 @@ class ProfileManagementController @Inject constructor( this.pin = pin this.allowDownloadAccess = allowDownloadAccess this.allowInLessonQuickLanguageSwitching = allowInLessonQuickLanguageSwitching - this.id = ProfileId.newBuilder().setInternalId(nextProfileId).build() + this.id = ProfileId.newBuilder().setLoggedInInternalProfileId(nextProfileId).build() dateCreatedTimestampMs = oppiaClock.getCurrentTimeMs() this.isAdmin = isAdmin readingTextSize = ReadingTextSize.MEDIUM_TEXT_SIZE @@ -329,7 +329,9 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.internalId] ?: return@storeDataWithCustomChannelAsync Pair( + it.profilesMap[ + profileId.loggedInInternalProfileId + ] ?: return@storeDataWithCustomChannelAsync Pair( it, ProfileActionStatus.PROFILE_NOT_FOUND ) @@ -351,7 +353,9 @@ class ProfileManagementController @Inject constructor( } val profileDatabaseBuilder = - it.toBuilder().putProfiles(profileId.internalId, updatedProfileBuilder.build()) + it.toBuilder().putProfiles( + profileId.loggedInInternalProfileId, updatedProfileBuilder.build() + ) Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) } return dataProviders.createInMemoryDataProviderAsync( @@ -379,13 +383,15 @@ class ProfileManagementController @Inject constructor( return@storeDataWithCustomChannelAsync Pair(it, ProfileActionStatus.PROFILE_NAME_NOT_UNIQUE) } val profile = - it.profilesMap[profileId.internalId] ?: return@storeDataWithCustomChannelAsync Pair( + it.profilesMap[ + profileId.loggedInInternalProfileId + ] ?: return@storeDataWithCustomChannelAsync Pair( it, ProfileActionStatus.PROFILE_NOT_FOUND ) val updatedProfile = profile.toBuilder().setName(newName).build() val profileDatabaseBuilder = it.toBuilder().putProfiles( - profileId.internalId, + profileId.loggedInInternalProfileId, updatedProfile ) Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) @@ -407,13 +413,15 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.internalId] ?: return@storeDataWithCustomChannelAsync Pair( + it.profilesMap[ + profileId.loggedInInternalProfileId + ] ?: return@storeDataWithCustomChannelAsync Pair( it, ProfileActionStatus.PROFILE_NOT_FOUND ) val updatedProfile = profile.toBuilder().setPin(newPin).build() val profileDatabaseBuilder = it.toBuilder().putProfiles( - profileId.internalId, + profileId.loggedInInternalProfileId, updatedProfile ) Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) @@ -438,7 +446,9 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.internalId] ?: return@storeDataWithCustomChannelAsync Pair( + it.profilesMap[ + profileId.loggedInInternalProfileId + ] ?: return@storeDataWithCustomChannelAsync Pair( it, ProfileActionStatus.PROFILE_NOT_FOUND ) @@ -474,7 +484,9 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.internalId] ?: return@storeDataWithCustomChannelAsync Pair( + it.profilesMap[ + profileId.loggedInInternalProfileId + ] ?: return@storeDataWithCustomChannelAsync Pair( it, ProfileActionStatus.PROFILE_NOT_FOUND ) @@ -510,14 +522,16 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.internalId] ?: return@storeDataWithCustomChannelAsync Pair( + it.profilesMap[ + profileId.loggedInInternalProfileId + ] ?: return@storeDataWithCustomChannelAsync Pair( it, ProfileActionStatus.PROFILE_NOT_FOUND ) val updatedProfile = profile.toBuilder().setAllowDownloadAccess(allowDownloadAccess) .build() val profileDatabaseBuilder = it.toBuilder().putProfiles( - profileId.internalId, + profileId.loggedInInternalProfileId, updatedProfile ) Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) @@ -545,12 +559,14 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.internalId] ?: return@storeDataWithCustomChannelAsync Pair( + it.profilesMap[ + profileId.loggedInInternalProfileId + ] ?: return@storeDataWithCustomChannelAsync Pair( it, ProfileActionStatus.PROFILE_NOT_FOUND ) val updatedProfileDatabase = it.toBuilder().putProfiles( - profileId.internalId, + profileId.loggedInInternalProfileId, profile.toBuilder().apply { this.allowInLessonQuickLanguageSwitching = allowInLessonQuickLanguageSwitching }.build() @@ -579,13 +595,15 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.internalId] ?: return@storeDataWithCustomChannelAsync Pair( + it.profilesMap[ + profileId.loggedInInternalProfileId + ] ?: return@storeDataWithCustomChannelAsync Pair( it, ProfileActionStatus.PROFILE_NOT_FOUND ) val updatedProfile = profile.toBuilder().setReadingTextSize(readingTextSize).build() val profileDatabaseBuilder = it.toBuilder().putProfiles( - profileId.internalId, + profileId.loggedInInternalProfileId, updatedProfile ) Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) @@ -606,7 +624,9 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.internalId] ?: return@storeDataWithCustomChannelAsync Pair( + it.profilesMap[ + profileId.loggedInInternalProfileId + ] ?: return@storeDataWithCustomChannelAsync Pair( it, ProfileActionStatus.PROFILE_NOT_FOUND ) @@ -619,7 +639,7 @@ class ProfileManagementController @Inject constructor( } }.build() val profileDatabaseBuilder = it.toBuilder().putProfiles( - profileId.internalId, + profileId.loggedInInternalProfileId, updatedProfile ) Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) @@ -704,14 +724,14 @@ class ProfileManagementController @Inject constructor( private fun setCurrentProfileId(profileId: ProfileId): DataProvider { return dataProviders.createInMemoryDataProviderAsync(SET_CURRENT_PROFILE_ID_PROVIDER_ID) { val profileDatabase = profileDataStore.readDataAsync().await() - if (profileDatabase.profilesMap.containsKey(profileId.internalId)) { - currentProfileId = profileId.internalId + if (profileDatabase.profilesMap.containsKey(profileId.loggedInInternalProfileId)) { + currentProfileId = profileId return@createInMemoryDataProviderAsync AsyncResult.Success(0) } AsyncResult.Failure( ProfileNotFoundException( - "ProfileId ${profileId.internalId} is" + - " not associated with an existing profile" + "ProfileId " + + "${profileId.loggedInInternalProfileId} is not associated with an existing profile" ) ) } @@ -720,14 +740,15 @@ class ProfileManagementController @Inject constructor( private fun updateLastLoggedInAsyncAndNumberOfLogins(profileId: ProfileId): Deferred { return profileDataStore.storeDataWithCustomChannelAsync(updateInMemoryCache = true) { - val profile = it.profilesMap[profileId.internalId] - ?: return@storeDataWithCustomChannelAsync Pair(it, ProfileActionStatus.PROFILE_NOT_FOUND) + val profile = it.profilesMap[ + profileId.loggedInInternalProfileId + ] ?: return@storeDataWithCustomChannelAsync Pair(it, ProfileActionStatus.PROFILE_NOT_FOUND) val updatedProfile = profile.toBuilder() .setLastLoggedInTimestampMs(oppiaClock.getCurrentTimeMs()) .setNumberOfLogins(profile.numberOfLogins + 1) .build() val profileDatabaseBuilder = it.toBuilder().putProfiles( - profileId.internalId, + profileId.loggedInInternalProfileId, updatedProfile ) Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) @@ -742,16 +763,19 @@ class ProfileManagementController @Inject constructor( */ fun deleteProfile(profileId: ProfileId): DataProvider { val deferred = profileDataStore.storeDataWithCustomChannelAsync(updateInMemoryCache = true) { - if (!it.profilesMap.containsKey(profileId.internalId)) { + if (!it.profilesMap.containsKey(profileId.loggedInInternalProfileId)) { return@storeDataWithCustomChannelAsync Pair(it, ProfileActionStatus.PROFILE_NOT_FOUND) } - if (!directoryManagementUtil.deleteDir(profileId.internalId.toString())) { + if (!directoryManagementUtil.deleteDir(profileId.loggedInInternalProfileId.toString())) { return@storeDataWithCustomChannelAsync Pair(it, ProfileActionStatus.FAILED_TO_DELETE_DIR) } val installationId = loggingIdentifierController.fetchInstallationId() - val learnerId = it.profilesMap.getValue(profileId.internalId).learnerId + val learnerId = it.profilesMap.getValue(profileId.loggedInInternalProfileId).learnerId learnerAnalyticsLogger.logDeleteProfile(installationId, profileId = null, learnerId) - Pair(it.toBuilder().removeProfiles(profileId.internalId).build(), ProfileActionStatus.SUCCESS) + Pair( + it.toBuilder().removeProfiles(profileId.loggedInInternalProfileId).build(), + ProfileActionStatus.SUCCESS + ) } return dataProviders.createInMemoryDataProviderAsync(DELETE_PROFILE_PROVIDER_ID) { return@createInMemoryDataProviderAsync getDeferredResult(profileId, null, deferred) @@ -784,9 +808,7 @@ class ProfileManagementController @Inject constructor( /** Returns the [ProfileId] of the current profile, or null if one hasn't yet been logged into. */ fun getCurrentProfileId(): ProfileId? { - return currentProfileId.takeIf { it != DEFAULT_LOGGED_OUT_INTERNAL_PROFILE_ID }?.let { - ProfileId.newBuilder().setInternalId(it).build() - } + return if (!currentProfileId.loggedOut) currentProfileId else null } /** @@ -812,7 +834,7 @@ class ProfileManagementController @Inject constructor( */ suspend fun fetchLearnerId(profileId: ProfileId): String? { val profileDatabase = profileDataStore.readDataAsync().await() - return profileDatabase.profilesMap[profileId.internalId]?.learnerId + return profileDatabase.profilesMap[profileId.loggedInInternalProfileId]?.learnerId } /** @@ -821,17 +843,19 @@ class ProfileManagementController @Inject constructor( */ suspend fun fetchContinueAnimationSeenStatus(profileId: ProfileId): Boolean? { val profileDatabase = profileDataStore.readDataAsync().await() - return profileDatabase.profilesMap[profileId.internalId]?.isContinueButtonAnimationSeen + return profileDatabase.profilesMap[ + profileId.loggedInInternalProfileId + ]?.isContinueButtonAnimationSeen } /** Marks that the continue button animation has been seen for the specified profile. */ suspend fun markContinueButtonAnimationSeen(profileId: ProfileId) { val updateDatabaseDeferred = profileDataStore.storeDataAsync(true) { - val profile = it.profilesMap[profileId.internalId] + val profile = it.profilesMap[profileId.loggedInInternalProfileId] if (profile != null) { val updatedProfile = profile.toBuilder().setIsContinueButtonAnimationSeen(true).build() val profileDatabaseBuilder = it.toBuilder().putProfiles( - profileId.internalId, + profileId.loggedInInternalProfileId, updatedProfile ) return@storeDataAsync profileDatabaseBuilder.build() @@ -848,12 +872,12 @@ class ProfileManagementController @Inject constructor( val deferred = profileDataStore.storeDataWithCustomChannelAsync( updateInMemoryCache = true ) { profileDatabase -> - val profile = profileDatabase.profilesMap[profileId.internalId] + val profile = profileDatabase.profilesMap[profileId.loggedInInternalProfileId] val updatedProfile = profile?.toBuilder()?.setSurveyLastShownTimestampMs( oppiaClock.getCurrentTimeMs() )?.build() val profileDatabaseBuilder = profileDatabase.toBuilder().putProfiles( - profileId.internalId, + profileId.loggedInInternalProfileId, updatedProfile ) Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) @@ -871,7 +895,7 @@ class ProfileManagementController @Inject constructor( ): DataProvider { return profileDataStore.transformAsync(RETRIEVE_SURVEY_LAST_SHOWN_TIMESTAMP_PROVIDER_ID) { val surveyLastShownTimestampMs = - it.profilesMap[profileId.internalId]?.surveyLastShownTimestampMs ?: 0L + it.profilesMap[profileId.loggedInInternalProfileId]?.surveyLastShownTimestampMs ?: 0L AsyncResult.Success(surveyLastShownTimestampMs) } } @@ -887,12 +911,12 @@ class ProfileManagementController @Inject constructor( val deferred = profileDataStore.storeDataWithCustomChannelAsync( updateInMemoryCache = true ) { profileDatabase -> - val profile = profileDatabase.profilesMap[profileId.internalId] + val profile = profileDatabase.profilesMap[profileId.loggedInInternalProfileId] val updatedProfile = profile?.toBuilder()?.setLastSelectedClassroomId( classroomId )?.build() val profileDatabaseBuilder = profileDatabase.toBuilder().putProfiles( - profileId.internalId, + profileId.loggedInInternalProfileId, updatedProfile ) Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) @@ -912,7 +936,9 @@ class ProfileManagementController @Inject constructor( profileId: ProfileId ): DataProvider { return profileDataStore.transformAsync(RETRIEVE_LAST_SELECTED_CLASSROOM_ID_PROVIDER_ID) { - val lastSelectedClassroomId = it.profilesMap[profileId.internalId]?.lastSelectedClassroomId + val lastSelectedClassroomId = it.profilesMap[ + profileId.loggedInInternalProfileId + ]?.lastSelectedClassroomId AsyncResult.Success(lastSelectedClassroomId) } } @@ -941,19 +967,19 @@ class ProfileManagementController @Inject constructor( ProfileActionStatus.FAILED_TO_DELETE_DIR -> AsyncResult.Failure( FailedToDeleteDirException( - "Failed to delete directory with ${profileId?.internalId}" + "Failed to delete directory with ${profileId?.loggedInInternalProfileId}" ) ) ProfileActionStatus.PROFILE_NOT_FOUND -> AsyncResult.Failure( ProfileNotFoundException( - "ProfileId ${profileId?.internalId} does not match an existing Profile" + "ProfileId ${profileId?.loggedInInternalProfileId} does not match an existing Profile" ) ) ProfileActionStatus.PROFILE_NOT_ADMIN -> AsyncResult.Failure( ProfileNotAdminException( - "ProfileId ${profileId?.internalId} does not match an existing admin" + "ProfileId ${profileId?.loggedInInternalProfileId} does not match an existing admin" ) ) ProfileActionStatus.PROFILE_ALREADY_HAS_ADMIN -> diff --git a/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt index c3ef0be50a8..8ed1654d289 100644 --- a/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt @@ -114,7 +114,9 @@ class AudioPlayerControllerTest { private val TEST_URL2 = "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-2.mp3" private val TEST_FAIL_URL = "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-2" - private val profileId by lazy { ProfileId.newBuilder().apply { internalId = 0 }.build() } + private val profileId by lazy { + ProfileId.newBuilder().apply { loggedInInternalProfileId = 0 }.build() + } @Test fun testController_initializePlayer_invokePrepared_reportsSuccessfulInit() { diff --git a/domain/src/test/java/org/oppia/android/domain/classroom/ClassroomControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/classroom/ClassroomControllerTest.kt index 24129abc307..cf929054d59 100644 --- a/domain/src/test/java/org/oppia/android/domain/classroom/ClassroomControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classroom/ClassroomControllerTest.kt @@ -71,7 +71,7 @@ class ClassroomControllerTest { @Before fun setUp() { - profileId0 = ProfileId.newBuilder().setInternalId(0).build() + profileId0 = ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() TestPlatformParameterModule.forceEnableMultipleClassrooms(true) setUpTestApplicationComponent() } diff --git a/domain/src/test/java/org/oppia/android/domain/devoptions/ModifyLessonProgressControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/devoptions/ModifyLessonProgressControllerTest.kt index 8039a9d77de..612570b94e1 100644 --- a/domain/src/test/java/org/oppia/android/domain/devoptions/ModifyLessonProgressControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/devoptions/ModifyLessonProgressControllerTest.kt @@ -82,7 +82,7 @@ class ModifyLessonProgressControllerTest { @Before fun setUp() { - profileId = ProfileId.newBuilder().setInternalId(1).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() setUpTestApplicationComponent() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) } diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationActiveTimeControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationActiveTimeControllerTest.kt index 5de6ae1179c..743d39bc5ce 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationActiveTimeControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationActiveTimeControllerTest.kt @@ -95,8 +95,8 @@ class ExplorationActiveTimeControllerTest { @Inject lateinit var explorationDataController: ExplorationDataController - private val firstTestProfile = ProfileId.newBuilder().setInternalId(0).build() - private val secondTestProfile = ProfileId.newBuilder().setInternalId(1).build() + private val firstTestProfile = ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() + private val secondTestProfile = ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() @Before fun setUp() { @@ -492,7 +492,7 @@ class ExplorationActiveTimeControllerTest { ) { val startPlayingProvider = explorationDataController.startPlayingNewExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId.loggedInInternalProfileId, classroomId, topicId, storyId, explorationId ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationDataControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationDataControllerTest.kt index 9e6e7e78b5e..43075caab6e 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationDataControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationDataControllerTest.kt @@ -89,7 +89,7 @@ class ExplorationDataControllerTest { @Inject lateinit var monitorFactory: DataProviderTestMonitor.Factory @Inject lateinit var explorationCheckpointController: ExplorationCheckpointController - private val profileId = ProfileId.newBuilder().setInternalId(0).build() + private val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() @Before fun setUp() { @@ -188,7 +188,7 @@ class ExplorationDataControllerTest { fun testStartPlayingNewExploration_returnsSuccess() { val startProvider = explorationDataController.startPlayingNewExploration( - profileId.internalId, + profileId.loggedInInternalProfileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -210,7 +210,7 @@ class ExplorationDataControllerTest { val secondStartProvider = explorationDataController.startPlayingNewExploration( - profileId.internalId, + profileId.loggedInInternalProfileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, TEST_EXPLORATION_ID_2 @@ -232,7 +232,7 @@ class ExplorationDataControllerTest { val checkpoint = retrieveExplorationCheckpoint(TEST_EXPLORATION_ID_2) val secondStartProvider = explorationDataController.resumeExploration( - profileId.internalId, + profileId.loggedInInternalProfileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -247,7 +247,7 @@ class ExplorationDataControllerTest { fun testRestartExploration_returnsSuccess() { val startProvider = explorationDataController.restartExploration( - profileId.internalId, + profileId.loggedInInternalProfileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -269,7 +269,7 @@ class ExplorationDataControllerTest { val secondStartProvider = explorationDataController.restartExploration( - profileId.internalId, + profileId.loggedInInternalProfileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -283,7 +283,7 @@ class ExplorationDataControllerTest { fun testReplayExploration_returnsSuccess() { val startProvider = explorationDataController.replayExploration( - profileId.internalId, + profileId.loggedInInternalProfileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -305,7 +305,7 @@ class ExplorationDataControllerTest { val secondStartProvider = explorationDataController.replayExploration( - profileId.internalId, + profileId.loggedInInternalProfileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -326,7 +326,7 @@ class ExplorationDataControllerTest { val dataProvider = explorationDataController.replayExploration( - profileId.internalId, + profileId.loggedInInternalProfileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_1, TEST_STORY_ID_2, @@ -386,7 +386,7 @@ class ExplorationDataControllerTest { ) { val startPlayingProvider = explorationDataController.startPlayingNewExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId.loggedInInternalProfileId, classroomId, topicId, storyId, explorationId ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } @@ -399,7 +399,7 @@ class ExplorationDataControllerTest { ) { val startPlayingProvider = explorationDataController.restartExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId.loggedInInternalProfileId, classroomId, topicId, storyId, explorationId ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } @@ -412,7 +412,7 @@ class ExplorationDataControllerTest { ) { val startPlayingProvider = explorationDataController.replayExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId.loggedInInternalProfileId, classroomId, topicId, storyId, explorationId ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt index 3026b834567..0ffbc8b0a3a 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt @@ -163,7 +163,7 @@ class ExplorationProgressControllerTest { @Inject lateinit var profileManagementController: ProfileManagementController @Inject lateinit var explorationActiveTimeController: ExplorationActiveTimeController - private val profileId = ProfileId.newBuilder().setInternalId(0).build() + private val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() @Before fun setUp() { @@ -182,7 +182,7 @@ class ExplorationProgressControllerTest { fun testPlayExploration_invalid_returnsSuccess() { val resultDataProvider = explorationDataController.replayExploration( - profileId.internalId, + profileId.loggedInInternalProfileId, INVALID_CLASSROOM_ID, INVALID_TOPIC_ID, INVALID_STORY_ID, @@ -209,7 +209,7 @@ class ExplorationProgressControllerTest { fun testPlayExploration_valid_returnsSuccess() { val resultDataProvider = explorationDataController.replayExploration( - profileId.internalId, + profileId.loggedInInternalProfileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -258,7 +258,7 @@ class ExplorationProgressControllerTest { @Test fun testEphemeralState_profile1ClicksContinue_switchToProfile2_shouldIndicateButtonAnimation() { oppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) - val profileId2 = ProfileId.newBuilder().setInternalId(1).build() + val profileId2 = ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() startPlayingNewExploration( TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, TEST_EXPLORATION_ID_2 ) @@ -348,7 +348,7 @@ class ExplorationProgressControllerTest { // Try playing another exploration without finishing the previous one. val resultDataProvider = explorationDataController.replayExploration( - profileId.internalId, + profileId.loggedInInternalProfileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -2172,7 +2172,7 @@ class ExplorationProgressControllerTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) // Languages unsupported in Gradle builds. fun testGetCurrentState_englishLangProfile_includesTranslationContextForEnglish() { - val englishProfileId = ProfileId.newBuilder().apply { internalId = 1 }.build() + val englishProfileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 1 }.build() updateContentLanguage(englishProfileId, OppiaLanguage.ENGLISH) startPlayingNewExploration( TEST_CLASSROOM_ID_0, @@ -2194,7 +2194,7 @@ class ExplorationProgressControllerTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) // Languages unsupported in Gradle builds. fun testGetCurrentState_englishLangProfile_switchToArabic_includesTranslationContextForArabic() { - val englishProfileId = ProfileId.newBuilder().apply { internalId = 1 }.build() + val englishProfileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 1 }.build() updateContentLanguage(englishProfileId, OppiaLanguage.ENGLISH) startPlayingNewExploration( TEST_CLASSROOM_ID_0, @@ -2218,8 +2218,8 @@ class ExplorationProgressControllerTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) // Languages unsupported in Gradle builds. fun testGetCurrentState_arabicLangProfile_includesTranslationContextForArabic() { - val englishProfileId = ProfileId.newBuilder().apply { internalId = 1 }.build() - val arabicProfileId = ProfileId.newBuilder().apply { internalId = 2 }.build() + val englishProfileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 1 }.build() + val arabicProfileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 2 }.build() updateContentLanguage(englishProfileId, OppiaLanguage.ENGLISH) updateContentLanguage(arabicProfileId, OppiaLanguage.ARABIC) startPlayingNewExploration( @@ -3184,8 +3184,8 @@ class ExplorationProgressControllerTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) fun testUpdateLanguageMidLesson_englishToSwahili_diffProfile_doesNotChangeOtherProfilesLang() { - val englishProfileId = ProfileId.newBuilder().apply { internalId = 1 }.build() - val arabicProfileId = ProfileId.newBuilder().apply { internalId = 2 }.build() + val englishProfileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 1 }.build() + val arabicProfileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 2 }.build() updateContentLanguage(englishProfileId, OppiaLanguage.ENGLISH) updateContentLanguage(arabicProfileId, OppiaLanguage.ARABIC) startPlayingNewExploration( @@ -3305,7 +3305,7 @@ class ExplorationProgressControllerTest { ) { val startPlayingProvider = explorationDataController.startPlayingNewExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId.loggedInInternalProfileId, classroomId, topicId, storyId, explorationId ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } @@ -3320,7 +3320,12 @@ class ExplorationProgressControllerTest { ) { val startPlayingProvider = explorationDataController.resumeExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId, explorationCheckpoint + profileId.loggedInInternalProfileId, + classroomId, + topicId, + storyId, + explorationId, + explorationCheckpoint ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } @@ -3334,7 +3339,7 @@ class ExplorationProgressControllerTest { ) { val startPlayingProvider = explorationDataController.restartExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId.loggedInInternalProfileId, classroomId, topicId, storyId, explorationId ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } @@ -3348,7 +3353,7 @@ class ExplorationProgressControllerTest { ) { val startPlayingProvider = explorationDataController.replayExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId.loggedInInternalProfileId, classroomId, topicId, storyId, explorationId ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointControllerTest.kt index 864af6b2745..88c7dac0f06 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointControllerTest.kt @@ -118,8 +118,8 @@ class ExplorationCheckpointControllerTest { @Inject lateinit var monitorFactory: DataProviderTestMonitor.Factory @Inject lateinit var fakeExplorationRetriever: FakeExplorationRetriever - private val firstTestProfile = ProfileId.newBuilder().setInternalId(0).build() - private val secondTestProfile = ProfileId.newBuilder().setInternalId(1).build() + private val firstTestProfile = ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() + private val secondTestProfile = ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() @Before fun setUp() { @@ -901,7 +901,7 @@ class ExplorationCheckpointControllerTest { expIdToLoadInstead = "test_checkpointing_base_exploration" ) explorationDataController.startPlayingNewExploration( - internalProfileId = profileId.internalId, + internalProfileId = profileId.loggedInInternalProfileId, classroomId = "", topicId = "", storyId = "", diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/AnalyticsControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/AnalyticsControllerTest.kt index aadb627472f..353e3b594e1 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/AnalyticsControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/AnalyticsControllerTest.kt @@ -1240,10 +1240,11 @@ class AnalyticsControllerTest { ) monitorFactory.ensureDataProviderExecutes(addProfileProvider) - return ProfileId.newBuilder().apply { internalId = 0 }.build().also { expectedProfileId -> - val logInProvider = profileManagementController.loginToProfile(expectedProfileId) - monitorFactory.waitForNextSuccessfulResult(logInProvider) // Ensure that the login succeeds. - } + return ProfileId.newBuilder().apply { loggedInInternalProfileId = 0 }.build() + .also { expectedProfileId -> + val logInProvider = profileManagementController.loginToProfile(expectedProfileId) + monitorFactory.waitForNextSuccessfulResult(logInProvider) // Ensure that the login succeeds. + } } private fun ensureAppLanguageIsUpdatedTo(profileId: ProfileId, language: OppiaLanguage) { diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FirestoreDataControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FirestoreDataControllerTest.kt index 2de079ee3c0..3bcc88c8220 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FirestoreDataControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FirestoreDataControllerTest.kt @@ -84,7 +84,9 @@ class FirestoreDataControllerTest { @Inject lateinit var persistentCacheStoryFactory: PersistentCacheStore.Factory - private val profileId by lazy { ProfileId.newBuilder().apply { internalId = 0 }.build() } + private val profileId by lazy { + ProfileId.newBuilder().apply { loggedInInternalProfileId = 0 }.build() + } private val dataController by lazy { dataControllerProvider.get() } @@ -401,7 +403,7 @@ class FirestoreDataControllerTest { profileId: ProfileId? ): EventLog.SurveyResponseContext { return EventLog.SurveyResponseContext.newBuilder() - .setProfileId(profileId?.internalId.toString()) + .setProfileId(profileId?.loggedInInternalProfileId.toString()) .setSurveyId(surveyId) .build() } diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt index 30523eb52e7..81f861d80e1 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt @@ -115,7 +115,9 @@ class LearnerAnalyticsLoggerTest { private val expectedLearnerIdParameter: String get() = elid private val expectedInstallIdParameter: String get() = eid - private val profileId by lazy { ProfileId.newBuilder().apply { internalId = 0 }.build() } + private val profileId by lazy { + ProfileId.newBuilder().apply { loggedInInternalProfileId = 0 }.build() + } @Before fun setUp() { diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/SurveyEventsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/SurveyEventsLoggerTest.kt index a8962bb0af4..7ad52fd3930 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/SurveyEventsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/SurveyEventsLoggerTest.kt @@ -70,7 +70,9 @@ class SurveyEventsLoggerTest { @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers - private val profileId by lazy { ProfileId.newBuilder().apply { internalId = 0 }.build() } + private val profileId by lazy { + ProfileId.newBuilder().apply { loggedInInternalProfileId = 0 }.build() + } @Before fun setUp() { diff --git a/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt index 91d58907646..cf2cd64a68a 100644 --- a/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt @@ -102,13 +102,13 @@ class ProfileManagementControllerTest { Profile.newBuilder().setName("Veena").setPin("567").setAllowDownloadAccess(true).build() ) - private val ADMIN_PROFILE_ID_0 = ProfileId.newBuilder().setInternalId(0).build() - private val PROFILE_ID_0 = ProfileId.newBuilder().setInternalId(0).build() - private val PROFILE_ID_1 = ProfileId.newBuilder().setInternalId(1).build() - private val PROFILE_ID_2 = ProfileId.newBuilder().setInternalId(2).build() - private val PROFILE_ID_3 = ProfileId.newBuilder().setInternalId(3).build() - private val PROFILE_ID_4 = ProfileId.newBuilder().setInternalId(4).build() - private val PROFILE_ID_6 = ProfileId.newBuilder().setInternalId(6).build() + private val ADMIN_PROFILE_ID_0 = ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() + private val PROFILE_ID_0 = ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() + private val PROFILE_ID_1 = ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() + private val PROFILE_ID_2 = ProfileId.newBuilder().setLoggedInInternalProfileId(2).build() + private val PROFILE_ID_3 = ProfileId.newBuilder().setLoggedInInternalProfileId(3).build() + private val PROFILE_ID_4 = ProfileId.newBuilder().setLoggedInInternalProfileId(4).build() + private val PROFILE_ID_6 = ProfileId.newBuilder().setLoggedInInternalProfileId(6).build() private const val DEFAULT_PIN = "12345" private const val DEFAULT_ALLOW_DOWNLOAD_ACCESS = true @@ -135,7 +135,7 @@ class ProfileManagementControllerTest { assertThat(profile.name).isEqualTo("James") assertThat(profile.pin).isEqualTo("123") assertThat(profile.allowDownloadAccess).isEqualTo(true) - assertThat(profile.id.internalId).isEqualTo(0) + assertThat(profile.id.loggedInInternalProfileId).isEqualTo(0) assertThat(profile.readingTextSize).isEqualTo(MEDIUM_TEXT_SIZE) assertThat(profile.numberOfLogins).isEqualTo(0) assertThat(profile.isContinueButtonAnimationSeen).isEqualTo(false) @@ -202,7 +202,7 @@ class ProfileManagementControllerTest { assertThat(profile.name).isEqualTo("Rajat") assertThat(profile.pin).isEqualTo("456") assertThat(profile.allowDownloadAccess).isEqualTo(false) - assertThat(profile.id.internalId).isEqualTo(3) + assertThat(profile.id.loggedInInternalProfileId).isEqualTo(3) assertThat(profile.readingTextSize).isEqualTo(MEDIUM_TEXT_SIZE) } @@ -214,7 +214,7 @@ class ProfileManagementControllerTest { val dataProvider = profileManagementController.getProfiles() val profiles = monitorFactory.waitForNextSuccessfulResult(dataProvider).sortedBy { - it.id.internalId + it.id.loggedInInternalProfileId } assertThat(profiles.size).isEqualTo(PROFILES_LIST.size) checkTestProfilesArePresent(profiles) @@ -230,7 +230,7 @@ class ProfileManagementControllerTest { val dataProvider = profileManagementController.getProfiles() val profiles = monitorFactory.waitForNextSuccessfulResult(dataProvider).sortedBy { - it.id.internalId + it.id.loggedInInternalProfileId } assertThat(profiles.size).isEqualTo(PROFILES_LIST.size + 1) checkTestProfilesArePresent(profiles) @@ -242,7 +242,7 @@ class ProfileManagementControllerTest { addTestProfiles() testCoroutineDispatchers.runCurrent() - val profileId = ProfileId.newBuilder().setInternalId(2).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(2).build() val updateProvider = profileManagementController.initializeLearnerId(profileId) monitorFactory.ensureDataProviderExecutes(updateProvider) val profileProvider = profileManagementController.getProfile(profileId) @@ -258,7 +258,7 @@ class ProfileManagementControllerTest { addTestProfiles() testCoroutineDispatchers.runCurrent() - val profileId = ProfileId.newBuilder().setInternalId(2).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(2).build() val updateProvider = profileManagementController.initializeLearnerId(profileId) monitorFactory.ensureDataProviderExecutes(updateProvider) val profileProvider = profileManagementController.getProfile(profileId) @@ -909,12 +909,12 @@ class ProfileManagementControllerTest { val profilesProvider = profileManagementController.getProfiles() val profiles = monitorFactory.waitForNextSuccessfulResult(profilesProvider).sortedBy { - it.id.internalId + it.id.loggedInInternalProfileId } assertThat(profiles.size).isEqualTo(4) assertThat(profiles[profiles.size - 2].name).isEqualTo("Ben") assertThat(profiles.last().name).isEqualTo("John") - assertThat(profiles.last().id.internalId).isEqualTo(5) + assertThat(profiles.last().id.loggedInInternalProfileId).isEqualTo(5) assertThat(File(getAbsoluteDirPath("3")).isDirectory).isFalse() assertThat(File(getAbsoluteDirPath("4")).isDirectory).isFalse() } @@ -950,7 +950,11 @@ class ProfileManagementControllerTest { val profileProvider = profileManagementController.getProfile(PROFILE_ID_2) monitorFactory.waitForNextSuccessfulResult(loginProvider) val profile = monitorFactory.waitForNextSuccessfulResult(profileProvider) - assertThat(profileManagementController.getCurrentProfileId()?.internalId).isEqualTo(2) + assertThat( + profileManagementController.getCurrentProfileId()?.loggedInInternalProfileId + ).isEqualTo( + 2 + ) assertThat(profile.lastLoggedInTimestampMs).isNotEqualTo(0) assertThat(profile.numberOfLogins).isEqualTo(1) } @@ -1446,7 +1450,7 @@ class ProfileManagementControllerTest { assertThat(resultList[idx].name).isEqualTo(profile.name) assertThat(resultList[idx].pin).isEqualTo(profile.pin) assertThat(resultList[idx].allowDownloadAccess).isEqualTo(profile.allowDownloadAccess) - assertThat(resultList[idx].id.internalId).isEqualTo(idx) + assertThat(resultList[idx].id.loggedInInternalProfileId).isEqualTo(idx) assertThat(File(getAbsoluteDirPath(idx.toString())).isDirectory).isTrue() } } diff --git a/domain/src/test/java/org/oppia/android/domain/question/QuestionAssessmentProgressControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/question/QuestionAssessmentProgressControllerTest.kt index 0c686230064..c8bdcac0d64 100644 --- a/domain/src/test/java/org/oppia/android/domain/question/QuestionAssessmentProgressControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/question/QuestionAssessmentProgressControllerTest.kt @@ -107,7 +107,7 @@ class QuestionAssessmentProgressControllerTest { @Before fun setUp() { - profileId1 = ProfileId.newBuilder().setInternalId(1).build() + profileId1 = ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() } @Test @@ -1316,7 +1316,7 @@ class QuestionAssessmentProgressControllerTest { @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) // Languages unsupported in Gradle builds. fun testGetCurrentState_englishLangProfile_includesTranslationContextForEnglish() { setUpTestApplicationWithSeed(questionSeed = 1) - val englishProfileId = ProfileId.newBuilder().apply { internalId = 2 }.build() + val englishProfileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 2 }.build() updateContentLanguage(englishProfileId, OppiaLanguage.ENGLISH) startSuccessfulTrainingSession(englishProfileId, TEST_SKILL_ID_LIST_01) @@ -1333,7 +1333,7 @@ class QuestionAssessmentProgressControllerTest { @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) // Languages unsupported in Gradle builds. fun testGetCurrentState_englishLangProfile_switchToArabic_includesTranslationContextForArabic() { setUpTestApplicationWithSeed(questionSeed = 1) - val englishProfileId = ProfileId.newBuilder().apply { internalId = 2 }.build() + val englishProfileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 2 }.build() updateContentLanguage(englishProfileId, OppiaLanguage.ENGLISH) startSuccessfulTrainingSession(englishProfileId, TEST_SKILL_ID_LIST_01) val monitor = @@ -1353,8 +1353,8 @@ class QuestionAssessmentProgressControllerTest { @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) // Languages unsupported in Gradle builds. fun testGetCurrentState_arabicLangProfile_includesTranslationContextForArabic() { setUpTestApplicationWithSeed(questionSeed = 1) - val englishProfileId = ProfileId.newBuilder().apply { internalId = 2 }.build() - val arabicProfileId = ProfileId.newBuilder().apply { internalId = 3 }.build() + val englishProfileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 2 }.build() + val arabicProfileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 3 }.build() updateContentLanguage(englishProfileId, OppiaLanguage.ENGLISH) updateContentLanguage(arabicProfileId, OppiaLanguage.ARABIC) startSuccessfulTrainingSession(arabicProfileId, TEST_SKILL_ID_LIST_01) diff --git a/domain/src/test/java/org/oppia/android/domain/question/QuestionTrainingControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/question/QuestionTrainingControllerTest.kt index 206dee7d22b..70c5c3f3ae7 100644 --- a/domain/src/test/java/org/oppia/android/domain/question/QuestionTrainingControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/question/QuestionTrainingControllerTest.kt @@ -80,7 +80,7 @@ class QuestionTrainingControllerTest { @Before fun setUp() { - profileId1 = ProfileId.newBuilder().setInternalId(1).build() + profileId1 = ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() } @Test diff --git a/domain/src/test/java/org/oppia/android/domain/spotlight/SpotlightStateControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/spotlight/SpotlightStateControllerTest.kt index a6d69f7e768..392b40ed655 100644 --- a/domain/src/test/java/org/oppia/android/domain/spotlight/SpotlightStateControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/spotlight/SpotlightStateControllerTest.kt @@ -80,8 +80,8 @@ class SpotlightStateControllerTest { @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers - private val profileId0 = ProfileId.newBuilder().setInternalId(0).build() - private val profileId1 = ProfileId.newBuilder().setInternalId(1).build() + private val profileId0 = ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() + private val profileId1 = ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() @Before fun setUp() { diff --git a/domain/src/test/java/org/oppia/android/domain/survey/SurveyControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/survey/SurveyControllerTest.kt index 8ea319426f5..c2497c596cc 100644 --- a/domain/src/test/java/org/oppia/android/domain/survey/SurveyControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/survey/SurveyControllerTest.kt @@ -68,7 +68,7 @@ class SurveyControllerTest { SurveyQuestionName.MARKET_FIT, SurveyQuestionName.NPS ) - private val profileId = ProfileId.newBuilder().setInternalId(1).build() + private val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() @Before fun setUp() { diff --git a/domain/src/test/java/org/oppia/android/domain/survey/SurveyGatingControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/survey/SurveyGatingControllerTest.kt index b757364aab3..08b8218a7b9 100644 --- a/domain/src/test/java/org/oppia/android/domain/survey/SurveyGatingControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/survey/SurveyGatingControllerTest.kt @@ -708,7 +708,7 @@ class SurveyGatingControllerTest { // Date & time: Tue Apr 23 2019 23:22:00 GMT. private const val LATE_NIGHT_UTC_TIMESTAMP_MILLIS = 1556061720000 - private val PROFILE_ID_0 = ProfileId.newBuilder().setInternalId(0).build() - private val PROFILE_ID_1 = ProfileId.newBuilder().setInternalId(1).build() + private val PROFILE_ID_0 = ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() + private val PROFILE_ID_1 = ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() } } diff --git a/domain/src/test/java/org/oppia/android/domain/survey/SurveyProgressControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/survey/SurveyProgressControllerTest.kt index ea336df027a..185461cad37 100644 --- a/domain/src/test/java/org/oppia/android/domain/survey/SurveyProgressControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/survey/SurveyProgressControllerTest.kt @@ -77,7 +77,7 @@ class SurveyProgressControllerTest { @Inject lateinit var fakeFirestoreEventLogger: FakeFirestoreEventLogger - private val profileId = ProfileId.newBuilder().setInternalId(1).build() + private val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() @Before fun setUp() { diff --git a/domain/src/test/java/org/oppia/android/domain/topic/StoryProgressControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/topic/StoryProgressControllerTest.kt index ac37fe5a6e0..b1992cbe40e 100644 --- a/domain/src/test/java/org/oppia/android/domain/topic/StoryProgressControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/topic/StoryProgressControllerTest.kt @@ -59,7 +59,7 @@ class StoryProgressControllerTest { @Before fun setUp() { - profileId = ProfileId.newBuilder().setInternalId(0).build() + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() setUpTestApplicationComponent() } diff --git a/domain/src/test/java/org/oppia/android/domain/topic/TopicControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/topic/TopicControllerTest.kt index 02cd5660933..ef3972384fb 100755 --- a/domain/src/test/java/org/oppia/android/domain/topic/TopicControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/topic/TopicControllerTest.kt @@ -90,8 +90,8 @@ class TopicControllerTest { @Before fun setUp() { - profileId1 = ProfileId.newBuilder().setInternalId(1).build() - profileId2 = ProfileId.newBuilder().setInternalId(2).build() + profileId1 = ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() + profileId2 = ProfileId.newBuilder().setLoggedInInternalProfileId(2).build() setUpTestApplicationComponent() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) } diff --git a/domain/src/test/java/org/oppia/android/domain/topic/TopicListControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/topic/TopicListControllerTest.kt index 052b684c8e6..93b5bc0a788 100644 --- a/domain/src/test/java/org/oppia/android/domain/topic/TopicListControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/topic/TopicListControllerTest.kt @@ -80,7 +80,7 @@ class TopicListControllerTest { @Before fun setUp() { - profileId0 = ProfileId.newBuilder().setInternalId(0).build() + profileId0 = ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() setUpTestApplicationComponent() // Use uptime millis for time tracking since that allows proper time management for recorded diff --git a/domain/src/test/java/org/oppia/android/domain/translation/TranslationControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/translation/TranslationControllerTest.kt index c483bf494dd..c566f61ca50 100644 --- a/domain/src/test/java/org/oppia/android/domain/translation/TranslationControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/translation/TranslationControllerTest.kt @@ -1957,11 +1957,11 @@ class TranslationControllerTest { private val KENYA_KISWAHILI_LOCALE = Locale("sw", "KE") private val PROFILE_ID_0 = ProfileId.newBuilder().apply { - internalId = 0 + loggedInInternalProfileId = 0 }.build() private val PROFILE_ID_1 = ProfileId.newBuilder().apply { - internalId = 1 + loggedInInternalProfileId = 1 }.build() private val APP_LANGUAGE_SELECTION_SYSTEM = AppLanguageSelection.newBuilder().apply { diff --git a/model/src/main/proto/profile.proto b/model/src/main/proto/profile.proto index bffdb1ec194..04fd9856ece 100644 --- a/model/src/main/proto/profile.proto +++ b/model/src/main/proto/profile.proto @@ -109,7 +109,12 @@ message ProfileId { * Unique ID used to identify a single profile. * Should not be used directory outside of the profile system. */ - int32 internal_id = 1; + reserved 1; + oneof type { + int32 logged_in_internal_profile_id = 2; + // Boolean if user is logged_out or not. + bool logged_out = 3; + } } // Used in BindableAdapter for ProfileChooserFragment. diff --git a/testing/src/main/java/org/oppia/android/testing/profile/ProfileTestHelper.kt b/testing/src/main/java/org/oppia/android/testing/profile/ProfileTestHelper.kt index 3dc71a049a1..fbf9ce669d6 100644 --- a/testing/src/main/java/org/oppia/android/testing/profile/ProfileTestHelper.kt +++ b/testing/src/main/java/org/oppia/android/testing/profile/ProfileTestHelper.kt @@ -90,7 +90,7 @@ class ProfileTestHelper @Inject constructor( private fun logIntoProfile(internalProfileId: Int): DataProvider { return profileManagementController.loginToProfile( - ProfileId.newBuilder().setInternalId(internalProfileId).build() + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() ) } diff --git a/testing/src/test/java/org/oppia/android/testing/lightweightcheckpointing/ExplorationCheckpointTestHelperTest.kt b/testing/src/test/java/org/oppia/android/testing/lightweightcheckpointing/ExplorationCheckpointTestHelperTest.kt index 40c87c049d0..e3a86b263b2 100644 --- a/testing/src/test/java/org/oppia/android/testing/lightweightcheckpointing/ExplorationCheckpointTestHelperTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/lightweightcheckpointing/ExplorationCheckpointTestHelperTest.kt @@ -76,7 +76,7 @@ class ExplorationCheckpointTestHelperTest { @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @Inject lateinit var monitorFactory: DataProviderTestMonitor.Factory - private val profileId = ProfileId.newBuilder().setInternalId(0).build() + private val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() @Before fun setUp() { diff --git a/testing/src/test/java/org/oppia/android/testing/profile/ProfileTestHelperTest.kt b/testing/src/test/java/org/oppia/android/testing/profile/ProfileTestHelperTest.kt index dcddadc11ab..5a7bc99a468 100644 --- a/testing/src/test/java/org/oppia/android/testing/profile/ProfileTestHelperTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/profile/ProfileTestHelperTest.kt @@ -74,7 +74,11 @@ class ProfileTestHelperTest { assertThat(profiles[0].isAdmin).isTrue() assertThat(profiles[1].name).isEqualTo("Ben") assertThat(profiles[1].isAdmin).isFalse() - assertThat(profileManagementController.getCurrentProfileId()?.internalId).isEqualTo(0) + assertThat( + profileManagementController.getCurrentProfileId()?.loggedInInternalProfileId + ).isEqualTo( + 0 + ) } @Test @@ -88,7 +92,11 @@ class ProfileTestHelperTest { assertThat(profiles.size).isEqualTo(1) assertThat(profiles[0].name).isEqualTo("Admin") assertThat(profiles[0].isAdmin).isTrue() - assertThat(profileManagementController.getCurrentProfileId()?.internalId).isEqualTo(0) + assertThat( + profileManagementController.getCurrentProfileId()?.loggedInInternalProfileId + ).isEqualTo( + 0 + ) } @Test @@ -107,7 +115,11 @@ class ProfileTestHelperTest { profileTestHelper.initializeProfiles() val loginProvider = profileTestHelper.logIntoAdmin() monitorFactory.waitForNextSuccessfulResult(loginProvider) - assertThat(profileManagementController.getCurrentProfileId()?.internalId).isEqualTo(0) + assertThat( + profileManagementController.getCurrentProfileId()?.loggedInInternalProfileId + ).isEqualTo( + 0 + ) } @Test @@ -115,7 +127,11 @@ class ProfileTestHelperTest { profileTestHelper.initializeProfiles() val loginProvider = profileTestHelper.logIntoUser() monitorFactory.waitForNextSuccessfulResult(loginProvider) - assertThat(profileManagementController.getCurrentProfileId()?.internalId).isEqualTo(1) + assertThat( + profileManagementController.getCurrentProfileId()?.loggedInInternalProfileId + ).isEqualTo( + 1 + ) } @Test @@ -123,7 +139,11 @@ class ProfileTestHelperTest { profileTestHelper.initializeProfiles() val loginProvider = profileTestHelper.logIntoNewUser() monitorFactory.waitForNextSuccessfulResult(loginProvider) - assertThat(profileManagementController.getCurrentProfileId()?.internalId).isEqualTo(2) + assertThat( + profileManagementController.getCurrentProfileId()?.loggedInInternalProfileId + ).isEqualTo( + 2 + ) } // TODO(#89): Move this to a common test application component. diff --git a/testing/src/test/java/org/oppia/android/testing/story/StoryProgressTestHelperTest.kt b/testing/src/test/java/org/oppia/android/testing/story/StoryProgressTestHelperTest.kt index 1cd8edc65cd..4f5ebd6d4dc 100644 --- a/testing/src/test/java/org/oppia/android/testing/story/StoryProgressTestHelperTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/story/StoryProgressTestHelperTest.kt @@ -85,8 +85,12 @@ class StoryProgressTestHelperTest { @Inject lateinit var fakeOppiaClock: FakeOppiaClock @Inject lateinit var monitorFactory: DataProviderTestMonitor.Factory - private val profileId0: ProfileId by lazy { ProfileId.newBuilder().setInternalId(0).build() } - private val profileId1: ProfileId by lazy { ProfileId.newBuilder().setInternalId(1).build() } + private val profileId0: ProfileId by lazy { + ProfileId.newBuilder().setLoggedInInternalProfileId(0).build() + } + private val profileId1: ProfileId by lazy { + ProfileId.newBuilder().setLoggedInInternalProfileId(1).build() + } @Before fun setUp() { diff --git a/utility/src/test/java/org/oppia/android/util/profile/CurrentUserProfileIdIntentDecoratorTest.kt b/utility/src/test/java/org/oppia/android/util/profile/CurrentUserProfileIdIntentDecoratorTest.kt index 679dd21a3f0..69461790b74 100644 --- a/utility/src/test/java/org/oppia/android/util/profile/CurrentUserProfileIdIntentDecoratorTest.kt +++ b/utility/src/test/java/org/oppia/android/util/profile/CurrentUserProfileIdIntentDecoratorTest.kt @@ -24,12 +24,12 @@ class CurrentUserProfileIdIntentDecoratorTest { val intent = Intent().apply { decorateWithUserProfileId( ProfileId.newBuilder().apply { - internalId = 1 + loggedInInternalProfileId = 1 }.build() ) } val currentProfileId = intent.extractCurrentUserProfileId() - assertThat(currentProfileId.internalId).isEqualTo(1) + assertThat(currentProfileId.loggedInInternalProfileId).isEqualTo(1) } @Test @@ -50,7 +50,7 @@ class CurrentUserProfileIdIntentDecoratorTest { @Test fun testDecorator_decorateBundleWithProfileId_returnsBundleWithCorrectProfileId() { - val profileId = ProfileId.newBuilder().apply { internalId = 1 }.build() + val profileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 1 }.build() val bundle = Bundle().apply { decorateWithUserProfileId(profileId) } diff --git a/wiki/Spotlight-Guide.md b/wiki/Spotlight-Guide.md index 60d4db2dff9..901e17c41f3 100644 --- a/wiki/Spotlight-Guide.md +++ b/wiki/Spotlight-Guide.md @@ -137,7 +137,7 @@ In order to bypass a spotlight without any UI interaction, the ``SpotlightStateC ```kotlin private fun markAllSpotlightsSeen() { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() spotlightStateController.markSpotlightViewed(profileId, TOPIC_LESSON_TAB) spotlightStateController.markSpotlightViewed(profileId, TOPIC_REVISION_TAB) spotlightStateController.markSpotlightViewed(profileId, YOUR_FEATURE_NAME)