mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
protect toggling Show hidden media with the pattern when appropriate
This commit is contained in:
parent
f039afaca6
commit
2b518ec4f2
2 changed files with 24 additions and 2 deletions
|
@ -9,6 +9,7 @@ import com.simplemobiletools.commons.models.RadioItem
|
|||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.dialogs.PatternDialog
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.extensions.handleHiddenFolderPasswordProtection
|
||||
import com.simplemobiletools.gallery.helpers.*
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
|
||||
|
@ -64,11 +65,21 @@ class SettingsActivity : SimpleActivity() {
|
|||
private fun setupShowHiddenFolders() {
|
||||
settings_show_hidden_folders.isChecked = config.showHiddenMedia
|
||||
settings_show_hidden_folders_holder.setOnClickListener {
|
||||
settings_show_hidden_folders.toggle()
|
||||
config.showHiddenMedia = settings_show_hidden_folders.isChecked
|
||||
if (config.showHiddenMedia) {
|
||||
toggleHiddenFolders()
|
||||
} else {
|
||||
handleHiddenFolderPasswordProtection {
|
||||
toggleHiddenFolders()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleHiddenFolders() {
|
||||
settings_show_hidden_folders.toggle()
|
||||
config.showHiddenMedia = settings_show_hidden_folders.isChecked
|
||||
}
|
||||
|
||||
private fun setupAutoplayVideos() {
|
||||
settings_autoplay_videos.isChecked = config.autoplayVideos
|
||||
settings_autoplay_videos_holder.setOnClickListener {
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.simplemobiletools.commons.helpers.*
|
|||
import com.simplemobiletools.gallery.BuildConfig
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||
import com.simplemobiletools.gallery.dialogs.PatternDialog
|
||||
import com.simplemobiletools.gallery.helpers.NOMEDIA
|
||||
import com.simplemobiletools.gallery.helpers.REQUEST_EDIT_IMAGE
|
||||
import com.simplemobiletools.gallery.helpers.REQUEST_SET_AS
|
||||
|
@ -332,6 +333,16 @@ fun Activity.loadStaticGif(path: String, target: MySquareImageView) {
|
|||
builder.apply(options).into(target)
|
||||
}
|
||||
|
||||
fun SimpleActivity.handleHiddenFolderPasswordProtection(callback: () -> Unit) {
|
||||
if (config.isPasswordProtectionOn) {
|
||||
PatternDialog(this, config.passwordHash) {
|
||||
callback()
|
||||
}
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
fun Activity.getCachedDirectories(): ArrayList<Directory> {
|
||||
val token = object : TypeToken<List<Directory>>() {}.type
|
||||
return Gson().fromJson<ArrayList<Directory>>(config.directories, token) ?: ArrayList<Directory>(1)
|
||||
|
|
Loading…
Reference in a new issue