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();
|
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() {
|
public Set<String> getHiddenFolders() {
|
||||||
return mPrefs.getStringSet(Constants.HIDDEN_FOLDERS, new HashSet<String>());
|
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.app.ActivityCompat;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.util.Log;
|
|
||||||
import android.util.SparseBooleanArray;
|
import android.util.SparseBooleanArray;
|
||||||
import android.view.ActionMode;
|
import android.view.ActionMode;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
|
|
@ -130,6 +130,11 @@ public class MediaActivity extends SimpleActivity
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.menu_media, 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,6 +147,9 @@ public class MediaActivity extends SimpleActivity
|
||||||
case R.id.hide_folder:
|
case R.id.hide_folder:
|
||||||
hideDirectory();
|
hideDirectory();
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.unhide_folder:
|
||||||
|
unhideDirectory();
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
@ -166,7 +174,14 @@ public class MediaActivity extends SimpleActivity
|
||||||
|
|
||||||
private void hideDirectory() {
|
private void hideDirectory() {
|
||||||
mConfig.addHiddenDirectory(mPath);
|
mConfig.addHiddenDirectory(mPath);
|
||||||
finish();
|
|
||||||
|
if (!mConfig.getShowHiddenFolders())
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unhideDirectory() {
|
||||||
|
mConfig.removeHiddenDirectory(mPath);
|
||||||
|
invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteDirectoryIfEmpty() {
|
private void deleteDirectoryIfEmpty() {
|
||||||
|
|
|
@ -10,5 +10,8 @@
|
||||||
android:id="@+id/hide_folder"
|
android:id="@+id/hide_folder"
|
||||||
android:title="@string/hide_folder"
|
android:title="@string/hide_folder"
|
||||||
app:showAsAction="never"/>
|
app:showAsAction="never"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/unhide_folder"
|
||||||
|
android:title="@string/unhide_folder"
|
||||||
|
app:showAsAction="never"/>
|
||||||
</menu>
|
</menu>
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
<string name="open_with">Open with</string>
|
<string name="open_with">Open with</string>
|
||||||
<string name="no_app_found">No valid app found</string>
|
<string name="no_app_found">No valid app found</string>
|
||||||
<string name="hide_folder">Hide folder</string>
|
<string name="hide_folder">Hide folder</string>
|
||||||
|
<string name="unhide_folder">Unhide folder</string>
|
||||||
|
|
||||||
<plurals name="folders_deleted">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 Ordner gelöscht</item>
|
<item quantity="one">1 Ordner gelöscht</item>
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
<string name="open_with">Open with</string>
|
<string name="open_with">Open with</string>
|
||||||
<string name="no_app_found">No valid app found</string>
|
<string name="no_app_found">No valid app found</string>
|
||||||
<string name="hide_folder">Hide folder</string>
|
<string name="hide_folder">Hide folder</string>
|
||||||
|
<string name="unhide_folder">Unhide folder</string>
|
||||||
|
|
||||||
<plurals name="folders_deleted">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 carpeta eliminada</item>
|
<item quantity="one">1 carpeta eliminada</item>
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
<string name="open_with">Open with</string>
|
<string name="open_with">Open with</string>
|
||||||
<string name="no_app_found">No valid app found</string>
|
<string name="no_app_found">No valid app found</string>
|
||||||
<string name="hide_folder">Hide folder</string>
|
<string name="hide_folder">Hide folder</string>
|
||||||
|
<string name="unhide_folder">Unhide folder</string>
|
||||||
|
|
||||||
<plurals name="folders_deleted">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 cartella eliminata</item>
|
<item quantity="one">1 cartella eliminata</item>
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
<string name="open_with">Open with</string>
|
<string name="open_with">Open with</string>
|
||||||
<string name="no_app_found">No valid app found</string>
|
<string name="no_app_found">No valid app found</string>
|
||||||
<string name="hide_folder">Hide folder</string>
|
<string name="hide_folder">Hide folder</string>
|
||||||
|
<string name="unhide_folder">Unhide folder</string>
|
||||||
|
|
||||||
<plurals name="folders_deleted">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 フォルダーを削除しました</item>
|
<item quantity="one">1 フォルダーを削除しました</item>
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
<string name="open_with">Open with</string>
|
<string name="open_with">Open with</string>
|
||||||
<string name="no_app_found">No valid app found</string>
|
<string name="no_app_found">No valid app found</string>
|
||||||
<string name="hide_folder">Hide folder</string>
|
<string name="hide_folder">Hide folder</string>
|
||||||
|
<string name="unhide_folder">Unhide folder</string>
|
||||||
|
|
||||||
<plurals name="folders_deleted">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 pasta eliminada</item>
|
<item quantity="one">1 pasta eliminada</item>
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
<string name="open_with">Open with</string>
|
<string name="open_with">Open with</string>
|
||||||
<string name="no_app_found">No valid app found</string>
|
<string name="no_app_found">No valid app found</string>
|
||||||
<string name="hide_folder">Hide folder</string>
|
<string name="hide_folder">Hide folder</string>
|
||||||
|
<string name="unhide_folder">Unhide folder</string>
|
||||||
|
|
||||||
<plurals name="folders_deleted">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 mapp borttagen</item>
|
<item quantity="one">1 mapp borttagen</item>
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
<string name="open_with">Open with</string>
|
<string name="open_with">Open with</string>
|
||||||
<string name="no_app_found">No valid app found</string>
|
<string name="no_app_found">No valid app found</string>
|
||||||
<string name="hide_folder">Hide folder</string>
|
<string name="hide_folder">Hide folder</string>
|
||||||
|
<string name="unhide_folder">Unhide folder</string>
|
||||||
|
|
||||||
<plurals name="folders_deleted">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 folder deleted</item>
|
<item quantity="one">1 folder deleted</item>
|
||||||
|
|
Loading…
Reference in a new issue