mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
parent
134c2552f9
commit
8af3742945
3 changed files with 16 additions and 5 deletions
|
@ -130,6 +130,9 @@ class SearchActivity : MainActivity() {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (intent.action == SHORTCUT_MANGA_BACK) {
|
||||
SecureActivityDelegate.promptLockIfNeeded(this, true)
|
||||
}
|
||||
router.replaceTopController(
|
||||
RouterTransaction.with(MangaDetailsController(extras))
|
||||
.pushChangeHandler(SimpleSwapChangeHandler())
|
||||
|
@ -138,6 +141,7 @@ class SearchActivity : MainActivity() {
|
|||
}
|
||||
SHORTCUT_SOURCE -> {
|
||||
val extras = intent.extras ?: return false
|
||||
SecureActivityDelegate.promptLockIfNeeded(this, true)
|
||||
router.replaceTopController(
|
||||
RouterTransaction.with(BrowseSourceController(extras))
|
||||
.pushChangeHandler(SimpleSwapChangeHandler())
|
||||
|
|
|
@ -1203,9 +1203,16 @@ class MangaDetailsController :
|
|||
}
|
||||
|
||||
private fun isLocked(): Boolean {
|
||||
if (presenter.isLockedFromSearch) {
|
||||
return SecureActivityDelegate.shouldBeLocked()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private fun needsToBeUnlocked(): Boolean {
|
||||
if (presenter.isLockedFromSearch) {
|
||||
SecureActivityDelegate.promptLockIfNeeded(activity)
|
||||
return true
|
||||
return SecureActivityDelegate.shouldBeLocked()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -1352,7 +1359,7 @@ class MangaDetailsController :
|
|||
}
|
||||
|
||||
override fun favoriteManga(longPress: Boolean) {
|
||||
if (isLocked()) return
|
||||
if (needsToBeUnlocked()) return
|
||||
val manga = presenter.manga
|
||||
val categories = presenter.getCategories()
|
||||
if (!manga.favorite) {
|
||||
|
@ -1469,7 +1476,7 @@ class MangaDetailsController :
|
|||
}
|
||||
|
||||
override fun showTrackingSheet() {
|
||||
if (isLocked()) return
|
||||
if (needsToBeUnlocked()) return
|
||||
trackingBottomSheet =
|
||||
TrackingBottomSheet(this)
|
||||
trackingBottomSheet?.show()
|
||||
|
|
|
@ -28,13 +28,13 @@ object SecureActivityDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
fun promptLockIfNeeded(activity: Activity?) {
|
||||
fun promptLockIfNeeded(activity: Activity?, requireSuccess: Boolean = false) {
|
||||
if (activity == null || isAuthenticating) return
|
||||
val lockApp = preferences.useBiometrics().get()
|
||||
if (lockApp && BiometricManager.from(activity).canAuthenticate(BiometricManager.Authenticators.DEVICE_CREDENTIAL or BiometricManager.Authenticators.BIOMETRIC_WEAK) == BiometricManager.BIOMETRIC_SUCCESS) {
|
||||
if (isAppLocked()) {
|
||||
val intent = Intent(activity, BiometricActivity::class.java)
|
||||
intent.putExtra("fromSearch", (activity is SearchActivity))
|
||||
intent.putExtra("fromSearch", (activity is SearchActivity) && !requireSuccess)
|
||||
activity.startActivity(intent)
|
||||
activity.overridePendingTransition(0, 0)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue