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

Commit 29a44744 authored by Austin Delgado's avatar Austin Delgado
Browse files

Make fallback button optional for Credential View

Use findById instead of requireViewById for fallback button in
CredentialViewBinder. Custom auto or watch layouts may not have fallback button.

Test: AuthContainerViewTest
Flag: EXEMPT bugfix
Bug: 431279910
Change-Id: I5bef169c5b6f70b8c184227b1b049e7f3f2136b3
parent a8d0684b
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ object CredentialViewBinder {
        val errorView: TextView = view.requireViewById(R.id.error)
        val cancelButton: Button? = view.findViewById(R.id.cancel_button)
        val emergencyButtonView: Button = view.requireViewById(R.id.emergencyCallButton)
        val fallbackButton: Button = view.requireViewById(R.id.fallback_button)
        val fallbackButton: Button? = view.findViewById(R.id.fallback_button)

        var errorTimer: Job? = null

@@ -157,7 +157,7 @@ object CredentialViewBinder {
                launch {
                    viewModel.showFallbackButton.collect { showFallback ->
                        if (showFallback) {
                            fallbackButton.visibility = View.VISIBLE
                            fallbackButton?.visibility = View.VISIBLE
                        }
                    }
                }
@@ -165,15 +165,15 @@ object CredentialViewBinder {
                launch {
                    viewModel.fallbackOptions.collect { options ->
                        if (options.count() > 1) {
                            fallbackButton.text =
                            fallbackButton?.text =
                                view.context.getString(R.string.biometric_dialog_fallback_button)
                            fallbackButton.setOnClickListener {
                            fallbackButton?.setOnClickListener {
                                viewModel.onSwitchToFallbackScreen()
                            }
                        } else if (options.count() == 1) {
                            // If only one option, use it as the fallback button
                            fallbackButton.text = options[0].text
                            fallbackButton.setOnClickListener {
                            fallbackButton?.text = options[0].text
                            fallbackButton?.setOnClickListener {
                                legacyCallback.onFallbackOptionPressed(0)
                            }
                        }