Skip to content

Commit

Permalink
Gate the new ClassroomListActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
theMr17 committed Jun 20, 2024
1 parent d621144 commit 0551bea
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -54,7 +57,8 @@ class NavigationDrawerFragmentPresenter @Inject constructor(
private val oppiaLogger: OppiaLogger,
private val headerViewModel: NavigationDrawerHeaderViewModel,
private val footerViewModel: NavigationDrawerFooterViewModel,
private val developerOptionsStarter: Optional<DeveloperOptionsStarter>
private val developerOptionsStarter: Optional<DeveloperOptionsStarter>,
@EnableMultipleClassrooms private val enableMultipleClassrooms: PlatformParameterValue<Boolean>,
) : NavigationView.OnNavigationItemSelectedListener {
private lateinit var drawerToggle: ActionBarDrawerToggle
private lateinit var drawerLayout: DrawerLayout
Expand Down Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean>

private var internalProfileId: Int = -1

override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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<Boolean>,
) {
private var profileId = -1
private lateinit var alertDialog: AlertDialog
Expand Down Expand Up @@ -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)
)
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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<Boolean>,
) {
private lateinit var binding: ProfileChooserFragmentBinding
val hasProfileEverBeenAddedValue = ObservableField<Boolean>(true)
Expand Down Expand Up @@ -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
)
)
}
Expand Down

0 comments on commit 0551bea

Please sign in to comment.