add a menu item for removing all excluded folders

This commit is contained in:
tibbi 2017-02-26 21:31:52 +01:00
parent 535a9ba634
commit 6c11d71a9d
19 changed files with 68 additions and 4 deletions

View file

@ -1,6 +1,9 @@
package com.simplemobiletools.gallery.activities package com.simplemobiletools.gallery.activities
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.extensions.updateTextColors import com.simplemobiletools.commons.extensions.updateTextColors
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.extensions.config import com.simplemobiletools.gallery.extensions.config
@ -11,10 +14,10 @@ class ExcludedFoldersActivity : SimpleActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_excluded_folders) setContentView(R.layout.activity_excluded_folders)
addExcludedFolders() updateExcludedFolders()
} }
private fun addExcludedFolders() { private fun updateExcludedFolders() {
excluded_folders_holder.removeAllViews() excluded_folders_holder.removeAllViews()
val folders = config.excludedFolders val folders = config.excludedFolders
for (folder in folders) { for (folder in folders) {
@ -22,11 +25,30 @@ class ExcludedFoldersActivity : SimpleActivity() {
excluded_folder_title.text = folder excluded_folder_title.text = folder
excluded_folders_icon.setOnClickListener { excluded_folders_icon.setOnClickListener {
config.removeExcludedFolder(folder) config.removeExcludedFolder(folder)
addExcludedFolders() updateExcludedFolders()
} }
excluded_folders_holder.addView(this) excluded_folders_holder.addView(this)
} }
} }
updateTextColors(excluded_folders_holder) updateTextColors(excluded_folders_holder)
} }
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu_excluded_folders, menu)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.remove_all -> removeAllExcludedFolders()
}
return true
}
private fun removeAllExcludedFolders() {
ConfirmationDialog(this, getString(R.string.remove_all_description)) {
config.removeAllExcludedFolders()
updateExcludedFolders()
}
}
} }

View file

@ -125,7 +125,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
R.id.reduce_column_count -> reduceColumnCount() R.id.reduce_column_count -> reduceColumnCount()
R.id.settings -> launchSettings() R.id.settings -> launchSettings()
R.id.about -> launchAbout() R.id.about -> launchAbout()
else -> return super.onOptionsItemSelected(item)
} }
return true return true
} }

View file

@ -70,6 +70,10 @@ class Config(context: Context) : BaseConfig(context) {
excludedFolders = currExcludedFolders excludedFolders = currExcludedFolders
} }
fun removeAllExcludedFolders() {
prefs.edit().remove(EXCLUDED_FOLDERS).apply()
}
var excludedFolders: MutableSet<String> var excludedFolders: MutableSet<String>
get() = prefs.getStringSet(EXCLUDED_FOLDERS, HashSet<String>()) get() = prefs.getStringSet(EXCLUDED_FOLDERS, HashSet<String>())
set(excludedFolders) = prefs.edit().remove(EXCLUDED_FOLDERS).putStringSet(EXCLUDED_FOLDERS, excludedFolders).apply() set(excludedFolders) = prefs.edit().remove(EXCLUDED_FOLDERS).putStringSet(EXCLUDED_FOLDERS, excludedFolders).apply()

View 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/remove_all"
android:icon="@drawable/ic_cross"
android:title="@string/remove_all"
app:showAsAction="ifRoom"/>
</menu>

View file

@ -30,6 +30,8 @@
<string name="excluded_folders">Excluded folders</string> <string name="excluded_folders">Excluded folders</string>
<string name="manage_excluded_folders">Manage excluded folders</string> <string name="manage_excluded_folders">Manage excluded folders</string>
<string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string> <string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string>
<string name="remove_all">Remove all</string>
<string name="remove_all_description">Remove all folders from the list of excluded? This will not delete the folders.</string>
<!-- Resizing --> <!-- Resizing -->
<string name="resize">Resize</string> <string name="resize">Resize</string>

View file

