Merge "Report user_cancellation when the user back scroll from the UI activity" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b21390f0b6
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user