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