mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
Merge pull request #3734 from nextcloud/refactor-folder-layout-preference
Move folder layout preference to AppPreferences
This commit is contained in:
commit
def9054858
3 changed files with 24 additions and 20 deletions
|
@ -82,6 +82,23 @@ public interface AppPreferences {
|
|||
*/
|
||||
String getLastUploadPath();
|
||||
|
||||
/**
|
||||
* Get preferred folder display type.
|
||||
*
|
||||
* @param folder Folder
|
||||
* @return preference value, default is
|
||||
* {@link com.owncloud.android.ui.fragment.OCFileListFragment#FOLDER_LAYOUT_LIST}
|
||||
*/
|
||||
String getFolderLayout(OCFile folder);
|
||||
|
||||
/**
|
||||
* Set preferred folder display type.
|
||||
*
|
||||
* @param folder Folder
|
||||
* @param layout_name preference value
|
||||
*/
|
||||
void setFolderLayout(OCFile folder, String layout_name);
|
||||
|
||||
/**
|
||||
* Saves the path where the user selected to do the last upload of a file shared from other app.
|
||||
*
|
||||
|
|
|
@ -167,26 +167,13 @@ public final class PreferenceManager implements AppPreferences {
|
|||
return getDefaultSharedPreferences(context).getBoolean(SettingsActivity.PREFERENCE_USE_FINGERPRINT, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get preferred folder display type.
|
||||
*
|
||||
* @param context Caller {@link Context}, used to access to preferences manager.
|
||||
* @param folder Folder
|
||||
* @return preference value, default is
|
||||
* {@link com.owncloud.android.ui.fragment.OCFileListFragment#FOLDER_LAYOUT_LIST}
|
||||
*/
|
||||
public static String getFolderLayout(Context context, OCFile folder) {
|
||||
@Override
|
||||
public String getFolderLayout(OCFile folder) {
|
||||
return getFolderPreference(context, PREF__FOLDER_LAYOUT, folder, FOLDER_LAYOUT_LIST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set preferred folder display type.
|
||||
*
|
||||
* @param context Caller {@link Context}, used to access to shared preferences manager.
|
||||
* @param folder Folder
|
||||
* @param layout_name preference value
|
||||
*/
|
||||
public static void setFolderLayout(Context context, OCFile folder, String layout_name) {
|
||||
@Override
|
||||
public void setFolderLayout(OCFile folder, String layout_name) {
|
||||
setFolderPreference(context, PREF__FOLDER_LAYOUT, folder, layout_name);
|
||||
}
|
||||
|
||||
|
|
|
@ -1201,11 +1201,11 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
* @return 'true' is folder should be shown in grid mode, 'false' if list mode is preferred.
|
||||
*/
|
||||
public boolean isGridViewPreferred(OCFile folder) {
|
||||
return FOLDER_LAYOUT_GRID.equals(PreferenceManager.getFolderLayout(getActivity(), folder));
|
||||
return FOLDER_LAYOUT_GRID.equals(preferences.getFolderLayout(folder));
|
||||
}
|
||||
|
||||
public void setListAsPreferred() {
|
||||
PreferenceManager.setFolderLayout(getActivity(), mFile, FOLDER_LAYOUT_LIST);
|
||||
preferences.setFolderLayout(mFile, FOLDER_LAYOUT_LIST);
|
||||
switchToListView();
|
||||
}
|
||||
|
||||
|
@ -1216,7 +1216,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
}
|
||||
|
||||
public void setGridAsPreferred() {
|
||||
PreferenceManager.setFolderLayout(getActivity(), mFile, FOLDER_LAYOUT_GRID);
|
||||
preferences.setFolderLayout(mFile, FOLDER_LAYOUT_GRID);
|
||||
switchToGridView();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue