forked from starfish23/mangafeed
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fingerprint/Biometric Unlock Support
Version 0.9.3 set
- Loading branch information
1 parent
5448a16
commit 51e735a
Showing
12 changed files
with
194 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
app/src/main/java/eu/kanade/tachiyomi/ui/main/BiometricActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package eu.kanade.tachiyomi.ui.main | ||
|
||
import android.os.Bundle | ||
import androidx.biometric.BiometricPrompt | ||
import eu.kanade.tachiyomi.R | ||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper | ||
import eu.kanade.tachiyomi.ui.base.activity.BaseActivity | ||
import uy.kohesive.injekt.injectLazy | ||
import java.util.Date | ||
import java.util.concurrent.Executors | ||
|
||
class BiometricActivity : BaseActivity() { | ||
val executor = Executors.newSingleThreadExecutor() | ||
|
||
val preferences: PreferencesHelper by injectLazy() | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
val biometricPrompt = BiometricPrompt(this, executor, object : BiometricPrompt | ||
.AuthenticationCallback() { | ||
|
||
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) { | ||
super.onAuthenticationError(errorCode, errString) | ||
finishAffinity() | ||
} | ||
|
||
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) { | ||
super.onAuthenticationSucceeded(result) | ||
MainActivity.unlocked = true | ||
preferences.lastUnlock().set(Date().time) | ||
finish() | ||
} | ||
|
||
override fun onAuthenticationFailed() { | ||
super.onAuthenticationFailed() | ||
// TODO("Called when a biometric is valid but not recognized.") | ||
} | ||
}) | ||
|
||
val promptInfo = BiometricPrompt.PromptInfo.Builder() | ||
.setTitle(getString(R.string.unlock_library)) | ||
.setNegativeButtonText(getString(android.R.string.cancel)) | ||
.build() | ||
|
||
biometricPrompt.authenticate(promptInfo) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.