Fix illegalstate when managing views

This commit is contained in:
J-Jamet
2020-12-28 11:17:38 +01:00
parent 9522328238
commit 0f6376fb80

View File

@@ -304,7 +304,7 @@ class AdvancedUnlockFragment: StylishFragment(), AdvancedUnlockManager.AdvancedU
@RequiresApi(Build.VERSION_CODES.M) @RequiresApi(Build.VERSION_CODES.M)
private fun openAdvancedUnlockPrompt(cryptoPrompt: AdvancedUnlockCryptoPrompt) { private fun openAdvancedUnlockPrompt(cryptoPrompt: AdvancedUnlockCryptoPrompt) {
requireActivity().runOnUiThread { activity?.runOnUiThread {
if (allowOpenBiometricPrompt) { if (allowOpenBiometricPrompt) {
if (cryptoPrompt.isDeviceCredentialOperation) if (cryptoPrompt.isDeviceCredentialOperation)
keepConnection = true keepConnection = true
@@ -392,7 +392,7 @@ class AdvancedUnlockFragment: StylishFragment(), AdvancedUnlockManager.AdvancedU
&& (biometricMode != Mode.BIOMETRIC_UNAVAILABLE && (biometricMode != Mode.BIOMETRIC_UNAVAILABLE
&& biometricMode != Mode.KEY_MANAGER_UNAVAILABLE) && biometricMode != Mode.KEY_MANAGER_UNAVAILABLE)
mAddBiometricMenuInProgress = false mAddBiometricMenuInProgress = false
requireActivity().invalidateOptionsMenu() activity?.invalidateOptionsMenu()
} }
} }
} }
@@ -446,7 +446,7 @@ class AdvancedUnlockFragment: StylishFragment(), AdvancedUnlockManager.AdvancedU
} }
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) { override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
requireActivity().runOnUiThread { activity?.runOnUiThread {
Log.e(TAG, "Biometric authentication error. Code : $errorCode Error : $errString") Log.e(TAG, "Biometric authentication error. Code : $errorCode Error : $errString")
setAdvancedUnlockedMessageView(errString.toString()) setAdvancedUnlockedMessageView(errString.toString())
} }
@@ -454,7 +454,7 @@ class AdvancedUnlockFragment: StylishFragment(), AdvancedUnlockManager.AdvancedU
@RequiresApi(Build.VERSION_CODES.M) @RequiresApi(Build.VERSION_CODES.M)
override fun onAuthenticationFailed() { override fun onAuthenticationFailed() {
requireActivity().runOnUiThread { activity?.runOnUiThread {
Log.e(TAG, "Biometric authentication failed, biometric not recognized") Log.e(TAG, "Biometric authentication failed, biometric not recognized")
setAdvancedUnlockedMessageView(R.string.advanced_unlock_not_recognized) setAdvancedUnlockedMessageView(R.string.advanced_unlock_not_recognized)
} }
@@ -462,7 +462,7 @@ class AdvancedUnlockFragment: StylishFragment(), AdvancedUnlockManager.AdvancedU
@RequiresApi(Build.VERSION_CODES.M) @RequiresApi(Build.VERSION_CODES.M)
override fun onAuthenticationSucceeded() { override fun onAuthenticationSucceeded() {
requireActivity().runOnUiThread { activity?.runOnUiThread {
when (biometricMode) { when (biometricMode) {
Mode.BIOMETRIC_UNAVAILABLE -> { Mode.BIOMETRIC_UNAVAILABLE -> {
} }
@@ -521,7 +521,7 @@ class AdvancedUnlockFragment: StylishFragment(), AdvancedUnlockManager.AdvancedU
} }
private fun showViews(show: Boolean) { private fun showViews(show: Boolean) {
requireActivity().runOnUiThread { activity?.runOnUiThread {
mAdvancedUnlockInfoView?.visibility = if (show) mAdvancedUnlockInfoView?.visibility = if (show)
View.VISIBLE View.VISIBLE
else { else {
@@ -532,20 +532,20 @@ class AdvancedUnlockFragment: StylishFragment(), AdvancedUnlockManager.AdvancedU
@RequiresApi(Build.VERSION_CODES.M) @RequiresApi(Build.VERSION_CODES.M)
private fun setAdvancedUnlockedTitleView(textId: Int) { private fun setAdvancedUnlockedTitleView(textId: Int) {
requireActivity().runOnUiThread { activity?.runOnUiThread {
mAdvancedUnlockInfoView?.setTitle(textId) mAdvancedUnlockInfoView?.setTitle(textId)
} }
} }
@RequiresApi(Build.VERSION_CODES.M) @RequiresApi(Build.VERSION_CODES.M)
private fun setAdvancedUnlockedMessageView(textId: Int) { private fun setAdvancedUnlockedMessageView(textId: Int) {
requireActivity().runOnUiThread { activity?.runOnUiThread {
mAdvancedUnlockInfoView?.setMessage(textId) mAdvancedUnlockInfoView?.setMessage(textId)
} }
} }
private fun setAdvancedUnlockedMessageView(text: CharSequence) { private fun setAdvancedUnlockedMessageView(text: CharSequence) {
requireActivity().runOnUiThread { activity?.runOnUiThread {
mAdvancedUnlockInfoView?.message = text mAdvancedUnlockInfoView?.message = text
} }
} }