mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 23:28:42 +03:00
Move hidden files pref to AppPreferences
Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
This commit is contained in:
parent
02e98f25a5
commit
92d13f2f1a
5 changed files with 17 additions and 11 deletions
|
@ -27,6 +27,9 @@ public interface AppPreferences {
|
|||
boolean instantPictureUploadEnabled();
|
||||
boolean instantVideoUploadEnabled();
|
||||
|
||||
boolean isShowHiddenFilesEnabled();
|
||||
void setShowHiddenFilesEnabled(boolean enabled);
|
||||
|
||||
/**
|
||||
* Gets the selected file extension position the user selected to do the
|
||||
* last upload of a url file shared from other app.
|
||||
|
|
|
@ -50,6 +50,7 @@ public final class PreferenceManager implements AppPreferences {
|
|||
public static final String AUTO_PREF__LAST_SEEN_VERSION_CODE = "lastSeenVersionCode";
|
||||
private static final String PREF__INSTANT_UPLOADING = "instant_uploading";
|
||||
private static final String PREF__INSTANT_VIDEO_UPLOADING = "instant_video_uploading";
|
||||
private static final String PREF__SHOW_HIDDEN_FILES = "show_hidden_files_pref";
|
||||
private static final String PREF__LEGACY_CLEAN = "legacyClean";
|
||||
public static final String PREF__KEYS_MIGRATION = "keysMigration";
|
||||
private static final String PREF__FIX_STORAGE_PATH = "storagePathFix";
|
||||
|
@ -103,8 +104,14 @@ public final class PreferenceManager implements AppPreferences {
|
|||
return preferences.getBoolean(PREF__INSTANT_VIDEO_UPLOADING, false);
|
||||
}
|
||||
|
||||
public static boolean showHiddenFilesEnabled(Context context) {
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("show_hidden_files_pref", false);
|
||||
@Override
|
||||
public boolean isShowHiddenFilesEnabled() {
|
||||
return preferences.getBoolean(PREF__SHOW_HIDDEN_FILES, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShowHiddenFilesEnabled(boolean enabled) {
|
||||
preferences.edit().putBoolean(PREF__SHOW_HIDDEN_FILES, enabled).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -534,11 +534,7 @@ public class SettingsActivity extends PreferenceActivity
|
|||
showHiddenFiles = (SwitchPreference) findPreference("show_hidden_files");
|
||||
if (fShowHiddenFilesEnabled) {
|
||||
showHiddenFiles.setOnPreferenceClickListener(preference -> {
|
||||
SharedPreferences appPrefs =
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
SharedPreferences.Editor editor = appPrefs.edit();
|
||||
editor.putBoolean("show_hidden_files_pref", showHiddenFiles.isChecked());
|
||||
editor.apply();
|
||||
preferences.setShowHiddenFilesEnabled(showHiddenFiles.isChecked());
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -324,7 +324,7 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
mFiles = sortOrder.sortLocalFiles(mFiles);
|
||||
|
||||
// Fetch preferences for showing hidden files
|
||||
boolean showHiddenFiles = PreferenceManager.showHiddenFilesEnabled(mContext);
|
||||
boolean showHiddenFiles = preferences.isShowHiddenFilesEnabled();
|
||||
if (!showHiddenFiles) {
|
||||
mFiles = filterHiddenFiles(mFiles);
|
||||
}
|
||||
|
|
|
@ -522,7 +522,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
int foldersCount = 0;
|
||||
int count = mFiles.size();
|
||||
OCFile file;
|
||||
final boolean showHiddenFiles = PreferenceManager.showHiddenFilesEnabled(mContext);
|
||||
final boolean showHiddenFiles = preferences.isShowHiddenFilesEnabled();
|
||||
for (int i = 0; i < count; i++) {
|
||||
file = getItem(i);
|
||||
if (file.isFolder()) {
|
||||
|
@ -619,7 +619,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
if (mStorageManager != null) {
|
||||
mFiles = mStorageManager.getFolderContent(directory, onlyOnDevice);
|
||||
|
||||
if (!PreferenceManager.showHiddenFilesEnabled(mContext)) {
|
||||
if (!preferences.isShowHiddenFilesEnabled()) {
|
||||
mFiles = filterHiddenFiles(mFiles);
|
||||
}
|
||||
if (!limitToMimeType.isEmpty()) {
|
||||
|
@ -846,7 +846,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
mFiles.clear();
|
||||
if (ocFiles != null && ocFiles.size() > 0) {
|
||||
mFiles.addAll(ocFiles);
|
||||
if (!PreferenceManager.showHiddenFilesEnabled(mContext)) {
|
||||
if (!preferences.isShowHiddenFilesEnabled()) {
|
||||
mFiles = filterHiddenFiles(mFiles);
|
||||
}
|
||||
FileSortOrder sortOrder = preferences.getSortOrderByFolder(currentDirectory);
|
||||
|
|
Loading…
Reference in a new issue