From a5b67a0f0811b31fe52b23f46785986bfa9583d5 Mon Sep 17 00:00:00 2001 From: MohitGupta121 Date: Thu, 8 Aug 2024 17:36:37 +0530 Subject: [PATCH 1/6] introduce new ProfileId message --- .../AdministratorControlsFragmentPresenter.kt | 4 +- .../app/classroom/ClassroomListActivity.kt | 4 +- .../ClassroomListFragmentPresenter.kt | 2 +- .../app/classroom/ClassroomListViewModel.kt | 2 +- .../CompletedStoryListActivity.kt | 4 +- .../CompletedStoryListFragment.kt | 4 +- .../CompletedStoryListViewModel.kt | 2 +- .../devoptions/DeveloperOptionsActivity.kt | 2 +- .../MarkChaptersCompletedFragmentPresenter.kt | 2 +- .../MarkStoriesCompletedActivity.kt | 4 +- .../MarkStoriesCompletedFragment.kt | 4 +- .../MarkStoriesCompletedFragmentPresenter.kt | 2 +- .../MarkStoriesCompletedTestActivity.kt | 4 +- .../MarkTopicsCompletedActivity.kt | 4 +- .../MarkTopicsCompletedFragment.kt | 4 +- .../MarkTopicsCompletedFragmentPresenter.kt | 2 +- .../MarkTopicsCompletedTestActivity.kt | 4 +- .../testing/DeveloperOptionsTestActivity.kt | 4 +- .../NavigationDrawerFragmentPresenter.kt | 2 +- .../drawer/NavigationDrawerHeaderViewModel.kt | 2 +- .../oppia/android/app/home/HomeActivity.kt | 4 +- .../android/app/home/HomeFragmentPresenter.kt | 6 +- .../oppia/android/app/home/HomeViewModel.kt | 2 +- .../RecentlyPlayedActivityPresenter.kt | 2 +- .../recentlyplayed/RecentlyPlayedFragment.kt | 4 +- .../RecentlyPlayedFragmentPresenter.kt | 6 +- .../app/mydownloads/MyDownloadsActivity.kt | 6 +- .../OngoingTopicListActivity.kt | 4 +- .../OngoingTopicListFragment.kt | 4 +- .../OngoingTopicListViewModel.kt | 2 +- .../app/options/AppLanguageActivity.kt | 4 +- .../app/options/AppLanguageFragment.kt | 4 +- .../options/AppLanguageFragmentPresenter.kt | 2 +- .../android/app/options/OptionsActivity.kt | 2 +- .../app/options/OptionsFragmentPresenter.kt | 4 +- .../android/app/player/audio/AudioFragment.kt | 4 +- .../player/audio/AudioFragmentPresenter.kt | 2 +- .../ExplorationActivityPresenter.kt | 4 +- .../ExplorationFragmentPresenter.kt | 6 +- .../player/state/StateFragmentPresenter.kt | 4 +- .../testing/StateFragmentTestActivity.kt | 2 +- .../StateFragmentTestActivityPresenter.kt | 2 +- .../app/profile/AdminAuthActivityPresenter.kt | 2 +- .../app/profile/AdminPinActivityPresenter.kt | 2 +- .../profile/PinPasswordActivityPresenter.kt | 2 +- .../app/profile/PinPasswordViewModel.kt | 2 +- .../ProfileChooserFragmentPresenter.kt | 8 +- .../ResetPinDialogFragmentPresenter.kt | 2 +- .../profileprogress/ProfilePictureActivity.kt | 4 +- .../ProfilePictureActivityPresenter.kt | 2 +- .../ProfileProgressActivity.kt | 6 +- .../ProfileProgressActivityPresenter.kt | 2 +- .../ProfileProgressFragment.kt | 4 +- .../ProfileProgressViewModel.kt | 2 +- .../ResumeLessonFragmentPresenter.kt | 4 +- .../ProfileEditDeletionDialogFragment.kt | 4 +- .../profile/ProfileEditFragmentPresenter.kt | 6 +- .../settings/profile/ProfileEditViewModel.kt | 4 +- .../profile/ProfileListFragmentPresenter.kt | 4 +- .../settings/profile/ProfileRenameActivity.kt | 4 +- .../settings/profile/ProfileRenameFragment.kt | 4 +- .../profile/ProfileRenameFragmentPresenter.kt | 2 +- .../ProfileResetPinFragmentPresenter.kt | 2 +- .../android/app/shim/IntentFactoryShimImpl.kt | 4 +- .../app/spotlight/SpotlightFragment.kt | 8 +- .../oppia/android/app/story/StoryActivity.kt | 4 +- .../oppia/android/app/story/StoryFragment.kt | 4 +- .../app/story/StoryFragmentPresenter.kt | 6 +- .../oppia/android/app/story/StoryViewModel.kt | 2 +- .../StoryChapterSummaryViewModel.kt | 4 +- .../android/app/survey/SurveyActivity.kt | 2 +- .../android/app/survey/SurveyFragment.kt | 4 +- .../app/survey/SurveyFragmentPresenter.kt | 2 +- ...ministratorControlsFragmentTestActivity.kt | 2 +- .../app/testing/AudioFragmentTestActivity.kt | 4 +- .../ExplorationTestActivityPresenter.kt | 2 +- .../testing/NavigationDrawerTestActivity.kt | 6 +- .../ProfileEditFragmentTestActivity.kt | 2 +- ...rofileEditFragmentTestActivityPresenter.kt | 2 +- .../testing/SpotlightFragmentTestActivity.kt | 4 +- .../SpotlightFragmentTestActivityPresenter.kt | 2 +- .../oppia/android/app/topic/TopicActivity.kt | 10 +-- .../app/topic/TopicActivityPresenter.kt | 2 +- .../oppia/android/app/topic/TopicFragment.kt | 2 +- .../app/topic/TopicFragmentPresenter.kt | 2 +- .../oppia/android/app/topic/TopicViewModel.kt | 4 +- .../app/topic/info/TopicInfoFragment.kt | 4 +- .../topic/info/TopicInfoFragmentPresenter.kt | 2 +- .../app/topic/lessons/TopicLessonViewModel.kt | 2 +- .../app/topic/lessons/TopicLessonsFragment.kt | 4 +- .../lessons/TopicLessonsFragmentPresenter.kt | 2 +- .../topic/practice/TopicPracticeFragment.kt | 4 +- .../topic/practice/TopicPracticeViewModel.kt | 2 +- .../topic/revision/TopicRevisionFragment.kt | 4 +- .../topic/revision/TopicRevisionViewModel.kt | 2 +- .../revisioncard/RevisionCardActivity.kt | 4 +- .../RevisionCardActivityPresenter.kt | 2 +- .../revisioncard/RevisionCardViewModel.kt | 4 +- .../app/walkthrough/WalkthroughActivity.kt | 2 +- .../end/WalkthroughFinalFragmentPresenter.kt | 4 +- .../WalkthroughWelcomeFragmentPresenter.kt | 4 +- .../AdministratorControlsActivityTest.kt | 10 +-- .../AppVersionActivityTest.kt | 2 +- .../ProfileAndDeviceIdFragmentTest.kt | 2 +- .../classroom/ClassroomListActivityTest.kt | 4 +- .../classroom/ClassroomListFragmentTest.kt | 2 +- .../CompletedStoryListActivityTest.kt | 2 +- .../DeveloperOptionsActivityTest.kt | 2 +- .../MarkChaptersCompletedFragmentTest.kt | 2 +- .../MarkStoriesCompletedFragmentTest.kt | 2 +- .../MarkTopicsCompletedFragmentTest.kt | 2 +- .../devoptions/ViewEventLogsFragmentTest.kt | 2 +- .../android/app/help/HelpActivityTest.kt | 2 +- .../android/app/help/HelpFragmentTest.kt | 2 +- .../android/app/home/HomeActivityTest.kt | 8 +- .../app/home/RecentlyPlayedFragmentTest.kt | 24 ++--- .../OngoingTopicListActivityTest.kt | 6 +- .../app/options/OptionsActivityTest.kt | 2 +- .../app/options/OptionsFragmentTest.kt | 2 +- .../options/ReadingTextSizeFragmentTest.kt | 2 +- .../app/player/audio/AudioFragmentTest.kt | 2 +- .../exploration/ExplorationActivityTest.kt | 78 ++++++++-------- .../app/player/state/StateFragmentTest.kt | 4 +- .../app/profile/ProfileChooserFragmentTest.kt | 2 +- .../ProfileProgressFragmentTest.kt | 16 ++-- .../resumelesson/ResumeLessonActivityTest.kt | 2 +- .../resumelesson/ResumeLessonFragmentTest.kt | 4 +- .../profile/ProfileEditFragmentTest.kt | 6 +- .../android/app/story/StoryActivityTest.kt | 2 +- .../android/app/story/StoryFragmentTest.kt | 2 +- .../android/app/survey/SurveyActivityTest.kt | 2 +- .../android/app/survey/SurveyFragmentTest.kt | 4 +- .../NavigationDrawerActivityDebugTest.kt | 2 +- .../NavigationDrawerActivityProdTest.kt | 10 +-- .../android/app/topic/TopicActivityTest.kt | 4 +- .../android/app/topic/TopicFragmentTest.kt | 6 +- .../conceptcard/ConceptCardFragmentTest.kt | 2 +- .../topic/lessons/TopicLessonsFragmentTest.kt | 12 +-- .../practice/TopicPracticeFragmentTest.kt | 2 +- .../QuestionPlayerActivityTest.kt | 2 +- .../revision/TopicRevisionFragmentTest.kt | 2 +- .../revisioncard/RevisionCardActivityTest.kt | 4 +- .../revisioncard/RevisionCardFragmentTest.kt | 58 ++++++------ .../WalkthroughWelcomeFragmentTest.kt | 2 +- .../activity/ActivityIntentFactoriesTest.kt | 4 +- .../app/activity/route/ActivityRouterTest.kt | 2 +- .../android/app/home/HomeActivityLocalTest.kt | 2 +- .../ExplorationActivityLocalTest.kt | 6 +- .../player/state/StateFragmentLocalTest.kt | 4 +- .../oppia/android/app/testing/HomeSpanTest.kt | 2 +- .../app/testing/RecentlyPlayedSpanTest.kt | 4 +- .../AdministratorControlsFragmentTest.kt | 2 +- .../testing/options/OptionsFragmentTest.kt | 2 +- .../data/persistence/PersistentCacheStore.kt | 2 +- .../exploration/ExplorationDataController.kt | 2 +- .../ExplorationCheckpointController.kt | 4 +- .../oppialogger/survey/SurveyEventsLogger.kt | 2 +- .../profile/ProfileManagementController.kt | 88 +++++++++---------- .../domain/audio/AudioPlayerControllerTest.kt | 2 +- .../classroom/ClassroomControllerTest.kt | 2 +- .../ModifyLessonProgressControllerTest.kt | 2 +- .../ExplorationActiveTimeControllerTest.kt | 6 +- .../ExplorationDataControllerTest.kt | 24 ++--- .../ExplorationProgressControllerTest.kt | 30 +++---- .../ExplorationCheckpointControllerTest.kt | 6 +- .../analytics/AnalyticsControllerTest.kt | 2 +- .../analytics/FirestoreDataControllerTest.kt | 4 +- .../analytics/LearnerAnalyticsLoggerTest.kt | 2 +- .../analytics/SurveyEventsLoggerTest.kt | 2 +- .../ProfileManagementControllerTest.kt | 34 +++---- ...uestionAssessmentProgressControllerTest.kt | 10 +-- .../QuestionTrainingControllerTest.kt | 2 +- .../spotlight/SpotlightStateControllerTest.kt | 4 +- .../domain/survey/SurveyControllerTest.kt | 2 +- .../survey/SurveyGatingControllerTest.kt | 4 +- .../survey/SurveyProgressControllerTest.kt | 2 +- .../topic/StoryProgressControllerTest.kt | 2 +- .../domain/topic/TopicControllerTest.kt | 4 +- .../domain/topic/TopicListControllerTest.kt | 2 +- .../translation/TranslationControllerTest.kt | 4 +- model/src/main/proto/profile.proto | 5 +- .../testing/profile/ProfileTestHelper.kt | 2 +- .../ExplorationCheckpointTestHelperTest.kt | 2 +- .../testing/profile/ProfileTestHelperTest.kt | 10 +-- .../story/StoryProgressTestHelperTest.kt | 4 +- ...CurrentUserProfileIdIntentDecoratorTest.kt | 6 +- wiki/Spotlight-Guide.md | 2 +- 187 files changed, 483 insertions(+), 480 deletions(-) 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..740a6442052 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,8 @@ class AdministratorControlsFragmentPresenter @Inject constructor( /* attachToRoot= */ false ) - internalProfileId = activity.intent.extractCurrentUserProfileId().internalId - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + internalProfileId = activity.intent.extractCurrentUserProfileId().loggedInInternalProfileId + profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() 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..a3e023a473d 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 @@ -58,7 +58,7 @@ class ClassroomListActivity : super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - internalProfileId = intent.extractCurrentUserProfileId().internalId + internalProfileId = intent.extractCurrentUserProfileId().loggedInInternalProfileId 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.newBuilder().setLoggedInInternalProfileId(internalProfileId).build()) .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 4b70fdddc67..e881ab0a355 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 @@ -100,7 +100,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 df1b5cd8f13..63dcac21a79 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 @@ -62,7 +62,7 @@ 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..f551f74ca90 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,7 @@ 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 +30,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..bf8bad19c20 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,7 +47,7 @@ class CompletedStoryListFragment : InjectableFragment() { "Expected arguments to be passed to CompletedStoryListFragment" } val profileId = arguments.extractCurrentUserProfileId() - val internalProfileId = profileId.internalId + val internalProfileId = profileId.loggedInInternalProfileId return completedStoryListFragmentPresenter.handleCreateView( inflater, container, 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..55bbf0a9545 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 @@ -31,7 +31,7 @@ class CompletedStoryListViewModel @Inject constructor( private val completedStoryListResultLiveData: LiveData> by lazy { topicController.getCompletedStoryList( - ProfileId.newBuilder().setInternalId(internalProfileId).build() + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() ).toLiveData() } 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..bbc537c9c11 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 @@ -42,7 +42,7 @@ class DeveloperOptionsActivity : override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - internalProfileId = intent.extractCurrentUserProfileId().internalId + internalProfileId = intent.extractCurrentUserProfileId().loggedInInternalProfileId developerOptionsActivityPresenter.handleOnCreate() title = resourceHandler.getStringInLocale(R.string.developer_options_activity_title) } 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..453b3df78eb 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 @@ -31,7 +31,7 @@ class MarkStoriesCompletedActivity : InjectableAutoLocalizedAppCompatActivity() (activityComponent as ActivityComponentImpl).inject(this) val profileId = intent?.extractCurrentUserProfileId() - internalProfileId = profileId?.internalId ?: -1 + internalProfileId = profileId?.loggedInInternalProfileId ?: -1 markStoriesCompletedActivityPresenter.handleOnCreate(internalProfileId) title = resourceHandler.getStringInLocale(R.string.mark_stories_completed_activity_title) } @@ -48,7 +48,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..cd8f615b510 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 @@ -31,7 +31,7 @@ class MarkTopicsCompletedActivity : InjectableAutoLocalizedAppCompatActivity() { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) val profileId = intent?.extractCurrentUserProfileId() - internalProfileId = profileId?.internalId ?: -1 + internalProfileId = profileId?.loggedInInternalProfileId ?: -1 markTopicsCompletedActivityPresenter.handleOnCreate(internalProfileId) title = resourceHandler.getStringInLocale(R.string.mark_topics_completed_activity_title) } @@ -47,7 +47,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..6d51eccce5e 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 @@ -23,7 +23,7 @@ class MarkTopicsCompletedTestActivity : InjectableAutoLocalizedAppCompatActivity supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_arrow_back_white_24dp) setContentView(R.layout.mark_topics_completed_activity) val profileId = intent?.extractCurrentUserProfileId() - internalProfileId = profileId?.internalId ?: -1 + internalProfileId = profileId?.loggedInInternalProfileId ?: -1 if (getMarkTopicsCompletedFragment() == null) { val markTopicsCompletedFragment = MarkTopicsCompletedFragment.newInstance(internalProfileId) supportFragmentManager.beginTransaction().add( @@ -41,7 +41,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..204b1bdfef2 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 @@ -38,7 +38,7 @@ class DeveloperOptionsTestActivity : setContentView(R.layout.developer_options_activity) val profileId = intent?.extractCurrentUserProfileId() - internalProfileId = profileId?.internalId ?: -1 + internalProfileId = profileId?.loggedInInternalProfileId ?: -1 if (getDeveloperOptionsFragment() == null) { supportFragmentManager.beginTransaction().add( @@ -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/NavigationDrawerFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerFragmentPresenter.kt index f606bafca88..21da3017a23 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 @@ -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..dcc5ff7ed5d 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,7 @@ 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..a1bbb3d24a0 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,7 @@ 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..7ff81221149 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,7 @@ 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..1c24fbf6535 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,7 @@ 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..21e79038427 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,12 @@ 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 +47,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..7a37c0c57f3 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,7 @@ 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 +28,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..959cfa324ad 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 @@ -28,7 +28,7 @@ class AppLanguageActivity : InjectableAutoLocalizedAppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - profileId = intent?.extractCurrentUserProfileId()?.internalId ?: -1 + profileId = intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 appLanguageActivityPresenter.handleOnCreate( savedInstanceState?.retrieveLanguageFromSavedState() ?: intent.retrieveLanguageFromParams(), profileId!! @@ -45,7 +45,7 @@ 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..8a78d91f44d 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 @@ -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,7 +70,7 @@ class AppLanguageFragment : InjectableFragment(), AppLanguageRadioButtonListener savedInstanceState?.retrieveLanguageFromSavedState() ?: arguments?.retrieveLanguageFromArguments() ) { "Expected arguments to be passed to AppLanguageFragment" } - profileId = arguments?.extractCurrentUserProfileId()?.internalId ?: -1 + profileId = arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 return appLanguageFragmentPresenter.handleOnCreateView( inflater, 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..b521fb917ff 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,8 @@ 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 69b433d8aa9..86c61fd0604 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 @@ -72,7 +72,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..702ecac31ed 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,7 @@ 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..9ecab88d3d6 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 @@ -85,7 +85,7 @@ class AdminAuthActivityPresenter @Inject constructor( when (args?.adminPinEnum ?: 0) { AdminAuthEnum.PROFILE_ADMIN_CONTROLS.value -> { val internalId = args?.internalProfileId ?: -1 - val profileId = ProfileId.newBuilder().setInternalId(internalId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalId).build() activity.startActivity( AdministratorControlsActivity.createAdministratorControlsActivityIntent( context, profileId 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..467614f2a2e 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 @@ -117,7 +117,7 @@ class AdminPinActivityPresenter @Inject constructor( } val profileId = ProfileId.newBuilder() - .setInternalId(args?.internalProfileId ?: -1) + .setLoggedInInternalProfileId(args?.internalProfileId ?: -1) .build() profileManagementController.updatePin(profileId, inputPin).toLiveData().observe( 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..8548cc807ea 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 @@ -52,7 +52,7 @@ class PinPasswordActivityPresenter @Inject constructor( val adminPin = args?.adminPin internalProfileId = args?.internalProfileId ?: -1 - profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + 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..d2b34c14364 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,7 @@ 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 +246,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..fd5429014f4 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,7 @@ 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..71a51de2c57 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,7 @@ class ProfileProgressActivity : val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId(ProfileId.newBuilder().setInternalId(internalProfileId).build()) + .setProfileId(ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build()) .setActivityTitle(recentlyPlayedActivityTitle) .build() @@ -95,7 +95,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..a19e7a18567 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,11 @@ 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..93069c59023 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,7 @@ 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..d698a286682 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,7 @@ 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..7c6a5b9a36b 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 @@ -73,7 +73,7 @@ class SpotlightFragment : InjectableFragment(), SpotlightNavigationListener, Spo override fun onAttach(context: Context) { super.onAttach(context) (fragmentComponent as FragmentComponentImpl).inject(this) - internalProfileId = arguments?.extractCurrentUserProfileId()?.internalId ?: -1 + internalProfileId = arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 calculateScreenSize() } @@ -100,7 +100,7 @@ class SpotlightFragment : InjectableFragment(), SpotlightNavigationListener, Spo // potentially make the app experience difficult for a non-sighted user. if (accessibilityService.isScreenReaderEnabled() || !enableSpotlightUi.value) return val profileId = ProfileId.newBuilder() - .setInternalId(internalProfileId) + .setLoggedInInternalProfileId(internalProfileId) .build() val featureViewStateLiveData = @@ -140,7 +140,7 @@ class SpotlightFragment : InjectableFragment(), SpotlightNavigationListener, Spo override fun onEnded() { if (targetList.isNotEmpty()) targetList.removeFirst() val profileId = ProfileId.newBuilder() - .setInternalId(internalProfileId) + .setLoggedInInternalProfileId(internalProfileId) .build() spotlightStateController.markSpotlightViewed(profileId, spotlightTarget.feature) } @@ -385,7 +385,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..7ca54d1949f 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 @@ -40,7 +40,7 @@ class StoryActivity : STORY_ACTIVITY_PARAMS_KEY, StoryActivityParams.getDefaultInstance() ) - internalProfileId = intent?.extractCurrentUserProfileId()?.internalId ?: -1 + internalProfileId = intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 classroomId = checkNotNull(args.classroomId) { "Expected extra classroom ID to be included for StoryActivity." } @@ -116,7 +116,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..0ac4f572531 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,7 +82,7 @@ class StoryFragmentPresenter @Inject constructor( container, /* attachToRoot= */ false ) - profileId = ProfileId.newBuilder().apply { internalId = internalProfileId }.build() + profileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() storyViewModel.setInternalProfileId(internalProfileId) storyViewModel.setClassroomId(classroomId) storyViewModel.setTopicId(topicId) @@ -282,7 +282,7 @@ class StoryFragmentPresenter @Inject constructor( // one. val startPlayingProvider = if (canHavePartialProgressSaved) { explorationDataController.startPlayingNewExploration( - profileId.internalId, + profileId.loggedInInternalProfileId, classroomId, topicId, storyId, @@ -290,7 +290,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..bff8c267125 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 @@ -41,7 +41,7 @@ class StoryViewModel @Inject constructor( private val storyResultLiveData: LiveData> by lazy { topicController.getStory( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), topicId, storyId ).toLiveData() 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..30e39937e67 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,7 @@ 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..b252a12ec17 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,7 @@ 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..c6a24e30a15 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,13 @@ 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..ffb41e8f052 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,7 @@ 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, 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..7a1ead8a9fd 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,7 @@ 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 +51,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 +88,7 @@ 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..5f9ae2357a5 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,7 @@ 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..ee5d8612dab 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,7 @@ 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..2b0f5fd6df5 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 @@ -45,7 +45,7 @@ class TopicActivity : override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - internalProfileId = intent?.extractCurrentUserProfileId()?.internalId ?: -1 + internalProfileId = intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 val args = intent?.getProtoExtra( TOPIC_ACTIVITY_PARAMS_KEY, TopicActivityParams.getDefaultInstance() @@ -65,7 +65,7 @@ class TopicActivity : QuestionPlayerActivity.createQuestionPlayerActivityIntent( this, skillIdList, - ProfileId.newBuilder().setInternalId(internalProfileId).build() + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() ) ) } @@ -158,7 +158,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 +168,7 @@ class TopicActivity : ): Intent = createTopicPlayStoryActivityIntent( activity, - profileId.internalId, + profileId.loggedInInternalProfileId, classroomId, topicId, storyId @@ -190,7 +190,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..382066da82d 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,7 @@ class TopicFragment : InjectableFragment() { TOPIC_FRAGMENT_ARGUMENTS_KEY, TopicFragmentArguments.getDefaultInstance() ) - val internalProfileId = arguments?.extractCurrentUserProfileId()?.internalId ?: -1 + val internalProfileId = arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 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..a4acbfda676 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 @@ -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..9891a0e77ba 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 @@ -31,7 +31,7 @@ class TopicViewModel @Inject constructor( private val topicResultLiveData: LiveData> by lazy { topicController.getTopic( - ProfileId.newBuilder().setInternalId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), topicId ).toLiveData() } @@ -39,7 +39,7 @@ class TopicViewModel @Inject constructor( 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() + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() ).toLiveData() } 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..b3718caa6f8 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,7 @@ class TopicInfoFragment : InjectableFragment() { TopicInfoFragmentArguments.getDefaultInstance() ) - val internalProfileId = arguments?.extractCurrentUserProfileId()?.internalId ?: -1 + val internalProfileId = arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 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..78a5212cbda 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 @@ -69,7 +69,7 @@ class TopicInfoFragmentPresenter @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/TopicLessonViewModel.kt b/app/src/main/java/org/oppia/android/app/topic/lessons/TopicLessonViewModel.kt index 6e6cfc71789..bb40d71da7b 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 @@ -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..c7d711f26b2 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,7 @@ class TopicLessonsFragment : } isDefaultStoryExpanded = stateArgs?.isDefaultStoryExpanded ?: false } - val internalProfileId = arguments?.extractCurrentUserProfileId()?.internalId ?: -1 + val internalProfileId = arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 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..ce218f030e7 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 @@ -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..2c90dfab894 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,7 @@ class TopicPracticeFragment : InjectableFragment() { /** Returns a new [TopicPracticeFragment]. */ fun newInstance(internalProfileId: Int, topicId: String): TopicPracticeFragment { - val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val args = TopicPracticeFragmentArguments.newBuilder().apply { this.topicId = topicId }.build() @@ -70,7 +70,7 @@ class TopicPracticeFragment : InjectableFragment() { TOPIC_PRACTICE_FRAGMENT_ARGUMENTS_KEY, TopicPracticeFragmentArguments.getDefaultInstance() ) - val internalProfileId = arguments?.extractCurrentUserProfileId()?.internalId ?: -1 + val internalProfileId = arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -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..efb6a9f7717 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 @@ -30,7 +30,7 @@ class TopicPracticeViewModel @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/revision/TopicRevisionFragment.kt b/app/src/main/java/org/oppia/android/app/topic/revision/TopicRevisionFragment.kt index 5573ce83b54..75dd8ffe334 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,7 @@ 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..13aca390887 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,8 @@ 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..31aff3b82e0 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 @@ -48,8 +48,8 @@ class WalkthroughWelcomeFragmentPresenter @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() 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..ecf2e8691b5 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,7 @@ 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 +700,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 +726,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 +753,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 +780,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 4a3fe4c6360..032e632f1f2 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 @@ -185,7 +185,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..732f70c0236 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,7 @@ 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 c45a0580213..3a0a9ea38d3 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,7 @@ class RecentlyPlayedFragmentTest { val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId(ProfileId.newBuilder().setInternalId(internalProfileId).build()) + .setProfileId(ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build()) .setActivityTitle(recentlyPlayedActivityTitle) .build() return RecentlyPlayedActivity.createRecentlyPlayedActivityIntent( @@ -471,7 +471,7 @@ class RecentlyPlayedFragmentTest { ) activityTestRule.launchActivity( createRecentlyPlayedActivityIntent( - internalProfileId = profileId.internalId + internalProfileId = profileId.loggedInInternalProfileId ) ) activityTestRule.activity.window.decorView.layoutDirection = ViewCompat.LAYOUT_DIRECTION_RTL @@ -512,7 +512,7 @@ class RecentlyPlayedFragmentTest { ) activityTestRule.launchActivity( createRecentlyPlayedActivityIntent( - internalProfileId = profileId.internalId + internalProfileId = profileId.loggedInInternalProfileId ) ) activityTestRule.activity.window.decorView.layoutDirection = ViewCompat.LAYOUT_DIRECTION_RTL @@ -560,7 +560,7 @@ class RecentlyPlayedFragmentTest { ) activityTestRule.launchActivity( createRecentlyPlayedActivityIntent( - internalProfileId = profileId.internalId + internalProfileId = profileId.loggedInInternalProfileId ) ) activityTestRule.activity.window.decorView.layoutDirection = ViewCompat.LAYOUT_DIRECTION_RTL @@ -614,7 +614,7 @@ class RecentlyPlayedFragmentTest { ) activityTestRule.launchActivity( createRecentlyPlayedActivityIntent( - internalProfileId = profileId.internalId + internalProfileId = profileId.loggedInInternalProfileId ) ) activityTestRule.activity.window.decorView.layoutDirection = ViewCompat.LAYOUT_DIRECTION_RTL @@ -665,7 +665,7 @@ class RecentlyPlayedFragmentTest { ) activityTestRule.launchActivity( createRecentlyPlayedActivityIntent( - internalProfileId = profileId.internalId + internalProfileId = profileId.loggedInInternalProfileId ) ) testCoroutineDispatchers.runCurrent() @@ -691,7 +691,7 @@ class RecentlyPlayedFragmentTest { activityTestRule.launchActivity( createRecentlyPlayedActivityIntent( - internalProfileId = profileId.internalId + internalProfileId = profileId.loggedInInternalProfileId ) ) activityTestRule.activity.window.decorView.layoutDirection = ViewCompat.LAYOUT_DIRECTION_RTL @@ -844,7 +844,7 @@ 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?" @@ -902,7 +902,7 @@ 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() @@ -942,7 +942,7 @@ 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() @@ -987,7 +987,7 @@ 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 75e9b20db35..bb9f5d8086a 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 @@ -197,7 +197,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..9ffc6c1935c 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,7 @@ 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..13ef619271d 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,7 @@ 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 +700,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 +720,7 @@ 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 +815,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..583bc433b8d 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,7 @@ 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..68c1c5146c9 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,7 @@ 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 +221,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..fc0c8dbcf70 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,7 @@ 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 +787,7 @@ 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 +825,7 @@ 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 +868,7 @@ 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 +910,7 @@ 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..e0807c881ea 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,7 @@ 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..06b24443afe 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,7 @@ 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 51db3f941bb..7320fecd86d 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 @@ -194,13 +194,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" ) ) @@ -271,7 +271,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 @@ -326,7 +326,7 @@ 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 ) @@ -348,7 +348,7 @@ 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( @@ -376,13 +376,13 @@ 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) @@ -404,13 +404,13 @@ 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) @@ -435,7 +435,7 @@ 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 ) @@ -471,7 +471,7 @@ 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 ) @@ -507,14 +507,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 updatedProfile = profile.toBuilder().setAllowDownloadAccess(allowDownloadAccess) .build() val profileDatabaseBuilder = it.toBuilder().putProfiles( - profileId.internalId, + profileId.loggedInInternalProfileId, updatedProfile ) Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) @@ -542,12 +542,12 @@ 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() @@ -576,13 +576,13 @@ 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) @@ -603,7 +603,7 @@ 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 ) @@ -616,7 +616,7 @@ class ProfileManagementController @Inject constructor( } }.build() val profileDatabaseBuilder = it.toBuilder().putProfiles( - profileId.internalId, + profileId.loggedInInternalProfileId, updatedProfile ) Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) @@ -640,13 +640,13 @@ 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().setAudioLanguage(audioLanguage).build() val profileDatabaseBuilder = it.toBuilder().putProfiles( - profileId.internalId, + profileId.loggedInInternalProfileId, updatedProfile ) Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) @@ -683,13 +683,13 @@ 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.loggedInInternalProfileId return@createInMemoryDataProviderAsync AsyncResult.Success(0) } AsyncResult.Failure( ProfileNotFoundException( - "ProfileId ${profileId.internalId} is" + + "ProfileId ${profileId.loggedInInternalProfileId} is" + " not associated with an existing profile" ) ) @@ -699,14 +699,14 @@ class ProfileManagementController @Inject constructor( private fun updateLastLoggedInAsyncAndNumberOfLogins(profileId: ProfileId): Deferred { return profileDataStore.storeDataWithCustomChannelAsync(updateInMemoryCache = true) { - val profile = it.profilesMap[profileId.internalId] + 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) @@ -721,16 +721,16 @@ 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) @@ -764,7 +764,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() + ProfileId.newBuilder().setLoggedInInternalProfileId(it).build() } } @@ -791,7 +791,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 } /** @@ -800,17 +800,17 @@ 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() @@ -827,12 +827,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) @@ -850,7 +850,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) } } @@ -866,12 +866,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) @@ -891,7 +891,7 @@ 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) } } @@ -920,19 +920,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 ee63c50d628..62b1dd5e5ff 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 @@ -113,7 +113,7 @@ 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..c67575fe99e 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,7 @@ 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 +3334,7 @@ class ExplorationProgressControllerTest { ) { val startPlayingProvider = explorationDataController.restartExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId.loggedInInternalProfileId, classroomId, topicId, storyId, explorationId ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } @@ -3348,7 +3348,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..2bfd71c9602 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,7 +1240,7 @@ class AnalyticsControllerTest { ) monitorFactory.ensureDataProviderExecutes(addProfileProvider) - return ProfileId.newBuilder().apply { internalId = 0 }.build().also { expectedProfileId -> + return ProfileId.newBuilder().apply { loggedInInternalProfileId = 0 }.build().also { expectedProfileId -> val logInProvider = profileManagementController.loginToProfile(expectedProfileId) monitorFactory.waitForNextSuccessfulResult(logInProvider) // Ensure that the login succeeds. } 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..220185b9c4e 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,7 @@ 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 +401,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..5dad1d8d47e 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,7 @@ 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..581abd0318a 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,7 @@ 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 ba6082fa1c5..10abc7b1387 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 @@ -94,13 +94,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 @@ -127,7 +127,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.audioLanguage).isEqualTo(AudioLanguage.ENGLISH_AUDIO_LANGUAGE) assertThat(profile.numberOfLogins).isEqualTo(0) @@ -195,7 +195,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) assertThat(profile.audioLanguage).isEqualTo(AudioLanguage.ENGLISH_AUDIO_LANGUAGE) } @@ -208,7 +208,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) @@ -224,7 +224,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) @@ -236,7 +236,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) @@ -252,7 +252,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) @@ -753,12 +753,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() } @@ -794,7 +794,7 @@ 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) } @@ -1290,7 +1290,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 b3b501ff94c..55ad5603484 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 cc395949209..5117db65763 100644 --- a/model/src/main/proto/profile.proto +++ b/model/src/main/proto/profile.proto @@ -109,7 +109,10 @@ message ProfileId { * Unique ID used to identify a single profile. * Should not be used directory outside of the profile system. */ - int32 internal_id = 1; + oneof type { + int32 logged_in_internal_profile_id = 1; + bool logged_out = 2; // Can be true or false; presence is sufficient. + } } // 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..8ea21e4bd6b 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,7 @@ 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 +88,7 @@ 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 +107,7 @@ 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 +115,7 @@ 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 +123,7 @@ 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..a61b6352026 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,8 @@ 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) From 51736af839a9504b27e9c3917e03e4a016ded476 Mon Sep 17 00:00:00 2001 From: MohitGupta121 Date: Thu, 8 Aug 2024 21:12:17 +0530 Subject: [PATCH 2/6] fixed lint error --- .../app/classroom/ClassroomListActivity.kt | 4 +- .../app/classroom/ClassroomListViewModel.kt | 3 +- .../CompletedStoryListActivity.kt | 3 +- .../drawer/NavigationDrawerHeaderViewModel.kt | 4 +- .../oppia/android/app/home/HomeActivity.kt | 4 +- .../oppia/android/app/home/HomeViewModel.kt | 3 +- .../RecentlyPlayedActivityPresenter.kt | 4 +- .../app/mydownloads/MyDownloadsActivity.kt | 4 +- .../OngoingTopicListActivity.kt | 3 +- .../app/options/AppLanguageActivity.kt | 3 +- .../app/options/OptionsFragmentPresenter.kt | 3 +- .../player/state/StateFragmentPresenter.kt | 3 +- .../ProfileChooserFragmentPresenter.kt | 4 +- .../ResetPinDialogFragmentPresenter.kt | 5 +- .../ProfileProgressActivity.kt | 4 +- .../ResumeLessonFragmentPresenter.kt | 7 +- .../profile/ProfileEditFragmentPresenter.kt | 3 +- .../ProfileResetPinFragmentPresenter.kt | 3 +- .../app/story/StoryFragmentPresenter.kt | 3 +- .../android/app/survey/SurveyActivity.kt | 3 +- ...ministratorControlsFragmentTestActivity.kt | 3 +- .../app/testing/AudioFragmentTestActivity.kt | 3 +- .../ExplorationTestActivityPresenter.kt | 6 +- .../testing/NavigationDrawerTestActivity.kt | 7 +- .../ProfileEditFragmentTestActivity.kt | 3 +- .../SpotlightFragmentTestActivityPresenter.kt | 3 +- .../oppia/android/app/topic/TopicFragment.kt | 3 +- .../app/topic/info/TopicInfoFragment.kt | 3 +- .../app/topic/lessons/TopicLessonsFragment.kt | 3 +- .../topic/practice/TopicPracticeFragment.kt | 3 +- .../topic/revision/TopicRevisionFragment.kt | 3 +- .../end/WalkthroughFinalFragmentPresenter.kt | 3 +- .../WalkthroughWelcomeFragmentPresenter.kt | 3 +- .../AdministratorControlsActivityTest.kt | 3 +- .../CompletedStoryListActivityTest.kt | 3 +- .../app/home/RecentlyPlayedFragmentTest.kt | 16 ++- .../app/player/audio/AudioFragmentTest.kt | 3 +- .../ProfileProgressFragmentTest.kt | 8 +- .../android/app/story/StoryActivityTest.kt | 3 +- .../android/app/topic/TopicActivityTest.kt | 3 +- .../topic/lessons/TopicLessonsFragmentTest.kt | 15 ++- .../app/activity/route/ActivityRouterTest.kt | 4 +- .../data/persistence/PersistentCacheStore.kt | 3 +- .../profile/ProfileManagementController.kt | 127 ++++++++++-------- .../domain/audio/AudioPlayerControllerTest.kt | 4 +- .../ExplorationProgressControllerTest.kt | 7 +- .../analytics/AnalyticsControllerTest.kt | 9 +- .../analytics/FirestoreDataControllerTest.kt | 4 +- .../analytics/LearnerAnalyticsLoggerTest.kt | 4 +- .../analytics/SurveyEventsLoggerTest.kt | 4 +- .../ProfileManagementControllerTest.kt | 6 +- .../testing/profile/ProfileTestHelperTest.kt | 30 ++++- .../story/StoryProgressTestHelperTest.kt | 8 +- 53 files changed, 256 insertions(+), 127 deletions(-) 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 a3e023a473d..311d484433c 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 @@ -88,7 +88,9 @@ class ClassroomListActivity : val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId(ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build()) + .setProfileId( + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + ) .setActivityTitle(recentlyPlayedActivityTitle).build() activityRouter.routeToScreen( 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 63dcac21a79..dc73f1f679a 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 @@ -62,7 +62,8 @@ class ClassroomListViewModel( private val dateTimeUtil: DateTimeUtil, private val translationController: TranslationController ) : ObservableViewModel() { - private val profileId: ProfileId = ProfileId.newBuilder().setLoggedInInternalProfileId(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 f551f74ca90..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()?.loggedInInternalProfileId ?: -1 + val internalProfileId: Int = + intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 completedStoryListActivityPresenter.handleOnCreate(internalProfileId) } 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 dcc5ff7ed5d..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.loggedInInternalProfileId) + 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 a1bbb3d24a0..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 @@ -110,7 +110,9 @@ class HomeActivity : val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId(ProfileId.newBuilder().setLoggedInInternalProfileId(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/HomeViewModel.kt b/app/src/main/java/org/oppia/android/app/home/HomeViewModel.kt index 7ff81221149..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().setLoggedInInternalProfileId(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 1c24fbf6535..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.loggedInInternalProfileId), + RecentlyPlayedFragment.newInstance( + recentlyPlayedActivityParams.profileId.loggedInInternalProfileId + ), RecentlyPlayedFragment.TAG_RECENTLY_PLAYED_FRAGMENT ).commitNow() } 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 21e79038427..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 @@ -36,7 +36,9 @@ class MyDownloadsActivity : InjectableAutoLocalizedAppCompatActivity() { companion object { fun createMyDownloadsActivityIntent(context: Context, internalProfileId: Int?): Intent { - val profileId = internalProfileId?.let { ProfileId.newBuilder().setLoggedInInternalProfileId(it).build() } + val profileId = internalProfileId?.let { + ProfileId.newBuilder().setLoggedInInternalProfileId(it).build() + } val intent = Intent(context, MyDownloadsActivity::class.java) if (profileId != null) { intent.decorateWithUserProfileId(profileId) 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 7a37c0c57f3..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()?.loggedInInternalProfileId ?: -1 + val internalProfileId: Int = + intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 ongoingTopicListActivityPresenter.handleOnCreate(internalProfileId) } 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 959cfa324ad..0bfabf92232 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 @@ -45,7 +45,8 @@ class AppLanguageActivity : InjectableAutoLocalizedAppCompatActivity() { oppiaLanguage: OppiaLanguage, internalProfileId: Int? ): Intent { - val profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(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/OptionsFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/options/OptionsFragmentPresenter.kt index b521fb917ff..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,7 +70,8 @@ class OptionsFragmentPresenter @Inject constructor( /* attachToRoot= */ false ) - internalProfileId = activity.intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 + internalProfileId = + activity.intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() optionControlsViewModel.setProfileId(profileId) 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 702ecac31ed..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 @@ -288,7 +288,8 @@ class StateFragmentPresenter @Inject constructor( private fun getAudioUiManager(): AudioUiManager? { if (getAudioFragment() == null) { - val audioFragment: AudioFragment = AudioFragment.newInstance(profileId.loggedInInternalProfileId) + 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/profile/ProfileChooserFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/profile/ProfileChooserFragmentPresenter.kt index d2b34c14364..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 @@ -234,7 +234,9 @@ class ProfileChooserFragmentPresenter @Inject constructor( fun routeToAdminPin() { if (chooserViewModel.adminPin.isEmpty()) { val profileId = - ProfileId.newBuilder().setLoggedInInternalProfileId(chooserViewModel.adminProfileId.loggedInInternalProfileId).build() + ProfileId.newBuilder() + .setLoggedInInternalProfileId(chooserViewModel.adminProfileId.loggedInInternalProfileId) + .build() activity.startActivity( AdministratorControlsActivity.createAdministratorControlsActivityIntent( activity, 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 fd5429014f4..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().setLoggedInInternalProfileId(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/ProfileProgressActivity.kt b/app/src/main/java/org/oppia/android/app/profileprogress/ProfileProgressActivity.kt index 71a51de2c57..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 @@ -61,7 +61,9 @@ class ProfileProgressActivity : val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId(ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build()) + .setProfileId( + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + ) .setActivityTitle(recentlyPlayedActivityTitle) .build() 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 a19e7a18567..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 @@ -202,7 +202,12 @@ class ResumeLessonFragmentPresenter @Inject constructor( ) } else { explorationDataController.resumeExploration( - profileId.loggedInInternalProfileId, 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/ProfileEditFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditFragmentPresenter.kt index 93069c59023..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 @@ -146,7 +146,8 @@ class ProfileEditFragmentPresenter @Inject constructor( */ fun deleteProfile(internalProfileId: Int) { profileManagementController - .deleteProfile(ProfileId.newBuilder().setLoggedInInternalProfileId(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/ProfileResetPinFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileResetPinFragmentPresenter.kt index d698a286682..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().setLoggedInInternalProfileId(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/story/StoryFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/story/StoryFragmentPresenter.kt index 0ac4f572531..423b544194c 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,7 +82,8 @@ class StoryFragmentPresenter @Inject constructor( container, /* attachToRoot= */ false ) - profileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() + profileId = + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() storyViewModel.setInternalProfileId(internalProfileId) storyViewModel.setClassroomId(classroomId) storyViewModel.setTopicId(topicId) 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 30e39937e67..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().setLoggedInInternalProfileId(-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/testing/AdministratorControlsFragmentTestActivity.kt b/app/src/main/java/org/oppia/android/app/testing/AdministratorControlsFragmentTestActivity.kt index b252a12ec17..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().setLoggedInInternalProfileId(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 c6a24e30a15..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 @@ -26,7 +26,8 @@ class AudioFragmentTestActivity : InjectableAutoLocalizedAppCompatActivity() { companion object { fun createAudioFragmentTestActivity(context: Context, internalProfileId: Int?): Intent { - val profileId = internalProfileId?.let { ProfileId.newBuilder().setLoggedInInternalProfileId(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 ffb41e8f052..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 { loggedInInternalProfileId = 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 7a1ead8a9fd..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().setLoggedInInternalProfileId(it).build() } + val profileId = + internalProfileId?.let { ProfileId.newBuilder().setLoggedInInternalProfileId(it).build() } if (profileId != null) { intent.decorateWithUserProfileId(profileId) } @@ -88,7 +89,9 @@ class NavigationDrawerTestActivity : val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId(ProfileId.newBuilder().setLoggedInInternalProfileId(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 5f9ae2357a5..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().setLoggedInInternalProfileId(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/SpotlightFragmentTestActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/testing/SpotlightFragmentTestActivityPresenter.kt index ee5d8612dab..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().setLoggedInInternalProfileId(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/TopicFragment.kt b/app/src/main/java/org/oppia/android/app/topic/TopicFragment.kt index 382066da82d..514684bdc08 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,8 @@ class TopicFragment : InjectableFragment() { TOPIC_FRAGMENT_ARGUMENTS_KEY, TopicFragmentArguments.getDefaultInstance() ) - val internalProfileId = arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 + val internalProfileId = + arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 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/info/TopicInfoFragment.kt b/app/src/main/java/org/oppia/android/app/topic/info/TopicInfoFragment.kt index b3718caa6f8..a0184f7d29a 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 @@ -54,7 +54,8 @@ class TopicInfoFragment : InjectableFragment() { TopicInfoFragmentArguments.getDefaultInstance() ) - val internalProfileId = arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 + val internalProfileId = + arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 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/lessons/TopicLessonsFragment.kt b/app/src/main/java/org/oppia/android/app/topic/lessons/TopicLessonsFragment.kt index c7d711f26b2..77dffd80c31 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 @@ -88,7 +88,8 @@ class TopicLessonsFragment : } isDefaultStoryExpanded = stateArgs?.isDefaultStoryExpanded ?: false } - val internalProfileId = arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 + val internalProfileId = + arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 val args = arguments?.getProto( TOPIC_LESSONS_FRAGMENT_ARGUMENTS_KEY, TopicLessonsFragmentArguments.getDefaultInstance() 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 2c90dfab894..e011f534b92 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 @@ -70,7 +70,8 @@ class TopicPracticeFragment : InjectableFragment() { TOPIC_PRACTICE_FRAGMENT_ARGUMENTS_KEY, TopicPracticeFragmentArguments.getDefaultInstance() ) - val internalProfileId = arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 + val internalProfileId = + arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -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/revision/TopicRevisionFragment.kt b/app/src/main/java/org/oppia/android/app/topic/revision/TopicRevisionFragment.kt index 75dd8ffe334..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 @@ -51,7 +51,8 @@ class TopicRevisionFragment : InjectableFragment(), RevisionSubtopicSelector { container: ViewGroup?, savedInstanceState: Bundle? ): View? { - val internalProfileId = arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -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/walkthrough/end/WalkthroughFinalFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/walkthrough/end/WalkthroughFinalFragmentPresenter.kt index 13aca390887..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,7 +45,8 @@ class WalkthroughFinalFragmentPresenter @Inject constructor( /* attachToRoot= */ false ) this.topicId = topicId - val internalProfileId = activity.intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 + 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 31aff3b82e0..df4a29a181d 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 @@ -48,7 +48,8 @@ class WalkthroughWelcomeFragmentPresenter @Inject constructor( /* attachToRoot= */ false ) - internalProfileId = activity.intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 + internalProfileId = + activity.intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() walkthroughWelcomeViewModel = WalkthroughWelcomeViewModel() 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 ecf2e8691b5..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().setLoggedInInternalProfileId(internalProfileId).build() + private val profileId = + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() @Inject lateinit var profileTestHelper: ProfileTestHelper 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 732f70c0236..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().setLoggedInInternalProfileId(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/home/RecentlyPlayedFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/RecentlyPlayedFragmentTest.kt index 3a0a9ea38d3..b6aa8cc2258 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 @@ -200,7 +200,9 @@ class RecentlyPlayedFragmentTest { val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId(ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build()) + .setProfileId( + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + ) .setActivityTitle(recentlyPlayedActivityTitle) .build() return RecentlyPlayedActivity.createRecentlyPlayedActivityIntent( @@ -844,7 +846,8 @@ class RecentlyPlayedFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() + profileId = + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() parentScreen = ExplorationActivityParams.ParentScreen.PARENT_SCREEN_UNSPECIFIED checkpoint = ExplorationCheckpoint.newBuilder().apply { explorationTitle = "What is a Fraction?" @@ -902,7 +905,8 @@ class RecentlyPlayedFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() + profileId = + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() isCheckpointingEnabled = true parentScreen = ExplorationActivityParams.ParentScreen.PARENT_SCREEN_UNSPECIFIED }.build() @@ -942,7 +946,8 @@ class RecentlyPlayedFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() + profileId = + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() isCheckpointingEnabled = true parentScreen = ExplorationActivityParams.ParentScreen.PARENT_SCREEN_UNSPECIFIED }.build() @@ -987,7 +992,8 @@ class RecentlyPlayedFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 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/player/audio/AudioFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/player/audio/AudioFragmentTest.kt index 9ffc6c1935c..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().setLoggedInInternalProfileId(internalProfileId).build() + private var profileId = + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() @Before fun setUp() { 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 13ef619271d..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 @@ -684,7 +684,9 @@ class ProfileProgressFragmentTest { ) val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId(ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build()) + .setProfileId( + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + ) .setActivityTitle(RecentlyPlayedActivityTitle.STORIES_FOR_YOU) .build() clickProfileProgressItem(itemPosition = 0, targetViewId = R.id.view_all_text_view) @@ -720,7 +722,9 @@ class ProfileProgressFragmentTest { ) val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId(ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build()) + .setProfileId( + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + ) .setActivityTitle(RecentlyPlayedActivityTitle.RECENTLY_PLAYED_STORIES) .build() clickProfileProgressItem(itemPosition = 0, targetViewId = R.id.view_all_text_view) 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 583bc433b8d..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 { loggedInInternalProfileId = 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/topic/TopicActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/TopicActivityTest.kt index 68c1c5146c9..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 { loggedInInternalProfileId = internalProfileId }.build() + val profileId = + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() intended(hasComponent(QuestionPlayerActivity::class.java.name)) intended(hasProtoExtra(PROFILE_ID_INTENT_DECORATOR, profileId)) } 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 fc0c8dbcf70..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 @@ -731,7 +731,8 @@ class TopicLessonsFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = 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 { loggedInInternalProfileId = 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 { loggedInInternalProfileId = 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 { loggedInInternalProfileId = 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 { loggedInInternalProfileId = internalProfileId }.build() + profileId = + ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() isCheckpointingEnabled = false parentScreen = ExplorationActivityParams.ParentScreen.TOPIC_SCREEN_LESSONS_TAB }.build() 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 e0807c881ea..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().setLoggedInInternalProfileId(internalProfileId).build()) + .setProfileId( + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + ) .setActivityTitle(RecentlyPlayedActivityTitle.RECENTLY_PLAYED_STORIES).build() activityRouter.routeToScreen( DestinationScreen 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 06b24443afe..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.loggedInInternalProfileId.toString()) + val profileDirectory = + directoryManagementUtil.getOrCreateDir(profileId.loggedInInternalProfileId.toString()) return PersistentCacheStore( application, cacheFactory, 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 7320fecd86d..1002076fbf9 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 @@ -326,10 +326,11 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.loggedInInternalProfileId] ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + it.profilesMap[profileId.loggedInInternalProfileId] + ?: return@storeDataWithCustomChannelAsync Pair( + it, + ProfileActionStatus.PROFILE_NOT_FOUND + ) val profileDir = directoryManagementUtil.getOrCreateDir(profileId.toString()) val updatedProfileBuilder = profile.toBuilder() @@ -348,7 +349,8 @@ class ProfileManagementController @Inject constructor( } val profileDatabaseBuilder = - it.toBuilder().putProfiles(profileId.loggedInInternalProfileId, updatedProfileBuilder.build()) + it.toBuilder() + .putProfiles(profileId.loggedInInternalProfileId, updatedProfileBuilder.build()) Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) } return dataProviders.createInMemoryDataProviderAsync( @@ -376,10 +378,11 @@ class ProfileManagementController @Inject constructor( return@storeDataWithCustomChannelAsync Pair(it, ProfileActionStatus.PROFILE_NAME_NOT_UNIQUE) } val profile = - it.profilesMap[profileId.loggedInInternalProfileId] ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + 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.loggedInInternalProfileId, @@ -404,10 +407,11 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.loggedInInternalProfileId] ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + 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.loggedInInternalProfileId, @@ -435,10 +439,11 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.loggedInInternalProfileId] ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + it.profilesMap[profileId.loggedInInternalProfileId] + ?: return@storeDataWithCustomChannelAsync Pair( + it, + ProfileActionStatus.PROFILE_NOT_FOUND + ) val profileDatabaseBuilder = it.toBuilder() if (profile.isAdmin) { val deviceSettingsBuilder = it.deviceSettings.toBuilder() @@ -471,10 +476,11 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.loggedInInternalProfileId] ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + it.profilesMap[profileId.loggedInInternalProfileId] + ?: return@storeDataWithCustomChannelAsync Pair( + it, + ProfileActionStatus.PROFILE_NOT_FOUND + ) val profileDatabaseBuilder = it.toBuilder() if (profile.isAdmin) { val deviceSettingsBuilder = it.deviceSettings.toBuilder() @@ -507,10 +513,11 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.loggedInInternalProfileId] ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + it.profilesMap[profileId.loggedInInternalProfileId] + ?: return@storeDataWithCustomChannelAsync Pair( + it, + ProfileActionStatus.PROFILE_NOT_FOUND + ) val updatedProfile = profile.toBuilder().setAllowDownloadAccess(allowDownloadAccess) .build() val profileDatabaseBuilder = it.toBuilder().putProfiles( @@ -542,10 +549,11 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.loggedInInternalProfileId] ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + it.profilesMap[profileId.loggedInInternalProfileId] + ?: return@storeDataWithCustomChannelAsync Pair( + it, + ProfileActionStatus.PROFILE_NOT_FOUND + ) val updatedProfileDatabase = it.toBuilder().putProfiles( profileId.loggedInInternalProfileId, profile.toBuilder().apply { @@ -576,10 +584,11 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.loggedInInternalProfileId] ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + 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.loggedInInternalProfileId, @@ -603,10 +612,11 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.loggedInInternalProfileId] ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + it.profilesMap[profileId.loggedInInternalProfileId] + ?: return@storeDataWithCustomChannelAsync Pair( + it, + ProfileActionStatus.PROFILE_NOT_FOUND + ) val updatedProfile = profile.toBuilder().apply { learnerId = when { // There should be no learner ID if no ongoing study. @@ -640,10 +650,11 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.loggedInInternalProfileId] ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + it.profilesMap[profileId.loggedInInternalProfileId] + ?: return@storeDataWithCustomChannelAsync Pair( + it, + ProfileActionStatus.PROFILE_NOT_FOUND + ) val updatedProfile = profile.toBuilder().setAudioLanguage(audioLanguage).build() val profileDatabaseBuilder = it.toBuilder().putProfiles( profileId.loggedInInternalProfileId, @@ -698,20 +709,20 @@ class ProfileManagementController @Inject constructor( private fun updateLastLoggedInAsyncAndNumberOfLogins(profileId: ProfileId): Deferred { - return profileDataStore.storeDataWithCustomChannelAsync(updateInMemoryCache = true) { - 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.loggedInInternalProfileId, - updatedProfile - ) - Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) - } + return profileDataStore.storeDataWithCustomChannelAsync(updateInMemoryCache = true) { + 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.loggedInInternalProfileId, + updatedProfile + ) + Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) } + } /** * Deletes an existing profile. @@ -730,7 +741,10 @@ class ProfileManagementController @Inject constructor( val installationId = loggingIdentifierController.fetchInstallationId() val learnerId = it.profilesMap.getValue(profileId.loggedInInternalProfileId).learnerId learnerAnalyticsLogger.logDeleteProfile(installationId, profileId = null, learnerId) - Pair(it.toBuilder().removeProfiles(profileId.loggedInInternalProfileId).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) @@ -891,7 +905,8 @@ class ProfileManagementController @Inject constructor( profileId: ProfileId ): DataProvider { return profileDataStore.transformAsync(RETRIEVE_LAST_SELECTED_CLASSROOM_ID_PROVIDER_ID) { - val lastSelectedClassroomId = it.profilesMap[profileId.loggedInInternalProfileId]?.lastSelectedClassroomId + val lastSelectedClassroomId = + it.profilesMap[profileId.loggedInInternalProfileId]?.lastSelectedClassroomId AsyncResult.Success(lastSelectedClassroomId) } } 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 62b1dd5e5ff..550c4e56473 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 @@ -113,7 +113,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 { loggedInInternalProfileId = 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/exploration/ExplorationProgressControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt index c67575fe99e..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 @@ -3320,7 +3320,12 @@ class ExplorationProgressControllerTest { ) { val startPlayingProvider = explorationDataController.resumeExploration( - profileId.loggedInInternalProfileId, classroomId, topicId, storyId, explorationId, explorationCheckpoint + profileId.loggedInInternalProfileId, + classroomId, + topicId, + storyId, + explorationId, + explorationCheckpoint ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } 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 2bfd71c9602..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 { loggedInInternalProfileId = 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 220185b9c4e..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 { loggedInInternalProfileId = 0 }.build() } + private val profileId by lazy { + ProfileId.newBuilder().apply { loggedInInternalProfileId = 0 }.build() + } private val dataController by lazy { dataControllerProvider.get() } 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 5dad1d8d47e..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 { loggedInInternalProfileId = 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 581abd0318a..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 { loggedInInternalProfileId = 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 10abc7b1387..53cab978fdd 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 @@ -794,7 +794,11 @@ class ProfileManagementControllerTest { val profileProvider = profileManagementController.getProfile(PROFILE_ID_2) monitorFactory.waitForNextSuccessfulResult(loginProvider) val profile = monitorFactory.waitForNextSuccessfulResult(profileProvider) - assertThat(profileManagementController.getCurrentProfileId()?.loggedInInternalProfileId).isEqualTo(2) + assertThat( + profileManagementController.getCurrentProfileId()?.loggedInInternalProfileId + ).isEqualTo( + 2 + ) assertThat(profile.lastLoggedInTimestampMs).isNotEqualTo(0) assertThat(profile.numberOfLogins).isEqualTo(1) } 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 8ea21e4bd6b..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()?.loggedInInternalProfileId).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()?.loggedInInternalProfileId).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()?.loggedInInternalProfileId).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()?.loggedInInternalProfileId).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()?.loggedInInternalProfileId).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 a61b6352026..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().setLoggedInInternalProfileId(0).build() } - private val profileId1: ProfileId by lazy { ProfileId.newBuilder().setLoggedInInternalProfileId(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() { From e4746b16198ac5b1682db0dda2aba693735db5ab Mon Sep 17 00:00:00 2001 From: MohitGupta121 Date: Thu, 8 Aug 2024 21:22:46 +0530 Subject: [PATCH 3/6] fixed lint error --- .../profile/ProfileManagementController.kt | 151 ++++++++++-------- 1 file changed, 83 insertions(+), 68 deletions(-) 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 1002076fbf9..91183a265a0 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 @@ -326,11 +326,12 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.loggedInInternalProfileId] - ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + it.profilesMap[ + profileId.loggedInInternalProfileId + ] ?: return@storeDataWithCustomChannelAsync Pair( + it, + ProfileActionStatus.PROFILE_NOT_FOUND + ) val profileDir = directoryManagementUtil.getOrCreateDir(profileId.toString()) val updatedProfileBuilder = profile.toBuilder() @@ -349,8 +350,9 @@ class ProfileManagementController @Inject constructor( } val profileDatabaseBuilder = - it.toBuilder() - .putProfiles(profileId.loggedInInternalProfileId, updatedProfileBuilder.build()) + it.toBuilder().putProfiles( + profileId.loggedInInternalProfileId, updatedProfileBuilder.build() + ) Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) } return dataProviders.createInMemoryDataProviderAsync( @@ -378,11 +380,12 @@ class ProfileManagementController @Inject constructor( return@storeDataWithCustomChannelAsync Pair(it, ProfileActionStatus.PROFILE_NAME_NOT_UNIQUE) } val profile = - it.profilesMap[profileId.loggedInInternalProfileId] - ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + 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.loggedInInternalProfileId, @@ -407,11 +410,12 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.loggedInInternalProfileId] - ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + 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.loggedInInternalProfileId, @@ -439,11 +443,12 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.loggedInInternalProfileId] - ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + it.profilesMap[ + profileId.loggedInInternalProfileId + ] ?: return@storeDataWithCustomChannelAsync Pair( + it, + ProfileActionStatus.PROFILE_NOT_FOUND + ) val profileDatabaseBuilder = it.toBuilder() if (profile.isAdmin) { val deviceSettingsBuilder = it.deviceSettings.toBuilder() @@ -476,11 +481,12 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.loggedInInternalProfileId] - ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + it.profilesMap[ + profileId.loggedInInternalProfileId + ] ?: return@storeDataWithCustomChannelAsync Pair( + it, + ProfileActionStatus.PROFILE_NOT_FOUND + ) val profileDatabaseBuilder = it.toBuilder() if (profile.isAdmin) { val deviceSettingsBuilder = it.deviceSettings.toBuilder() @@ -513,11 +519,12 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.loggedInInternalProfileId] - ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + it.profilesMap[ + profileId.loggedInInternalProfileId + ] ?: return@storeDataWithCustomChannelAsync Pair( + it, + ProfileActionStatus.PROFILE_NOT_FOUND + ) val updatedProfile = profile.toBuilder().setAllowDownloadAccess(allowDownloadAccess) .build() val profileDatabaseBuilder = it.toBuilder().putProfiles( @@ -549,11 +556,12 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.loggedInInternalProfileId] - ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + it.profilesMap[ + profileId.loggedInInternalProfileId + ] ?: return@storeDataWithCustomChannelAsync Pair( + it, + ProfileActionStatus.PROFILE_NOT_FOUND + ) val updatedProfileDatabase = it.toBuilder().putProfiles( profileId.loggedInInternalProfileId, profile.toBuilder().apply { @@ -584,11 +592,12 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.loggedInInternalProfileId] - ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + 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.loggedInInternalProfileId, @@ -612,11 +621,12 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.loggedInInternalProfileId] - ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + it.profilesMap[ + profileId.loggedInInternalProfileId + ] ?: return@storeDataWithCustomChannelAsync Pair( + it, + ProfileActionStatus.PROFILE_NOT_FOUND + ) val updatedProfile = profile.toBuilder().apply { learnerId = when { // There should be no learner ID if no ongoing study. @@ -650,11 +660,12 @@ class ProfileManagementController @Inject constructor( updateInMemoryCache = true ) { val profile = - it.profilesMap[profileId.loggedInInternalProfileId] - ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) + it.profilesMap[ + profileId.loggedInInternalProfileId + ] ?: return@storeDataWithCustomChannelAsync Pair( + it, + ProfileActionStatus.PROFILE_NOT_FOUND + ) val updatedProfile = profile.toBuilder().setAudioLanguage(audioLanguage).build() val profileDatabaseBuilder = it.toBuilder().putProfiles( profileId.loggedInInternalProfileId, @@ -709,20 +720,21 @@ class ProfileManagementController @Inject constructor( private fun updateLastLoggedInAsyncAndNumberOfLogins(profileId: ProfileId): Deferred { - return profileDataStore.storeDataWithCustomChannelAsync(updateInMemoryCache = true) { - 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.loggedInInternalProfileId, - updatedProfile - ) - Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) + return profileDataStore.storeDataWithCustomChannelAsync(updateInMemoryCache = true) { + 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.loggedInInternalProfileId, + updatedProfile + ) + Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) + } } - } /** * Deletes an existing profile. @@ -814,7 +826,9 @@ class ProfileManagementController @Inject constructor( */ suspend fun fetchContinueAnimationSeenStatus(profileId: ProfileId): Boolean? { val profileDatabase = profileDataStore.readDataAsync().await() - return profileDatabase.profilesMap[profileId.loggedInInternalProfileId]?.isContinueButtonAnimationSeen + return profileDatabase.profilesMap[ + profileId.loggedInInternalProfileId + ]?.isContinueButtonAnimationSeen } /** Marks that the continue button animation has been seen for the specified profile. */ @@ -905,8 +919,9 @@ class ProfileManagementController @Inject constructor( profileId: ProfileId ): DataProvider { return profileDataStore.transformAsync(RETRIEVE_LAST_SELECTED_CLASSROOM_ID_PROVIDER_ID) { - val lastSelectedClassroomId = - it.profilesMap[profileId.loggedInInternalProfileId]?.lastSelectedClassroomId + val lastSelectedClassroomId = it.profilesMap[ + profileId.loggedInInternalProfileId + ]?.lastSelectedClassroomId AsyncResult.Success(lastSelectedClassroomId) } } From e2e85900f4a486989f2eb1630497f25be29d37da Mon Sep 17 00:00:00 2001 From: MohitGupta121 Date: Tue, 13 Aug 2024 11:40:58 +0530 Subject: [PATCH 4/6] Added logout case instead of -1 --- .../app/classroom/ClassroomListActivity.kt | 6 +++--- .../CompletedStoryListFragment.kt | 3 +-- .../CompletedStoryListFragmentPresenter.kt | 5 +++-- .../CompletedStoryListViewModel.kt | 16 +++++++--------- .../app/devoptions/DeveloperOptionsActivity.kt | 18 ++++++++++-------- .../MarkStoriesCompletedActivity.kt | 6 +++--- .../MarkTopicsCompletedActivity.kt | 9 +++++---- .../testing/MarkTopicsCompletedTestActivity.kt | 8 +++++--- .../testing/DeveloperOptionsTestActivity.kt | 11 +++++------ .../app/drawer/ExitProfileDialogFragment.kt | 8 ++++++++ .../NavigationDrawerFragmentPresenter.kt | 2 +- .../android/app/options/AppLanguageActivity.kt | 6 +++--- .../android/app/options/AppLanguageFragment.kt | 6 +++--- .../app/profile/AdminAuthActivityPresenter.kt | 11 ++++++++--- .../app/profile/AdminPinActivityPresenter.kt | 9 +++++---- .../profile/PinPasswordActivityPresenter.kt | 4 ++-- .../android/app/spotlight/SpotlightFragment.kt | 16 +++++----------- .../oppia/android/app/story/StoryActivity.kt | 9 ++++++--- .../app/story/StoryFragmentPresenter.kt | 2 +- .../oppia/android/app/story/StoryViewModel.kt | 8 ++++---- .../oppia/android/app/topic/TopicActivity.kt | 8 ++++---- .../oppia/android/app/topic/TopicFragment.kt | 8 ++++++-- .../app/topic/TopicFragmentPresenter.kt | 2 +- .../oppia/android/app/topic/TopicViewModel.kt | 13 ++++--------- .../app/topic/info/TopicInfoFragment.kt | 3 ++- .../topic/info/TopicInfoFragmentPresenter.kt | 9 +++------ .../app/topic/lessons/TopicLessonViewModel.kt | 2 +- .../app/topic/lessons/TopicLessonsFragment.kt | 10 +++++++--- .../lessons/TopicLessonsFragmentPresenter.kt | 2 +- .../topic/practice/TopicPracticeFragment.kt | 14 ++++++++++++-- .../topic/practice/TopicPracticeViewModel.kt | 2 +- .../WalkthroughWelcomeFragmentPresenter.kt | 5 +---- .../profile/ProfileManagementController.kt | 13 +++++-------- 33 files changed, 136 insertions(+), 118 deletions(-) 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 311d484433c..542b48c1c8a 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 internalProfileId: 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().loggedInInternalProfileId + internalProfileId = intent.extractCurrentUserProfileId() classroomListActivityPresenter.handleOnCreate() title = resourceHandler.getStringInLocale(R.string.classroom_list_activity_title) } @@ -89,7 +89,7 @@ class ClassroomListActivity : RecentlyPlayedActivityParams .newBuilder() .setProfileId( - ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId.loggedInInternalProfileId).build() ) .setActivityTitle(recentlyPlayedActivityTitle).build() 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 bf8bad19c20..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 @@ -47,11 +47,10 @@ class CompletedStoryListFragment : InjectableFragment() { "Expected arguments to be passed to CompletedStoryListFragment" } val profileId = arguments.extractCurrentUserProfileId() - val internalProfileId = profileId.loggedInInternalProfileId 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..645859f9e40 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 @@ -11,6 +11,7 @@ import org.oppia.android.app.recyclerview.BindableAdapter import org.oppia.android.databinding.CompletedStoryItemBinding import org.oppia.android.databinding.CompletedStoryListFragmentBinding import javax.inject.Inject +import org.oppia.android.app.model.ProfileId /** The presenter for [CompletedStoryListFragment]. */ class CompletedStoryListFragmentPresenter @Inject constructor( @@ -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 55bbf0a9545..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().setLoggedInInternalProfileId(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 bbc537c9c11..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().loggedInInternalProfileId + 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/markstoriescompleted/MarkStoriesCompletedActivity.kt b/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedActivity.kt index 453b3df78eb..940938bc417 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,15 @@ class MarkStoriesCompletedActivity : InjectableAutoLocalizedAppCompatActivity() @Inject lateinit var resourceHandler: AppLanguageResourceHandler - private var internalProfileId = -1 + private var internalProfileId: 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?.loggedInInternalProfileId ?: -1 - markStoriesCompletedActivityPresenter.handleOnCreate(internalProfileId) + internalProfileId = profileId ?: ProfileId.newBuilder().setLoggedOut(true).build() + markStoriesCompletedActivityPresenter.handleOnCreate(internalProfileId.loggedInInternalProfileId) title = resourceHandler.getStringInLocale(R.string.mark_stories_completed_activity_title) } 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 cd8f615b510..2c62458151c 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,15 @@ 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?.loggedInInternalProfileId ?: -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) } 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 6d51eccce5e..96bcd570985 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 internalProfileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -23,9 +23,11 @@ class MarkTopicsCompletedTestActivity : InjectableAutoLocalizedAppCompatActivity supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_arrow_back_white_24dp) setContentView(R.layout.mark_topics_completed_activity) val profileId = intent?.extractCurrentUserProfileId() - internalProfileId = profileId?.loggedInInternalProfileId ?: -1 + internalProfileId = profileId ?: ProfileId.newBuilder().setLoggedOut(true).build() if (getMarkTopicsCompletedFragment() == null) { - val markTopicsCompletedFragment = MarkTopicsCompletedFragment.newInstance(internalProfileId) + val markTopicsCompletedFragment = MarkTopicsCompletedFragment.newInstance( + internalProfileId.loggedInInternalProfileId + ) supportFragmentManager.beginTransaction().add( R.id.mark_topics_completed_container, markTopicsCompletedFragment 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 204b1bdfef2..f15d39c8a1a 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,14 @@ 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?.loggedInInternalProfileId ?: -1 + profileId = intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() if (getDeveloperOptionsFragment() == null) { supportFragmentManager.beginTransaction().add( @@ -57,7 +56,7 @@ class DeveloperOptionsTestActivity : override fun routeToMarkChaptersCompleted() { startActivity( MarkChaptersCompletedActivity.createMarkChaptersCompletedIntent( - context = this, internalProfileId, showConfirmationNotice = false + context = this, profileId.loggedInInternalProfileId, showConfirmationNotice = false ) ) } @@ -65,14 +64,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) ) } 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..286dfe1bf10 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 @@ -5,15 +5,19 @@ import android.content.Context import android.content.DialogInterface import android.content.Intent import android.os.Bundle +import android.util.Log import androidx.appcompat.app.AlertDialog import androidx.appcompat.view.ContextThemeWrapper import androidx.fragment.app.DialogFragment +import javax.inject.Inject import org.oppia.android.R 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.domain.profile.ProfileManagementController import org.oppia.android.util.extensions.getProto import org.oppia.android.util.extensions.putProto @@ -70,6 +74,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 21da3017a23..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) 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 0bfabf92232..412dfd402e4 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,15 @@ 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()?.loggedInInternalProfileId ?: -1 + profileId = intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() appLanguageActivityPresenter.handleOnCreate( savedInstanceState?.retrieveLanguageFromSavedState() ?: intent.retrieveLanguageFromParams(), - profileId!! + profileId.loggedInInternalProfileId ) } 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 8a78d91f44d..53ec347dec8 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" @@ -70,13 +70,13 @@ class AppLanguageFragment : InjectableFragment(), AppLanguageRadioButtonListener savedInstanceState?.retrieveLanguageFromSavedState() ?: arguments?.retrieveLanguageFromArguments() ) { "Expected arguments to be passed to AppLanguageFragment" } - profileId = arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -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/profile/AdminAuthActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/profile/AdminAuthActivityPresenter.kt index 9ecab88d3d6..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().setLoggedInInternalProfileId(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 467614f2a2e..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() - .setLoggedInInternalProfileId(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 8548cc807ea..c679244d5d4 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,7 @@ 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,7 +51,7 @@ class PinPasswordActivityPresenter @Inject constructor( ) val adminPin = args?.adminPin - internalProfileId = args?.internalProfileId ?: -1 + internalProfileId = args?.internalProfileId ?: ProfileId.newBuilder().setLoggedOut(true).build().loggedInInternalProfileId profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val binding = DataBindingUtil.setContentView( 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 7c6a5b9a36b..19a16a0df66 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 internalProfileId: 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()?.loggedInInternalProfileId ?: -1 + internalProfileId = + 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() - .setLoggedInInternalProfileId(internalProfileId) - .build() - + val profileId = internalProfileId val featureViewStateLiveData = spotlightStateController.retrieveSpotlightViewState( profileId, spotlightTarget.feature ).toLiveData() - // Use activity as observer because this fragment's view hasn't been created yet. featureViewStateLiveData.observe( activity, object : Observer> { @@ -139,10 +136,7 @@ class SpotlightFragment : InjectableFragment(), SpotlightNavigationListener, Spo override fun onEnded() { if (targetList.isNotEmpty()) targetList.removeFirst() - val profileId = ProfileId.newBuilder() - .setLoggedInInternalProfileId(internalProfileId) - .build() - spotlightStateController.markSpotlightViewed(profileId, spotlightTarget.feature) + spotlightStateController.markSpotlightViewed(internalProfileId, spotlightTarget.feature) } }) .build(spotlightTarget.anchor) 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 7ca54d1949f..4652e11265e 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,7 @@ class StoryActivity : STORY_ACTIVITY_PARAMS_KEY, StoryActivityParams.getDefaultInstance() ) - internalProfileId = intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 + profileId = intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() classroomId = checkNotNull(args.classroomId) { "Expected extra classroom ID to be included for StoryActivity." } @@ -50,7 +50,10 @@ 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( 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 423b544194c..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 @@ -84,7 +84,7 @@ class StoryFragmentPresenter @Inject constructor( ) profileId = ProfileId.newBuilder().apply { loggedInInternalProfileId = internalProfileId }.build() - storyViewModel.setInternalProfileId(internalProfileId) + storyViewModel.setInternalProfileId(profileId) storyViewModel.setClassroomId(classroomId) storyViewModel.setTopicId(topicId) storyViewModel.setStoryId(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 bff8c267125..f75ab57f91e 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 internalProfileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() private lateinit var classroomId: String private lateinit var topicId: String @@ -41,7 +41,7 @@ class StoryViewModel @Inject constructor( private val storyResultLiveData: LiveData> by lazy { topicController.getStory( - ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId.loggedInInternalProfileId).build(), topicId, storyId ).toLiveData() @@ -59,7 +59,7 @@ class StoryViewModel @Inject constructor( Transformations.map(storyLiveData, ::processStoryChapterList) } - fun setInternalProfileId(internalProfileId: Int) { + fun setInternalProfileId(internalProfileId: ProfileId) { this.internalProfileId = internalProfileId } @@ -125,7 +125,7 @@ class StoryViewModel @Inject constructor( fragment, explorationSelectionListener, explorationCheckpointController, - internalProfileId, + internalProfileId.loggedInInternalProfileId, classroomId, topicId, storyId, 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 2b0f5fd6df5..ac420082535 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 internalProfileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() private lateinit var topicId: String private lateinit var classroomId: String private var storyId: String? = null @@ -45,7 +45,7 @@ class TopicActivity : override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - internalProfileId = intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 + internalProfileId = intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() val args = intent?.getProtoExtra( TOPIC_ACTIVITY_PARAMS_KEY, TopicActivityParams.getDefaultInstance() @@ -57,7 +57,7 @@ class TopicActivity : "Expected topic ID to be included in intent for TopicActivity." } storyId = args?.storyId - topicActivityPresenter.handleOnCreate(internalProfileId, classroomId, topicId, storyId) + topicActivityPresenter.handleOnCreate(internalProfileId.loggedInInternalProfileId, classroomId, topicId, storyId) } override fun routeToQuestionPlayer(skillIdList: ArrayList) { @@ -65,7 +65,7 @@ class TopicActivity : QuestionPlayerActivity.createQuestionPlayerActivityIntent( this, skillIdList, - ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId.loggedInInternalProfileId).build() ) ) } 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 514684bdc08..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,8 +34,12 @@ class TopicFragment : InjectableFragment() { TOPIC_FRAGMENT_ARGUMENTS_KEY, TopicFragmentArguments.getDefaultInstance() ) - val internalProfileId = - arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -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 a4acbfda676..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 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 9891a0e77ba..0cb46b7178e 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 internalProfileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() private lateinit var topicId: String private val topicResultLiveData: LiveData> by lazy { - topicController.getTopic( - ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), - topicId - ).toLiveData() + topicController.getTopic(internalProfileId, 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().setLoggedInInternalProfileId(internalProfileId).build() - ).toLiveData() + topicListController.getPromotedActivityList(internalProfileId).toLiveData() } val numberOfChaptersCompletedLiveData: LiveData by lazy { @@ -84,7 +79,7 @@ class TopicViewModel @Inject constructor( } fun setInternalProfileId(internalProfileId: Int) { - this.internalProfileId = internalProfileId + this.internalProfileId = 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 a0184f7d29a..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 @@ -55,7 +55,8 @@ class TopicInfoFragment : InjectableFragment() { ) val internalProfileId = - arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 + 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 78a5212cbda..604bac20d2f 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,13 +30,13 @@ class TopicInfoFragmentPresenter @Inject constructor( @DefaultResourceBucketName private val resourceBucketName: String ) { private lateinit var binding: TopicInfoFragmentBinding - private var internalProfileId: Int = -1 + private lateinit var internalProfileId: ProfileId private lateinit var topicId: String fun handleCreateView( inflater: LayoutInflater, container: ViewGroup?, - internalProfileId: Int, + internalProfileId: ProfileId, topicId: String ): View? { this.internalProfileId = internalProfileId @@ -68,10 +68,7 @@ class TopicInfoFragmentPresenter @Inject constructor( } private val topicResultLiveData: LiveData> by lazy { - topicController.getTopic( - ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build(), - topicId - ).toLiveData() + topicController.getTopic(internalProfileId, 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 bb40d71da7b..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 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 77dffd80c31..411eba00516 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 @@ -5,6 +5,7 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import javax.inject.Inject import org.oppia.android.app.fragment.FragmentComponentImpl import org.oppia.android.app.fragment.InjectableFragment import org.oppia.android.app.model.ChapterPlayState @@ -16,7 +17,6 @@ import org.oppia.android.util.extensions.getProto import org.oppia.android.util.extensions.putProto import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.decorateWithUserProfileId import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.extractCurrentUserProfileId -import javax.inject.Inject private const val CURRENT_EXPANDED_LIST_INDEX_SAVED_KEY = "TopicLessonsFragment.current_expanded_list_index" @@ -88,8 +88,12 @@ class TopicLessonsFragment : } isDefaultStoryExpanded = stateArgs?.isDefaultStoryExpanded ?: false } - val internalProfileId = - arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -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 ce218f030e7..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 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 e011f534b92..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().setLoggedInInternalProfileId(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,8 +75,13 @@ class TopicPracticeFragment : InjectableFragment() { TOPIC_PRACTICE_FRAGMENT_ARGUMENTS_KEY, TopicPracticeFragmentArguments.getDefaultInstance() ) + val profileId = arguments?.extractCurrentUserProfileId() val internalProfileId = - arguments?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 + 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 efb6a9f7717..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,7 +26,7 @@ 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( 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 df4a29a181d..f2fb20b5361 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,9 +47,7 @@ class WalkthroughWelcomeFragmentPresenter @Inject constructor( /* attachToRoot= */ false ) - internalProfileId = - activity.intent?.extractCurrentUserProfileId()?.loggedInInternalProfileId ?: -1 - profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + profileId = activity.intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() walkthroughWelcomeViewModel = WalkthroughWelcomeViewModel() binding.let { 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 91183a265a0..297268c1b67 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 @@ -39,7 +39,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 DEFAULT_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 = @@ -95,7 +95,7 @@ class ProfileManagementController @Inject constructor( private val enableLoggingLearnerStudyIds: PlatformParameterValue, private val profileNameValidator: ProfileNameValidator ) { - private var currentProfileId: Int = DEFAULT_LOGGED_OUT_INTERNAL_PROFILE_ID + private var currentProfileId: ProfileId = DEFAULT_LOGGED_OUT_PROFILE_ID private val profileDataStore = cacheStoreFactory.create("profile_database", ProfileDatabase.getDefaultInstance()) @@ -706,13 +706,12 @@ class ProfileManagementController @Inject constructor( return dataProviders.createInMemoryDataProviderAsync(SET_CURRENT_PROFILE_ID_PROVIDER_ID) { val profileDatabase = profileDataStore.readDataAsync().await() if (profileDatabase.profilesMap.containsKey(profileId.loggedInInternalProfileId)) { - currentProfileId = profileId.loggedInInternalProfileId + currentProfileId = profileId return@createInMemoryDataProviderAsync AsyncResult.Success(0) } AsyncResult.Failure( ProfileNotFoundException( - "ProfileId ${profileId.loggedInInternalProfileId} is" + - " not associated with an existing profile" + "ProfileId ${profileId.loggedInInternalProfileId} is not associated with an existing profile" ) ) } @@ -789,9 +788,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().setLoggedInInternalProfileId(it).build() - } + return if (!currentProfileId.loggedOut) currentProfileId else null } /** From 9e8604e3c56cfc22c0440ea24a970b3b89004502 Mon Sep 17 00:00:00 2001 From: MohitGupta121 Date: Tue, 13 Aug 2024 11:50:11 +0530 Subject: [PATCH 5/6] fix lint checks --- .../android/app/classroom/ClassroomListActivity.kt | 3 ++- .../CompletedStoryListFragmentPresenter.kt | 2 +- .../MarkStoriesCompletedActivity.kt | 4 +++- .../MarkTopicsCompletedActivity.kt | 3 ++- .../testing/DeveloperOptionsTestActivity.kt | 3 ++- .../android/app/drawer/ExitProfileDialogFragment.kt | 3 --- .../android/app/options/AppLanguageActivity.kt | 3 ++- .../android/app/options/AppLanguageFragment.kt | 3 ++- .../app/profile/PinPasswordActivityPresenter.kt | 6 ++++-- .../org/oppia/android/app/story/StoryActivity.kt | 10 ++++++++-- .../org/oppia/android/app/story/StoryViewModel.kt | 3 ++- .../org/oppia/android/app/topic/TopicActivity.kt | 13 ++++++++++--- .../org/oppia/android/app/topic/TopicViewModel.kt | 3 ++- .../app/topic/lessons/TopicLessonsFragment.kt | 2 +- .../welcome/WalkthroughWelcomeFragmentPresenter.kt | 4 +++- .../domain/profile/ProfileManagementController.kt | 3 ++- 16 files changed, 46 insertions(+), 22 deletions(-) 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 542b48c1c8a..9fed5e9200b 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 @@ -89,7 +89,8 @@ class ClassroomListActivity : RecentlyPlayedActivityParams .newBuilder() .setProfileId( - ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId.loggedInInternalProfileId).build() + ProfileId.newBuilder() + .setLoggedInInternalProfileId(internalProfileId.loggedInInternalProfileId).build() ) .setActivityTitle(recentlyPlayedActivityTitle).build() 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 645859f9e40..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,11 +7,11 @@ 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 import javax.inject.Inject -import org.oppia.android.app.model.ProfileId /** The presenter for [CompletedStoryListFragment]. */ class CompletedStoryListFragmentPresenter @Inject constructor( 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 940938bc417..23401a4a217 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 @@ -32,7 +32,9 @@ class MarkStoriesCompletedActivity : InjectableAutoLocalizedAppCompatActivity() val profileId = intent?.extractCurrentUserProfileId() internalProfileId = profileId ?: ProfileId.newBuilder().setLoggedOut(true).build() - markStoriesCompletedActivityPresenter.handleOnCreate(internalProfileId.loggedInInternalProfileId) + markStoriesCompletedActivityPresenter.handleOnCreate( + internalProfileId.loggedInInternalProfileId + ) title = resourceHandler.getStringInLocale(R.string.mark_stories_completed_activity_title) } 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 2c62458151c..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 @@ -30,7 +30,8 @@ class MarkTopicsCompletedActivity : InjectableAutoLocalizedAppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - profileId = intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() + profileId = + intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() if (!profileId.loggedOut) { markTopicsCompletedActivityPresenter.handleOnCreate(profileId.loggedInInternalProfileId) } 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 f15d39c8a1a..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 @@ -37,7 +37,8 @@ class DeveloperOptionsTestActivity : (activityComponent as ActivityComponentImpl).inject(this) setContentView(R.layout.developer_options_activity) - profileId = intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() + profileId = + intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() if (getDeveloperOptionsFragment() == null) { supportFragmentManager.beginTransaction().add( 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 286dfe1bf10..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 @@ -5,11 +5,9 @@ import android.content.Context import android.content.DialogInterface import android.content.Intent import android.os.Bundle -import android.util.Log import androidx.appcompat.app.AlertDialog import androidx.appcompat.view.ContextThemeWrapper import androidx.fragment.app.DialogFragment -import javax.inject.Inject import org.oppia.android.R import org.oppia.android.app.fragment.FragmentComponentImpl import org.oppia.android.app.fragment.InjectableDialogFragment @@ -17,7 +15,6 @@ 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.domain.profile.ProfileManagementController import org.oppia.android.util.extensions.getProto import org.oppia.android.util.extensions.putProto 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 412dfd402e4..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 @@ -28,7 +28,8 @@ class AppLanguageActivity : InjectableAutoLocalizedAppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - profileId = intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() + profileId = + intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() appLanguageActivityPresenter.handleOnCreate( savedInstanceState?.retrieveLanguageFromSavedState() ?: intent.retrieveLanguageFromParams(), profileId.loggedInInternalProfileId 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 53ec347dec8..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 @@ -70,7 +70,8 @@ class AppLanguageFragment : InjectableFragment(), AppLanguageRadioButtonListener savedInstanceState?.retrieveLanguageFromSavedState() ?: arguments?.retrieveLanguageFromArguments() ) { "Expected arguments to be passed to AppLanguageFragment" } - profileId = arguments?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() + profileId = + arguments?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() return appLanguageFragmentPresenter.handleOnCreateView( inflater, 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 c679244d5d4..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 = ProfileId.newBuilder().setLoggedOut(true).build().loggedInInternalProfileId + private var internalProfileId = + ProfileId.newBuilder().setLoggedOut(true).build().loggedInInternalProfileId private var profileId = ProfileId.getDefaultInstance() private lateinit var alertDialog: AlertDialog private var confirmedDeletion = false @@ -51,7 +52,8 @@ class PinPasswordActivityPresenter @Inject constructor( ) val adminPin = args?.adminPin - internalProfileId = args?.internalProfileId ?: ProfileId.newBuilder().setLoggedOut(true).build().loggedInInternalProfileId + internalProfileId = args?.internalProfileId ?: ProfileId.newBuilder().setLoggedOut(true) + .build().loggedInInternalProfileId profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() val binding = DataBindingUtil.setContentView( 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 4652e11265e..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 @@ -40,7 +40,8 @@ class StoryActivity : STORY_ACTIVITY_PARAMS_KEY, StoryActivityParams.getDefaultInstance() ) - profileId = intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() + profileId = + intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() classroomId = checkNotNull(args.classroomId) { "Expected extra classroom ID to be included for StoryActivity." } @@ -52,7 +53,12 @@ class StoryActivity : } if (!profileId.loggedOut) { - storyActivityPresenter.handleOnCreate(profileId.loggedInInternalProfileId, classroomId, topicId, storyId) + storyActivityPresenter.handleOnCreate( + 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 f75ab57f91e..5b8e31d65b2 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 @@ -41,7 +41,8 @@ class StoryViewModel @Inject constructor( private val storyResultLiveData: LiveData> by lazy { topicController.getStory( - ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId.loggedInInternalProfileId).build(), + ProfileId.newBuilder() + .setLoggedInInternalProfileId(internalProfileId.loggedInInternalProfileId).build(), topicId, storyId ).toLiveData() 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 ac420082535..4d5c68996df 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 @@ -45,7 +45,8 @@ class TopicActivity : override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - internalProfileId = intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() + internalProfileId = + 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.loggedInInternalProfileId, classroomId, topicId, storyId) + topicActivityPresenter.handleOnCreate( + internalProfileId.loggedInInternalProfileId, + classroomId, + topicId, + storyId + ) } override fun routeToQuestionPlayer(skillIdList: ArrayList) { @@ -65,7 +71,8 @@ class TopicActivity : QuestionPlayerActivity.createQuestionPlayerActivityIntent( this, skillIdList, - ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId.loggedInInternalProfileId).build() + ProfileId.newBuilder() + .setLoggedInInternalProfileId(internalProfileId.loggedInInternalProfileId).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 0cb46b7178e..35e18f3393a 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 @@ -79,7 +79,8 @@ class TopicViewModel @Inject constructor( } fun setInternalProfileId(internalProfileId: Int) { - this.internalProfileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() + this.internalProfileId = + ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() } fun setTopicId(topicId: String) { 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 411eba00516..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 @@ -5,7 +5,6 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import javax.inject.Inject import org.oppia.android.app.fragment.FragmentComponentImpl import org.oppia.android.app.fragment.InjectableFragment import org.oppia.android.app.model.ChapterPlayState @@ -17,6 +16,7 @@ import org.oppia.android.util.extensions.getProto import org.oppia.android.util.extensions.putProto import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.decorateWithUserProfileId import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.extractCurrentUserProfileId +import javax.inject.Inject private const val CURRENT_EXPANDED_LIST_INDEX_SAVED_KEY = "TopicLessonsFragment.current_expanded_list_index" 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 f2fb20b5361..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 @@ -47,7 +47,9 @@ class WalkthroughWelcomeFragmentPresenter @Inject constructor( /* attachToRoot= */ false ) - profileId = activity.intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() + profileId = + activity.intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true) + .build() walkthroughWelcomeViewModel = WalkthroughWelcomeViewModel() binding.let { 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 297268c1b67..b7c9dba7ef2 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 @@ -711,7 +711,8 @@ class ProfileManagementController @Inject constructor( } AsyncResult.Failure( ProfileNotFoundException( - "ProfileId ${profileId.loggedInInternalProfileId} is not associated with an existing profile" + "ProfileId " + + "${profileId.loggedInInternalProfileId} is not associated with an existing profile" ) ) } From 190fbeec8852ffe979834e456154e747cf7b1389 Mon Sep 17 00:00:00 2001 From: MohitGupta121 Date: Sun, 25 Aug 2024 17:47:16 +0530 Subject: [PATCH 6/6] Fix initial review changes --- .../AdministratorControlsFragmentPresenter.kt | 3 +-- .../android/app/classroom/ClassroomListActivity.kt | 9 +++------ .../MarkStoriesCompletedActivity.kt | 8 ++++---- .../testing/MarkTopicsCompletedTestActivity.kt | 8 ++++---- .../oppia/android/app/spotlight/SpotlightFragment.kt | 10 +++++----- .../java/org/oppia/android/app/story/StoryViewModel.kt | 8 ++++---- .../java/org/oppia/android/app/topic/TopicActivity.kt | 8 ++++---- .../java/org/oppia/android/app/topic/TopicViewModel.kt | 8 ++++---- .../app/topic/info/TopicInfoFragmentPresenter.kt | 6 +++--- .../domain/profile/ProfileManagementController.kt | 4 ++-- model/src/main/proto/profile.proto | 6 ++++-- 11 files changed, 38 insertions(+), 40 deletions(-) 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 740a6442052..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().loggedInInternalProfileId - profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(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 9fed5e9200b..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 lateinit var internalProfileId: ProfileId + 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() + profileId = intent.extractCurrentUserProfileId() classroomListActivityPresenter.handleOnCreate() title = resourceHandler.getStringInLocale(R.string.classroom_list_activity_title) } @@ -88,10 +88,7 @@ class ClassroomListActivity : val recentlyPlayedActivityParams = RecentlyPlayedActivityParams .newBuilder() - .setProfileId( - ProfileId.newBuilder() - .setLoggedInInternalProfileId(internalProfileId.loggedInInternalProfileId).build() - ) + .setProfileId(profileId) .setActivityTitle(recentlyPlayedActivityTitle).build() activityRouter.routeToScreen( 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 23401a4a217..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,16 +24,16 @@ class MarkStoriesCompletedActivity : InjectableAutoLocalizedAppCompatActivity() @Inject lateinit var resourceHandler: AppLanguageResourceHandler - private var internalProfileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() + 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 ?: ProfileId.newBuilder().setLoggedOut(true).build() + val currentProfileId = intent?.extractCurrentUserProfileId() + profileId = currentProfileId ?: ProfileId.newBuilder().setLoggedOut(true).build() markStoriesCompletedActivityPresenter.handleOnCreate( - internalProfileId.loggedInInternalProfileId + profileId.loggedInInternalProfileId ) title = resourceHandler.getStringInLocale(R.string.mark_stories_completed_activity_title) } 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 96bcd570985..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: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() + private var profileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -22,11 +22,11 @@ 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 ?: ProfileId.newBuilder().setLoggedOut(true).build() + val currentProfileId = intent?.extractCurrentUserProfileId() + profileId = currentProfileId ?: ProfileId.newBuilder().setLoggedOut(true).build() if (getMarkTopicsCompletedFragment() == null) { val markTopicsCompletedFragment = MarkTopicsCompletedFragment.newInstance( - internalProfileId.loggedInInternalProfileId + profileId.loggedInInternalProfileId ) supportFragmentManager.beginTransaction().add( R.id.mark_topics_completed_container, 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 19a16a0df66..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: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() + 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,7 @@ class SpotlightFragment : InjectableFragment(), SpotlightNavigationListener, Spo override fun onAttach(context: Context) { super.onAttach(context) (fragmentComponent as FragmentComponentImpl).inject(this) - internalProfileId = + profileId = arguments?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() calculateScreenSize() } @@ -100,10 +100,10 @@ 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 = internalProfileId + val currentProfileId = profileId val featureViewStateLiveData = spotlightStateController.retrieveSpotlightViewState( - profileId, + currentProfileId, spotlightTarget.feature ).toLiveData() @@ -136,7 +136,7 @@ class SpotlightFragment : InjectableFragment(), SpotlightNavigationListener, Spo override fun onEnded() { if (targetList.isNotEmpty()) targetList.removeFirst() - spotlightStateController.markSpotlightViewed(internalProfileId, spotlightTarget.feature) + spotlightStateController.markSpotlightViewed(profileId, spotlightTarget.feature) } }) .build(spotlightTarget.anchor) 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 5b8e31d65b2..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: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() + private var profileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() private lateinit var classroomId: String private lateinit var topicId: String @@ -42,7 +42,7 @@ class StoryViewModel @Inject constructor( private val storyResultLiveData: LiveData> by lazy { topicController.getStory( ProfileId.newBuilder() - .setLoggedInInternalProfileId(internalProfileId.loggedInInternalProfileId).build(), + .setLoggedInInternalProfileId(profileId.loggedInInternalProfileId).build(), topicId, storyId ).toLiveData() @@ -61,7 +61,7 @@ class StoryViewModel @Inject constructor( } fun setInternalProfileId(internalProfileId: ProfileId) { - this.internalProfileId = internalProfileId + this.profileId = internalProfileId } fun setClassroomId(classroomId: String) { @@ -126,7 +126,7 @@ class StoryViewModel @Inject constructor( fragment, explorationSelectionListener, explorationCheckpointController, - internalProfileId.loggedInInternalProfileId, + profileId.loggedInInternalProfileId, classroomId, topicId, storyId, 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 4d5c68996df..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: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() + 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,7 @@ class TopicActivity : override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) - internalProfileId = + profileId = intent?.extractCurrentUserProfileId() ?: ProfileId.newBuilder().setLoggedOut(true).build() val args = intent?.getProtoExtra( TOPIC_ACTIVITY_PARAMS_KEY, @@ -59,7 +59,7 @@ class TopicActivity : } storyId = args?.storyId topicActivityPresenter.handleOnCreate( - internalProfileId.loggedInInternalProfileId, + profileId.loggedInInternalProfileId, classroomId, topicId, storyId @@ -72,7 +72,7 @@ class TopicActivity : this, skillIdList, ProfileId.newBuilder() - .setLoggedInInternalProfileId(internalProfileId.loggedInInternalProfileId).build() + .setLoggedInInternalProfileId(profileId.loggedInInternalProfileId).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 35e18f3393a..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,16 +26,16 @@ class TopicViewModel @Inject constructor( private val resourceHandler: AppLanguageResourceHandler, private val translationController: TranslationController ) : ObservableViewModel() { - private var internalProfileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() + private var profileId: ProfileId = ProfileId.newBuilder().setLoggedOut(true).build() private lateinit var topicId: String private val topicResultLiveData: LiveData> by lazy { - topicController.getTopic(internalProfileId, 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(internalProfileId).toLiveData() + topicListController.getPromotedActivityList(profileId).toLiveData() } val numberOfChaptersCompletedLiveData: LiveData by lazy { @@ -79,7 +79,7 @@ class TopicViewModel @Inject constructor( } fun setInternalProfileId(internalProfileId: Int) { - this.internalProfileId = + this.profileId = ProfileId.newBuilder().setLoggedInInternalProfileId(internalProfileId).build() } 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 604bac20d2f..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,7 +30,7 @@ class TopicInfoFragmentPresenter @Inject constructor( @DefaultResourceBucketName private val resourceBucketName: String ) { private lateinit var binding: TopicInfoFragmentBinding - private lateinit var internalProfileId: ProfileId + private lateinit var profileId: ProfileId private lateinit var topicId: String fun handleCreateView( @@ -39,7 +39,7 @@ class TopicInfoFragmentPresenter @Inject constructor( internalProfileId: ProfileId, topicId: String ): View? { - this.internalProfileId = internalProfileId + this.profileId = internalProfileId this.topicId = topicId binding = TopicInfoFragmentBinding.inflate( inflater, @@ -68,7 +68,7 @@ class TopicInfoFragmentPresenter @Inject constructor( } private val topicResultLiveData: LiveData> by lazy { - topicController.getTopic(internalProfileId, topicId).toLiveData() + topicController.getTopic(profileId, topicId).toLiveData() } private fun getTopicList(): LiveData { 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 b7c9dba7ef2..cb795a3453c 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 @@ -39,7 +39,7 @@ import java.io.FileOutputStream import javax.inject.Inject import javax.inject.Singleton -private val DEFAULT_LOGGED_OUT_PROFILE_ID = ProfileId.newBuilder().setLoggedOut(true).build() +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 = @@ -95,7 +95,7 @@ class ProfileManagementController @Inject constructor( private val enableLoggingLearnerStudyIds: PlatformParameterValue, private val profileNameValidator: ProfileNameValidator ) { - private var currentProfileId: ProfileId = DEFAULT_LOGGED_OUT_PROFILE_ID + private var currentProfileId: ProfileId = LOGGED_OUT_PROFILE_ID private val profileDataStore = cacheStoreFactory.create("profile_database", ProfileDatabase.getDefaultInstance()) diff --git a/model/src/main/proto/profile.proto b/model/src/main/proto/profile.proto index 5117db65763..23b19c54ae8 100644 --- a/model/src/main/proto/profile.proto +++ b/model/src/main/proto/profile.proto @@ -109,9 +109,11 @@ message ProfileId { * Unique ID used to identify a single profile. * Should not be used directory outside of the profile system. */ + reserved 1; oneof type { - int32 logged_in_internal_profile_id = 1; - bool logged_out = 2; // Can be true or false; presence is sufficient. + int32 logged_in_internal_profile_id = 2; + // Boolean if user is logged_out or not. + bool logged_out = 3; } }