diff --git a/app/src/main/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivity.kt b/app/src/main/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivity.kt index 2cda2286d02..c0b89421a33 100644 --- a/app/src/main/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivity.kt +++ b/app/src/main/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivity.kt @@ -3,6 +3,7 @@ package org.oppia.android.app.administratorcontrols import android.content.Context import android.content.Intent import android.os.Bundle +import androidx.activity.OnBackPressedCallback import org.oppia.android.R import org.oppia.android.app.activity.ActivityComponentImpl import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity @@ -83,6 +84,33 @@ class AdministratorControlsActivity : isProfileDeletionDialogVisible ) title = resourceHandler.getStringInLocale(R.string.administrator_controls) + handleBackPress() + } + + private fun handleBackPress() { + onBackPressedDispatcher.addCallback( + this@AdministratorControlsActivity, + object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + val fragment = + supportFragmentManager.findFragmentById( + R.id.administrator_controls_fragment_multipane_placeholder + ) + /* + * If the current fragment is ProfileListFragment then the activity should end on back press. + * If it's instead ProfileEditFragment then profileListFragment should be inflated via + * handleOnBackPressed. + */ + if (fragment is ProfileEditFragment) { + administratorControlsActivityPresenter.handleOnBackPressed() + } else { + isEnabled = false + onBackPressedDispatcher.onBackPressed() + isEnabled = true + } + } + } + ) } override fun routeToAppVersion() { @@ -121,24 +149,6 @@ class AdministratorControlsActivity : } } - override fun onBackPressed() { - val fragment = - supportFragmentManager.findFragmentById( - R.id.administrator_controls_fragment_multipane_placeholder - ) - /* - * If the current fragment is ProfileListFragment then the activity should end on back press. - * If it's instead ProfileEditFragment then profileListFragment should be inflated via - * handleOnBackPressed. - */ - if (fragment is ProfileEditFragment) { - administratorControlsActivityPresenter.handleOnBackPressed() - } else { - @Suppress("DEPRECATION") // TODO(#5404): Migrate to a back pressed dispatcher. - super.onBackPressed() - } - } - override fun loadProfileList() { lastLoadedFragment = PROFILE_LIST_FRAGMENT administratorControlsActivityPresenter diff --git a/app/src/main/java/org/oppia/android/app/administratorcontrols/appversion/AppVersionActivity.kt b/app/src/main/java/org/oppia/android/app/administratorcontrols/appversion/AppVersionActivity.kt index e41600bb929..eed542e207e 100644 --- a/app/src/main/java/org/oppia/android/app/administratorcontrols/appversion/AppVersionActivity.kt +++ b/app/src/main/java/org/oppia/android/app/administratorcontrols/appversion/AppVersionActivity.kt @@ -4,6 +4,7 @@ import android.content.Context import android.content.Intent import android.os.Bundle import android.view.MenuItem +import androidx.activity.OnBackPressedCallback import org.oppia.android.app.activity.ActivityComponentImpl import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity import org.oppia.android.app.model.ScreenName.APP_VERSION_ACTIVITY @@ -19,16 +20,29 @@ class AppVersionActivity : InjectableAutoLocalizedAppCompatActivity() { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) appVersionActivityPresenter.handleOnCreate() + handleBackPress() } override fun onOptionsItemSelected(item: MenuItem): Boolean { if (item.itemId == android.R.id.home) { - @Suppress("DEPRECATION") // TODO(#5404): Migrate to a back pressed dispatcher. - onBackPressed() + onBackPressedDispatcher.onBackPressed() } return super.onOptionsItemSelected(item) } + private fun handleBackPress() { + onBackPressedDispatcher.addCallback( + this@AppVersionActivity, + object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + isEnabled = false + onBackPressedDispatcher.onBackPressed() + isEnabled = true + } + } + ) + } + companion object { /** Returns an [Intent] to start this activity. */ fun createAppVersionActivityIntent(context: Context): Intent { diff --git a/app/src/main/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdActivity.kt b/app/src/main/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdActivity.kt index cf6fb025db6..f30ea370552 100644 --- a/app/src/main/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdActivity.kt +++ b/app/src/main/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdActivity.kt @@ -4,6 +4,7 @@ import android.content.Context import android.content.Intent import android.os.Bundle import android.view.MenuItem +import androidx.activity.OnBackPressedCallback import org.oppia.android.app.activity.ActivityComponentImpl import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity import org.oppia.android.app.model.ScreenName.PROFILE_AND_DEVICE_ID_ACTIVITY @@ -24,16 +25,28 @@ class ProfileAndDeviceIdActivity : InjectableAutoLocalizedAppCompatActivity() { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) profileAndDeviceIdActivityPresenter.handleOnCreate() + handleBackPress() } override fun onOptionsItemSelected(item: MenuItem): Boolean { if (item.itemId == android.R.id.home) { - @Suppress("DEPRECATION") // TODO(#5404): Migrate to a back pressed dispatcher. - onBackPressed() + onBackPressedDispatcher.onBackPressed() } return super.onOptionsItemSelected(item) } + private fun handleBackPress() { + onBackPressedDispatcher.addCallback( + this@ProfileAndDeviceIdActivity, + object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + isEnabled = false + onBackPressedDispatcher.onBackPressed() + isEnabled = true + } + } + ) + } companion object { /** Returns an [Intent] to launch [ProfileAndDeviceIdActivity]. */ fun createIntent(context: Context): Intent { diff --git a/app/src/main/java/org/oppia/android/app/devoptions/markchapterscompleted/MarkChaptersCompletedActivity.kt b/app/src/main/java/org/oppia/android/app/devoptions/markchapterscompleted/MarkChaptersCompletedActivity.kt index ec8979dad41..0dedb0e8b84 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/markchapterscompleted/MarkChaptersCompletedActivity.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/markchapterscompleted/MarkChaptersCompletedActivity.kt @@ -4,6 +4,7 @@ import android.content.Context import android.content.Intent import android.os.Bundle import android.view.MenuItem +import androidx.activity.OnBackPressedCallback import org.oppia.android.R import org.oppia.android.app.activity.ActivityComponentImpl import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity @@ -37,12 +38,25 @@ class MarkChaptersCompletedActivity : InjectableAutoLocalizedAppCompatActivity() val showConfirmationNotice = args?.showConfirmationNotice ?: false markChaptersCompletedActivityPresenter.handleOnCreate(internalProfileId, showConfirmationNotice) title = resourceHandler.getStringInLocale(R.string.mark_chapters_completed_activity_title) + handleBackPress() + } + + private fun handleBackPress() { + onBackPressedDispatcher.addCallback( + this@MarkChaptersCompletedActivity, + object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + isEnabled = false + onBackPressedDispatcher.onBackPressed() + isEnabled = true + } + } + ) } override fun onOptionsItemSelected(item: MenuItem): Boolean { if (item.itemId == android.R.id.home) { - @Suppress("DEPRECATION") // TODO(#5404): Migrate to a back pressed dispatcher. - onBackPressed() + onBackPressedDispatcher.onBackPressed() } return super.onOptionsItemSelected(item) } diff --git a/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedActivity.kt b/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedActivity.kt index e3373fc7df6..bb68866c9ed 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedActivity.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/MarkStoriesCompletedActivity.kt @@ -4,6 +4,7 @@ import android.content.Context import android.content.Intent import android.os.Bundle import android.view.MenuItem +import androidx.activity.OnBackPressedCallback import org.oppia.android.R import org.oppia.android.app.activity.ActivityComponentImpl import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity @@ -34,12 +35,25 @@ class MarkStoriesCompletedActivity : InjectableAutoLocalizedAppCompatActivity() internalProfileId = profileId?.internalId ?: -1 markStoriesCompletedActivityPresenter.handleOnCreate(internalProfileId) title = resourceHandler.getStringInLocale(R.string.mark_stories_completed_activity_title) + handleBackPress() + } + + private fun handleBackPress() { + onBackPressedDispatcher.addCallback( + this@MarkStoriesCompletedActivity, + object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + isEnabled = false + onBackPressedDispatcher.onBackPressed() + isEnabled = true + } + } + ) } override fun onOptionsItemSelected(item: MenuItem): Boolean { if (item.itemId == android.R.id.home) { - @Suppress("DEPRECATION") // TODO(#5404): Migrate to a back pressed dispatcher. - onBackPressed() + onBackPressedDispatcher.onBackPressed() } return super.onOptionsItemSelected(item) } diff --git a/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedActivity.kt b/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedActivity.kt index a891de3a059..8fe9011083a 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedActivity.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/MarkTopicsCompletedActivity.kt @@ -4,6 +4,7 @@ import android.content.Context import android.content.Intent import android.os.Bundle import android.view.MenuItem +import androidx.activity.OnBackPressedCallback import org.oppia.android.R import org.oppia.android.app.activity.ActivityComponentImpl import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity @@ -34,12 +35,25 @@ class MarkTopicsCompletedActivity : InjectableAutoLocalizedAppCompatActivity() { internalProfileId = profileId?.internalId ?: -1 markTopicsCompletedActivityPresenter.handleOnCreate(internalProfileId) title = resourceHandler.getStringInLocale(R.string.mark_topics_completed_activity_title) + handleBackPress() + } + + private fun handleBackPress() { + onBackPressedDispatcher.addCallback( + this@MarkTopicsCompletedActivity, + object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + isEnabled = false + onBackPressedDispatcher.onBackPressed() + isEnabled = true + } + } + ) } override fun onOptionsItemSelected(item: MenuItem): Boolean { if (item.itemId == android.R.id.home) { - @Suppress("DEPRECATION") // TODO(#5404): Migrate to a back pressed dispatcher. - onBackPressed() + onBackPressedDispatcher.onBackPressed() } return super.onOptionsItemSelected(item) } diff --git a/app/src/main/java/org/oppia/android/app/options/ReadingTextSizeActivity.kt b/app/src/main/java/org/oppia/android/app/options/ReadingTextSizeActivity.kt index e88525841b5..f2717cb9065 100644 --- a/app/src/main/java/org/oppia/android/app/options/ReadingTextSizeActivity.kt +++ b/app/src/main/java/org/oppia/android/app/options/ReadingTextSizeActivity.kt @@ -3,6 +3,7 @@ package org.oppia.android.app.options import android.content.Context import android.content.Intent import android.os.Bundle +import androidx.activity.OnBackPressedCallback import org.oppia.android.app.activity.ActivityComponentImpl import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity import org.oppia.android.app.model.ReadingTextSize @@ -34,6 +35,18 @@ class ReadingTextSizeActivity : InjectableAutoLocalizedAppCompatActivity() { savedInstanceState?.retrieveStateBundle()?.selectedReadingTextSize ?: retrieveActivityParams().readingTextSize readingTextSizeActivityPresenter.handleOnCreate(readingTextSize) + handleBackPress() + } + + private fun handleBackPress() { + onBackPressedDispatcher.addCallback( + this@ReadingTextSizeActivity, + object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + onBackPressedDispatcher.onBackPressed() + } + } + ) } companion object { diff --git a/app/src/main/java/org/oppia/android/app/options/ReadingTextSizeActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/options/ReadingTextSizeActivityPresenter.kt index 85eedd9d379..491ad80fb11 100644 --- a/app/src/main/java/org/oppia/android/app/options/ReadingTextSizeActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/options/ReadingTextSizeActivityPresenter.kt @@ -28,8 +28,7 @@ class ReadingTextSizeActivityPresenter @Inject constructor( private fun setToolbar() { val readingTextSizeToolbar: Toolbar = activity.findViewById(R.id.reading_text_size_toolbar) readingTextSizeToolbar.setNavigationOnClickListener { - @Suppress("DEPRECATION") // TODO(#5404): Migrate to a back pressed dispatcher. - activity.onBackPressed() + activity.onBackPressedDispatcher.onBackPressed() } } diff --git a/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivity.kt b/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivity.kt index 4e73ac992e3..35a829542ec 100755 --- a/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivity.kt +++ b/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivity.kt @@ -3,6 +3,7 @@ package org.oppia.android.app.player.exploration import android.content.Context import android.content.Intent import android.os.Bundle +import androidx.activity.OnBackPressedCallback import org.oppia.android.app.activity.ActivityComponentImpl import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity import org.oppia.android.app.hintsandsolution.HintsAndSolutionDialogFragment @@ -66,6 +67,20 @@ class ExplorationActivity : params.parentScreen, params.isCheckpointingEnabled ) + handleBackPress() + } + + private fun handleBackPress() { + onBackPressedDispatcher.addCallback( + this@ExplorationActivity, + object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + isEnabled = true + onBackPressedDispatcher.onBackPressed() + isEnabled = false + } + } + ) } // TODO(#1655): Re-restrict access to fields in tests post-Gradle. diff --git a/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivityPresenter.kt index 76812ff7522..91527d3cee2 100644 --- a/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivityPresenter.kt @@ -111,8 +111,7 @@ class ExplorationActivityPresenter @Inject constructor( } binding.explorationToolbar.setNavigationOnClickListener { - @Suppress("DEPRECATION") // TODO(#5404): Migrate to a back pressed dispatcher. - activity.onBackPressed() + activity.onBackPressedDispatcher.onBackPressed() } binding.actionAudioPlayer.setOnClickListener { diff --git a/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonActivity.kt b/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonActivity.kt index 9ffbd1969e3..486edf748d3 100644 --- a/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonActivity.kt +++ b/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonActivity.kt @@ -3,6 +3,7 @@ package org.oppia.android.app.resumelesson import android.content.Context import android.content.Intent import android.os.Bundle +import androidx.activity.OnBackPressedCallback import org.oppia.android.app.activity.ActivityComponentImpl import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity import org.oppia.android.app.home.RouteToExplorationListener @@ -37,6 +38,20 @@ class ResumeLessonActivity : params.parentScreen, params.checkpoint ) + handleBackPress() + } + + private fun handleBackPress() { + onBackPressedDispatcher.addCallback( + this@ResumeLessonActivity, + object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + isEnabled = false + onBackPressedDispatcher.onBackPressed() + isEnabled = true + } + } + ) } // TODO(#1655): Re-restrict access to fields in tests post-Gradle. diff --git a/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonActivityPresenter.kt index e6cbc39c507..3cabfab80e3 100644 --- a/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonActivityPresenter.kt @@ -33,8 +33,7 @@ class ResumeLessonActivityPresenter @Inject constructor( activity.setSupportActionBar(resumeLessonToolbar) resumeLessonToolbar.setNavigationOnClickListener { - @Suppress("DEPRECATION") // TODO(#5404): Migrate to a back pressed dispatcher. - activity.onBackPressed() + activity.onBackPressedDispatcher.onBackPressed() } if (getResumeLessonFragment() == null) { diff --git a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditActivity.kt b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditActivity.kt index c595bd367ca..c8b31f3fc92 100644 --- a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditActivity.kt +++ b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditActivity.kt @@ -3,6 +3,7 @@ package org.oppia.android.app.settings.profile import android.content.Context import android.content.Intent import android.os.Bundle +import androidx.activity.OnBackPressedCallback import org.oppia.android.app.activity.ActivityComponentImpl import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity import org.oppia.android.app.model.ProfileEditActivityParams @@ -43,21 +44,24 @@ class ProfileEditActivity : InjectableAutoLocalizedAppCompatActivity() { super.onCreate(savedInstanceState) (activityComponent as ActivityComponentImpl).inject(this) profileEditActivityPresenter.handleOnCreate() + handleBackPress() } - override fun onBackPressed() { - val args = intent.getProtoExtra( - PROFILE_EDIT_ACTIVITY_PARAMS_KEY, - ProfileEditActivityParams.getDefaultInstance() + private fun handleBackPress() { + onBackPressedDispatcher.addCallback( + this@ProfileEditActivity, + object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + val isMultipane: Boolean = intent.extras!!.getBoolean(IS_MULTIPANE_EXTRA_KEY, false) + if (isMultipane) { + onBackPressedDispatcher.onBackPressed() + } else { + val intent = Intent(this@ProfileEditActivity, ProfileListActivity::class.java) + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) + startActivity(intent) + } + } + } ) - val isMultipane = args?.isMultipane ?: false - if (isMultipane) { - @Suppress("DEPRECATION") // TODO(#5404): Migrate to a back pressed dispatcher. - super.onBackPressed() - } else { - val intent = Intent(this, ProfileListActivity::class.java) - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) - startActivity(intent) - } } } diff --git a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditActivityPresenter.kt index ea67fb89474..9adcb402c29 100644 --- a/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/settings/profile/ProfileEditActivityPresenter.kt @@ -1,6 +1,5 @@ package org.oppia.android.app.settings.profile -import android.content.Intent import android.view.View import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar @@ -30,14 +29,7 @@ class ProfileEditActivityPresenter @Inject constructor( val isMultipane = args?.isMultipane ?: false toolbar.setNavigationOnClickListener { - if (isMultipane) { - @Suppress("DEPRECATION") // TODO(#5404): Migrate to a back pressed dispatcher. - activity.onBackPressed() - } else { - val intent = Intent(activity, ProfileListActivity::class.java) - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) - activity.startActivity(intent) - } + activity.onBackPressedDispatcher.onBackPressed() } if (getProfileEditFragment() == null) { diff --git a/app/src/main/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivity.kt b/app/src/main/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivity.kt index 1f4a1c57e74..202267462f3 100644 --- a/app/src/main/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivity.kt +++ b/app/src/main/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivity.kt @@ -3,6 +3,7 @@ package org.oppia.android.app.topic.questionplayer import android.content.Context import android.content.Intent import android.os.Bundle +import androidx.activity.OnBackPressedCallback import org.oppia.android.app.activity.ActivityComponentImpl import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity import org.oppia.android.app.hintsandsolution.HintsAndSolutionListener @@ -53,10 +54,21 @@ class QuestionPlayerActivity : val profileId = intent.extractCurrentUserProfileId() questionPlayerActivityPresenter.handleOnCreate(profileId) + handleBackPress() } - override fun onBackPressed() { - showStopExplorationDialogFragment() + private fun handleBackPress() { + onBackPressedDispatcher.addCallback( + this@QuestionPlayerActivity, + object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + isEnabled = false + showStopExplorationDialogFragment() + onBackPressedDispatcher.onBackPressed() + isEnabled = true + } + } + ) } override fun restartSession() = questionPlayerActivityPresenter.restartSession() diff --git a/app/src/main/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityPresenter.kt index c705384c950..7d610d0b8e1 100644 --- a/app/src/main/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityPresenter.kt @@ -50,8 +50,7 @@ class QuestionPlayerActivityPresenter @Inject constructor( activity.setSupportActionBar(binding.questionPlayerToolbar) binding.questionPlayerToolbar.setNavigationOnClickListener { - @Suppress("DEPRECATION") // TODO(#5404): Migrate to a back pressed dispatcher. - activity.onBackPressed() + activity.onBackPressedDispatcher.onBackPressed() } if (getQuestionPlayerFragment() == null) {