mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
add logging and preference
This commit is contained in:
parent
b529ca110c
commit
0d76753df0
7 changed files with 53 additions and 48 deletions
6
.idea/gradle.xml
generated
6
.idea/gradle.xml
generated
|
@ -4,17 +4,15 @@
|
|||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="delegatedBuild" value="true" />
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="jbr-17" />
|
||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveExternalAnnotations" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
|
|
|
@ -159,15 +159,15 @@ dependencies {
|
|||
// Android Core & Lifecycle
|
||||
implementation("androidx.core:core-ktx:1.12.0")
|
||||
implementation("androidx.appcompat:appcompat:1.6.1")
|
||||
implementation("androidx.navigation:navigation-ui-ktx:2.7.6")
|
||||
implementation("androidx.navigation:navigation-ui-ktx:2.7.5")
|
||||
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.2")
|
||||
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2")
|
||||
implementation("androidx.navigation:navigation-fragment-ktx:2.7.6")
|
||||
implementation("androidx.navigation:navigation-fragment-ktx:2.7.5")
|
||||
|
||||
// Design & UI
|
||||
implementation("jp.wasabeef:glide-transformations:4.3.0")
|
||||
implementation("androidx.preference:preference-ktx:1.2.1")
|
||||
implementation("com.google.android.material:material:1.11.0")
|
||||
implementation("com.google.android.material:material:1.10.0")
|
||||
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
|
||||
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
|
||||
|
||||
|
@ -200,16 +200,15 @@ dependencies {
|
|||
implementation("com.github.albfernandez:juniversalchardet:2.4.0") // Subtitle Decoding
|
||||
|
||||
// Crash Reports (AcraApplication.kt)
|
||||
implementation("ch.acra:acra-core:5.11.3")
|
||||
implementation("ch.acra:acra-toast:5.11.3")
|
||||
|
||||
implementation ("androidx.biometric:biometric:1.2.0-alpha05")
|
||||
implementation("ch.acra:acra-core:5.11.2")
|
||||
implementation("ch.acra:acra-toast:5.11.2")
|
||||
|
||||
// UI Stuff
|
||||
implementation("com.facebook.shimmer:shimmer:0.5.0") // Shimmering Effect (Loading Skeleton)
|
||||
implementation("androidx.palette:palette-ktx:1.0.0") // Palette For Images -> Colors
|
||||
implementation("androidx.tvprovider:tvprovider:1.0.0")
|
||||
implementation("com.github.discord:OverlappingPanels:0.1.5") // Gestures
|
||||
implementation ("androidx.biometric:biometric:1.2.0-alpha05") // Fingerprint Authentication
|
||||
implementation("com.github.rubensousa:previewseekbar-media3:1.1.1.0") // SeekBar Preview
|
||||
|
||||
// Extensions & Other Libs
|
||||
|
@ -226,8 +225,8 @@ dependencies {
|
|||
Level 25 or Less. */
|
||||
|
||||
// Downloading & Networking
|
||||
implementation("androidx.work:work-runtime:2.9.0")
|
||||
implementation("androidx.work:work-runtime-ktx:2.9.0")
|
||||
implementation("androidx.work:work-runtime:2.8.1")
|
||||
implementation("androidx.work:work-runtime-ktx:2.8.1")
|
||||
implementation("com.github.Blatzar:NiceHttp:0.4.4") // HTTP Lib
|
||||
}
|
||||
|
||||
|
|
|
@ -14,9 +14,7 @@
|
|||
<uses-permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA" /> <!-- Used for Android TV watch next -->
|
||||
<uses-permission android:name="android.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION" /> <!-- Used for updates without prompt -->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <!-- Used for update service -->
|
||||
|
||||
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
|
||||
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||
|
||||
<!-- Required for getting arbitrary Aniyomi packages -->
|
||||
|
|
|
@ -1157,6 +1157,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
|
||||
changeStatusBarState(isEmulatorSettings())
|
||||
|
||||
/** Biometric Stuff **/
|
||||
val authEnabled = settingsManager.getBoolean(
|
||||
getString(R.string.biometric_enabled_key), false)
|
||||
|
||||
|
|
|
@ -26,29 +26,28 @@ object BiometricAuthenticator {
|
|||
val executor = ContextCompat.getMainExecutor(activity)
|
||||
biometricManager = BiometricManager.from(activity)
|
||||
|
||||
biometricPrompt = BiometricPrompt(activity, executor,
|
||||
object : BiometricPrompt.AuthenticationCallback() {
|
||||
biometricPrompt = BiometricPrompt(activity, executor, object : BiometricPrompt.AuthenticationCallback() {
|
||||
|
||||
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
|
||||
super.onAuthenticationError(errorCode, errString)
|
||||
Toast.makeText(context?.applicationContext, "Authentication error: $errString", Toast.LENGTH_SHORT).show()
|
||||
// Handle error as needed
|
||||
activity.finish()
|
||||
}
|
||||
|
||||
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
|
||||
super.onAuthenticationSucceeded(result)
|
||||
Toast.makeText(context?.applicationContext, "Authentication succeeded!", Toast.LENGTH_SHORT).show()
|
||||
// Handle authentication success
|
||||
Log.d("Cs3Auth", "Biometric succeeded.")
|
||||
}
|
||||
|
||||
override fun onAuthenticationFailed() {
|
||||
super.onAuthenticationFailed()
|
||||
Toast.makeText(context?.applicationContext, "Authentication failed", Toast.LENGTH_SHORT).show()
|
||||
// Handle authentication failure
|
||||
activity.finish()
|
||||
}
|
||||
})
|
||||
|
||||
promptInfo = BiometricPrompt.PromptInfo.Builder()
|
||||
.setTitle("Biometric login for my app")
|
||||
.setTitle("CloudStream")
|
||||
.setSubtitle("Log in using your biometric credential")
|
||||
//.setNegativeButtonText("Use account password")
|
||||
.setAllowedAuthenticators(BIOMETRIC_WEAK or BIOMETRIC_STRONG or DEVICE_CREDENTIAL)
|
||||
|
@ -56,28 +55,19 @@ object BiometricAuthenticator {
|
|||
}
|
||||
|
||||
fun checkBiometricAvailability(context: Context) {
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
|
||||
// Strong and credential bundle cannot be checked at same time in API < 11
|
||||
when (biometricManager.canAuthenticate(BIOMETRIC_WEAK or BIOMETRIC_STRONG or DEVICE_CREDENTIAL)) {
|
||||
BiometricManager.BIOMETRIC_SUCCESS ->
|
||||
Toast.makeText(
|
||||
context,
|
||||
"Biometric authentication is available",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
Log.d("Cs3Auth", "App can authenticate.")
|
||||
|
||||
BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE ->
|
||||
Toast.makeText(
|
||||
context,
|
||||
"This device doesn't support biometric authentication",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
Log.d("Cs3Auth", "No biometric sensor found.")
|
||||
|
||||
BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE ->
|
||||
Toast.makeText(
|
||||
context,
|
||||
"Biometric authentication is currently unavailable",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
Log.d("Cs3Auth", "Biometric authentication is currently unavailable.")
|
||||
|
||||
BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED ->
|
||||
Toast.makeText(
|
||||
|
@ -87,21 +77,31 @@ object BiometricAuthenticator {
|
|||
).show()
|
||||
|
||||
BiometricManager.BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED -> {
|
||||
TODO()
|
||||
Toast.makeText(
|
||||
context,
|
||||
"Please update your software and security patches.",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
||||
BiometricManager.BIOMETRIC_ERROR_UNSUPPORTED -> {
|
||||
TODO()
|
||||
Toast.makeText(
|
||||
context,
|
||||
"Please update your software and security patches.",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
||||
BiometricManager.BIOMETRIC_STATUS_UNKNOWN -> {
|
||||
TODO()
|
||||
Log.d("Cs3Auth", "Unknown error encountered(Biometric data failed).")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
when (biometricManager.canAuthenticate(BIOMETRIC_WEAK or BIOMETRIC_STRONG)) {
|
||||
|
||||
BiometricManager.BIOMETRIC_SUCCESS ->
|
||||
Log.d("Cs3Auth", "App can authenticate using biometrics.")
|
||||
BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE ->
|
||||
|
@ -112,21 +112,30 @@ object BiometricAuthenticator {
|
|||
Log.e("Cs3Auth", "Biometric features are currently unavailable.")
|
||||
|
||||
BiometricManager.BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED -> {
|
||||
TODO()
|
||||
Toast.makeText(
|
||||
context,
|
||||
"Please update your software and security patches.",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
||||
BiometricManager.BIOMETRIC_ERROR_UNSUPPORTED -> {
|
||||
TODO()
|
||||
Toast.makeText(
|
||||
context,
|
||||
"Please update your software and security patches.",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
||||
BiometricManager.BIOMETRIC_STATUS_UNKNOWN -> {
|
||||
TODO()
|
||||
Log.d("Cs3Auth", "Unknown error encountered(Biometric data failed).")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// yes, this feature is phone exclusive
|
||||
fun isTruePhone(): Boolean {
|
||||
return !isTrueTvSettings() && !isTvSettings() && context?.isEmulatorSettings() != true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,7 +240,7 @@
|
|||
<string name="backup_failed_error_format">Error backing up %s</string>
|
||||
<string name="search">Search</string>
|
||||
<string name="library">Library</string>
|
||||
<string name="category_account">Accounts</string>
|
||||
<string name="category_account">Accounts and Security</string>
|
||||
<string name="category_updates">Updates and backup</string>
|
||||
<string name="settings_info">Info</string>
|
||||
<string name="advanced_search">Advanced Search</string>
|
||||
|
@ -734,5 +734,5 @@
|
|||
<string name="logged_account" formatted="true">Logged in as %s</string>
|
||||
<string name="skip_startup_account_select_pref">Skip account selection at startup</string>
|
||||
<string name="use_default_account">Use Default Account</string>
|
||||
<string name="biometric_setting">Use Fingerprint Authentication</string>
|
||||
<string name="biometric_setting">Use Fingerprint authentication</string>
|
||||
</resources>
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
android:key="@string/skip_startup_account_select_key"
|
||||
android:title="@string/skip_startup_account_select_pref" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
<SwitchPreferenceCompat
|
||||
android:key="@string/biometric_enabled_key"
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_fingerprint"
|
||||
android:title="@string/biometric_setting" />
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue