mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
merge with upstream #2
This commit is contained in:
parent
8ba2fb8046
commit
bbcf02487c
3 changed files with 5 additions and 9 deletions
|
@ -23,8 +23,10 @@ import com.lagradost.cloudstream3.ui.settings.Globals.PHONE
|
||||||
import com.lagradost.cloudstream3.ui.settings.Globals.TV
|
import com.lagradost.cloudstream3.ui.settings.Globals.TV
|
||||||
import com.lagradost.cloudstream3.ui.settings.Globals.isLayout
|
import com.lagradost.cloudstream3.ui.settings.Globals.isLayout
|
||||||
import com.lagradost.cloudstream3.utils.BiometricAuthenticator
|
import com.lagradost.cloudstream3.utils.BiometricAuthenticator
|
||||||
|
import com.lagradost.cloudstream3.utils.BiometricAuthenticator.biometricPrompt
|
||||||
import com.lagradost.cloudstream3.utils.BiometricAuthenticator.deviceHasPasswordPinLock
|
import com.lagradost.cloudstream3.utils.BiometricAuthenticator.deviceHasPasswordPinLock
|
||||||
import com.lagradost.cloudstream3.utils.BiometricAuthenticator.isAuthEnabled
|
import com.lagradost.cloudstream3.utils.BiometricAuthenticator.isAuthEnabled
|
||||||
|
import com.lagradost.cloudstream3.utils.BiometricAuthenticator.promptInfo
|
||||||
import com.lagradost.cloudstream3.utils.BiometricAuthenticator.startBiometricAuthentication
|
import com.lagradost.cloudstream3.utils.BiometricAuthenticator.startBiometricAuthentication
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.accounts
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.accounts
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.selectedKeyIndex
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.selectedKeyIndex
|
||||||
|
@ -64,8 +66,8 @@ class AccountSelectActivity : AppCompatActivity(), BiometricAuthenticator.Biomet
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
BiometricAuthenticator.promptInfo?.let { prompt ->
|
promptInfo?.let { prompt ->
|
||||||
BiometricAuthenticator.biometricPrompt?.authenticate(prompt)
|
biometricPrompt?.authenticate(prompt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,7 +298,7 @@ class SettingsAccount : PreferenceFragmentCompat(), BiometricAuthenticator.Biome
|
||||||
setPreferencesFromResource(R.xml.settings_account, rootKey)
|
setPreferencesFromResource(R.xml.settings_account, rootKey)
|
||||||
// hide preference on tvs and emulators
|
// hide preference on tvs and emulators
|
||||||
if (!isLayout(PHONE)) {
|
if (!isLayout(PHONE)) {
|
||||||
getPref(R.string.biometric_key)?.isVisible = false
|
getPref(R.string.biometric_key)?.isEnabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
getPref(R.string.biometric_key)?.setOnPreferenceClickListener {
|
getPref(R.string.biometric_key)?.setOnPreferenceClickListener {
|
||||||
|
|
|
@ -37,7 +37,6 @@ object BiometricAuthenticator {
|
||||||
activity as FragmentActivity,
|
activity as FragmentActivity,
|
||||||
executor,
|
executor,
|
||||||
object : BiometricPrompt.AuthenticationCallback() {
|
object : BiometricPrompt.AuthenticationCallback() {
|
||||||
|
|
||||||
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
|
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
|
||||||
super.onAuthenticationError(errorCode, errString)
|
super.onAuthenticationError(errorCode, errString)
|
||||||
showToast("$errString")
|
showToast("$errString")
|
||||||
|
@ -82,7 +81,6 @@ object BiometricAuthenticator {
|
||||||
.setDescription(description)
|
.setDescription(description)
|
||||||
.setAllowedAuthenticators(authFlag)
|
.setAllowedAuthenticators(authFlag)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// for apis < 30
|
// for apis < 30
|
||||||
promptInfo = BiometricPrompt.PromptInfo.Builder()
|
promptInfo = BiometricPrompt.PromptInfo.Builder()
|
||||||
|
@ -91,7 +89,6 @@ object BiometricAuthenticator {
|
||||||
.setDeviceCredentialAllowed(true)
|
.setDeviceCredentialAllowed(true)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// fallback for A12+ when both fingerprint & Face unlock is absent but PIN is set
|
// fallback for A12+ when both fingerprint & Face unlock is absent but PIN is set
|
||||||
promptInfo = BiometricPrompt.PromptInfo.Builder()
|
promptInfo = BiometricPrompt.PromptInfo.Builder()
|
||||||
|
@ -107,7 +104,6 @@ object BiometricAuthenticator {
|
||||||
var result = false
|
var result = false
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
|
||||||
when (biometricManager?.canAuthenticate(
|
when (biometricManager?.canAuthenticate(
|
||||||
DEVICE_CREDENTIAL or BIOMETRIC_STRONG or BIOMETRIC_WEAK
|
DEVICE_CREDENTIAL or BIOMETRIC_STRONG or BIOMETRIC_WEAK
|
||||||
)) {
|
)) {
|
||||||
|
@ -119,7 +115,6 @@ object BiometricAuthenticator {
|
||||||
BiometricManager.BIOMETRIC_ERROR_UNSUPPORTED -> result = true
|
BiometricManager.BIOMETRIC_ERROR_UNSUPPORTED -> result = true
|
||||||
BiometricManager.BIOMETRIC_STATUS_UNKNOWN -> result = false
|
BiometricManager.BIOMETRIC_STATUS_UNKNOWN -> result = false
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
when (biometricManager?.canAuthenticate()) {
|
when (biometricManager?.canAuthenticate()) {
|
||||||
|
@ -151,7 +146,6 @@ object BiometricAuthenticator {
|
||||||
authCallback = activity as? BiometricAuthCallback
|
authCallback = activity as? BiometricAuthCallback
|
||||||
authenticationDialog(activity, title, setDeviceCred)
|
authenticationDialog(activity, title, setDeviceCred)
|
||||||
promptInfo?.let { biometricPrompt?.authenticate(it) }
|
promptInfo?.let { biometricPrompt?.authenticate(it) }
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (deviceHasPasswordPinLock(activity)) {
|
if (deviceHasPasswordPinLock(activity)) {
|
||||||
authCallback = activity as? BiometricAuthCallback
|
authCallback = activity as? BiometricAuthCallback
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue