allow protecting excluded folder visibility
This commit is contained in:
parent
284ff32771
commit
d28d57f961
|
@ -325,8 +325,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
R.id.change_view_type -> changeViewType()
|
||||
R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden()
|
||||
R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden()
|
||||
R.id.temporarily_show_excluded -> toggleTemporarilyShowExcluded(true)
|
||||
R.id.stop_showing_excluded -> toggleTemporarilyShowExcluded(false)
|
||||
R.id.temporarily_show_excluded -> tryToggleTemporarilyShowExcluded()
|
||||
R.id.stop_showing_excluded -> tryToggleTemporarilyShowExcluded()
|
||||
R.id.create_new_folder -> createNewFolder()
|
||||
R.id.show_the_recycle_bin -> toggleRecycleBin(true)
|
||||
R.id.hide_the_recycle_bin -> toggleRecycleBin(false)
|
||||
|
@ -577,6 +577,16 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
private fun tryToggleTemporarilyShowExcluded() {
|
||||
if (config.temporarilyShowExcluded) {
|
||||
toggleTemporarilyShowExcluded(false)
|
||||
} else {
|
||||
handleExcludedFolderPasswordProtection {
|
||||
toggleTemporarilyShowExcluded(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleTemporarilyShowExcluded(show: Boolean) {
|
||||
mLoadedInitialPhotos = false
|
||||
config.temporarilyShowExcluded = show
|
||||
|
|
|
@ -58,6 +58,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupScreenRotation()
|
||||
setupHideSystemUI()
|
||||
setupHiddenItemPasswordProtection()
|
||||
setupExcludedItemPasswordProtection()
|
||||
setupAppPasswordProtection()
|
||||
setupFileDeletionPasswordProtection()
|
||||
setupDeleteEmptyFolders()
|
||||
|
@ -201,9 +202,11 @@ class SettingsActivity : SimpleActivity() {
|
|||
|
||||
private fun setupManageExcludedFolders() {
|
||||
settings_manage_excluded_folders_holder.setOnClickListener {
|
||||
handleExcludedFolderPasswordProtection {
|
||||
startActivity(Intent(this, ExcludedFoldersActivity::class.java))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupManageHiddenFolders() {
|
||||
settings_manage_hidden_folders_holder.beGoneIf(isQPlus())
|
||||
|
@ -337,6 +340,29 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupExcludedItemPasswordProtection() {
|
||||
settings_excluded_item_password_protection_holder.beGoneIf(settings_hidden_item_password_protection_holder.isVisible())
|
||||
settings_excluded_item_password_protection.isChecked = config.isExcludedPasswordProtectionOn
|
||||
settings_excluded_item_password_protection_holder.setOnClickListener {
|
||||
val tabToShow = if (config.isExcludedPasswordProtectionOn) config.excludedProtectionType else SHOW_ALL_TABS
|
||||
SecurityDialog(this, config.excludedPasswordHash, tabToShow) { hash, type, success ->
|
||||
if (success) {
|
||||
val hasPasswordProtection = config.isExcludedPasswordProtectionOn
|
||||
settings_excluded_item_password_protection.isChecked = !hasPasswordProtection
|
||||
config.isExcludedPasswordProtectionOn = !hasPasswordProtection
|
||||
config.excludedPasswordHash = if (hasPasswordProtection) "" else hash
|
||||
config.excludedProtectionType = type
|
||||
|
||||
if (config.isExcludedPasswordProtectionOn) {
|
||||
val confirmationTextId = if (config.excludedProtectionType == PROTECTION_FINGERPRINT)
|
||||
R.string.fingerprint_setup_successfully else R.string.protection_setup_successfully
|
||||
ConfirmationDialog(this, "", confirmationTextId, R.string.ok, 0) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupAppPasswordProtection() {
|
||||
settings_app_password_protection.isChecked = config.isAppPasswordProtectionOn
|
||||
settings_app_password_protection_holder.setOnClickListener {
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.bumptech.glide.request.RequestOptions
|
|||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationAdvancedDialog
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.dialogs.SecurityDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.FAQItem
|
||||
|
@ -775,3 +776,15 @@ fun Activity.showFileOnMap(path: String) {
|
|||
toast(R.string.unknown_location)
|
||||
}
|
||||
}
|
||||
|
||||
fun Activity.handleExcludedFolderPasswordProtection(callback: () -> Unit) {
|
||||
if (config.isExcludedPasswordProtectionOn) {
|
||||
SecurityDialog(this, config.excludedPasswordHash, config.excludedProtectionType) { _, _, success ->
|
||||
if (success) {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,7 @@ import android.content.res.Configuration
|
|||
import android.os.Environment
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.simplemobiletools.commons.helpers.BaseConfig
|
||||
import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED
|
||||
import com.simplemobiletools.commons.helpers.SORT_DESCENDING
|
||||
import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.gallery.pro.R
|
||||
import com.simplemobiletools.gallery.pro.models.AlbumCover
|
||||
import java.util.*
|
||||
|
@ -125,6 +122,18 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
get() = prefs.getStringSet(EXCLUDED_FOLDERS, HashSet())!!
|
||||
set(excludedFolders) = prefs.edit().remove(EXCLUDED_FOLDERS).putStringSet(EXCLUDED_FOLDERS, excludedFolders).apply()
|
||||
|
||||
var isExcludedPasswordProtectionOn: Boolean
|
||||
get() = prefs.getBoolean(EXCLUDED_PASSWORD_PROTECTION, false)
|
||||
set(isExcludedPasswordProtectionOn) = prefs.edit().putBoolean(EXCLUDED_PASSWORD_PROTECTION, isExcludedPasswordProtectionOn).apply()
|
||||
|
||||
var excludedPasswordHash: String
|
||||
get() = prefs.getString(EXCLUDED_PASSWORD_HASH, "")!!
|
||||
set(excludedPasswordHash) = prefs.edit().putString(EXCLUDED_PASSWORD_HASH, excludedPasswordHash).apply()
|
||||
|
||||
var excludedProtectionType: Int
|
||||
get() = prefs.getInt(EXCLUDED_PROTECTION_TYPE, PROTECTION_PATTERN)
|
||||
set(excludedProtectionType) = prefs.edit().putInt(EXCLUDED_PROTECTION_TYPE, excludedProtectionType).apply()
|
||||
|
||||
fun addIncludedFolder(path: String) {
|
||||
val currIncludedFolders = HashSet<String>(includedFolders)
|
||||
currIncludedFolders.add(path)
|
||||
|
|
|
@ -10,6 +10,9 @@ const val VIEW_TYPE_PREFIX = "view_type_folder_"
|
|||
const val SHOW_HIDDEN_MEDIA = "show_hidden_media"
|
||||
const val TEMPORARILY_SHOW_HIDDEN = "temporarily_show_hidden"
|
||||
const val TEMPORARILY_SHOW_EXCLUDED = "temporarily_show_excluded"
|
||||
const val EXCLUDED_PASSWORD_PROTECTION = "excluded_password_protection"
|
||||
const val EXCLUDED_PASSWORD_HASH = "excluded_password_hash"
|
||||
const val EXCLUDED_PROTECTION_TYPE = "excluded_protection_type"
|
||||
const val IS_THIRD_PARTY_INTENT = "is_third_party_intent"
|
||||
const val AUTOPLAY_VIDEOS = "autoplay_videos"
|
||||
const val REMEMBER_LAST_VIDEO_POSITION = "remember_last_video_position"
|
||||
|
|
|
@ -738,6 +738,22 @@
|
|||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_excluded_item_password_protection_holder"
|
||||
style="@style/SettingsHolderCheckboxStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple_background">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||
android:id="@+id/settings_excluded_item_password_protection"
|
||||
style="@style/SettingsCheckboxStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/password_protect_excluded" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_file_deletion_password_protection_holder"
|
||||
style="@style/SettingsHolderCheckboxStyle"
|
||||
|
|
Loading…
Reference in New Issue