Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/oppia#4419' into oppia#4419
Browse files Browse the repository at this point in the history
# Conflicts:
#	utility/src/main/java/org/oppia/android/util/logging/EventTypeToHumanReadableNameConverter.kt
  • Loading branch information
XichengSpencer committed Oct 25, 2024
2 parents 9095025 + 455134c commit 8391237
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 18 deletions.
1 change: 0 additions & 1 deletion app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,6 @@ TEST_DEPS = [
"//utility/src/main/java/org/oppia/android/util/accessibility:test_module",
"//utility/src/main/java/org/oppia/android/util/caching:asset_prod_module",
"//utility/src/main/java/org/oppia/android/util/caching/testing:caching_test_module",
"//utility/src/main/java/org/oppia/android/util/logging:standard_event_logging_configuration_module",
"//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module",
"//utility/src/main/java/org/oppia/android/util/math:math_expression_parser",
"//utility/src/main/java/org/oppia/android/util/networking:debug_module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -43,17 +44,25 @@ class ProfileEditActivity : InjectableAutoLocalizedAppCompatActivity() {
super.onCreate(savedInstanceState)
(activityComponent as ActivityComponentImpl).inject(this)
profileEditActivityPresenter.handleOnCreate()

onBackPressedDispatcher.addCallback(
this,
object : OnBackPressedCallback(/* enabled = */ true) {
override fun handleOnBackPressed() {
this@ProfileEditActivity.handleBackPress()
}
}
)
}

override fun onBackPressed() {
private fun handleBackPress() {
val args = intent.getProtoExtra(
PROFILE_EDIT_ACTIVITY_PARAMS_KEY,
ProfileEditActivityParams.getDefaultInstance()
)
val isMultipane = args?.isMultipane ?: false
if (isMultipane) {
@Suppress("DEPRECATION") // TODO(#5404): Migrate to a back pressed dispatcher.
super.onBackPressed()
finish()
} else {
val intent = Intent(this, ProfileListActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class ProfileEditActivityPresenter @Inject constructor(

toolbar.setNavigationOnClickListener {
if (isMultipane) {
@Suppress("DEPRECATION") // TODO(#5404): Migrate to a back pressed dispatcher.
activity.onBackPressed()
activity.onBackPressedDispatcher.onBackPressed()
} else {
val intent = Intent(activity, ProfileListActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -56,11 +57,16 @@ class QuestionPlayerActivity :
val profileId =
intent.extractCurrentUserProfileId()
questionPlayerActivityPresenter.handleOnCreate(profileId)
}

override fun onBackPressed() {
showStopExplorationDialogFragment()
questionPlayerActivityPresenter.setReadingTextSizeNormal()
onBackPressedDispatcher.addCallback(
this,
object : OnBackPressedCallback(/* enabled = */ true) {
override fun handleOnBackPressed() {
showStopExplorationDialogFragment()
questionPlayerActivityPresenter.setReadingTextSizeNormal()
}
}
)
}

override fun restartSession() = questionPlayerActivityPresenter.restartSession()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,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()
}

retrieveReadingTextSize().observe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.oppia.android.app.walkthrough
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.ProfileId
Expand All @@ -22,6 +23,15 @@ class WalkthroughActivity :
super.onCreate(savedInstanceState)
(activityComponent as ActivityComponentImpl).inject(this)
walkthroughActivityPresenter.handleOnCreate()

onBackPressedDispatcher.addCallback(
this,
object : OnBackPressedCallback(/* enabled = */ true) {
override fun handleOnBackPressed() {
walkthroughActivityPresenter.handleSystemBack()
}
}
)
}

override fun currentPage(walkthroughPage: Int) {
Expand All @@ -33,10 +43,6 @@ class WalkthroughActivity :
walkthroughActivityPresenter.changePage(walkthroughPage)
}

override fun onBackPressed() {
walkthroughActivityPresenter.handleSystemBack()
}

companion object {

fun createWalkthroughActivityIntent(context: Context, internalProfileId: Int): Intent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ class WalkthroughFinalFragmentPresenter @Inject constructor(
}

override fun goBack() {
@Suppress("DEPRECATION") // TODO(#5404): Migrate to a back pressed dispatcher.
activity.onBackPressed()
activity.onBackPressedDispatcher.onBackPressed()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ import javax.inject.Inject
* given event, unlike its name returned by this implementation).
*/
class EventTypeToHumanReadableNameConverter @Inject constructor() {
/**
* Converts an event type to a human-readable name.
*
* @param eventType The type of event to convert.
* @return A human-readable string representation of the event type.
*/
fun convertToHumanReadableName(eventType: ActivityContextCase): String {
return when (eventType) {
ActivityContextCase.OPEN_EXPLORATION_ACTIVITY -> "open_exploration_player_screen"
Expand Down

0 comments on commit 8391237

Please sign in to comment.