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
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.gallery.R
import com.simplemobiletools.gallery.extensions.config
@ -11,10 +14,10 @@ class ExcludedFoldersActivity : SimpleActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_excluded_folders)
addExcludedFolders()
updateExcludedFolders()
}
private fun addExcludedFolders() {
private fun updateExcludedFolders() {
excluded_folders_holder.removeAllViews()
val folders = config.excludedFolders
for (folder in folders) {
@ -22,11 +25,30 @@ class ExcludedFoldersActivity : SimpleActivity() {
excluded_folder_title.text = folder
excluded_folders_icon.setOnClickListener {
config.removeExcludedFolder(folder)
addExcludedFolders()
updateExcludedFolders()
}
excluded_folders_holder.addView(this)
}
}
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.settings -> launchSettings()
R.id.about -> launchAbout()
else -> return super.onOptionsItemSelected(item)
}
return true
}

View File

@ -70,6 +70,10 @@ 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()

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="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="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 -->
<string name="resize">Resize</string>

View File

@ -30,6 +30,8 @@
<string name="excluded_folders">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="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 -->
<string name="resize">Größe ändern</string>

View File

@ -30,6 +30,8 @@
<string name="excluded_folders">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="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 -->
<string name="resize">Resize</string>

View File

@ -30,6 +30,8 @@
<string name="excluded_folders">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="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 -->
<string name="resize">Redimensionner</string>

View File

@ -30,6 +30,8 @@
<string name="excluded_folders">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="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 -->
<string name="resize">Resize</string>

View File

@ -30,6 +30,8 @@
<string name="excluded_folders">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="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 -->
<string name="resize">Resize</string>

View File

@ -30,6 +30,8 @@
<string name="excluded_folders">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="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 -->
<string name="resize">Resize</string>

View File

@ -30,6 +30,8 @@
<string name="excluded_folders">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="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 -->
<string name="resize">Redimensionar</string>

View File

@ -30,6 +30,8 @@
<string name="excluded_folders">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="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 -->
<string name="resize">Изменить размер</string>

View File

@ -30,6 +30,8 @@
<string name="excluded_folders">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="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 -->
<string name="resize">Zmeniť veľkosť</string>

View File

@ -28,6 +28,8 @@
<string name="excluded_folders">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="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 -->
<string name="resize">Ändra storlek</string>

View File

@ -30,6 +30,8 @@
<string name="excluded_folders">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="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 -->
<string name="resize">Yeniden boyutlandır</string>

View File

@ -30,6 +30,8 @@
<string name="excluded_folders">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="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 -->
<string name="resize">缩放</string>

View File

@ -30,6 +30,8 @@
<string name="excluded_folders">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="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 -->
<string name="resize">縮放</string>

View File

@ -30,6 +30,8 @@
<string name="excluded_folders">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="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 -->
<string name="resize">Resize</string>