mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 04:28:00 +01:00
Implement global app locking
Notes: - App is locked instantly on back press. - App is locked after 30 seconds when closed using any other gesture or method. Closes https://github.com/FossifyOrg/Gallery/issues/126
This commit is contained in:
parent
24232c8205
commit
51f0669e9f
4 changed files with 9 additions and 34 deletions
|
@ -1,17 +1,15 @@
|
|||
package org.fossify.gallery
|
||||
|
||||
import android.app.Application
|
||||
import com.github.ajalt.reprint.core.Reprint
|
||||
import com.squareup.picasso.Downloader
|
||||
import com.squareup.picasso.Picasso
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import org.fossify.commons.extensions.checkUseEnglish
|
||||
import org.fossify.commons.FossifyApp
|
||||
|
||||
class App : Application() {
|
||||
class App : FossifyApp() {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
checkUseEnglish()
|
||||
Reprint.initialize(this)
|
||||
Picasso.setSingletonInstance(Picasso.Builder(this).downloader(object : Downloader {
|
||||
override fun load(request: Request) = Response.Builder().build()
|
||||
|
|
|
@ -57,12 +57,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
private var mIsThirdPartyIntent = false
|
||||
private var mIsGettingDirs = false
|
||||
private var mLoadedInitialPhotos = false
|
||||
private var mIsPasswordProtectionPending = false
|
||||
private var mWasProtectionHandled = false
|
||||
private var mShouldStopFetching = false
|
||||
private var mWasDefaultFolderChecked = false
|
||||
private var mWasMediaManagementPromptShown = false
|
||||
private var mWasUpgradedFromFreeShown = false
|
||||
private var mLatestMediaId = 0L
|
||||
private var mLatestMediaDateId = 0L
|
||||
private var mCurrentPathPrefix = "" // used at "Group direct subfolders" for navigation
|
||||
|
@ -123,8 +120,6 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
binding.directoriesRefreshLayout.setOnRefreshListener { getDirectories() }
|
||||
storeStateVariables()
|
||||
checkWhatsNewDialog()
|
||||
|
||||
mIsPasswordProtectionPending = config.isAppPasswordProtectionOn
|
||||
setupLatestMediaId()
|
||||
|
||||
if (!config.wereFavoritesPinned) {
|
||||
|
@ -228,19 +223,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
|
||||
if (!binding.mainMenu.isSearchOpen) {
|
||||
refreshMenuItems()
|
||||
if (mIsPasswordProtectionPending && !mWasProtectionHandled) {
|
||||
handleAppPasswordProtection {
|
||||
mWasProtectionHandled = it
|
||||
if (it) {
|
||||
mIsPasswordProtectionPending = false
|
||||
tryLoadGallery()
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tryLoadGallery()
|
||||
}
|
||||
tryLoadGallery()
|
||||
}
|
||||
|
||||
if (config.searchAllFilesByDefault) {
|
||||
|
@ -303,6 +286,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
setupAdapter(mDirs)
|
||||
}
|
||||
} else {
|
||||
appLockManager.lock()
|
||||
super.onBackPressed()
|
||||
}
|
||||
}
|
||||
|
@ -404,16 +388,6 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
outState.putBoolean(WAS_PROTECTION_HANDLED, mWasProtectionHandled)
|
||||
}
|
||||
|
||||
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
||||
super.onRestoreInstanceState(savedInstanceState)
|
||||
mWasProtectionHandled = savedInstanceState.getBoolean(WAS_PROTECTION_HANDLED, false)
|
||||
}
|
||||
|
||||
private fun updateMenuColors() {
|
||||
updateStatusbarColor(getProperBackgroundColor())
|
||||
binding.mainMenu.updateColors()
|
||||
|
|
|
@ -50,7 +50,6 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
private var mShowAll = false
|
||||
private var mLoadedInitialPhotos = false
|
||||
private var mWasFullscreenViewOpen = false
|
||||
private var mWasUpgradedFromFreeShown = false
|
||||
private var mLastSearchedText = ""
|
||||
private var mLatestMediaId = 0L
|
||||
private var mLatestMediaDateId = 0L
|
||||
|
@ -229,6 +228,10 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
if (binding.mediaMenu.isSearchOpen) {
|
||||
binding.mediaMenu.closeSearch()
|
||||
} else {
|
||||
if (config.showAll) {
|
||||
appLockManager.lock()
|
||||
}
|
||||
|
||||
super.onBackPressed()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ exif = "1.0.1"
|
|||
#Room
|
||||
room = "2.6.1"
|
||||
#Fossify
|
||||
commons = "e40963a843"
|
||||
commons = "45f8e23a33"
|
||||
#Gradle4
|
||||
gradlePlugins-agp = "8.5.0"
|
||||
#Other
|
||||
|
|
Loading…
Reference in a new issue