disable "Temporarily show hidden" after 10 minutes of app backgrounding

This commit is contained in:
tibbi 2018-01-28 21:30:14 +01:00
parent c3a7068806
commit 7c7b7d254d
3 changed files with 49 additions and 12 deletions

View file

@ -52,6 +52,14 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
private var mAllowPickingMultiple = false private var mAllowPickingMultiple = false
private var mIsThirdPartyIntent = false private var mIsThirdPartyIntent = false
private var mIsGettingDirs = false private var mIsGettingDirs = false
private var mLoadedInitialPhotos = false
private var mIsPasswordProtectionPending = false
private var mLatestMediaId = 0L
private var mLastMediaHandler = Handler()
private var mTempShowHiddenHandler = Handler()
private var mCurrAsyncTask: GetDirectoriesAsynctask? = null
private var mZoomListener: MyRecyclerView.MyZoomListener? = null
private var mStoredUseEnglish = false private var mStoredUseEnglish = false
private var mStoredAnimateGifs = true private var mStoredAnimateGifs = true
private var mStoredCropThumbnails = true private var mStoredCropThumbnails = true
@ -59,12 +67,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
private var mStoredShowMediaCount = true private var mStoredShowMediaCount = true
private var mStoredShowInfoBubble = true private var mStoredShowInfoBubble = true
private var mStoredTextColor = 0 private var mStoredTextColor = 0
private var mLoadedInitialPhotos = false
private var mIsPasswordProtectionPending = false
private var mLatestMediaId = 0L
private var mLastMediaHandler = Handler()
private var mCurrAsyncTask: GetDirectoriesAsynctask? = null
private var mZoomListener: MyRecyclerView.MyZoomListener? = null
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -94,6 +96,11 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
mIsPasswordProtectionPending = config.appPasswordProtectionOn mIsPasswordProtectionPending = config.appPasswordProtectionOn
} }
override fun onStart() {
super.onStart()
mTempShowHiddenHandler.removeCallbacksAndMessages(null)
}
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
config.isThirdPartyIntent = false config.isThirdPartyIntent = false
@ -156,9 +163,21 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
} }
} }
override fun onStop() {
super.onStop()
if (config.temporarilyShowHidden) {
mTempShowHiddenHandler.postDelayed({
config.temporarilyShowHidden = false
}, SHOW_TEMP_HIDDEN_DURATION)
} else {
mTempShowHiddenHandler.removeCallbacksAndMessages(null)
}
}
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
config.temporarilyShowHidden = false config.temporarilyShowHidden = false
mTempShowHiddenHandler.removeCallbacksAndMessages(null)
removeTempFolder() removeTempFolder()
} }

View file

@ -53,17 +53,19 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
private var mAllowPickingMultiple = false private var mAllowPickingMultiple = false
private var mShowAll = false private var mShowAll = false
private var mLoadedInitialPhotos = false private var mLoadedInitialPhotos = false
private var mLatestMediaId = 0L
private var mLastMediaHandler = Handler()
private var mTempShowHiddenHandler = Handler()
private var mCurrAsyncTask: GetMediaAsynctask? = null
private var mZoomListener: MyRecyclerView.MyZoomListener? = null
private var mSearchMenuItem: MenuItem? = null
private var mStoredUseEnglish = false private var mStoredUseEnglish = false
private var mStoredAnimateGifs = true private var mStoredAnimateGifs = true
private var mStoredCropThumbnails = true private var mStoredCropThumbnails = true
private var mStoredScrollHorizontally = true private var mStoredScrollHorizontally = true
private var mStoredShowInfoBubble = true private var mStoredShowInfoBubble = true
private var mStoredTextColor = 0 private var mStoredTextColor = 0
private var mLatestMediaId = 0L
private var mLastMediaHandler = Handler()
private var mCurrAsyncTask: GetMediaAsynctask? = null
private var mZoomListener: MyRecyclerView.MyZoomListener? = null
private var mSearchMenuItem: MenuItem? = null
companion object { companion object {
var mMedia = ArrayList<Medium>() var mMedia = ArrayList<Medium>()
@ -90,6 +92,11 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
} }
} }
override fun onStart() {
super.onStart()
mTempShowHiddenHandler.removeCallbacksAndMessages(null)
}
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
if (mStoredUseEnglish != config.useEnglish) { if (mStoredUseEnglish != config.useEnglish) {
@ -139,13 +146,23 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
if (mSearchMenuItem != null) { if (mSearchMenuItem != null) {
MenuItemCompat.collapseActionView(mSearchMenuItem) MenuItemCompat.collapseActionView(mSearchMenuItem)
} }
if (config.temporarilyShowHidden) {
mTempShowHiddenHandler.postDelayed({
config.temporarilyShowHidden = false
}, SHOW_TEMP_HIDDEN_DURATION)
} else {
mTempShowHiddenHandler.removeCallbacksAndMessages(null)
}
} }
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
if (config.showAll) if (config.showAll) {
config.temporarilyShowHidden = false config.temporarilyShowHidden = false
}
mTempShowHiddenHandler.removeCallbacksAndMessages(null)
mMedia.clear() mMedia.clear()
} }

View file

@ -62,6 +62,7 @@ const val SLIDESHOW_SCROLL_DURATION = 500L
const val NOMEDIA = ".nomedia" const val NOMEDIA = ".nomedia"
const val MAX_COLUMN_COUNT = 20 const val MAX_COLUMN_COUNT = 20
const val SHOW_TEMP_HIDDEN_DURATION = 600000L
const val DIRECTORY = "directory" const val DIRECTORY = "directory"
const val MEDIUM = "medium" const val MEDIUM = "medium"