From 81df68e1370e5c08169f07e1f69979691dad0ba6 Mon Sep 17 00:00:00 2001 From: IndusAryan <125901294+IndusAryan@users.noreply.github.com> Date: Mon, 11 Mar 2024 03:45:23 +0530 Subject: [PATCH] fix(hotfix): bottom sheet appearing when turning biometrics off and remove toast. (#971) * fix biometric regressions * use nullable context * aha! --- .../com/lagradost/cloudstream3/MainActivity.kt | 3 --- .../ui/account/AccountSelectActivity.kt | 9 +++++---- .../cloudstream3/ui/settings/SettingsAccount.kt | 16 +++++++++++----- app/src/main/res/values/strings.xml | 1 - 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt index fa6cae18..48798ce6 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt @@ -19,7 +19,6 @@ import android.view.View import android.view.ViewGroup import android.view.WindowManager import android.widget.Toast -import android.widget.Toast.LENGTH_LONG import androidx.activity.OnBackPressedCallback import androidx.activity.result.ActivityResultLauncher import androidx.annotation.IdRes @@ -1240,8 +1239,6 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricAu // hide background while authenticating, Sorry moms & dads 🙏 binding?.navHostFragment?.isInvisible = true - } else { - showToast(R.string.phone_not_secured, LENGTH_LONG) } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/account/AccountSelectActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/account/AccountSelectActivity.kt index ccaa38f0..1dae5a0f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/account/AccountSelectActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/account/AccountSelectActivity.kt @@ -4,7 +4,6 @@ import android.annotation.SuppressLint import android.content.Intent import android.os.Bundle import android.util.Log -import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.ViewModelProvider import androidx.preference.PreferenceManager @@ -57,14 +56,16 @@ class AccountSelectActivity : AppCompatActivity(), BiometricAuthenticator.Biomet if (isTruePhone() && authEnabled) { if (deviceHasPasswordPinLock(this)) { - startBiometricAuthentication(this, R.string.biometric_authentication_title, false) + startBiometricAuthentication( + this, + R.string.biometric_authentication_title, + false + ) BiometricAuthenticator.promptInfo?.let { BiometricAuthenticator.biometricPrompt?.authenticate(it) } } - } else { - showToast(R.string.phone_not_secured, Toast.LENGTH_LONG) } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsAccount.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsAccount.kt index d04757da..14f11c1e 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsAccount.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsAccount.kt @@ -11,6 +11,7 @@ import androidx.core.view.isGone import androidx.core.view.isVisible import androidx.fragment.app.FragmentActivity import androidx.preference.PreferenceFragmentCompat +import androidx.preference.PreferenceManager import androidx.recyclerview.widget.RecyclerView import com.lagradost.cloudstream3.AcraApplication.Companion.openBrowser import com.lagradost.cloudstream3.CommonActivity.onDialogDismissedEvent @@ -261,15 +262,20 @@ class SettingsAccount : PreferenceFragmentCompat() { setPreferencesFromResource(R.xml.settings_account, rootKey) getPref(R.string.biometric_key)?.setOnPreferenceClickListener { + val authEnabled = PreferenceManager.getDefaultSharedPreferences( + context ?: return@setOnPreferenceClickListener false + ) + .getBoolean(getString(R.string.biometric_key), false) + if (authEnabled) { BackupUtils.backup(activity) val title = activity?.getString(R.string.biometric_setting) val warning = activity?.getString(R.string.biometric_warning) - activity?.showBottomDialogText( - title as String, - warning.html() - ) { onDialogDismissedEvent } - + activity?.showBottomDialogText( + title as String, + warning.html() + ) { onDialogDismissedEvent } + } true } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f7d58d22..b4f9d14d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -754,7 +754,6 @@ Lock with Biometrics Password/PIN Authentication Biometric authentication is not supported on this device - Please disable fingerprint authentication if device has no lock. Unlock the app with Fingerprint, Face ID, PIN, Pattern and Password. This window will close after few failed attempts. You\'ll have to restart the App. Your CloudStream data has been backed up now, although probability of this rare case is very low but all