mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
allow hiding folders
This commit is contained in:
parent
cff90e1e8b
commit
848fe154be
12 changed files with 53 additions and 3 deletions
|
@ -3,6 +3,9 @@ package com.simplemobiletools.gallery;
|
|||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class Config {
|
||||
private SharedPreferences mPrefs;
|
||||
|
||||
|
@ -10,7 +13,7 @@ public class Config {
|
|||
return new Config(context);
|
||||
}
|
||||
|
||||
public Config(Context context) {
|
||||
private Config(Context context) {
|
||||
mPrefs = context.getSharedPreferences(Constants.PREFS_KEY, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
|
@ -59,4 +62,14 @@ public class Config {
|
|||
public void setDirectorySorting(int order) {
|
||||
mPrefs.edit().putInt(Constants.DIRECTORY_SORT_ORDER, order).apply();
|
||||
}
|
||||
|
||||
public void addHiddenDirectory(String path) {
|
||||
final Set<String> hiddenFolders = getHiddenFolders();
|
||||
hiddenFolders.add(path);
|
||||
mPrefs.edit().putStringSet(Constants.HIDDEN_FOLDERS, hiddenFolders).apply();
|
||||
}
|
||||
|
||||
public Set<String> getHiddenFolders() {
|
||||
return mPrefs.getStringSet(Constants.HIDDEN_FOLDERS, new HashSet<String>());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ public class Constants {
|
|||
public static final String IS_SAME_SORTING = "is_same_sorting";
|
||||
public static final String SORT_ORDER = "sort_order";
|
||||
public static final String DIRECTORY_SORT_ORDER = "directory_sort_order";
|
||||
public static final String HIDDEN_FOLDERS = "hidden_foldersy";
|
||||
|
||||
// sorting
|
||||
public static final int SORT_BY_NAME = 1;
|
||||
|
|
|
@ -43,6 +43,7 @@ import java.util.Collections;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
@ -228,7 +229,7 @@ public class MainActivity extends SimpleActivity
|
|||
}
|
||||
|
||||
final List<Directory> dirs = new ArrayList<>(directories.values());
|
||||
removeNoMediaDirs(dirs);
|
||||
filderDirectories(dirs);
|
||||
Directory.mSorting = mConfig.getDirectorySorting();
|
||||
Collections.sort(dirs);
|
||||
|
||||
|
@ -238,7 +239,23 @@ public class MainActivity extends SimpleActivity
|
|||
return dirs;
|
||||
}
|
||||
|
||||
private void removeNoMediaDirs(List<Directory> dirs) {
|
||||
private void filderDirectories(List<Directory> dirs) {
|
||||
removeHiddenFolders(dirs);
|
||||
removeNoMediaFolders(dirs);
|
||||
}
|
||||
|
||||
private void removeHiddenFolders(List<Directory> dirs) {
|
||||
final Set<String> hiddenDirs = mConfig.getHiddenFolders();
|
||||
final List<Directory> ignoreDirs = new ArrayList<>();
|
||||
for (Directory d : dirs) {
|
||||
if (hiddenDirs.contains(d.getPath()))
|
||||
ignoreDirs.add(d);
|
||||
}
|
||||
|
||||
dirs.removeAll(ignoreDirs);
|
||||
}
|
||||
|
||||
private void removeNoMediaFolders(List<Directory> dirs) {
|
||||
final List<Directory> ignoreDirs = new ArrayList<>();
|
||||
for (final Directory d : dirs) {
|
||||
final File dir = new File(d.getPath());
|
||||
|
|
|
@ -139,6 +139,9 @@ public class MediaActivity extends SimpleActivity
|
|||
case R.id.sort:
|
||||
showSortingDialog();
|
||||
return true;
|
||||
case R.id.hide_folder:
|
||||
hideDirectory();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
@ -161,6 +164,10 @@ public class MediaActivity extends SimpleActivity
|
|||
new ChangeSorting(this, false);
|
||||
}
|
||||
|
||||
private void hideDirectory() {
|
||||
mConfig.addHiddenDirectory(mPath);
|
||||
}
|
||||
|
||||
private void deleteDirectoryIfEmpty() {
|
||||
final File file = new File(mPath);
|
||||
if (file.isDirectory() && file.listFiles().length == 0) {
|
||||
|
|
|
@ -6,4 +6,9 @@
|
|||
android:icon="@mipmap/sort"
|
||||
android:title="@string/sort_by"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/hide_folder"
|
||||
android:title="@string/hide_folder"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
</menu>
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
<string name="cancel">Abbrechen</string>
|
||||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
<string name="hide_folder">Hide folder</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 Ordner gelöscht</item>
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
<string name="cancel">Cancelar</string>
|
||||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
<string name="hide_folder">Hide folder</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 carpeta eliminada</item>
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
<string name="cancel">Cancel</string>
|
||||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
<string name="hide_folder">Hide folder</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 cartella eliminata</item>
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
<string name="cancel">Cancel</string>
|
||||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
<string name="hide_folder">Hide folder</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 フォルダーを削除しました</item>
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
<string name="cancel">Cancelar</string>
|
||||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
<string name="hide_folder">Hide folder</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 pasta eliminada</item>
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
<string name="cancel">Cancel</string>
|
||||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
<string name="hide_folder">Hide folder</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 mapp borttagen</item>
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
<string name="cancel">Cancel</string>
|
||||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
<string name="hide_folder">Hide folder</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 folder deleted</item>
|
||||
|
|
Loading…
Reference in a new issue