From 75709409bfd498432b19b16b2471c895b4f53051 Mon Sep 17 00:00:00 2001 From: Akash Koradia Date: Fri, 17 Jan 2020 23:32:34 +0530 Subject: [PATCH 1/9] Fix part of #10: Hifi ContinuePlaying (#605) * Removed padding from sides in Image in ongoing_story_card in ContinuePlayingList. * Reapplied side padding to the image. Removed hardcoded height attribute and applied dimensionRatio to the image. * ContentDescription attribute and the string reference for it is added in ongoing_story_card. * ScaleType of ImageView is changed and side paddings are removed, RecyclerView paddingBottom set to 172dp * Removed padding top from the image in ongoing_story_card. --- app/src/main/res/layout/continue_playing_fragment.xml | 2 +- app/src/main/res/layout/ongoing_story_card.xml | 10 ++++------ app/src/main/res/values/strings.xml | 1 + 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/src/main/res/layout/continue_playing_fragment.xml b/app/src/main/res/layout/continue_playing_fragment.xml index 1d0c4432b07..213b0eac59e 100644 --- a/app/src/main/res/layout/continue_playing_fragment.xml +++ b/app/src/main/res/layout/continue_playing_fragment.xml @@ -45,7 +45,7 @@ android:clipToPadding="false" android:overScrollMode="never" android:paddingTop="8dp" - android:paddingBottom="128dp" + android:paddingBottom="172dp" android:scrollbars="none" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> diff --git a/app/src/main/res/layout/ongoing_story_card.xml b/app/src/main/res/layout/ongoing_story_card.xml index dd14dea5114..ffadcb727b2 100755 --- a/app/src/main/res/layout/ongoing_story_card.xml +++ b/app/src/main/res/layout/ongoing_story_card.xml @@ -29,15 +29,13 @@ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index da9713ebe06..bb7e71d40b8 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -60,6 +60,7 @@ View All Played within the Last Week Played within the Last Month + Image for %s All Topics Stories You Can Play Go to previous page. From fd809362b566a664995ab7732e5f01a836b0784e Mon Sep 17 00:00:00 2001 From: Veena Date: Tue, 21 Jan 2020 16:26:27 +0530 Subject: [PATCH 2/9] Fix part #549 : Options Navigation Drawer Domain layer part 1 (#548) * Added option screen * working on bindable adapter * Update OptionsFragment.kt * adde test cases * Done nit changes * renamed toolbar * Update OptionsFragmentTest.kt * Update OptionsFragmentTest.kt * nit change * fixed nit * working on shared pref * Update OptionsFragment.kt * working on domain layer * fixed livedata issue. * Update OptionsFragment.kt * Update AndroidManifest.xml * Update OptionsFragment.kt * Fixed nit * added test cases * Update OptionsFragment.kt * Update ActivityComponent.kt * added options in navigation * added icon for options * added currentprofileId * removed app module from this pr * removed layouts * Update misc.xml * updated parameters * Update ProfileManagementControllerTest.kt * add spacing * fixed spacing * add spacing * add default values * Update ProfileActivityPresenter.kt * Update ProfileManagementController.kt --- .../profile/AddProfileActivityPresenter.kt | 8 +- .../app/profile/ProfileActivityPresenter.kt | 5 +- .../app/profile/ProfileChooserFragmentTest.kt | 2 +- .../profile/ProfileEditActivityTest.kt | 5 +- .../profile/ProfileManagementController.kt | 91 ++++++++++++++++++- .../oppia/domain/profile/ProfileTestHelper.kt | 18 +++- .../ProfileManagementControllerTest.kt | 91 +++++++++++++++++-- model/src/main/proto/profile.proto | 10 ++ 8 files changed, 213 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/oppia/app/profile/AddProfileActivityPresenter.kt b/app/src/main/java/org/oppia/app/profile/AddProfileActivityPresenter.kt index cfb4307155b..447821e07aa 100644 --- a/app/src/main/java/org/oppia/app/profile/AddProfileActivityPresenter.kt +++ b/app/src/main/java/org/oppia/app/profile/AddProfileActivityPresenter.kt @@ -41,6 +41,9 @@ class AddProfileActivityPresenter @Inject constructor( private var allowDownloadAccess = false private var inputtedPin = false private var inputtedConfirmPin = false + private var storyTextSize = 14f + private var appLanguage = "English" + private var audioLanguage = "No Audio" @ExperimentalCoroutinesApi fun handleOnCreate() { @@ -111,7 +114,10 @@ class AddProfileActivityPresenter @Inject constructor( avatarImagePath = selectedImage, allowDownloadAccess = allowDownloadAccess, colorRgb = activity.intent.getIntExtra(KEY_ADD_PROFILE_COLOR_RGB, -10710042), - isAdmin = false + isAdmin = false, + storyTextSize = storyTextSize, + appLanguage = appLanguage, + audioLanguage = audioLanguage ) .observe(activity, Observer { handleAddProfileResult(it, binding) diff --git a/app/src/main/java/org/oppia/app/profile/ProfileActivityPresenter.kt b/app/src/main/java/org/oppia/app/profile/ProfileActivityPresenter.kt index 421a2c63147..dbf2dd10bef 100644 --- a/app/src/main/java/org/oppia/app/profile/ProfileActivityPresenter.kt +++ b/app/src/main/java/org/oppia/app/profile/ProfileActivityPresenter.kt @@ -21,7 +21,10 @@ class ProfileActivityPresenter @Inject constructor( avatarImagePath = null, allowDownloadAccess = true, colorRgb = -10710042, - isAdmin = true + isAdmin = true, + storyTextSize = 14f, + appLanguage = "English", + audioLanguage = "No Audio" ) activity.setContentView(R.layout.profile_activity) if (getProfileChooserFragment() == null) { diff --git a/app/src/sharedTest/java/org/oppia/app/profile/ProfileChooserFragmentTest.kt b/app/src/sharedTest/java/org/oppia/app/profile/ProfileChooserFragmentTest.kt index 43dd1bfb7f3..5a056e01669 100644 --- a/app/src/sharedTest/java/org/oppia/app/profile/ProfileChooserFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/app/profile/ProfileChooserFragmentTest.kt @@ -133,7 +133,7 @@ class ProfileChooserFragmentTest { @Test fun testProfileChooserFragment_clickAdminProfileWithNoPin_checkOpensAdminPinActivity() { - profileManagementController.addProfile("Sean", "", null, true, -10710042, true) + profileManagementController.addProfile("Sean", "", null, true, -10710042, true, 16f, "English", "English") ActivityScenario.launch(ProfileActivity::class.java).use { onView(atPosition(R.id.profile_recycler_view, 1)).perform(click()) intended(hasComponent(AdminPinActivity::class.java.name)) diff --git a/app/src/sharedTest/java/org/oppia/app/settings/profile/ProfileEditActivityTest.kt b/app/src/sharedTest/java/org/oppia/app/settings/profile/ProfileEditActivityTest.kt index 2b1cc6cd6d0..20936395a80 100644 --- a/app/src/sharedTest/java/org/oppia/app/settings/profile/ProfileEditActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/app/settings/profile/ProfileEditActivityTest.kt @@ -129,7 +129,10 @@ class ProfileEditActivityTest { avatarImagePath = null, allowDownloadAccess = true, colorRgb = -10710042, - isAdmin = false + isAdmin = false, + storyTextSize = 16f, + appLanguage = "English", + audioLanguage = "No Audio" ) ActivityScenario.launch(ProfileEditActivity.createProfileEditActivity(context, 2)).use { onView(withId(R.id.profile_edit_allow_download_switch)).check(matches(isChecked())) diff --git a/domain/src/main/java/org/oppia/domain/profile/ProfileManagementController.kt b/domain/src/main/java/org/oppia/domain/profile/ProfileManagementController.kt index 70d55a86517..176e3b1d42b 100644 --- a/domain/src/main/java/org/oppia/domain/profile/ProfileManagementController.kt +++ b/domain/src/main/java/org/oppia/domain/profile/ProfileManagementController.kt @@ -22,9 +22,7 @@ import org.oppia.util.logging.Logger import org.oppia.util.profile.DirectoryManagementUtil import java.io.File import java.io.FileOutputStream -import java.lang.Exception -import java.util.Date -import java.util.Locale +import java.util.* import javax.inject.Inject import javax.inject.Singleton @@ -37,6 +35,9 @@ private const val UPDATE_DOWNLOAD_ACCESS_TRANSFORMED_PROVIDER_ID = "update_downl private const val LOGIN_PROFILE_TRANSFORMED_PROVIDER_ID = "login_profile_transformed_id" private const val DELETE_PROFILE_TRANSFORMED_PROVIDER_ID = "delete_profile_transformed_id" private const val SET_PROFILE_TRANSFORMED_PROVIDER_ID = "set_profile_transformed_id" +private const val UPDATE_STORY_TEXT_SIZE_TRANSFORMED_ID = "update_story_text_size_transformed_id" +private const val UPDATE_APP_LANGUAGE_TRANSFORMED_PROVIDER_ID = "update_app_language_transformed_id" +private const val UPDATE_AUDIO_LANGUAGE_TRANSFORMED_PROVIDER_ID = "update_audio_language_transformed_id" const val PROFILE_AVATAR_FILE_NAME = "profile_avatar.png" @@ -132,8 +133,12 @@ class ProfileManagementController @Inject constructor( avatarImagePath: Uri?, allowDownloadAccess: Boolean, colorRgb: Int, - isAdmin: Boolean + isAdmin: Boolean, + storyTextSize: Float?, + appLanguage: String?, + audioLanguage: String? ): LiveData> { + if (!onlyLetters(name)) { return MutableLiveData(AsyncResult.failed(ProfileNameOnlyLettersException("$name does not contain only letters"))) } @@ -151,6 +156,9 @@ class ProfileManagementController @Inject constructor( .setAllowDownloadAccess(allowDownloadAccess) .setId(ProfileId.newBuilder().setInternalId(nextProfileId)) .setDateCreatedTimestampMs(Date().time).setIsAdmin(isAdmin) + .setStoryTextSize(storyTextSize!!) + .setAppLanguage(appLanguage) + .setAudioLanguage(audioLanguage) if (avatarImagePath != null) { val imageUri = @@ -250,6 +258,81 @@ class ProfileManagementController @Inject constructor( }) } + /** + * Updates the story text size of the profile. + * + * @param profileId the ID corresponding to the profile being updated. + * @param storyTextSize New text size for the profile being updated. + * @return a [LiveData] that indicates the success/failure of this update operation. + */ + fun updateStoryTextSize( + profileId: ProfileId, storyTextSize: Float + ): LiveData> { + val deferred = profileDataStore.storeDataWithCustomChannelAsync(updateInMemoryCache = true) { + val profile = it.profilesMap[profileId.internalId] ?: return@storeDataWithCustomChannelAsync Pair( + it, + ProfileActionStatus.PROFILE_NOT_FOUND + ) + val updatedProfile = profile.toBuilder().setStoryTextSize(storyTextSize).build() + val profileDatabaseBuilder = it.toBuilder().putProfiles(profileId.internalId, updatedProfile) + Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) + } + return dataProviders.convertToLiveData( + dataProviders.createInMemoryDataProviderAsync(UPDATE_STORY_TEXT_SIZE_TRANSFORMED_ID) { + return@createInMemoryDataProviderAsync getDeferredResult(profileId, null, deferred) + }) + } + + /** + * Updates the app language of the profile. + * + * @param profileId the ID corresponding to the profile being updated. + * @param appLanguage New app language for the profile being updated. + * @return a [LiveData] that indicates the success/failure of this update operation. + */ + fun updateAppLanguage( + profileId: ProfileId, appLanguage: String + ): LiveData> { + val deferred = profileDataStore.storeDataWithCustomChannelAsync(updateInMemoryCache = true) { + val profile = it.profilesMap[profileId.internalId] ?: return@storeDataWithCustomChannelAsync Pair( + it, + ProfileActionStatus.PROFILE_NOT_FOUND + ) + val updatedProfile = profile.toBuilder().setAppLanguage(appLanguage).build() + val profileDatabaseBuilder = it.toBuilder().putProfiles(profileId.internalId, updatedProfile) + Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) + } + return dataProviders.convertToLiveData( + dataProviders.createInMemoryDataProviderAsync(UPDATE_APP_LANGUAGE_TRANSFORMED_PROVIDER_ID) { + return@createInMemoryDataProviderAsync getDeferredResult(profileId, null, deferred) + }) + } + + /** + * Updates the audio language of the profile. + * + * @param profileId the ID corresponding to the profile being updated. + * @param audioLanguage New audio language for the profile being updated. + * @return a [LiveData] that indicates the success/failure of this update operation. + */ + fun updateAudioLanguage( + profileId: ProfileId, audioLanguage: String + ): LiveData> { + val deferred = profileDataStore.storeDataWithCustomChannelAsync(updateInMemoryCache = true) { + val profile = it.profilesMap[profileId.internalId] ?: return@storeDataWithCustomChannelAsync Pair( + it, + ProfileActionStatus.PROFILE_NOT_FOUND + ) + val updatedProfile = profile.toBuilder().setAudioLanguage(audioLanguage).build() + val profileDatabaseBuilder = it.toBuilder().putProfiles(profileId.internalId, updatedProfile) + Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) + } + return dataProviders.convertToLiveData( + dataProviders.createInMemoryDataProviderAsync(UPDATE_AUDIO_LANGUAGE_TRANSFORMED_PROVIDER_ID) { + return@createInMemoryDataProviderAsync getDeferredResult(profileId, null, deferred) + }) + } + /** * Log in to the user's Profile by setting the current profile Id and updating profile's last logged in time. * diff --git a/domain/src/main/java/org/oppia/domain/profile/ProfileTestHelper.kt b/domain/src/main/java/org/oppia/domain/profile/ProfileTestHelper.kt index 4ad980f0ebe..3ae6a4fefb7 100644 --- a/domain/src/main/java/org/oppia/domain/profile/ProfileTestHelper.kt +++ b/domain/src/main/java/org/oppia/domain/profile/ProfileTestHelper.kt @@ -17,7 +17,10 @@ class ProfileTestHelper @Inject constructor( avatarImagePath = null, allowDownloadAccess = true, colorRgb = -10710042, - isAdmin = true + isAdmin = true, + storyTextSize = 16f, + appLanguage = "English", + audioLanguage = "Hindi" ) profileManagementController.addProfile( name = "Ben", @@ -25,7 +28,10 @@ class ProfileTestHelper @Inject constructor( avatarImagePath = null, allowDownloadAccess = false, colorRgb = -10710042, - isAdmin = false + isAdmin = false, + storyTextSize = 16f, + appLanguage = "Hindi", + audioLanguage = "English" ) return profileManagementController.loginToProfile(ProfileId.newBuilder().setInternalId(0).build()) } @@ -39,7 +45,10 @@ class ProfileTestHelper @Inject constructor( avatarImagePath = null, allowDownloadAccess = false, colorRgb = -10710042, - isAdmin = false + isAdmin = false, + storyTextSize = 18f, + appLanguage = "Chinese", + audioLanguage = "French" ) } } @@ -51,4 +60,7 @@ class ProfileTestHelper @Inject constructor( /** Login to user profile. */ fun loginToUser() = profileManagementController.loginToProfile(ProfileId.newBuilder().setInternalId(1).build()) + /** Login to user profile. */ + fun loginToUser2() = + profileManagementController.loginToProfile(ProfileId.newBuilder().setInternalId(2).build()) } diff --git a/domain/src/test/java/org/oppia/domain/profile/ProfileManagementControllerTest.kt b/domain/src/test/java/org/oppia/domain/profile/ProfileManagementControllerTest.kt index c389d8a9e7d..c81b82ffc91 100644 --- a/domain/src/test/java/org/oppia/domain/profile/ProfileManagementControllerTest.kt +++ b/domain/src/test/java/org/oppia/domain/profile/ProfileManagementControllerTest.kt @@ -128,7 +128,10 @@ class ProfileManagementControllerTest { avatarImagePath = null, allowDownloadAccess = true, colorRgb = -10710042, - isAdmin = true + isAdmin = true, + storyTextSize = 14f, + appLanguage = "English", + audioLanguage = "No Audio" ).observeForever(mockUpdateResultObserver) advanceUntilIdle() @@ -157,7 +160,10 @@ class ProfileManagementControllerTest { avatarImagePath = null, allowDownloadAccess = false, colorRgb = -10710042, - isAdmin = true + isAdmin = true, + storyTextSize = 14f, + appLanguage = "English", + audioLanguage = "No Audio" ).observeForever(mockUpdateResultObserver) verify(mockUpdateResultObserver, atLeastOnce()).onChanged(updateResultCaptor.capture()) @@ -179,7 +185,10 @@ class ProfileManagementControllerTest { avatarImagePath = null, allowDownloadAccess = false, colorRgb = -10710042, - isAdmin = true + isAdmin = true, + storyTextSize = 14f, + appLanguage = "English", + audioLanguage = "No Audio" ).observeForever(mockUpdateResultObserver) verify(mockUpdateResultObserver, atLeastOnce()).onChanged(updateResultCaptor.capture()) @@ -237,7 +246,10 @@ class ProfileManagementControllerTest { avatarImagePath = null, allowDownloadAccess = false, colorRgb = -10710042, - isAdmin = false + isAdmin = false, + storyTextSize = 14f, + appLanguage = "English", + audioLanguage = "No Audio" ) advanceUntilIdle() profileManagementController.getProfiles().observeForever(mockProfilesObserver) @@ -381,6 +393,67 @@ class ProfileManagementControllerTest { .contains("ProfileId 6 does not match an existing Profile") } + + @Test + @ExperimentalCoroutinesApi + fun testUpdateStoryTextSize_addProfiles_updateWithFontSize18_checkUpdateIsSuccessful() = + runBlockingTest(coroutineContext) { + addTestProfiles() + advanceUntilIdle() + + val profileId = ProfileId.newBuilder().setInternalId(2).build() + profileManagementController.updateStoryTextSize(profileId, 18f) + .observeForever(mockUpdateResultObserver) + advanceUntilIdle() + profileManagementController.getProfile(profileId).observeForever(mockProfileObserver) + + verify(mockUpdateResultObserver, atLeastOnce()).onChanged(updateResultCaptor.capture()) + verify(mockProfileObserver, atLeastOnce()).onChanged(profileResultCaptor.capture()) + assertThat(updateResultCaptor.value.isSuccess()).isTrue() + assertThat(profileResultCaptor.value.isSuccess()).isTrue() + assertThat(profileResultCaptor.value.getOrThrow().storyTextSize).isEqualTo(18f) + } + + @Test + @ExperimentalCoroutinesApi + fun testUpdateAppLanguage_addProfiles_updateWithChineseLanguage_checkUpdateIsSuccessful() = + runBlockingTest(coroutineContext) { + addTestProfiles() + advanceUntilIdle() + + val profileId = ProfileId.newBuilder().setInternalId(2).build() + profileManagementController.updateAppLanguage(profileId, "Chinese") + .observeForever(mockUpdateResultObserver) + advanceUntilIdle() + profileManagementController.getProfile(profileId).observeForever(mockProfileObserver) + + verify(mockUpdateResultObserver, atLeastOnce()).onChanged(updateResultCaptor.capture()) + verify(mockProfileObserver, atLeastOnce()).onChanged(profileResultCaptor.capture()) + assertThat(updateResultCaptor.value.isSuccess()).isTrue() + assertThat(profileResultCaptor.value.isSuccess()).isTrue() + assertThat(profileResultCaptor.value.getOrThrow().appLanguage).isEqualTo("Chinese") + } + + @Test + @ExperimentalCoroutinesApi + fun testUpdateAudioLanguage_addProfiles_updateWithFrenchLanguage_checkUpdateIsSuccessful() = + runBlockingTest(coroutineContext) { + addTestProfiles() + advanceUntilIdle() + + val profileId = ProfileId.newBuilder().setInternalId(2).build() + profileManagementController.updateAudioLanguage(profileId, "French") + .observeForever(mockUpdateResultObserver) + advanceUntilIdle() + profileManagementController.getProfile(profileId).observeForever(mockProfileObserver) + + verify(mockUpdateResultObserver, atLeastOnce()).onChanged(updateResultCaptor.capture()) + verify(mockProfileObserver, atLeastOnce()).onChanged(profileResultCaptor.capture()) + assertThat(updateResultCaptor.value.isSuccess()).isTrue() + assertThat(profileResultCaptor.value.isSuccess()).isTrue() + assertThat(profileResultCaptor.value.getOrThrow().audioLanguage).isEqualTo("French") + } + @Test @ExperimentalCoroutinesApi fun testDeleteProfile_addProfiles_deleteProfile_checkDeletionIsSuccessful() = @@ -417,7 +490,10 @@ class ProfileManagementControllerTest { avatarImagePath = null, allowDownloadAccess = false, colorRgb = -10710042, - isAdmin = true + isAdmin = true, + storyTextSize = 14f, + appLanguage = "English", + audioLanguage = "No Audio" ) advanceUntilIdle() profileManagementController.getProfiles().observeForever(mockProfilesObserver) @@ -510,7 +586,10 @@ class ProfileManagementControllerTest { avatarImagePath = null, allowDownloadAccess = it.allowDownloadAccess, colorRgb = -10710042, - isAdmin = false + isAdmin = false, + storyTextSize = it.storyTextSize, + appLanguage = it.appLanguage, + audioLanguage = it.audioLanguage ) } } diff --git a/model/src/main/proto/profile.proto b/model/src/main/proto/profile.proto index b18a669398e..5e7e9776e1c 100644 --- a/model/src/main/proto/profile.proto +++ b/model/src/main/proto/profile.proto @@ -41,6 +41,15 @@ message Profile { // Represents the time the user's profile was created. int64 date_created_timestamp_ms = 9; + + // Represents user selected story-text-size. + float story_text_size = 10; + + // Represents user selected audio-language. + string audio_language = 11; + + // Represents user selected app-language. + string app_language = 12; } // Represents a profile avatar image. @@ -72,3 +81,4 @@ message ProfileChooserUiModel { bool add_profile = 2; } } + From 24b57509574da0e837ee0a04cf08661f4331284f Mon Sep 17 00:00:00 2001 From: Veena Date: Tue, 21 Jan 2020 16:48:34 +0530 Subject: [PATCH 3/9] Revert "Fix part #549 : Options Navigation Drawer Domain layer part 1 (#548)" (#616) This reverts commit fd809362b566a664995ab7732e5f01a836b0784e. --- .../profile/AddProfileActivityPresenter.kt | 8 +- .../app/profile/ProfileActivityPresenter.kt | 5 +- .../app/profile/ProfileChooserFragmentTest.kt | 2 +- .../profile/ProfileEditActivityTest.kt | 5 +- .../profile/ProfileManagementController.kt | 91 +------------------ .../oppia/domain/profile/ProfileTestHelper.kt | 18 +--- .../ProfileManagementControllerTest.kt | 91 ++----------------- model/src/main/proto/profile.proto | 10 -- 8 files changed, 17 insertions(+), 213 deletions(-) diff --git a/app/src/main/java/org/oppia/app/profile/AddProfileActivityPresenter.kt b/app/src/main/java/org/oppia/app/profile/AddProfileActivityPresenter.kt index 447821e07aa..cfb4307155b 100644 --- a/app/src/main/java/org/oppia/app/profile/AddProfileActivityPresenter.kt +++ b/app/src/main/java/org/oppia/app/profile/AddProfileActivityPresenter.kt @@ -41,9 +41,6 @@ class AddProfileActivityPresenter @Inject constructor( private var allowDownloadAccess = false private var inputtedPin = false private var inputtedConfirmPin = false - private var storyTextSize = 14f - private var appLanguage = "English" - private var audioLanguage = "No Audio" @ExperimentalCoroutinesApi fun handleOnCreate() { @@ -114,10 +111,7 @@ class AddProfileActivityPresenter @Inject constructor( avatarImagePath = selectedImage, allowDownloadAccess = allowDownloadAccess, colorRgb = activity.intent.getIntExtra(KEY_ADD_PROFILE_COLOR_RGB, -10710042), - isAdmin = false, - storyTextSize = storyTextSize, - appLanguage = appLanguage, - audioLanguage = audioLanguage + isAdmin = false ) .observe(activity, Observer { handleAddProfileResult(it, binding) diff --git a/app/src/main/java/org/oppia/app/profile/ProfileActivityPresenter.kt b/app/src/main/java/org/oppia/app/profile/ProfileActivityPresenter.kt index dbf2dd10bef..421a2c63147 100644 --- a/app/src/main/java/org/oppia/app/profile/ProfileActivityPresenter.kt +++ b/app/src/main/java/org/oppia/app/profile/ProfileActivityPresenter.kt @@ -21,10 +21,7 @@ class ProfileActivityPresenter @Inject constructor( avatarImagePath = null, allowDownloadAccess = true, colorRgb = -10710042, - isAdmin = true, - storyTextSize = 14f, - appLanguage = "English", - audioLanguage = "No Audio" + isAdmin = true ) activity.setContentView(R.layout.profile_activity) if (getProfileChooserFragment() == null) { diff --git a/app/src/sharedTest/java/org/oppia/app/profile/ProfileChooserFragmentTest.kt b/app/src/sharedTest/java/org/oppia/app/profile/ProfileChooserFragmentTest.kt index 5a056e01669..43dd1bfb7f3 100644 --- a/app/src/sharedTest/java/org/oppia/app/profile/ProfileChooserFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/app/profile/ProfileChooserFragmentTest.kt @@ -133,7 +133,7 @@ class ProfileChooserFragmentTest { @Test fun testProfileChooserFragment_clickAdminProfileWithNoPin_checkOpensAdminPinActivity() { - profileManagementController.addProfile("Sean", "", null, true, -10710042, true, 16f, "English", "English") + profileManagementController.addProfile("Sean", "", null, true, -10710042, true) ActivityScenario.launch(ProfileActivity::class.java).use { onView(atPosition(R.id.profile_recycler_view, 1)).perform(click()) intended(hasComponent(AdminPinActivity::class.java.name)) diff --git a/app/src/sharedTest/java/org/oppia/app/settings/profile/ProfileEditActivityTest.kt b/app/src/sharedTest/java/org/oppia/app/settings/profile/ProfileEditActivityTest.kt index 20936395a80..2b1cc6cd6d0 100644 --- a/app/src/sharedTest/java/org/oppia/app/settings/profile/ProfileEditActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/app/settings/profile/ProfileEditActivityTest.kt @@ -129,10 +129,7 @@ class ProfileEditActivityTest { avatarImagePath = null, allowDownloadAccess = true, colorRgb = -10710042, - isAdmin = false, - storyTextSize = 16f, - appLanguage = "English", - audioLanguage = "No Audio" + isAdmin = false ) ActivityScenario.launch(ProfileEditActivity.createProfileEditActivity(context, 2)).use { onView(withId(R.id.profile_edit_allow_download_switch)).check(matches(isChecked())) diff --git a/domain/src/main/java/org/oppia/domain/profile/ProfileManagementController.kt b/domain/src/main/java/org/oppia/domain/profile/ProfileManagementController.kt index 176e3b1d42b..70d55a86517 100644 --- a/domain/src/main/java/org/oppia/domain/profile/ProfileManagementController.kt +++ b/domain/src/main/java/org/oppia/domain/profile/ProfileManagementController.kt @@ -22,7 +22,9 @@ import org.oppia.util.logging.Logger import org.oppia.util.profile.DirectoryManagementUtil import java.io.File import java.io.FileOutputStream -import java.util.* +import java.lang.Exception +import java.util.Date +import java.util.Locale import javax.inject.Inject import javax.inject.Singleton @@ -35,9 +37,6 @@ private const val UPDATE_DOWNLOAD_ACCESS_TRANSFORMED_PROVIDER_ID = "update_downl private const val LOGIN_PROFILE_TRANSFORMED_PROVIDER_ID = "login_profile_transformed_id" private const val DELETE_PROFILE_TRANSFORMED_PROVIDER_ID = "delete_profile_transformed_id" private const val SET_PROFILE_TRANSFORMED_PROVIDER_ID = "set_profile_transformed_id" -private const val UPDATE_STORY_TEXT_SIZE_TRANSFORMED_ID = "update_story_text_size_transformed_id" -private const val UPDATE_APP_LANGUAGE_TRANSFORMED_PROVIDER_ID = "update_app_language_transformed_id" -private const val UPDATE_AUDIO_LANGUAGE_TRANSFORMED_PROVIDER_ID = "update_audio_language_transformed_id" const val PROFILE_AVATAR_FILE_NAME = "profile_avatar.png" @@ -133,12 +132,8 @@ class ProfileManagementController @Inject constructor( avatarImagePath: Uri?, allowDownloadAccess: Boolean, colorRgb: Int, - isAdmin: Boolean, - storyTextSize: Float?, - appLanguage: String?, - audioLanguage: String? + isAdmin: Boolean ): LiveData> { - if (!onlyLetters(name)) { return MutableLiveData(AsyncResult.failed(ProfileNameOnlyLettersException("$name does not contain only letters"))) } @@ -156,9 +151,6 @@ class ProfileManagementController @Inject constructor( .setAllowDownloadAccess(allowDownloadAccess) .setId(ProfileId.newBuilder().setInternalId(nextProfileId)) .setDateCreatedTimestampMs(Date().time).setIsAdmin(isAdmin) - .setStoryTextSize(storyTextSize!!) - .setAppLanguage(appLanguage) - .setAudioLanguage(audioLanguage) if (avatarImagePath != null) { val imageUri = @@ -258,81 +250,6 @@ class ProfileManagementController @Inject constructor( }) } - /** - * Updates the story text size of the profile. - * - * @param profileId the ID corresponding to the profile being updated. - * @param storyTextSize New text size for the profile being updated. - * @return a [LiveData] that indicates the success/failure of this update operation. - */ - fun updateStoryTextSize( - profileId: ProfileId, storyTextSize: Float - ): LiveData> { - val deferred = profileDataStore.storeDataWithCustomChannelAsync(updateInMemoryCache = true) { - val profile = it.profilesMap[profileId.internalId] ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) - val updatedProfile = profile.toBuilder().setStoryTextSize(storyTextSize).build() - val profileDatabaseBuilder = it.toBuilder().putProfiles(profileId.internalId, updatedProfile) - Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) - } - return dataProviders.convertToLiveData( - dataProviders.createInMemoryDataProviderAsync(UPDATE_STORY_TEXT_SIZE_TRANSFORMED_ID) { - return@createInMemoryDataProviderAsync getDeferredResult(profileId, null, deferred) - }) - } - - /** - * Updates the app language of the profile. - * - * @param profileId the ID corresponding to the profile being updated. - * @param appLanguage New app language for the profile being updated. - * @return a [LiveData] that indicates the success/failure of this update operation. - */ - fun updateAppLanguage( - profileId: ProfileId, appLanguage: String - ): LiveData> { - val deferred = profileDataStore.storeDataWithCustomChannelAsync(updateInMemoryCache = true) { - val profile = it.profilesMap[profileId.internalId] ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) - val updatedProfile = profile.toBuilder().setAppLanguage(appLanguage).build() - val profileDatabaseBuilder = it.toBuilder().putProfiles(profileId.internalId, updatedProfile) - Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) - } - return dataProviders.convertToLiveData( - dataProviders.createInMemoryDataProviderAsync(UPDATE_APP_LANGUAGE_TRANSFORMED_PROVIDER_ID) { - return@createInMemoryDataProviderAsync getDeferredResult(profileId, null, deferred) - }) - } - - /** - * Updates the audio language of the profile. - * - * @param profileId the ID corresponding to the profile being updated. - * @param audioLanguage New audio language for the profile being updated. - * @return a [LiveData] that indicates the success/failure of this update operation. - */ - fun updateAudioLanguage( - profileId: ProfileId, audioLanguage: String - ): LiveData> { - val deferred = profileDataStore.storeDataWithCustomChannelAsync(updateInMemoryCache = true) { - val profile = it.profilesMap[profileId.internalId] ?: return@storeDataWithCustomChannelAsync Pair( - it, - ProfileActionStatus.PROFILE_NOT_FOUND - ) - val updatedProfile = profile.toBuilder().setAudioLanguage(audioLanguage).build() - val profileDatabaseBuilder = it.toBuilder().putProfiles(profileId.internalId, updatedProfile) - Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS) - } - return dataProviders.convertToLiveData( - dataProviders.createInMemoryDataProviderAsync(UPDATE_AUDIO_LANGUAGE_TRANSFORMED_PROVIDER_ID) { - return@createInMemoryDataProviderAsync getDeferredResult(profileId, null, deferred) - }) - } - /** * Log in to the user's Profile by setting the current profile Id and updating profile's last logged in time. * diff --git a/domain/src/main/java/org/oppia/domain/profile/ProfileTestHelper.kt b/domain/src/main/java/org/oppia/domain/profile/ProfileTestHelper.kt index 3ae6a4fefb7..4ad980f0ebe 100644 --- a/domain/src/main/java/org/oppia/domain/profile/ProfileTestHelper.kt +++ b/domain/src/main/java/org/oppia/domain/profile/ProfileTestHelper.kt @@ -17,10 +17,7 @@ class ProfileTestHelper @Inject constructor( avatarImagePath = null, allowDownloadAccess = true, colorRgb = -10710042, - isAdmin = true, - storyTextSize = 16f, - appLanguage = "English", - audioLanguage = "Hindi" + isAdmin = true ) profileManagementController.addProfile( name = "Ben", @@ -28,10 +25,7 @@ class ProfileTestHelper @Inject constructor( avatarImagePath = null, allowDownloadAccess = false, colorRgb = -10710042, - isAdmin = false, - storyTextSize = 16f, - appLanguage = "Hindi", - audioLanguage = "English" + isAdmin = false ) return profileManagementController.loginToProfile(ProfileId.newBuilder().setInternalId(0).build()) } @@ -45,10 +39,7 @@ class ProfileTestHelper @Inject constructor( avatarImagePath = null, allowDownloadAccess = false, colorRgb = -10710042, - isAdmin = false, - storyTextSize = 18f, - appLanguage = "Chinese", - audioLanguage = "French" + isAdmin = false ) } } @@ -60,7 +51,4 @@ class ProfileTestHelper @Inject constructor( /** Login to user profile. */ fun loginToUser() = profileManagementController.loginToProfile(ProfileId.newBuilder().setInternalId(1).build()) - /** Login to user profile. */ - fun loginToUser2() = - profileManagementController.loginToProfile(ProfileId.newBuilder().setInternalId(2).build()) } diff --git a/domain/src/test/java/org/oppia/domain/profile/ProfileManagementControllerTest.kt b/domain/src/test/java/org/oppia/domain/profile/ProfileManagementControllerTest.kt index c81b82ffc91..c389d8a9e7d 100644 --- a/domain/src/test/java/org/oppia/domain/profile/ProfileManagementControllerTest.kt +++ b/domain/src/test/java/org/oppia/domain/profile/ProfileManagementControllerTest.kt @@ -128,10 +128,7 @@ class ProfileManagementControllerTest { avatarImagePath = null, allowDownloadAccess = true, colorRgb = -10710042, - isAdmin = true, - storyTextSize = 14f, - appLanguage = "English", - audioLanguage = "No Audio" + isAdmin = true ).observeForever(mockUpdateResultObserver) advanceUntilIdle() @@ -160,10 +157,7 @@ class ProfileManagementControllerTest { avatarImagePath = null, allowDownloadAccess = false, colorRgb = -10710042, - isAdmin = true, - storyTextSize = 14f, - appLanguage = "English", - audioLanguage = "No Audio" + isAdmin = true ).observeForever(mockUpdateResultObserver) verify(mockUpdateResultObserver, atLeastOnce()).onChanged(updateResultCaptor.capture()) @@ -185,10 +179,7 @@ class ProfileManagementControllerTest { avatarImagePath = null, allowDownloadAccess = false, colorRgb = -10710042, - isAdmin = true, - storyTextSize = 14f, - appLanguage = "English", - audioLanguage = "No Audio" + isAdmin = true ).observeForever(mockUpdateResultObserver) verify(mockUpdateResultObserver, atLeastOnce()).onChanged(updateResultCaptor.capture()) @@ -246,10 +237,7 @@ class ProfileManagementControllerTest { avatarImagePath = null, allowDownloadAccess = false, colorRgb = -10710042, - isAdmin = false, - storyTextSize = 14f, - appLanguage = "English", - audioLanguage = "No Audio" + isAdmin = false ) advanceUntilIdle() profileManagementController.getProfiles().observeForever(mockProfilesObserver) @@ -393,67 +381,6 @@ class ProfileManagementControllerTest { .contains("ProfileId 6 does not match an existing Profile") } - - @Test - @ExperimentalCoroutinesApi - fun testUpdateStoryTextSize_addProfiles_updateWithFontSize18_checkUpdateIsSuccessful() = - runBlockingTest(coroutineContext) { - addTestProfiles() - advanceUntilIdle() - - val profileId = ProfileId.newBuilder().setInternalId(2).build() - profileManagementController.updateStoryTextSize(profileId, 18f) - .observeForever(mockUpdateResultObserver) - advanceUntilIdle() - profileManagementController.getProfile(profileId).observeForever(mockProfileObserver) - - verify(mockUpdateResultObserver, atLeastOnce()).onChanged(updateResultCaptor.capture()) - verify(mockProfileObserver, atLeastOnce()).onChanged(profileResultCaptor.capture()) - assertThat(updateResultCaptor.value.isSuccess()).isTrue() - assertThat(profileResultCaptor.value.isSuccess()).isTrue() - assertThat(profileResultCaptor.value.getOrThrow().storyTextSize).isEqualTo(18f) - } - - @Test - @ExperimentalCoroutinesApi - fun testUpdateAppLanguage_addProfiles_updateWithChineseLanguage_checkUpdateIsSuccessful() = - runBlockingTest(coroutineContext) { - addTestProfiles() - advanceUntilIdle() - - val profileId = ProfileId.newBuilder().setInternalId(2).build() - profileManagementController.updateAppLanguage(profileId, "Chinese") - .observeForever(mockUpdateResultObserver) - advanceUntilIdle() - profileManagementController.getProfile(profileId).observeForever(mockProfileObserver) - - verify(mockUpdateResultObserver, atLeastOnce()).onChanged(updateResultCaptor.capture()) - verify(mockProfileObserver, atLeastOnce()).onChanged(profileResultCaptor.capture()) - assertThat(updateResultCaptor.value.isSuccess()).isTrue() - assertThat(profileResultCaptor.value.isSuccess()).isTrue() - assertThat(profileResultCaptor.value.getOrThrow().appLanguage).isEqualTo("Chinese") - } - - @Test - @ExperimentalCoroutinesApi - fun testUpdateAudioLanguage_addProfiles_updateWithFrenchLanguage_checkUpdateIsSuccessful() = - runBlockingTest(coroutineContext) { - addTestProfiles() - advanceUntilIdle() - - val profileId = ProfileId.newBuilder().setInternalId(2).build() - profileManagementController.updateAudioLanguage(profileId, "French") - .observeForever(mockUpdateResultObserver) - advanceUntilIdle() - profileManagementController.getProfile(profileId).observeForever(mockProfileObserver) - - verify(mockUpdateResultObserver, atLeastOnce()).onChanged(updateResultCaptor.capture()) - verify(mockProfileObserver, atLeastOnce()).onChanged(profileResultCaptor.capture()) - assertThat(updateResultCaptor.value.isSuccess()).isTrue() - assertThat(profileResultCaptor.value.isSuccess()).isTrue() - assertThat(profileResultCaptor.value.getOrThrow().audioLanguage).isEqualTo("French") - } - @Test @ExperimentalCoroutinesApi fun testDeleteProfile_addProfiles_deleteProfile_checkDeletionIsSuccessful() = @@ -490,10 +417,7 @@ class ProfileManagementControllerTest { avatarImagePath = null, allowDownloadAccess = false, colorRgb = -10710042, - isAdmin = true, - storyTextSize = 14f, - appLanguage = "English", - audioLanguage = "No Audio" + isAdmin = true ) advanceUntilIdle() profileManagementController.getProfiles().observeForever(mockProfilesObserver) @@ -586,10 +510,7 @@ class ProfileManagementControllerTest { avatarImagePath = null, allowDownloadAccess = it.allowDownloadAccess, colorRgb = -10710042, - isAdmin = false, - storyTextSize = it.storyTextSize, - appLanguage = it.appLanguage, - audioLanguage = it.audioLanguage + isAdmin = false ) } } diff --git a/model/src/main/proto/profile.proto b/model/src/main/proto/profile.proto index 5e7e9776e1c..b18a669398e 100644 --- a/model/src/main/proto/profile.proto +++ b/model/src/main/proto/profile.proto @@ -41,15 +41,6 @@ message Profile { // Represents the time the user's profile was created. int64 date_created_timestamp_ms = 9; - - // Represents user selected story-text-size. - float story_text_size = 10; - - // Represents user selected audio-language. - string audio_language = 11; - - // Represents user selected app-language. - string app_language = 12; } // Represents a profile avatar image. @@ -81,4 +72,3 @@ message ProfileChooserUiModel { bool add_profile = 2; } } - From 7e52d4d00998a06562bd2e0364a39bb5d107743a Mon Sep 17 00:00:00 2001 From: nikitamarysolomanpvt <54615666+nikitamarysolomanpvt@users.noreply.github.com> Date: Tue, 21 Jan 2020 17:42:40 +0530 Subject: [PATCH 4/9] Fix #535,Fix part of #530: Material bridge theme and card-view issue fix approach -2 (#537) * material bridge theme * nit --- app/build.gradle | 2 +- app/src/main/res/layout/topic_review_summary_view.xml | 2 +- app/src/main/res/values/styles.xml | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 2d123c82098..ddb27864f4e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -75,7 +75,7 @@ dependencies { 'androidx.recyclerview:recyclerview:1.0.0', 'com.chaos.view:pinview:1.4.3', 'com.github.bumptech.glide:glide:4.9.0', - 'com.google.android.material:material:1.0.0-alpha1', + 'com.google.android.material:material:1.2.0-alpha02', 'com.google.dagger:dagger:2.24', 'com.google.guava:guava:28.1-android', 'de.hdodenhof:circleimageview:3.0.1', diff --git a/app/src/main/res/layout/topic_review_summary_view.xml b/app/src/main/res/layout/topic_review_summary_view.xml index ca8e33b0202..cb470d210be 100755 --- a/app/src/main/res/layout/topic_review_summary_view.xml +++ b/app/src/main/res/layout/topic_review_summary_view.xml @@ -15,7 +15,7 @@ android:layout_margin="12dp" android:clipToPadding="true" app:cardCornerRadius="8dp" - app:cardElevation="0dp" + app:cardElevation="4dp" app:cardMaxElevation="4dp" app:strokeColor="@color/oppiaBrown" app:strokeWidth="2dp"> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index b7a02b8f112..ffa7a20eb30 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,13 +1,13 @@ - - - - + + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index ffa7a20eb30..1d2e64e5402 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -96,8 +96,6 @@ @color/colorPrimary @color/colorPrimaryDark @color/colorPrimary - @style/textAllCaps - @style/textAllCaps