summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2023-05-03 05:47:28 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-05-03 05:47:28 +0000
commitb21390f0b6c4815ad68f6e92609ecda9e031cc4c (patch)
treeda59263d7447066d9c6009312cb6db8e56b677fa
parent127453a4760951a48b4e08277249b4c05b921779 (diff)
parentf6bd8b06025c2eeb7663f3ac1c4447847a819570 (diff)
Merge "Report user_cancellation when the user back scroll from the UI activity" into udc-dev
-rw-r--r--packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorActivity.kt16
1 files changed, 15 insertions, 1 deletions
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorActivity.kt b/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorActivity.kt
index 1fb5e3f853b2..54a8678df9cc 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorActivity.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorActivity.kt
@@ -25,6 +25,7 @@ import android.os.Bundle
import android.os.ResultReceiver
import android.util.Log
import androidx.activity.ComponentActivity
+import androidx.activity.OnBackPressedCallback
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.compose.setContent
import androidx.activity.viewModels
@@ -48,11 +49,12 @@ import com.android.credentialmanager.ui.theme.PlatformTheme
class CredentialSelectorActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
+ Log.d(Constants.LOG_TAG, "Creating new CredentialSelectorActivity")
overrideActivityTransition(Activity.OVERRIDE_TRANSITION_OPEN,
0, 0)
overrideActivityTransition(Activity.OVERRIDE_TRANSITION_CLOSE,
0, 0)
- Log.d(Constants.LOG_TAG, "Creating new CredentialSelectorActivity")
+
try {
val (isCancellationRequest, shouldShowCancellationUi, _) =
maybeCancelUIUponRequest(intent)
@@ -61,6 +63,18 @@ class CredentialSelectorActivity : ComponentActivity() {
}
val userConfigRepo = UserConfigRepo(this)
val credManRepo = CredentialManagerRepo(this, intent, userConfigRepo)
+
+ val backPressedCallback = object : OnBackPressedCallback(
+ true // default to enabled
+ ) {
+ override fun handleOnBackPressed() {
+ credManRepo.onUserCancel()
+ Log.d(Constants.LOG_TAG, "Activity back triggered: finish the activity.")
+ this@CredentialSelectorActivity.finish()
+ }
+ }
+ onBackPressedDispatcher.addCallback(this, backPressedCallback)
+
setContent {
PlatformTheme {
CredentialManagerBottomSheet(