From 0551bea9e88cfa10043579528b6aa29dc6c5782b Mon Sep 17 00:00:00 2001 From: Saptak Manna Date: Thu, 20 Jun 2024 21:14:58 +0530 Subject: [PATCH] Gate the new ClassroomListActivity --- .../drawer/NavigationDrawerFragmentPresenter.kt | 11 +++++++++-- .../android/app/mydownloads/MyDownloadsActivity.kt | 13 ++++++++++++- .../app/profile/PinPasswordActivityPresenter.kt | 13 +++++++++++-- .../app/profile/ProfileChooserFragmentPresenter.kt | 14 +++++++++++--- 4 files changed, 43 insertions(+), 8 deletions(-) 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 f76c4cf919e..d967dae7735 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 @@ -16,6 +16,7 @@ import com.google.android.material.navigation.NavigationView import com.google.common.base.Optional import org.oppia.android.R import org.oppia.android.app.administratorcontrols.AdministratorControlsActivity +import org.oppia.android.app.classroom.ClassroomListActivity import org.oppia.android.app.devoptions.DeveloperOptionsStarter import org.oppia.android.app.fragment.FragmentScope import org.oppia.android.app.help.HelpActivity @@ -37,6 +38,8 @@ import org.oppia.android.domain.profile.ProfileManagementController import org.oppia.android.domain.topic.TopicController import org.oppia.android.util.data.AsyncResult import org.oppia.android.util.data.DataProviders.Companion.toLiveData +import org.oppia.android.util.platformparameter.EnableMultipleClassrooms +import org.oppia.android.util.platformparameter.PlatformParameterValue import org.oppia.android.util.statusbar.StatusBarColor import javax.inject.Inject @@ -54,7 +57,8 @@ class NavigationDrawerFragmentPresenter @Inject constructor( private val oppiaLogger: OppiaLogger, private val headerViewModel: NavigationDrawerHeaderViewModel, private val footerViewModel: NavigationDrawerFooterViewModel, - private val developerOptionsStarter: Optional + private val developerOptionsStarter: Optional, + @EnableMultipleClassrooms private val enableMultipleClassrooms: PlatformParameterValue, ) : NavigationView.OnNavigationItemSelectedListener { private lateinit var drawerToggle: ActionBarDrawerToggle private lateinit var drawerLayout: DrawerLayout @@ -233,7 +237,10 @@ class NavigationDrawerFragmentPresenter @Inject constructor( if (previousMenuItemId != menuItemId) { when (NavigationDrawerItem.valueFromNavId(menuItemId)) { NavigationDrawerItem.HOME -> { - val intent = HomeActivity.createHomeActivity(activity, internalProfileId) + val intent = if (enableMultipleClassrooms.value) + ClassroomListActivity.createClassroomListActivity(activity, internalProfileId) + else + HomeActivity.createHomeActivity(activity, internalProfileId) fragment.activity!!.startActivity(intent) drawerLayout.closeDrawers() } 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 9e288a070f4..73376ffb613 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 @@ -5,16 +5,24 @@ import android.content.Intent import android.os.Bundle import org.oppia.android.app.activity.ActivityComponentImpl import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity +import org.oppia.android.app.classroom.ClassroomListActivity import org.oppia.android.app.drawer.NAVIGATION_PROFILE_ID_ARGUMENT_KEY import org.oppia.android.app.home.HomeActivity import org.oppia.android.app.model.ScreenName.MY_DOWNLOADS_ACTIVITY import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.decorateWithScreenName +import org.oppia.android.util.platformparameter.EnableMultipleClassrooms +import org.oppia.android.util.platformparameter.PlatformParameterValue import javax.inject.Inject /** The activity for displaying [MyDownloadsFragment]. */ class MyDownloadsActivity : InjectableAutoLocalizedAppCompatActivity() { @Inject lateinit var myDownloadsActivityPresenter: MyDownloadsActivityPresenter + + @Inject + @EnableMultipleClassrooms + lateinit var enableMultipleClassrooms: PlatformParameterValue + private var internalProfileId: Int = -1 override fun onCreate(savedInstanceState: Bundle?) { @@ -38,7 +46,10 @@ class MyDownloadsActivity : InjectableAutoLocalizedAppCompatActivity() { } override fun onBackPressed() { - val intent = HomeActivity.createHomeActivity(this, internalProfileId) + val intent = if (enableMultipleClassrooms.value) + ClassroomListActivity.createClassroomListActivity(this, internalProfileId) + else + HomeActivity.createHomeActivity(this, internalProfileId) startActivity(intent) finish() } 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 2e5928fb4ac..392f1aa52d7 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 @@ -7,6 +7,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.databinding.DataBindingUtil import androidx.fragment.app.DialogFragment import org.oppia.android.R +import org.oppia.android.app.classroom.ClassroomListActivity import org.oppia.android.app.home.HomeActivity import org.oppia.android.app.model.ProfileId import org.oppia.android.app.translation.AppLanguageResourceHandler @@ -17,6 +18,8 @@ import org.oppia.android.domain.profile.ProfileManagementController import org.oppia.android.util.accessibility.AccessibilityService import org.oppia.android.util.data.AsyncResult import org.oppia.android.util.data.DataProviders.Companion.toLiveData +import org.oppia.android.util.platformparameter.EnableMultipleClassrooms +import org.oppia.android.util.platformparameter.PlatformParameterValue import javax.inject.Inject import kotlin.system.exitProcess @@ -30,7 +33,8 @@ class PinPasswordActivityPresenter @Inject constructor( private val lifecycleSafeTimerFactory: LifecycleSafeTimerFactory, private val pinViewModel: PinPasswordViewModel, private val resourceHandler: AppLanguageResourceHandler, - private val accessibilityService: AccessibilityService + private val accessibilityService: AccessibilityService, + @EnableMultipleClassrooms private val enableMultipleClassrooms: PlatformParameterValue, ) { private var profileId = -1 private lateinit var alertDialog: AlertDialog @@ -93,7 +97,12 @@ class PinPasswordActivityPresenter @Inject constructor( activity, { if (it is AsyncResult.Success) { - activity.startActivity((HomeActivity.createHomeActivity(activity, profileId))) + activity.startActivity( + if (enableMultipleClassrooms.value) + ClassroomListActivity.createClassroomListActivity(activity, profileId) + else + HomeActivity.createHomeActivity(activity, profileId) + ) } } ) 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 9ccd175ea45..21bd0728e8b 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 @@ -14,6 +14,7 @@ import androidx.lifecycle.Transformations import androidx.recyclerview.widget.GridLayoutManager import org.oppia.android.R import org.oppia.android.app.administratorcontrols.AdministratorControlsActivity +import org.oppia.android.app.classroom.ClassroomListActivity import org.oppia.android.app.fragment.FragmentScope import org.oppia.android.app.home.HomeActivity import org.oppia.android.app.model.Profile @@ -27,6 +28,8 @@ import org.oppia.android.domain.oppialogger.analytics.AnalyticsController import org.oppia.android.domain.profile.ProfileManagementController import org.oppia.android.util.data.AsyncResult import org.oppia.android.util.data.DataProviders.Companion.toLiveData +import org.oppia.android.util.platformparameter.EnableMultipleClassrooms +import org.oppia.android.util.platformparameter.PlatformParameterValue import org.oppia.android.util.statusbar.StatusBarColor import javax.inject.Inject @@ -67,7 +70,8 @@ class ProfileChooserFragmentPresenter @Inject constructor( private val profileManagementController: ProfileManagementController, private val oppiaLogger: OppiaLogger, private val analyticsController: AnalyticsController, - private val multiTypeBuilderFactory: BindableAdapter.MultiTypeBuilder.Factory + private val multiTypeBuilderFactory: BindableAdapter.MultiTypeBuilder.Factory, + @EnableMultipleClassrooms private val enableMultipleClassrooms: PlatformParameterValue, ) { private lateinit var binding: ProfileChooserFragmentBinding val hasProfileEverBeenAddedValue = ObservableField(true) @@ -175,11 +179,15 @@ class ProfileChooserFragmentPresenter @Inject constructor( Observer { if (it is AsyncResult.Success) { activity.startActivity( - ( - HomeActivity.createHomeActivity( + if (enableMultipleClassrooms.value) + ClassroomListActivity.createClassroomListActivity( activity, model.profile.id.internalId ) + else + HomeActivity.createHomeActivity( + activity, + model.profile.id.internalId ) ) }