mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57: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.R
|
||||||
import com.simplemobiletools.gallery.dialogs.PatternDialog
|
import com.simplemobiletools.gallery.dialogs.PatternDialog
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
import com.simplemobiletools.gallery.extensions.config
|
||||||
|
import com.simplemobiletools.gallery.extensions.handleHiddenFolderPasswordProtection
|
||||||
import com.simplemobiletools.gallery.helpers.*
|
import com.simplemobiletools.gallery.helpers.*
|
||||||
import kotlinx.android.synthetic.main.activity_settings.*
|
import kotlinx.android.synthetic.main.activity_settings.*
|
||||||
|
|
||||||
|
@ -64,10 +65,20 @@ class SettingsActivity : SimpleActivity() {
|
||||||
private fun setupShowHiddenFolders() {
|
private fun setupShowHiddenFolders() {
|
||||||
settings_show_hidden_folders.isChecked = config.showHiddenMedia
|
settings_show_hidden_folders.isChecked = config.showHiddenMedia
|
||||||
settings_show_hidden_folders_holder.setOnClickListener {
|
settings_show_hidden_folders_holder.setOnClickListener {
|
||||||
|
if (config.showHiddenMedia) {
|
||||||
|
toggleHiddenFolders()
|
||||||
|
} else {
|
||||||
|
handleHiddenFolderPasswordProtection {
|
||||||
|
toggleHiddenFolders()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun toggleHiddenFolders() {
|
||||||
settings_show_hidden_folders.toggle()
|
settings_show_hidden_folders.toggle()
|
||||||
config.showHiddenMedia = settings_show_hidden_folders.isChecked
|
config.showHiddenMedia = settings_show_hidden_folders.isChecked
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupAutoplayVideos() {
|
private fun setupAutoplayVideos() {
|
||||||
settings_autoplay_videos.isChecked = config.autoplayVideos
|
settings_autoplay_videos.isChecked = config.autoplayVideos
|
||||||
|
|
|
@ -24,6 +24,7 @@ import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.gallery.BuildConfig
|
import com.simplemobiletools.gallery.BuildConfig
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.gallery.dialogs.PatternDialog
|
||||||
import com.simplemobiletools.gallery.helpers.NOMEDIA
|
import com.simplemobiletools.gallery.helpers.NOMEDIA
|
||||||
import com.simplemobiletools.gallery.helpers.REQUEST_EDIT_IMAGE
|
import com.simplemobiletools.gallery.helpers.REQUEST_EDIT_IMAGE
|
||||||
import com.simplemobiletools.gallery.helpers.REQUEST_SET_AS
|
import com.simplemobiletools.gallery.helpers.REQUEST_SET_AS
|
||||||
|
@ -332,6 +333,16 @@ fun Activity.loadStaticGif(path: String, target: MySquareImageView) {
|
||||||
builder.apply(options).into(target)
|
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> {
|
fun Activity.getCachedDirectories(): ArrayList<Directory> {
|
||||||
val token = object : TypeToken<List<Directory>>() {}.type
|
val token = object : TypeToken<List<Directory>>() {}.type
|
||||||
return Gson().fromJson<ArrayList<Directory>>(config.directories, token) ?: ArrayList<Directory>(1)
|
return Gson().fromJson<ArrayList<Directory>>(config.directories, token) ?: ArrayList<Directory>(1)
|
||||||
|
|
Loading…
Reference in a new issue