-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(tabs-list-mode): layout switch #16305
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -557,6 +557,8 @@ private void onNavigationItemClicked(final MenuItem menuItem) { | |
| } | ||
|
|
||
| closeDrawer(); | ||
| setupHomeSearchToolbarWithSortAndListButtons(); | ||
| updateActionBarTitleAndHomeButton(null); | ||
| } else if (itemId == R.id.nav_favorites) { | ||
| openFavoritesTab(); | ||
| } else if (itemId == R.id.nav_gallery) { | ||
|
|
@@ -630,6 +632,8 @@ private void handleBottomNavigationViewClicks() { | |
| fda.browseToRoot(); | ||
| } | ||
| EventBus.getDefault().post(new ChangeMenuEvent()); | ||
| setupHomeSearchToolbarWithSortAndListButtons(); | ||
| updateActionBarTitleAndHomeButton(null); | ||
| } else if (menuItemId == R.id.nav_favorites) { | ||
| openFavoritesTab(); | ||
| } else if (menuItemId == R.id.nav_assistant && !(this instanceof ComposeActivity)) { | ||
|
|
@@ -706,8 +710,7 @@ private void resetFileDepth() { | |
| } | ||
| } | ||
|
|
||
| protected void openSharedTab() { | ||
| resetFileDepth(); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The call of |
||
| private void openSharedTab() { | ||
| resetOnlyPersonalAndOnDevice(); | ||
| SearchEvent searchEvent = new SearchEvent("", SearchRemoteOperation.SearchType.SHARED_FILTER); | ||
| launchActivityForSearch(searchEvent, R.id.nav_shared); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -435,7 +435,7 @@ public void onActivityCreated(Bundle savedInstanceState) { | |
| } else { | ||
| setGridAsPreferred(); | ||
| } | ||
| setGridSwitchButton(); | ||
| setLayoutSwitchButton(); | ||
| }); | ||
| } | ||
|
|
||
|
|
@@ -1573,17 +1573,9 @@ public void updateOCFile(@NonNull OCFile file) { | |
| } | ||
|
|
||
| private void updateLayout() { | ||
| // decide grid vs list view | ||
| if (isGridViewPreferred(mFile)) { | ||
| switchToGridView(); | ||
| } else { | ||
| switchToListView(); | ||
| } | ||
|
|
||
| setLayoutViewMode(); | ||
| updateSortButton(); | ||
| if (mSwitchGridViewButton != null) { | ||
| setGridSwitchButton(); | ||
| } | ||
| setLayoutSwitchButton(); | ||
|
|
||
| setFabVisible(!mHideFab); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| slideHideBottomBehaviourForBottomNavigationView(!mHideFab); | ||
|
|
@@ -1619,14 +1611,34 @@ public void sortFiles(FileSortOrder sortOrder) { | |
| } | ||
|
|
||
| /** | ||
| * Determines if user set folder to grid or list view. If folder is not set itself, it finds a parent that is set | ||
| * (at least root is set). | ||
| * Determines whether a folder should be displayed in grid or list view. | ||
| * <p> | ||
| * The preference is checked for the given folder. If the folder itself does not have a preference set, | ||
| * it will fall back to its parent folder recursively until a preference is found (root folder is always set). | ||
| * Additionally, if a search event is active and is of type {@code SHARED_FILTER}, grid view is disabled. | ||
| * | ||
| * @param folder Folder to check or null for root folder | ||
| * @return 'true' is folder should be shown in grid mode, 'false' if list mode is preferred. | ||
| * @param folder The folder to check, or {@code null} to refer to the root folder. | ||
| * @return {@code true} if the folder should be displayed in grid mode, {@code false} if list mode is preferred. | ||
| */ | ||
| public boolean isGridViewPreferred(@Nullable OCFile folder) { | ||
| return FOLDER_LAYOUT_GRID.equals(preferences.getFolderLayout(folder)); | ||
| private boolean isGridViewPreferred(@Nullable OCFile folder) { | ||
| if (searchEvent != null) { | ||
| return (searchEvent.toSearchType() != SHARED_FILTER) && | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Shared tab can only display files in list mode for now, so folder preferences cannot be applied there since there is no toggle to change it. |
||
| FOLDER_LAYOUT_GRID.equals(preferences.getFolderLayout(folder)); | ||
| } else { | ||
| return FOLDER_LAYOUT_GRID.equals(preferences.getFolderLayout(folder)); | ||
| } | ||
| } | ||
|
|
||
| private void setLayoutViewMode() { | ||
| boolean isGrid = isGridViewPreferred(mFile); | ||
|
|
||
| if (isGrid) { | ||
| switchToGridView(); | ||
| } else { | ||
| switchToListView(); | ||
| } | ||
|
|
||
| setLayoutSwitchButton(isGrid); | ||
| } | ||
|
|
||
| public void setListAsPreferred() { | ||
|
|
@@ -1857,11 +1869,7 @@ protected void handleSearchEvent(SearchEvent event) { | |
|
|
||
| new Handler(Looper.getMainLooper()).post(() -> { | ||
| updateSortButton(); | ||
| if (isGridViewPreferred(mFile) && !isGridEnabled()) { | ||
| switchToGridView(); | ||
| } else if (!isGridViewPreferred(mFile) && isGridEnabled()) { | ||
| switchToListView(); | ||
| } | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| setLayoutViewMode(); | ||
| }); | ||
|
|
||
| final User currentUser = accountManager.getUser(); | ||
|
|
||
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.
Needed to display the correct action bar when the user comes back from the shared tab. In the future, we can deduplicate the navigation logic.