add a menu button for adding included folders
This commit is contained in:
parent
dc98df713d
commit
ff1f29b1f8
4 changed files with 49 additions and 4 deletions
|
@ -1,11 +1,34 @@
|
|||
package com.simplemobiletools.gallery.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
|
||||
class IncludedFoldersActivity : SimpleActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_included_folders)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_included_folders, menu)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.add_folder -> addIncludedFolder()
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun addIncludedFolder() {
|
||||
FilePickerDialog(this, pickFile = false, showHidden = config.showHiddenFolders) {
|
||||
config.addIncludedFolder(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,14 +78,26 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
excludedFolders = currExcludedFolders
|
||||
}
|
||||
|
||||
fun removeAllExcludedFolders() {
|
||||
prefs.edit().remove(EXCLUDED_FOLDERS).apply()
|
||||
}
|
||||
|
||||
var excludedFolders: MutableSet<String>
|
||||
get() = prefs.getStringSet(EXCLUDED_FOLDERS, HashSet<String>())
|
||||
set(excludedFolders) = prefs.edit().remove(EXCLUDED_FOLDERS).putStringSet(EXCLUDED_FOLDERS, excludedFolders).apply()
|
||||
|
||||
fun addIncludedFolder(path: String) {
|
||||
val currIncludedFolders = HashSet<String>(includedFolders)
|
||||
currIncludedFolders.add(path)
|
||||
includedFolders = currIncludedFolders
|
||||
}
|
||||
|
||||
fun removeIncludedFolder(path: String) {
|
||||
val currIncludedFolders = HashSet<String>(includedFolders)
|
||||
currIncludedFolders.remove(path)
|
||||
includedFolders = currIncludedFolders
|
||||
}
|
||||
|
||||
var includedFolders: MutableSet<String>
|
||||
get() = prefs.getStringSet(INCLUDED_FOLDERS, HashSet<String>())
|
||||
set(includedFolders) = prefs.edit().remove(INCLUDED_FOLDERS).putStringSet(INCLUDED_FOLDERS, includedFolders).apply()
|
||||
|
||||
fun saveFolderMedia(path: String, json: String) {
|
||||
prefs.edit().putString(SAVE_FOLDER_PREFIX + path, json).apply()
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ val SHOW_MEDIA = "show_media"
|
|||
val SAVE_FOLDER_PREFIX = "folder_"
|
||||
val HIDE_FOLDER_TOOLTIP_SHOWN = "hide_folder_tooltip_shown"
|
||||
val EXCLUDED_FOLDERS = "excluded_folders"
|
||||
val INCLUDED_FOLDERS = "included_folders"
|
||||
|
||||
val NOMEDIA = ".nomedia"
|
||||
|
||||
|
|
9
app/src/main/res/menu/menu_included_folders.xml
Normal file
9
app/src/main/res/menu/menu_included_folders.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/add_folder"
|
||||
android:icon="@drawable/ic_plus"
|
||||
android:title="@string/add_folder"
|
||||
app:showAsAction="ifRoom"/>
|
||||
</menu>
|
Loading…
Reference in a new issue