diff --git a/app/src/main/java/com/simplemobiletools/gallery/Config.java b/app/src/main/java/com/simplemobiletools/gallery/Config.java index 3024c8ad3..d99d3d681 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/Config.java +++ b/app/src/main/java/com/simplemobiletools/gallery/Config.java @@ -77,12 +77,24 @@ public class Config { mPrefs.edit().putStringSet(Constants.HIDDEN_FOLDERS, hiddenFolders).apply(); } + public void addHiddenDirectories(Set paths) { + final Set hiddenFolders = getHiddenFolders(); + hiddenFolders.addAll(paths); + mPrefs.edit().putStringSet(Constants.HIDDEN_FOLDERS, hiddenFolders).apply(); + } + public void removeHiddenDirectory(String path) { final Set hiddenFolders = getHiddenFolders(); hiddenFolders.remove(path); mPrefs.edit().putStringSet(Constants.HIDDEN_FOLDERS, hiddenFolders).apply(); } + public void removeHiddenDirectories(Set paths) { + final Set hiddenFolders = getHiddenFolders(); + hiddenFolders.removeAll(paths); + mPrefs.edit().putStringSet(Constants.HIDDEN_FOLDERS, hiddenFolders).apply(); + } + public Set getHiddenFolders() { return mPrefs.getStringSet(Constants.HIDDEN_FOLDERS, new HashSet()); } diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java index f65295fc6..7183ffb11 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java @@ -40,6 +40,7 @@ import java.io.File; import java.io.FilenameFilter; import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -629,13 +630,28 @@ public class MainActivity extends SimpleActivity } private void hideFolders() { + mConfig.addHiddenDirectories(getSelectedPaths()); initializeGallery(); } private void unhideFolders() { + mConfig.removeHiddenDirectories(getSelectedPaths()); initializeGallery(); } + private Set getSelectedPaths() { + final SparseBooleanArray items = mGridView.getCheckedItemPositions(); + final Set selectedPaths = new HashSet<>(); + final int cnt = items.size(); + for (int i = 0; i < cnt; i++) { + if (items.valueAt(i)) { + final int id = items.keyAt(i); + selectedPaths.add(mDirs.get(id).getPath()); + } + } + return selectedPaths; + } + private void scanCompleted(final String path) { final File dir = new File(path); if (dir.isDirectory()) {