@ -30,6 +30,8 @@
<string name="excluded_folders">Excluded folders</string> <string name="excluded_folders">Excluded folders</string>
<string name="manage_excluded_folders">Manage excluded folders</string> <string name="manage_excluded_folders">Manage excluded folders</string>
<string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string> <string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string>
<string name="remove_all">Remove all</string>
<string name="remove_all_description">Remove all folders from the list of excluded? This will not delete the folders.</string>
<!-- Resizing --> <!-- Resizing -->
<string name="resize">Größe ändern</string> <string name="resize">Größe ändern</string>

View file

@ -30,6 +30,8 @@
<string name="excluded_folders">Excluded folders</string> <string name="excluded_folders">Excluded folders</string>
<string name="manage_excluded_folders">Manage excluded folders</string> <string name="manage_excluded_folders">Manage excluded folders</string>
<string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string> <string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string>
<string name="remove_all">Remove all</string>
<string name="remove_all_description">Remove all folders from the list of excluded? This will not delete the folders.</string>
<!-- Resizing --> <!-- Resizing -->
<string name="resize">Resize</string> <string name="resize">Resize</string>

View file

@ -30,6 +30,8 @@
<string name="excluded_folders">Excluded folders</string> <string name="excluded_folders">Excluded folders</string>
<string name="manage_excluded_folders">Manage excluded folders</string> <string name="manage_excluded_folders">Manage excluded folders</string>
<string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string> <string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string>
<string name="remove_all">Remove all</string>
<string name="remove_all_description">Remove all folders from the list of excluded? This will not delete the folders.</string>
<!-- Resizing --> <!-- Resizing -->
<string name="resize">Redimensionner</string> <string name="resize">Redimensionner</string>

View file

@ -30,6 +30,8 @@
<string name="excluded_folders">Excluded folders</string> <string name="excluded_folders">Excluded folders</string>
<string name="manage_excluded_folders">Manage excluded folders</string> <string name="manage_excluded_folders">Manage excluded folders</string>
<string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string> <string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string>
<string name="remove_all">Remove all</string>
<string name="remove_all_description">Remove all folders from the list of excluded? This will not delete the folders.</string>
<!-- Resizing --> <!-- Resizing -->
<string name="resize">Resize</string> <string name="resize">Resize</string>

View file

@ -30,6 +30,8 @@
<string name="excluded_folders">Excluded folders</string> <string name="excluded_folders">Excluded folders</string>
<string name="manage_excluded_folders">Manage excluded folders</string> <string name="manage_excluded_folders">Manage excluded folders</string>
<string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string> <string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string>
<string name="remove_all">Remove all</string>
<string name="remove_all_description">Remove all folders from the list of excluded? This will not delete the folders.</string>
<!-- Resizing --> <!-- Resizing -->
<string name="resize">Resize</string> <string name="resize">Resize</string>

View file

@ -30,6 +30,8 @@
<string name="excluded_folders">Excluded folders</string> <string name="excluded_folders">Excluded folders</string>
<string name="manage_excluded_folders">Manage excluded folders</string> <string name="manage_excluded_folders">Manage excluded folders</string>
<string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string> <string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string>
<string name="remove_all">Remove all</string>
<string name="remove_all_description">Remove all folders from the list of excluded? This will not delete the folders.</string>
<!-- Resizing --> <!-- Resizing -->
<string name="resize">Resize</string> <string name="resize">Resize</string>

View file

@ -30,6 +30,8 @@
<string name="excluded_folders">Excluded folders</string> <string name="excluded_folders">Excluded folders</string>
<string name="manage_excluded_folders">Manage excluded folders</string> <string name="manage_excluded_folders">Manage excluded folders</string>
<string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string> <string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string>
<string name="remove_all">Remove all</string>
<string name="remove_all_description">Remove all folders from the list of excluded? This will not delete the folders.</string>
<!-- Resizing --> <!-- Resizing -->
<string name="resize">Redimensionar</string> <string name="resize">Redimensionar</string>

View file

@ -30,6 +30,8 @@
<string name="excluded_folders">Excluded folders</string> <string name="excluded_folders">Excluded folders</string>
<string name="manage_excluded_folders">Manage excluded folders</string> <string name="manage_excluded_folders">Manage excluded folders</string>
<string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string> <string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string>
<string name="remove_all">Remove all</string>
<string name="remove_all_description">Remove all folders from the list of excluded? This will not delete the folders.</string>
<!-- Resizing --> <!-- Resizing -->
<string name="resize">Изменить размер</string> <string name="resize">Изменить размер</string>

