-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Per folder sort order #2499
base: master
Are you sure you want to change the base?
Per folder sort order #2499
Conversation
@@ -85,7 +87,7 @@ public boolean isPreferViewMode() { | |||
} | |||
|
|||
public void setNotebookDirectory(final File file) { | |||
setString(R.string.pref_key__notebook_directory, Document.getPath(file)); | |||
setString(R.string.pref_key__notebook_directory, GsFileUtils.getPath(file)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this routine to GsFileUtils
@@ -88,6 +88,7 @@ public static class DialogOptions { | |||
public List<? extends CharSequence> data = null; | |||
public List<? extends CharSequence> highlightData = null; | |||
public List<Integer> iconsForData; | |||
public Collection<Integer> radioSet = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allows us to have radio buttons in the dialog
@@ -340,31 +355,10 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { | |||
_cu.tintMenuItems(menu, true, Color.WHITE); | |||
_cu.setSubMenuIconsVisibility(menu, true); | |||
|
|||
MenuItem item; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this moved from menu to dialog
@@ -663,6 +664,10 @@ private void loadFolder(final File folder, final File show) { | |||
_currentFolder = GsCollectionUtils.getOrDefault(_virtualMapping, folder, folder); | |||
} | |||
|
|||
if (folderChanged) { | |||
_dopt.listener.onFsViewerFolderChange(_currentFolder); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new callback which is called right before a folder is (re)loaded
app:showAsAction="always"> | ||
|
||
<menu> | ||
<group |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these moved to dialog
if (GsTextUtils.isNullOrEmpty(path) || json == null) { | ||
sortOrder.sortByType = getFileBrowserSortByType(); | ||
sortOrder.reverse = isFileBrowserSortReverse(); | ||
sortOrder.folderFirst = isFileBrowserSortFolderFirst(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fall back to global if this folder does not have a custom setting
public boolean isMultiSelectEnabled = false; | ||
public Collection<Integer> preSelected = null; // Indices of pre-selected items | ||
public Collection<Integer> radioIndices = null; // Only one item can be selected among these | ||
public boolean showCountInOkButton = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just collected the multi-select related options to one place
} else { | ||
listAdapter._selectedItems.clear(); | ||
listAdapter._selectedItems.removeAll(listAdapter._filteredItems); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Select all adds and removes all visible options now
@@ -1070,43 +1090,4 @@ public void setFormatShareAsLink(final boolean asLink) { | |||
public boolean getFormatShareAsLink() { | |||
return getBool(R.string.pref_key__format_share_as_link, true); | |||
} | |||
|
|||
private static String mapToJsonString(final Map<String, String> map) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved these to GsTextUtils
public Collection<Integer> preSelected = null; // Indices of pre-selected items | ||
public boolean showSelectAllButton = true; | ||
public boolean showCountInOkButton = true; | ||
public GsCallback.a1<Set<Integer>> selectionChangedCallback = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allows us to add a lot of dynamic functionality into the dialog. In this PR I have used it to implement Radio buttons
|
||
final MenuItem sortItem = _fragmentMenu.findItem(R.id.action_sort); | ||
if (sortItem != null) { | ||
_cu.tintDrawable(sortItem.getIcon(), _dopt.sortOrder.isFolderLocal ? GsFileBrowserListAdapter.FAVOURITE_COLOR : Color.WHITE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Highlight the sort icon when the folder has a custom sort. This is a little visual hint
// Set new sort order to folder or global as needed | ||
_appSettings.setFolderSortOrder(order.isFolderLocal ? currentFolder : null, _dopt.sortOrder); | ||
|
||
_dopt.sortOrder = order; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO - this should be first line in the callback
In this PR I add per-folder sort support. This addresses #2435
Sample use cases:
I always want downloads to be sorted by time
I don't want folders to be first in my 'projects' folder