From f789ecdf02de3a5da17ec189d563b0576d1b9176 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 29 Jul 2017 21:56:45 +0200 Subject: [PATCH] apply the pattern protection to temporarily showing hidden folders too --- .../gallery/activities/MainActivity.kt | 14 ++++++++++++-- .../gallery/activities/MediaActivity.kt | 14 ++++++++++++-- .../gallery/activities/ViewPagerActivity.kt | 3 ++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index ba9476aec..25e104d4c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -97,8 +97,8 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { R.id.sort -> showSortingDialog() R.id.open_camera -> launchCamera() R.id.show_all -> showAllMedia() - R.id.temporarily_show_hidden -> toggleTemporarilyShowHidden(true) - R.id.stop_showing_hidden -> toggleTemporarilyShowHidden(false) + R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden(true) + R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden(false) R.id.increase_column_count -> increaseColumnCount() R.id.reduce_column_count -> reduceColumnCount() R.id.settings -> launchSettings() @@ -210,6 +210,16 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { finish() } + private fun tryToggleTemporarilyShowHidden(show: Boolean) { + if (config.temporarilyShowHidden) { + toggleTemporarilyShowHidden(show) + } else { + handleHiddenFolderPasswordProtection { + toggleTemporarilyShowHidden(show) + } + } + } + private fun toggleTemporarilyShowHidden(show: Boolean) { config.temporarilyShowHidden = show getDirectories() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 391edfe5d..c8f872de6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -216,8 +216,8 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { R.id.hide_folder -> tryHideFolder() R.id.unhide_folder -> unhideFolder() R.id.exclude_folder -> tryExcludeFolder() - R.id.temporarily_show_hidden -> toggleTemporarilyShowHidden(true) - R.id.stop_showing_hidden -> toggleTemporarilyShowHidden(false) + R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden(true) + R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden(false) R.id.increase_column_count -> increaseColumnCount() R.id.reduce_column_count -> reduceColumnCount() R.id.settings -> launchSettings() @@ -316,6 +316,16 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { false } + private fun tryToggleTemporarilyShowHidden(show: Boolean) { + if (config.temporarilyShowHidden) { + toggleTemporarilyShowHidden(show) + } else { + handleHiddenFolderPasswordProtection { + toggleTemporarilyShowHidden(show) + } + } + } + private fun toggleTemporarilyShowHidden(show: Boolean) { config.temporarilyShowHidden = show getMedia() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index cee4d7d42..3c46cbb1b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -89,7 +89,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } if (intent.extras?.containsKey(IS_VIEW_INTENT) == true) { - config.temporarilyShowHidden = true + if (!config.isPasswordProtectionOn) + config.temporarilyShowHidden = true } showSystemUI()