mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-25 14:08: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
|
package org.fossify.gallery
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import com.github.ajalt.reprint.core.Reprint
|
import com.github.ajalt.reprint.core.Reprint
|
||||||
import com.squareup.picasso.Downloader
|
import com.squareup.picasso.Downloader
|
||||||
import com.squareup.picasso.Picasso
|
import com.squareup.picasso.Picasso
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.fossify.commons.extensions.checkUseEnglish
|
import org.fossify.commons.FossifyApp
|
||||||
|
|
||||||
class App : Application() {
|
class App : FossifyApp() {
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
checkUseEnglish()
|
|
||||||
Reprint.initialize(this)
|
Reprint.initialize(this)
|
||||||
Picasso.setSingletonInstance(Picasso.Builder(this).downloader(object : Downloader {
|
Picasso.setSingletonInstance(Picasso.Builder(this).downloader(object : Downloader {
|
||||||
override fun load(request: Request) = Response.Builder().build()
|
override fun load(request: Request) = Response.Builder().build()
|
||||||
|
|
|
@ -57,12 +57,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
private var mIsThirdPartyIntent = false
|
private var mIsThirdPartyIntent = false
|
||||||
private var mIsGettingDirs = false
|
private var mIsGettingDirs = false
|
||||||
private var mLoadedInitialPhotos = false
|
private var mLoadedInitialPhotos = false
|
||||||
private var mIsPasswordProtectionPending = false
|
|
||||||
private var mWasProtectionHandled = false
|
|
||||||
private var mShouldStopFetching = false
|
private var mShouldStopFetching = false
|
||||||
private var mWasDefaultFolderChecked = false
|
private var mWasDefaultFolderChecked = false
|
||||||
private var mWasMediaManagementPromptShown = false
|
private var mWasMediaManagementPromptShown = false
|
||||||
private var mWasUpgradedFromFreeShown = false
|
|
||||||
private var mLatestMediaId = 0L
|
private var mLatestMediaId = 0L
|
||||||
private var mLatestMediaDateId = 0L
|
private var mLatestMediaDateId = 0L
|
||||||
private var mCurrentPathPrefix = "" // used at "Group direct subfolders" for navigation
|
private var mCurrentPathPrefix = "" // used at "Group direct subfolders" for navigation
|
||||||
|
@ -123,8 +120,6 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
binding.directoriesRefreshLayout.setOnRefreshListener { getDirectories() }
|
binding.directoriesRefreshLayout.setOnRefreshListener { getDirectories() }
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
checkWhatsNewDialog()
|
checkWhatsNewDialog()
|
||||||
|
|
||||||
mIsPasswordProtectionPending = config.isAppPasswordProtectionOn
|
|
||||||
setupLatestMediaId()
|
setupLatestMediaId()
|
||||||
|
|
||||||
if (!config.wereFavoritesPinned) {
|
if (!config.wereFavoritesPinned) {
|
||||||
|
@ -228,19 +223,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
|
|
||||||
if (!binding.mainMenu.isSearchOpen) {
|
if (!binding.mainMenu.isSearchOpen) {
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
if (mIsPasswordProtectionPending && !mWasProtectionHandled) {
|
tryLoadGallery()
|
||||||
handleAppPasswordProtection {
|
|
||||||
mWasProtectionHandled = it
|
|
||||||
if (it) {
|
|
||||||
mIsPasswordProtectionPending = false
|
|
||||||
tryLoadGallery()
|
|
||||||
} else {
|
|
||||||
finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
tryLoadGallery()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.searchAllFilesByDefault) {
|
if (config.searchAllFilesByDefault) {
|
||||||
|
@ -303,6 +286,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
setupAdapter(mDirs)
|
setupAdapter(mDirs)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
appLockManager.lock()
|
||||||
super.onBackPressed()
|
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() {
|
private fun updateMenuColors() {
|
||||||
updateStatusbarColor(getProperBackgroundColor())
|
updateStatusbarColor(getProperBackgroundColor())
|
||||||
binding.mainMenu.updateColors()
|
binding.mainMenu.updateColors()
|
||||||
|
|
|
@ -50,7 +50,6 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
private var mShowAll = false
|
private var mShowAll = false
|
||||||
private var mLoadedInitialPhotos = false
|
private var mLoadedInitialPhotos = false
|
||||||
private var mWasFullscreenViewOpen = false
|
private var mWasFullscreenViewOpen = false
|
||||||
private var mWasUpgradedFromFreeShown = false
|
|
||||||
private var mLastSearchedText = ""
|
private var mLastSearchedText = ""
|
||||||
private var mLatestMediaId = 0L
|
private var mLatestMediaId = 0L
|
||||||
private var mLatestMediaDateId = 0L
|
private var mLatestMediaDateId = 0L
|
||||||
|
@ -229,6 +228,10 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
if (binding.mediaMenu.isSearchOpen) {
|
if (binding.mediaMenu.isSearchOpen) {
|
||||||
binding.mediaMenu.closeSearch()
|
binding.mediaMenu.closeSearch()
|
||||||
} else {
|
} else {
|
||||||
|
if (config.showAll) {
|
||||||
|
appLockManager.lock()
|
||||||
|
}
|
||||||
|
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ exif = "1.0.1"
|
||||||
#Room
|
#Room
|
||||||
room = "2.6.1"
|
room = "2.6.1"
|
||||||
#Fossify
|
#Fossify
|
||||||
commons = "e40963a843"
|
commons = "45f8e23a33"
|
||||||
#Gradle4
|
#Gradle4
|
||||||
gradlePlugins-agp = "8.5.0"
|
gradlePlugins-agp = "8.5.0"
|
||||||
#Other
|
#Other
|
||||||
|
|
Loading…
Reference in a new issue