From 48980279c003bb9f4dbbb9b1c7eef1a436a642dd Mon Sep 17 00:00:00 2001 From: "Mr. 17" Date: Wed, 29 May 2024 06:34:08 +0530 Subject: [PATCH] Fix part of #5344: Add new feature flag for multiple classrooms (#5410) ## Explanation Fixes part of #5344 This PR introduces a feature flag `ENABLE_MULTIPLE_CLASSROOMS` which will be used to gate the new multiple classrooms screens. ## Essential Checklist - [x] The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".) - [x] Any changes to [scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [x] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [x] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [x] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [x] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)). ## For UI-specific PRs only If your PR includes UI-related changes, then: - Add screenshots for portrait/landscape for both a tablet & phone of the before & after UI changes - For the screenshots above, include both English and pseudo-localized (RTL) screenshots (see [RTL guide](https://github.com/oppia/oppia-android/wiki/RTL-Guidelines)) - Add a video showing the full UX flow with a screen reader enabled (see [accessibility guide](https://github.com/oppia/oppia-android/wiki/Accessibility-A11y-Guide)) - For PRs introducing new UI elements or color changes, both light and dark mode screenshots must be included - Add a screenshot demonstrating that you ran affected Espresso tests locally & that they're passing Co-authored-by: Ben Henning --- .../PlatformParameterAlphaKenyaModule.kt | 14 ++++++++++++++ .../PlatformParameterAlphaModule.kt | 14 ++++++++++++++ .../platformparameter/PlatformParameterModule.kt | 14 ++++++++++++++ .../TestPlatformParameterModule.kt | 16 ++++++++++++++++ .../platformparameter/FeatureFlagConstants.kt | 10 ++++++++++ 5 files changed, 68 insertions(+) diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt index 634755addb5..657ed9f43d1 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt @@ -15,6 +15,8 @@ import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.ENABLE_MULTIPLE_CLASSROOMS +import org.oppia.android.util.platformparameter.ENABLE_MULTIPLE_CLASSROOMS_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_NPS_SURVEY import org.oppia.android.util.platformparameter.ENABLE_NPS_SURVEY_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_ONBOARDING_FLOW_V2 @@ -31,6 +33,7 @@ import org.oppia.android.util.platformparameter.EnableFastLanguageSwitchingInLes import org.oppia.android.util.platformparameter.EnableInteractionConfigChangeStateRetention import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds +import org.oppia.android.util.platformparameter.EnableMultipleClassrooms import org.oppia.android.util.platformparameter.EnableNpsSurvey import org.oppia.android.util.platformparameter.EnableOnboardingFlowV2 import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection @@ -335,4 +338,15 @@ class PlatformParameterAlphaKenyaModule { ENABLE_ONBOARDING_FLOW_V2_DEFAULT_VALUE ) } + + @Provides + @EnableMultipleClassrooms + fun provideEnableMultipleClassrooms( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter(ENABLE_MULTIPLE_CLASSROOMS) + ?: PlatformParameterValue.createDefaultParameter( + ENABLE_MULTIPLE_CLASSROOMS_DEFAULT_VALUE + ) + } } diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt index 8f2b2769bdb..b9b9b92c338 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt @@ -15,6 +15,8 @@ import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.ENABLE_MULTIPLE_CLASSROOMS +import org.oppia.android.util.platformparameter.ENABLE_MULTIPLE_CLASSROOMS_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_NPS_SURVEY import org.oppia.android.util.platformparameter.ENABLE_NPS_SURVEY_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_ONBOARDING_FLOW_V2 @@ -30,6 +32,7 @@ import org.oppia.android.util.platformparameter.EnableFastLanguageSwitchingInLes import org.oppia.android.util.platformparameter.EnableInteractionConfigChangeStateRetention import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds +import org.oppia.android.util.platformparameter.EnableMultipleClassrooms import org.oppia.android.util.platformparameter.EnableNpsSurvey import org.oppia.android.util.platformparameter.EnableOnboardingFlowV2 import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection @@ -330,4 +333,15 @@ class PlatformParameterAlphaModule { ENABLE_ONBOARDING_FLOW_V2_DEFAULT_VALUE ) } + + @Provides + @EnableMultipleClassrooms + fun provideEnableMultipleClassrooms( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter(ENABLE_MULTIPLE_CLASSROOMS) + ?: PlatformParameterValue.createDefaultParameter( + ENABLE_MULTIPLE_CLASSROOMS_DEFAULT_VALUE + ) + } } diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt index fdca7c4cc41..2bafaedf87d 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt @@ -15,6 +15,8 @@ import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.ENABLE_MULTIPLE_CLASSROOMS +import org.oppia.android.util.platformparameter.ENABLE_MULTIPLE_CLASSROOMS_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_NPS_SURVEY import org.oppia.android.util.platformparameter.ENABLE_NPS_SURVEY_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_ONBOARDING_FLOW_V2 @@ -31,6 +33,7 @@ import org.oppia.android.util.platformparameter.EnableFastLanguageSwitchingInLes import org.oppia.android.util.platformparameter.EnableInteractionConfigChangeStateRetention import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds +import org.oppia.android.util.platformparameter.EnableMultipleClassrooms import org.oppia.android.util.platformparameter.EnableNpsSurvey import org.oppia.android.util.platformparameter.EnableOnboardingFlowV2 import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection @@ -332,4 +335,15 @@ class PlatformParameterModule { ENABLE_ONBOARDING_FLOW_V2_DEFAULT_VALUE ) } + + @Provides + @EnableMultipleClassrooms + fun provideEnableMultipleClassrooms( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter(ENABLE_MULTIPLE_CLASSROOMS) + ?: PlatformParameterValue.createDefaultParameter( + ENABLE_MULTIPLE_CLASSROOMS_DEFAULT_VALUE + ) + } } diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt index 7eb105d2b97..baaae39a962 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt @@ -14,6 +14,7 @@ import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.ENABLE_MULTIPLE_CLASSROOMS_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_NPS_SURVEY_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_ONBOARDING_FLOW_V2_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE @@ -25,6 +26,7 @@ import org.oppia.android.util.platformparameter.EnableFastLanguageSwitchingInLes import org.oppia.android.util.platformparameter.EnableInteractionConfigChangeStateRetention import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds +import org.oppia.android.util.platformparameter.EnableMultipleClassrooms import org.oppia.android.util.platformparameter.EnableNpsSurvey import org.oppia.android.util.platformparameter.EnableOnboardingFlowV2 import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection @@ -283,6 +285,12 @@ class TestPlatformParameterModule { return PlatformParameterValue.createDefaultParameter(enableOnboardingFlowV2) } + @Provides + @EnableMultipleClassrooms + fun provideEnableMultipleClassrooms(): PlatformParameterValue { + return PlatformParameterValue.createDefaultParameter(enableMultipleClassrooms) + } + companion object { private var enableDownloadsSupport = ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE private var enableEditAccountsOptionsUi = ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE @@ -302,6 +310,7 @@ class TestPlatformParameterModule { private var gracePeriodInDays = NPS_SURVEY_GRACE_PERIOD_IN_DAYS_DEFAULT_VALUE private var enableNpsSurvey = ENABLE_NPS_SURVEY_DEFAULT_VALUE private var enableOnboardingFlowV2 = ENABLE_ONBOARDING_FLOW_V2_DEFAULT_VALUE + private var enableMultipleClassrooms = ENABLE_MULTIPLE_CLASSROOMS_DEFAULT_VALUE @VisibleForTesting(otherwise = VisibleForTesting.NONE) fun forceEnableDownloadsSupport(value: Boolean) { @@ -368,6 +377,12 @@ class TestPlatformParameterModule { enableOnboardingFlowV2 = value } + /** Enables forcing [EnableMultipleClassrooms] platform parameter flag from tests. */ + @VisibleForTesting(otherwise = VisibleForTesting.NONE) + fun forceEnableMultipleClassrooms(value: Boolean) { + enableMultipleClassrooms = value + } + /** Enables forcing [EnableAppAndOsDeprecation] feature flag from tests. */ @VisibleForTesting(otherwise = VisibleForTesting.NONE) fun forceEnableAppAndOsDeprecation(value: Boolean) { @@ -387,6 +402,7 @@ class TestPlatformParameterModule { enablePerformanceMetricsCollection = ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE enableAppAndOsDeprecation = ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE enableOnboardingFlowV2 = ENABLE_ONBOARDING_FLOW_V2_DEFAULT_VALUE + enableMultipleClassrooms = ENABLE_MULTIPLE_CLASSROOMS_DEFAULT_VALUE } } } diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt index 0739648c1fa..4b65f954c7a 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt @@ -176,3 +176,13 @@ const val ENABLE_ONBOARDING_FLOW_V2 = "enable_onboarding_flow_v2" /** Default value of the feature flag corresponding to [EnableOnboardingFlowV2]. */ const val ENABLE_ONBOARDING_FLOW_V2_DEFAULT_VALUE = false + +/** Qualifier for the feature flag that toggles the new multiple classrooms. */ +@Qualifier +annotation class EnableMultipleClassrooms + +/** Name of the feature flag that toggles the new multiple classrooms. */ +const val ENABLE_MULTIPLE_CLASSROOMS = "enable_multiple_classrooms" + +/** Default value of the feature flag corresponding to [EnableMultipleClassrooms]. */ +const val ENABLE_MULTIPLE_CLASSROOMS_DEFAULT_VALUE = false