Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix #4606: Language selector feature implementation #4762

Merged
merged 157 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
451ee75
Refactor codebase in relation to #1628, change previous use of string…
KevinGitonga Nov 24, 2022
6db708a
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga Nov 24, 2022
98e7541
Add languages_proto dependency to profile_proto file.
KevinGitonga Nov 28, 2022
b404965
Add languages_proto dependency to arguments.proto.
KevinGitonga Nov 28, 2022
50ba462
Fix Bazel issue.
KevinGitonga Nov 28, 2022
b6f929f
Fix Bazel buildifier check failure issue.
KevinGitonga Nov 28, 2022
b226b21
Fix Bazel buildifier check failure issue.
KevinGitonga Nov 28, 2022
d2fdbc2
Merge remote-tracking branch 'origin/language_selector_feature' into …
KevinGitonga Nov 28, 2022
f91a939
Revert some refactor changes causing test failures.
KevinGitonga Nov 29, 2022
fee73f0
Revert some refactor changes on AppLanguageLocaleHandlerTest.
KevinGitonga Nov 29, 2022
87b7d63
Refactor ProfileManagementControllerTest changes to use OppiaLanguage.
KevinGitonga Nov 29, 2022
51ba347
Refactor ProfileManagementControllerTest changes to use OppiaLanguage.
KevinGitonga Nov 29, 2022
c38f28e
Changes for feature #1628 and Revert LanguageConfigRetriever to initial.
KevinGitonga Dec 14, 2022
0c572a4
Add Kdoc for retrieveAppLanguageSelection.
KevinGitonga Dec 14, 2022
ed80cc3
Add Bazel config no load "supported_languages" for translations. Fix …
KevinGitonga Dec 16, 2022
d134b03
Remove log declarations.
KevinGitonga Dec 16, 2022
826d63d
Update not to use OppiaLanguage due to logic change in TranslationCon…
KevinGitonga Dec 19, 2022
3c21b26
Roll back and intergrate some changes which were breaking some tests …
KevinGitonga Dec 20, 2022
dead613
Fix language changes not applying to activities in the Backstack afte…
KevinGitonga Dec 30, 2022
d65771e
Remove log statements used for debugging.
KevinGitonga Dec 30, 2022
6ee8cd7
Revert some changes.
KevinGitonga Jan 4, 2023
3bb2931
Merge branch 'develop' into language_selector_feature
KevinGitonga Jan 4, 2023
0c03454
Rename AppLanguage usage instances to OppiaLanguage.
KevinGitonga Jan 5, 2023
f13584e
Revert to using ProfileManagementController to access user selected O…
KevinGitonga Jan 9, 2023
abe14fa
Refactor more failing tests.
KevinGitonga Jan 9, 2023
4bec9a7
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga Jan 9, 2023
ac4867c
Remove redundant kdoc exemption for AppLanguageActivity .
KevinGitonga Jan 9, 2023
fb5ed18
Refactor AppLanguageFragmentTest.kt tests namings to Portuguese as Fr…
KevinGitonga Jan 9, 2023
555f4a3
Remove unnecessary language update on AppLanguageFragmentPresenter.kt
KevinGitonga Jan 11, 2023
0b2ebb8
Revert changes on AppLanguageFragmentPresenter.kt.
KevinGitonga Jan 11, 2023
0de3c63
Clean up and disable espresso tests for AppLanguageFragmentTest.kt.
KevinGitonga Jan 12, 2023
8baf438
Merge branch 'develop' into language_selector_feature
KevinGitonga Jan 13, 2023
55f6877
List only langs with "app_string_id", add language changes verificati…
KevinGitonga Jan 20, 2023
9453d65
Merge remote-tracking branch 'origin/language_selector_feature' into …
KevinGitonga Jan 20, 2023
085eef2
Add language definition list verification testcases.
KevinGitonga Jan 20, 2023
d31a472
Fix test naming typo.
KevinGitonga Jan 20, 2023
b1a5fb9
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga Jan 20, 2023
bc596d2
Update proto files per reviewer comments, add more TranslationControl…
KevinGitonga Jan 26, 2023
ad54de3
Update tests, change to use DataProviders to prevent blocking UI thread.
KevinGitonga Jan 30, 2023
a1af140
Remove log statement.
KevinGitonga Jan 30, 2023
2d512c0
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga Jan 30, 2023
69d1c93
Fix failing tests.
KevinGitonga Jan 30, 2023
5f0e877
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga Jan 31, 2023
759f404
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga Feb 20, 2023
528a272
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga Feb 22, 2023
f861552
Fix issue with per profile language changes.
KevinGitonga Feb 28, 2023
4067e45
Patch failing tests.
KevinGitonga Feb 28, 2023
8f40694
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga Mar 1, 2023
f6116fc
Fix ProfileChooserActivity picking up profile's language issue.
KevinGitonga Mar 2, 2023
626ae9b
Fix ProfileChooserActivity picking up profile's language issue.
KevinGitonga Mar 2, 2023
3fdf582
Update to shouldUseSystemLanguage for consistency.
KevinGitonga Mar 3, 2023
5e09570
Update to shouldUseSystemLanguage for consistency.
KevinGitonga Mar 3, 2023
50dbc06
Updates based on reviewer's comments.
KevinGitonga Mar 14, 2023
9b1e378
Merge branch 'develop' into language_selector_feature
KevinGitonga Mar 14, 2023
7a3a22e
Revert and similarly pick up some changes from develop which were pot…
KevinGitonga Mar 15, 2023
845a479
Revert some changes breaking some tests.
KevinGitonga Mar 15, 2023
f61381c
Revert "Merge branch 'develop' into language_selector_feature"
KevinGitonga Mar 16, 2023
de8e207
Merge remote-tracking branch 'origin/language_selector_feature' into …
KevinGitonga Mar 16, 2023
2bb78a0
Fix some merge conflicts.
KevinGitonga Mar 16, 2023
8ecdcc2
Revert some changes breaking tests.
KevinGitonga Mar 16, 2023
146cb74
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga Mar 17, 2023
0a2c986
Integrate some changes into TranslationController.kt and remove close…
KevinGitonga Mar 17, 2023
7aa661f
Refactor to use subclasses to allow activities to use either system l…
KevinGitonga Mar 20, 2023
76cc116
Refactor to use subclasses to allow activities to use either system l…
KevinGitonga Mar 20, 2023
f091ff6
Add screen-name exemption for InjectableSystemLocalizedAppCompatActi…
KevinGitonga Mar 20, 2023
8132896
Add exemption regex check for InjectableSystemLocalizedAppCompatActiv…
KevinGitonga Mar 20, 2023
9060391
Refactor to access ProfileId from top level Activity.
KevinGitonga Mar 20, 2023
6a5f5e6
Add tests for computeLocalizedDisplayName and more updates based on r…
KevinGitonga Mar 20, 2023
eedb376
Merge branch 'develop' into language_selector_feature
KevinGitonga Mar 21, 2023
4be3833
Revert "Revert "Merge branch 'develop' into language_selector_feature""
KevinGitonga Mar 23, 2023
339a078
Revert "Revert "Merge branch 'develop' into language_selector_feature""
KevinGitonga Mar 23, 2023
25f0e6e
Merge remote-tracking branch 'origin/language_selector_feature' into …
KevinGitonga Mar 23, 2023
a5ac839
Revert some files affecting branch after revert.
KevinGitonga Mar 23, 2023
e1b3d7b
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga Mar 23, 2023
920ea2e
Fix failing tests for AppLanguageWatcherMixin.kt.
KevinGitonga Mar 24, 2023
02c732b
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga Mar 24, 2023
233c315
Remove log statement.
KevinGitonga Mar 24, 2023
2120fbc
Remove log statement.
KevinGitonga Mar 24, 2023
51f2986
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga Apr 5, 2023
f772b05
Revert some changes on TranslationController.kt.
KevinGitonga Apr 5, 2023
0d9cfee
Update to inherit from InjectableAppCompatActivity.kt.
KevinGitonga Apr 5, 2023
162b8e9
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga Apr 6, 2023
cbd45e9
Address more reviewer comments.
KevinGitonga Apr 6, 2023
9ef4920
Update screenname regex check.
KevinGitonga Apr 6, 2023
ef4677e
Fix buildifier issue.
KevinGitonga Apr 6, 2023
0cc9a8a
Remove failing "updateAppLanguage" tests failing after reverting to P…
KevinGitonga Apr 6, 2023
752cbf6
Fix regex fails due to refactor.
KevinGitonga Apr 6, 2023
3ac3a24
Fix NIT in TranslationController.kt getAppLanguageSelection KDOC.
KevinGitonga Apr 7, 2023
9cd1253
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga Apr 11, 2023
9e2abb1
Add changes per reviewer's comment's.
KevinGitonga Apr 12, 2023
3b20c6f
Add changes per reviewer's comment's.
KevinGitonga Apr 14, 2023
00df29a
Add KDOC's to InjectableAppCompatActivity.kt.
KevinGitonga Apr 14, 2023
92cbf3f
Update regex checks.
KevinGitonga Apr 14, 2023
175cf58
Fix buildifier issue.
KevinGitonga Apr 14, 2023
c601895
Fix some Failing test's.
KevinGitonga Apr 14, 2023
ca5c9e8
Update to use only TranslationController.kt as the single point of tr…
KevinGitonga Apr 17, 2023
ce11b00
Remove some needless test from ProfileManagementControllerTest.kt, te…
KevinGitonga Apr 18, 2023
fb63686
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga Apr 18, 2023
abcd4be
Updates to fix some failing tests.
KevinGitonga Apr 19, 2023
08c35be
Update language selection UI constant.
KevinGitonga Apr 19, 2023
34a13df
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga Apr 21, 2023
4e91fd5
More updates per reviewer's comments.
KevinGitonga Apr 24, 2023
b861875
More updates per reviewer's comments.
KevinGitonga Apr 24, 2023
bec1c37
Ignore some Junit tests as they won't run.
KevinGitonga Apr 25, 2023
fbbb4f4
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga Apr 26, 2023
accaebd
Update files to fix back navigation issue after language change.
KevinGitonga Apr 26, 2023
d8daa19
Merge remote-tracking branch 'origin/language_selector_feature' into …
KevinGitonga Apr 26, 2023
d5e848c
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga Apr 27, 2023
7249adf
Update files to fix back navigation issue after language change, add …
KevinGitonga Apr 27, 2023
574bf3c
Fix Buildifier and lint issues.
KevinGitonga Apr 27, 2023
8d9e583
Fix OptionsFragmentTest.kt test issues.
KevinGitonga Apr 27, 2023
8116b92
Update run config.
KevinGitonga Apr 27, 2023
41d91f5
Update tests, remove logs.
KevinGitonga Apr 27, 2023
fee15c2
Update tests run config for ActivityLanguageLocaleHandlerTest.kt.
KevinGitonga Apr 27, 2023
a5553b8
Update tests run config for ActivityLanguageLocaleHandlerTest.kt.
KevinGitonga Apr 28, 2023
71feffd
Update tests for ActivityLanguageLocaleHandlerTest.kt.
KevinGitonga Apr 28, 2023
eae0051
Update tests.
KevinGitonga Apr 28, 2023
c59e8a2
Revert some changes.
KevinGitonga Apr 30, 2023
3668d53
Remove some tests.
KevinGitonga Apr 30, 2023
1fd82ee
Update some tests for OptionsFragmentTest.kt to run on Espresso Bazel…
KevinGitonga May 2, 2023
f6f4edd
Changes per reviewer's comment's.
KevinGitonga May 4, 2023
193730d
Fix bazel buildifier issue.
KevinGitonga May 4, 2023
58c5748
Remove affected files from Kdoc exemption.
KevinGitonga May 4, 2023
4293e7c
Update Kdocs for updated files.
KevinGitonga May 4, 2023
6471ddd
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga May 5, 2023
a3fc1be
Minor fixes to patch failing test's.
KevinGitonga May 7, 2023
135d95d
Patch missing Kdocs.
KevinGitonga May 7, 2023
9f7490a
Fix dagger issue, update ActivityLanguageLocaleHandlerTest.kt tests.
KevinGitonga May 8, 2023
b72c654
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga May 9, 2023
96725f4
update OptionControlsViewModel.kt.
KevinGitonga May 9, 2023
9e43be3
Merge remote-tracking branch 'origin/language_selector_feature' into …
KevinGitonga May 9, 2023
f1cbceb
Remove duplicate value.
KevinGitonga May 10, 2023
500ac0f
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga May 10, 2023
b7525a1
Fix some failing test's.
KevinGitonga May 10, 2023
13778bd
Remove runOnUIThread().
KevinGitonga May 11, 2023
8f9c9c3
Update test's.
KevinGitonga May 15, 2023
8619cbf
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga May 15, 2023
f366187
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga May 16, 2023
1097ffb
Fix some of the failing test's.
KevinGitonga May 16, 2023
a9790c6
Merge remote-tracking branch 'origin/language_selector_feature' into …
KevinGitonga May 16, 2023
525ff78
update platform param for language_selection_ui.
KevinGitonga May 17, 2023
1d8543e
Revert some files affecting branch after revert.
KevinGitonga May 18, 2023
094981b
Properly update KDOC'S per reviewer's comment's.
KevinGitonga May 19, 2023
46582ef
Add Kdoc's for more classes.
KevinGitonga May 19, 2023
e4a8b0c
Fix Kdoc's issue.
KevinGitonga May 19, 2023
e723fe0
Revert Kdoc reference breaking some test's.
KevinGitonga May 22, 2023
b708d42
Merge branch 'oppia:develop' into language_selector_feature
KevinGitonga May 29, 2023
b48dc2b
Update Kdoc's format.
KevinGitonga May 29, 2023
c1e382b
Updates per reviewers comments.
KevinGitonga May 31, 2023
e9adabd
Merge branch 'develop' into language_selector_feature
BenHenning May 31, 2023
e1993e4
Bunch of KDoc fixes.
BenHenning May 31, 2023
9b3d39c
Merge branch 'language_selector_feature' into finalize-language-selector
BenHenning May 31, 2023
18643ea
More fixes and finalization.
BenHenning Jun 1, 2023
2641bad
Re-disable language selection feature flag.
BenHenning Jun 1, 2023
a723e44
Fix broken tests & issues.
BenHenning Jun 1, 2023
27e0ee4
Merge pull request #5 from BenHenning/finalize-language-selector
KevinGitonga Jun 1, 2023
bc1ae8a
Merge branch 'develop' into language_selector_feature
BenHenning Jun 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ package_group(
multidex = apk_flavor_metadata["multidex"],
deps = [
"//app/src/main/java/org/oppia/android/app/application/dev:developer_application",
"//config/src/java/org/oppia/android/config:all_languages_config",
],
)
for apk_flavor_metadata in [
Expand Down
3 changes: 2 additions & 1 deletion app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,8 @@ kt_android_library(
":view_models",
":views",
"//app/src/main/java/org/oppia/android/app/activity:activity_intent_factories_shim",
"//app/src/main/java/org/oppia/android/app/activity:injectable_app_compat_activity",
"//app/src/main/java/org/oppia/android/app/activity:injectable_auto_localized_app_compat_activity",
"//app/src/main/java/org/oppia/android/app/activity:injectable_system_localized_app_compat_activity",
"//app/src/main/java/org/oppia/android/app/activity/route:activity_router",
"//app/src/main/java/org/oppia/android/app/fragment:injectable_bottom_sheet_dialog_fragment",
"//app/src/main/java/org/oppia/android/app/fragment:injectable_dialog_fragment",
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def filesToExclude = [
'**/*AppLanguageLocaleHandlerTest*.kt',
'**/*AppLanguageResourceHandlerTest*.kt',
'**/*AppLanguageWatcherMixinTest*.kt',
'**/*ActivityLanguageLocaleHandlerTest*.kt'
]
_excludeSourceFiles(filesToExclude)

Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/org/oppia/android/app/activity/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ kt_android_library(
],
)

kt_android_library(
name = "injectable_auto_localized_app_compat_activity",
srcs = ["InjectableAutoLocalizedAppCompatActivity.kt"],
visibility = ["//app:app_visibility"],
deps = [":injectable_app_compat_activity"],
)

kt_android_library(
name = "injectable_system_localized_app_compat_activity",
srcs = ["InjectableSystemLocalizedAppCompatActivity.kt"],
visibility = ["//app:app_visibility"],
deps = [":injectable_app_compat_activity"],
)

kt_android_library(
name = "activity_component",
srcs = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import org.oppia.android.app.fragment.FragmentComponentBuilderInjector
import org.oppia.android.app.fragment.FragmentComponentFactory
import org.oppia.android.app.translation.AppLanguageActivityInjector
import org.oppia.android.app.translation.AppLanguageActivityInjectorProvider
import org.oppia.android.app.translation.AppLanguageApplicationInjectorProvider

import org.oppia.android.app.translation.AppLanguageWatcherMixin
/**
* An [AppCompatActivity] that facilitates field injection to child activities and constituent
* fragments that extend [org.oppia.android.app.fragment.InjectableFragment].
Expand All @@ -31,7 +30,7 @@ abstract class InjectableAppCompatActivity :
"Expected attached Context to have an application context defined."
}
onInitializeActivityComponent(applicationContext)
val newConfiguration = onInitializeLocalization(applicationContext, newBase)
val newConfiguration = onInitializeLocalization(newBase)
super.attachBaseContext(newBase?.createConfigurationContext(newConfiguration))
}

Expand All @@ -58,26 +57,33 @@ abstract class InjectableAppCompatActivity :
}

private fun onInitializeLocalization(
applicationContext: Context,
newBase: Context?
): Configuration {
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
// Given how DataProviders work (i.e. by resolving data races using eventual consistency), it's
// possible to miss some updates in really unlikely situations. No additional work will be done
// to prevent these data races unless they're actually hit by users. It shouldn't, in practice,
// be possible since it requires changing the system language between activity transitions, and
// in most cases that should result in an activity recreation by the mixin, anyway.
val appLanguageAppInjectorProvider =
applicationContext as AppLanguageApplicationInjectorProvider
val appLanguageAppInjector = appLanguageAppInjectorProvider.getAppLanguageApplicationInjector()
val appLanguageActivityInjector = activityComponent as AppLanguageActivityInjector
val appLanguageLocaleHandler = appLanguageAppInjector.getAppLanguageHandler()
val appLanguageWatcherMixin = appLanguageActivityInjector.getAppLanguageWatcherMixin()
appLanguageWatcherMixin.initialize()
val activityLanguageInjectorProvider = this as AppLanguageActivityInjectorProvider
val activityLanguageActivityInjector =
activityLanguageInjectorProvider.getAppLanguageActivityInjector()
val activityLanguageLocaleHandler =
activityLanguageActivityInjector.getActivityLanguageHandler()

val appLanguageWatcherMixin = activityLanguageActivityInjector.getAppLanguageWatcherMixin()
initializeMixin(appLanguageWatcherMixin)

return Configuration(newBase?.resources?.configuration).also { newConfiguration ->
appLanguageLocaleHandler.initializeLocaleForActivity(newConfiguration)
activityLanguageLocaleHandler.initializeLocaleForActivity(newConfiguration)
}
}

/**
* Initializes [appLanguageWatcherMixin] based on the localization requirements of the implementation.
* This should never be directly implemented by non-abstract activity classes.
*/
abstract fun initializeMixin(appLanguageWatcherMixin: AppLanguageWatcherMixin)

private fun ensureLayoutDirection() {
// Ensure the root decor view has the correct layout direct setup per the base context. In some
// cases, Android will let the app recreate the activity & properly update the layout direction
Expand Down
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.oppia.android.app.activity

import androidx.appcompat.app.AppCompatActivity
import org.oppia.android.app.translation.AppLanguageWatcherMixin

/**
* An [AppCompatActivity] that facilitates field injection to child activities and constituent
* fragments that extend [org.oppia.android.app.fragment.InjectableFragment].
*
* This should be extended by all activities which should be automatically localized based on the
* user's selected app language.
*/
abstract class InjectableAutoLocalizedAppCompatActivity : InjectableAppCompatActivity() {

override fun initializeMixin(appLanguageWatcherMixin: AppLanguageWatcherMixin) {
appLanguageWatcherMixin.initialize(shouldOnlyUseSystemLanguage = false)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.oppia.android.app.activity

import androidx.appcompat.app.AppCompatActivity
import org.oppia.android.app.translation.AppLanguageWatcherMixin

/**
* An [AppCompatActivity] that facilitates field injection to child activities and constituent
* fragments that extend [org.oppia.android.app.fragment.InjectableFragment].
*
* This should be extended by all activities which should be system localized or use the
* device default language.
*/
abstract class InjectableSystemLocalizedAppCompatActivity : InjectableAppCompatActivity() {

override fun initializeMixin(appLanguageWatcherMixin: AppLanguageWatcherMixin) {
appLanguageWatcherMixin.initialize(shouldOnlyUseSystemLanguage = true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.content.Intent
import android.os.Bundle
import org.oppia.android.R
import org.oppia.android.app.activity.ActivityComponentImpl
import org.oppia.android.app.activity.InjectableAppCompatActivity
import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity
import org.oppia.android.app.administratorcontrols.appversion.AppVersionActivity
import org.oppia.android.app.administratorcontrols.learneranalytics.ProfileAndDeviceIdActivity
import org.oppia.android.app.drawer.NAVIGATION_PROFILE_ID_ARGUMENT_KEY
Expand Down Expand Up @@ -47,7 +47,7 @@ const val PROFILE_AND_DEVICE_ID_FRAGMENT = "PROFILE_AND_DEVICE_ID_FRAGMENT"

/** Activity [AdministratorControlsActivity] that allows user to change admin controls. */
class AdministratorControlsActivity :
InjectableAppCompatActivity(),
InjectableAutoLocalizedAppCompatActivity(),
RouteToProfileListListener,
RouteToAppVersionListener,
RouteToLearnerAnalyticsListener,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,17 @@ class AdministratorControlsFragmentPresenter @Inject constructor(
}

private enum class ViewType {
/** Represents [View] for the general section. */
VIEW_TYPE_GENERAL,
/** Represents [View] for the profile section. */
VIEW_TYPE_PROFILE,
/** Represents [View] for the download permissions section. */
VIEW_TYPE_DOWNLOAD_PERMISSIONS,
/** Represents [View] for the app information section. */
VIEW_TYPE_APP_INFORMATION,
/** Represents [View] for the account actions section. */
VIEW_TYPE_ACCOUNT_ACTIONS,
/** Represents [View] for the learner analytics section. */
VIEW_TYPE_LEARNER_ANALYTICS
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import org.oppia.android.app.profile.ProfileChooserActivity
class LogoutDialogFragment : InjectableDialogFragment() {

companion object {
/** [String] key to access [LogoutDialogFragment]. */
const val TAG_LOGOUT_DIALOG_FRAGMENT = "TAG_LOGOUT_DIALOG_FRAGMENT"

/** Returns a new [LogoutDialogFragment] instance. */
fun newInstance(): LogoutDialogFragment {
return LogoutDialogFragment()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ package org.oppia.android.app.administratorcontrols

/** Listener for when an activity should route to [AppVersionActivity]. */
interface RouteToAppVersionListener {
/** Called when [AppVersionActivity] should be loaded. */
fun routeToAppVersion()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.oppia.android.app.administratorcontrols.ShowLogoutDialogListener
class AdministratorControlsAccountActionsViewModel(
private val showLogoutDialogListener: ShowLogoutDialogListener
) : AdministratorControlsItemViewModel() {

/** Called when user clicks logout on [AdministratorControlsActivity]. */
fun onLogOutClicked() {
showLogoutDialogListener.showLogoutDialog()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class AdministratorControlsAppInformationViewModel(
private val routeToAppVersionListener = activity as RouteToAppVersionListener
private val loadAppVersionListener = activity as LoadAppVersionListener

/** Called when a user clicks on AppVersion in [AdministratorControlsActivity]. */
fun onAppVersionClicked() {
if (isMultipane.get()!!) {
loadAppVersionListener.loadAppVersion()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ class AdministratorControlsDownloadPermissionsViewModel(
private val userProfileId: ProfileId,
deviceSettings: DeviceSettings
) : AdministratorControlsItemViewModel() {
/**
* [Boolean] observable value showing if topic downloads and updates should happen only on Wifi.
*/
val isTopicWifiUpdatePermission =
ObservableField<Boolean>(deviceSettings.allowDownloadAndUpdateOnlyOnWifi)
/** [Boolean] observable value showing if topic updates should happen automatically. */
val isTopicAutoUpdatePermission =
ObservableField<Boolean>(deviceSettings.automaticallyUpdateTopics)

/** Called when topic wifi update permission changes. */
fun onTopicWifiUpdatePermissionChanged() {
profileManagementController.updateWifiPermissionDeviceSettings(
userProfileId,
Expand All @@ -42,6 +47,7 @@ class AdministratorControlsDownloadPermissionsViewModel(
)
}

/** Called when topic auto update permission changes. */
fun onTopicAutoUpdatePermissionChanged() {
profileManagementController.updateTopicAutomaticallyPermissionDeviceSettings(
userProfileId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ package org.oppia.android.app.administratorcontrols.administratorcontrolsitemvie
import androidx.databinding.ObservableField
import org.oppia.android.app.viewmodel.ObservableViewModel

/** Super-class for generalising different views for the recyclerView in [AdministratorControlsFragment] */
/**
* Super-class for generalising different views for the recyclerView in
* [AdministratorControlsFragment].
*/
abstract class AdministratorControlsItemViewModel : ObservableViewModel() {
/** [Boolean] observable value showing if [View] is multipane. */
val isMultipane = ObservableField<Boolean>(false)
/** [Int] representing the index of items bound in [AdministratorControlsActivity]. */
val itemIndex = ObservableField<Int>()
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class AdministratorControlsProfileViewModel(
private val loadProfileListListener: LoadProfileListListener
) : AdministratorControlsItemViewModel() {

/** Called when a user clicks on EditProfiles in [AdministratorControlsActivity]. */
fun onEditProfilesClicked() {
if (isMultipane.get()!!) {
loadProfileListListener.loadProfileList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import android.content.Intent
import android.os.Bundle
import android.view.MenuItem
import org.oppia.android.app.activity.ActivityComponentImpl
import org.oppia.android.app.activity.InjectableAppCompatActivity
import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity
import org.oppia.android.app.model.ScreenName.APP_VERSION_ACTIVITY
import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.decorateWithScreenName
import javax.inject.Inject

/** Activity for App Version. */
class AppVersionActivity : InjectableAppCompatActivity() {
class AppVersionActivity : InjectableAutoLocalizedAppCompatActivity() {
@Inject
lateinit var appVersionActivityPresenter: AppVersionActivityPresenter

Expand All @@ -29,6 +29,7 @@ class AppVersionActivity : InjectableAppCompatActivity() {
}

companion object {
/** Returns an [Intent] to start this activity. */
fun createAppVersionActivityIntent(context: Context): Intent {
return Intent(context, AppVersionActivity::class.java).apply {
decorateWithScreenName(APP_VERSION_ACTIVITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import javax.inject.Inject
/** The presenter for [AppVersionActivity]. */
@ActivityScope
class AppVersionActivityPresenter @Inject constructor(private val activity: AppCompatActivity) {

/** Initializes the [AppVersionActivity] views and binds [AppVersionFragment]. */
fun handleOnCreate() {
activity.setContentView(R.layout.app_version_activity)
setToolbar()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class AppVersionFragmentPresenter @Inject constructor(
) {
private lateinit var binding: AppVersionFragmentBinding

/** Initializes and creates the views for the [AppVersionFragment]. */
fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View? {
binding = AppVersionFragmentBinding.inflate(
inflater,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.oppia.android.app.utility.getVersionName
import org.oppia.android.app.viewmodel.ObservableViewModel
import javax.inject.Inject

/** [ViewModel] for [AppVersionFragment]*/
/** [ViewModel] for [AppVersionFragment]. */
@FragmentScope
class AppVersionViewModel @Inject constructor(
private val resourceHandler: AppLanguageResourceHandler,
Expand All @@ -20,9 +20,11 @@ class AppVersionViewModel @Inject constructor(
private val versionName: String = context.getVersionName()
private val lastUpdateDateTime = context.getLastUpdateTime()

/** Returns a localized, human-readable app version name. */
fun computeVersionNameText(): String =
resourceHandler.getStringInLocaleWithWrapping(R.string.app_version_name, versionName)

/** Returns a localized, human-readable lastUpdateDateTime. */
fun computeLastUpdatedDateText(): String =
resourceHandler.getStringInLocaleWithWrapping(
R.string.app_last_update_date, getDateTime(lastUpdateDateTime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.content.Intent
import android.os.Bundle
import android.view.MenuItem
import org.oppia.android.app.activity.ActivityComponentImpl
import org.oppia.android.app.activity.InjectableAppCompatActivity
import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity
import org.oppia.android.app.model.ScreenName.PROFILE_AND_DEVICE_ID_ACTIVITY
import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.decorateWithScreenName
import javax.inject.Inject
Expand All @@ -17,7 +17,7 @@ import javax.inject.Inject
* These IDs are meant to help facilitators of app user studies correspond specific logged events to
* a particular user or group.
*/
class ProfileAndDeviceIdActivity : InjectableAppCompatActivity() {
class ProfileAndDeviceIdActivity : InjectableAutoLocalizedAppCompatActivity() {
@Inject lateinit var profileAndDeviceIdActivityPresenter: ProfileAndDeviceIdActivityPresenter

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ class CompletedStoryItemViewModel(
private val intentFactoryShim: IntentFactoryShim,
translationController: TranslationController
) : ObservableViewModel(), RouteToTopicPlayStoryListener {
/** Holds lazily loaded completedStoryName [String] value. */
val completedStoryName by lazy {
translationController.extractString(
completedStory.storyTitle, completedStory.storyWrittenTranslationContext
)
}
/** Holds lazily loaded topicName [String] value. */
val topicName by lazy {
translationController.extractString(
completedStory.topicTitle, completedStory.topicWrittenTranslationContext
)
}

/** Called when user clicks on CompletedStoryItem. */
fun onCompletedStoryItemClicked() {
routeToTopicPlayStory(internalProfileId, completedStory.topicId, completedStory.storyId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import org.oppia.android.app.activity.ActivityComponentImpl
import org.oppia.android.app.activity.InjectableAppCompatActivity
import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity
import org.oppia.android.app.model.ScreenName.COMPLETED_STORY_LIST_ACTIVITY
import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.decorateWithScreenName
import javax.inject.Inject

/** Activity for completed stories. */
class CompletedStoryListActivity : InjectableAppCompatActivity() {
class CompletedStoryListActivity : InjectableAutoLocalizedAppCompatActivity() {
@Inject
lateinit var completedStoryListActivityPresenter: CompletedStoryListActivityPresenter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import javax.inject.Inject
class CompletedStoryListActivityPresenter @Inject constructor(
private val activity: AppCompatActivity
) {

/** Initializes views for [CompletedStoryListActivity] and binds [CompletedStoryListFragment]. */
fun handleOnCreate(internalProfileId: Int) {
activity.setContentView(R.layout.completed_story_list_activity)
if (getCompletedStoryListFragment() == null) {
Expand Down
Loading