allow unhiding folders
This commit is contained in:
parent
60494b0cfd
commit
7b7788b03c
11 changed files with 37 additions and 3 deletions
|
@ -77,7 +77,17 @@ public class Config {
|
|||
mPrefs.edit().putStringSet(Constants.HIDDEN_FOLDERS, hiddenFolders).apply();
|
||||
}
|
||||
|
||||
public void removeHiddenDirectory(String path) {
|
||||
final Set<String> hiddenFolders = getHiddenFolders();
|
||||
hiddenFolders.remove(path);
|
||||
mPrefs.edit().putStringSet(Constants.HIDDEN_FOLDERS, hiddenFolders).apply();
|
||||
}
|
||||
|
||||
public Set<String> getHiddenFolders() {
|
||||
return mPrefs.getStringSet(Constants.HIDDEN_FOLDERS, new HashSet<String>());
|
||||
}
|
||||
|
||||
public boolean getIsFolderHidden(String path) {
|
||||
return getHiddenFolders().contains(path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import android.support.design.widget.Snackbar;
|
|||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.Log;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.ActionMode;
|
||||
import android.view.Menu;
|
||||
|
|
|
@ -130,6 +130,11 @@ public class MediaActivity extends SimpleActivity
|
|||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_media, menu);
|
||||
|
||||
final boolean isFolderHidden = mConfig.getIsFolderHidden(mPath);
|
||||
menu.findItem(R.id.hide_folder).setVisible(!isFolderHidden);
|
||||
menu.findItem(R.id.unhide_folder).setVisible(isFolderHidden);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -142,6 +147,9 @@ public class MediaActivity extends SimpleActivity
|
|||
case R.id.hide_folder:
|
||||
hideDirectory();
|
||||
return true;
|
||||
case R.id.unhide_folder:
|
||||
unhideDirectory();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
@ -166,9 +174,16 @@ public class MediaActivity extends SimpleActivity
|
|||
|
||||
private void hideDirectory() {
|
||||
mConfig.addHiddenDirectory(mPath);
|
||||
|
||||
if (!mConfig.getShowHiddenFolders())
|
||||
finish();
|
||||
}
|
||||
|
||||
private void unhideDirectory() {
|
||||
mConfig.removeHiddenDirectory(mPath);
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
private void deleteDirectoryIfEmpty() {
|
||||
final File file = new File(mPath);
|
||||
if (file.isDirectory() && file.listFiles().length == 0) {
|
||||
|
|
|
@ -10,5 +10,8 @@
|
|||
android:id="@+id/hide_folder"
|
||||
android:title="@string/hide_folder"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/unhide_folder"
|
||||
android:title="@string/unhide_folder"
|
||||
app:showAsAction="never"/>
|
||||
</menu>
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
<string name="hide_folder">Hide folder</string>
|
||||
<string name="unhide_folder">Unhide folder</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 Ordner gelöscht</item>
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
<string name="hide_folder">Hide folder</string>
|
||||
<string name="unhide_folder">Unhide folder</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 carpeta eliminada</item>
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
<string name="hide_folder">Hide folder</string>
|
||||
<string name="unhide_folder">Unhide folder</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 cartella eliminata</item>
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
<string name="hide_folder">Hide folder</string>
|
||||
<string name="unhide_folder">Unhide folder</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 フォルダーを削除しました</item>
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
<string name="hide_folder">Hide folder</string>
|
||||
<string name="unhide_folder">Unhide folder</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 pasta eliminada</item>
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
<string name="hide_folder">Hide folder</string>
|
||||
<string name="unhide_folder">Unhide folder</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 mapp borttagen</item>
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
<string name="hide_folder">Hide folder</string>
|
||||
<string name="unhide_folder">Unhide folder</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 folder deleted</item>
|
||||
|
|
Loading…
Reference in a new issue