View file

@ -30,6 +30,8 @@
<string name="excluded_folders">Vylúčené priečinky</string> <string name="excluded_folders">Vylúčené priečinky</string>
<string name="manage_excluded_folders">Spravovať vylúčené priečinky</string> <string name="manage_excluded_folders">Spravovať vylúčené priečinky</string>
<string name="exclude_folder_description">Táto funkcia ukryje výber iba pred Jednoduchou galériou. Spravovať vylúčené priečinky je možné v nastaveniach. Pokračovať?</string> <string name="exclude_folder_description">Táto funkcia ukryje výber iba pred Jednoduchou galériou. Spravovať vylúčené priečinky je možné v nastaveniach. Pokračovať?</string>
<string name="remove_all">Odstrániť všetky</string>
<string name="remove_all_description">Odstrániť všetky priečinky zo zoznamu vylúčených? Táto operácia neodstráni samotný obsah priečinkov.</string>
<!-- Resizing --> <!-- Resizing -->
<string name="resize">Zmeniť veľkosť</string> <string name="resize">Zmeniť veľkosť</string>

View file

@ -28,6 +28,8 @@
<string name="excluded_folders">Excluded folders</string> <string name="excluded_folders">Excluded folders</string>
<string name="manage_excluded_folders">Manage excluded folders</string> <string name="manage_excluded_folders">Manage excluded folders</string>
<string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string> <string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string>
<string name="remove_all">Remove all</string>
<string name="remove_all_description">Remove all folders from the list of excluded? This will not delete the folders.</string>
<!-- Resizing --> <!-- Resizing -->
<string name="resize">Ändra storlek</string> <string name="resize">Ändra storlek</string>

View file

@ -30,6 +30,8 @@
<string name="excluded_folders">Excluded folders</string> <string name="excluded_folders">Excluded folders</string>
<string name="manage_excluded_folders">Manage excluded folders</string> <string name="manage_excluded_folders">Manage excluded folders</string>
<string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string> <string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string>
<string name="remove_all">Remove all</string>
<string name="remove_all_description">Remove all folders from the list of excluded? This will not delete the folders.</string>
<!-- Resizing --> <!-- Resizing -->
<string name="resize">Yeniden boyutlandır</string> <string name="resize">Yeniden boyutlandır</string>

View file

@ -30,6 +30,8 @@
<string name="excluded_folders">Excluded folders</string> <string name="excluded_folders">Excluded folders</string>
<string name="manage_excluded_folders">Manage excluded folders</string> <string name="manage_excluded_folders">Manage excluded folders</string>
<string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string> <string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string>
<string name="remove_all">Remove all</string>
<string name="remove_all_description">Remove all folders from the list of excluded? This will not delete the folders.</string>
<!-- Resizing --> <!-- Resizing -->
<string name="resize">缩放</string> <string name="resize">缩放</string>

View file

@ -30,6 +30,8 @@
<string name="excluded_folders">Excluded folders</string> <string name="excluded_folders">Excluded folders</string>
<string name="manage_excluded_folders">Manage excluded folders</string> <string name="manage_excluded_folders">Manage excluded folders</string>
<string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string> <string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string>
<string name="remove_all">Remove all</string>
<string name="remove_all_description">Remove all folders from the list of excluded? This will not delete the folders.</string>
<!-- Resizing --> <!-- Resizing -->
<string name="resize">縮放</string> <string name="resize">縮放</string>

View file

@ -30,6 +30,8 @@
<string name="excluded_folders">Excluded folders</string> <string name="excluded_folders">Excluded folders</string>
<string name="manage_excluded_folders">Manage excluded folders</string> <string name="manage_excluded_folders">Manage excluded folders</string>
<string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string> <string name="exclude_folder_description">This function will make the selection hidden only for Simple Gallery. You can manage hidden folders in Settings. Continue?</string>
<string name="remove_all">Remove all</string>
<string name="remove_all_description">Remove all folders from the list of excluded? This will not delete the folders.</string>
<!-- Resizing --> <!-- Resizing -->
<string name="resize">Resize</string> <string name="resize">Resize</string>