Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a60a5d7a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Controls UI - Fix multiple PIN dialog attempts" into rvc-dev

parents b20eb1ca e4dda8bf
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -50,7 +50,8 @@ object ChallengeDialogs {
    fun createPinDialog(
        cvh: ControlViewHolder,
        useAlphaNumeric: Boolean,
        useRetryStrings: Boolean
        useRetryStrings: Boolean,
        onCancel: () -> Unit
    ): Dialog? {
        val lastAction = cvh.lastAction
        if (lastAction == null) {
@@ -86,7 +87,10 @@ object ChallengeDialogs {
            })
            setNegativeButton(
                android.R.string.cancel,
                DialogInterface.OnClickListener { dialog, _ -> dialog.cancel() }
                DialogInterface.OnClickListener { dialog, _ ->
                    onCancel.invoke()
                    dialog.cancel()
                }
            )
        }
        return builder.create().apply {
@@ -111,7 +115,7 @@ object ChallengeDialogs {
    /**
     * AlertDialogs to handle [ControlAction#RESPONSE_CHALLENGE_ACK] response type.
     */
    fun createConfirmationDialog(cvh: ControlViewHolder): Dialog? {
    fun createConfirmationDialog(cvh: ControlViewHolder, onCancel: () -> Unit): Dialog? {
        val lastAction = cvh.lastAction
        if (lastAction == null) {
            Log.e(ControlsUiController.TAG,
@@ -130,7 +134,10 @@ object ChallengeDialogs {
            })
            setNegativeButton(
                android.R.string.cancel,
                DialogInterface.OnClickListener { dialog, _ -> dialog.cancel() }
                DialogInterface.OnClickListener { dialog, _ ->
                    onCancel.invoke()
                    dialog.cancel()
                }
            )
        }
        return builder.create().apply {
+7 −3
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ class ControlViewHolder(
    var behavior: Behavior? = null
    var lastAction: ControlAction? = null
    private var lastChallengeDialog: Dialog? = null
    private val onDialogCancel: () -> Unit = { lastChallengeDialog = null }

    val deviceType: Int
        get() = cws.control?.let { it.getDeviceType() } ?: cws.ci.deviceType
@@ -154,15 +155,18 @@ class ControlViewHolder(
                setTransientStatus(context.resources.getString(R.string.controls_error_failed))
            }
            ControlAction.RESPONSE_CHALLENGE_PIN -> {
                lastChallengeDialog = ChallengeDialogs.createPinDialog(this, false, failedAttempt)
                lastChallengeDialog = ChallengeDialogs.createPinDialog(
                    this, false, failedAttempt, onDialogCancel)
                lastChallengeDialog?.show()
            }
            ControlAction.RESPONSE_CHALLENGE_PASSPHRASE -> {
                lastChallengeDialog = ChallengeDialogs.createPinDialog(this, true, failedAttempt)
                lastChallengeDialog = ChallengeDialogs.createPinDialog(
                    this, false, failedAttempt, onDialogCancel)
                lastChallengeDialog?.show()
            }
            ControlAction.RESPONSE_CHALLENGE_ACK -> {
                lastChallengeDialog = ChallengeDialogs.createConfirmationDialog(this)
                lastChallengeDialog = ChallengeDialogs.createConfirmationDialog(
                    this, onDialogCancel)
                lastChallengeDialog?.show()
            }
        }