diff --git a/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java b/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java index fe184bcd81..8fcda74bbb 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java +++ b/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java @@ -1002,6 +1002,12 @@ public void goToMain(String path) { goToMain(path, false); } + /** + * Sets up the main view with the {@link MainFragment} + * + * @param path The path to which to go in the {@link MainFragment} + * @param hideFab Whether the FAB should be hidden in the new created {@link MainFragment} or not + */ public void goToMain(String path, boolean hideFab) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); // title.setText(R.string.app_name); @@ -1017,6 +1023,7 @@ public void goToMain(String path, boolean hideFab) { if (path != null && path.length() > 0) { b.putString("path", path); } + // This boolean will be given to the newly created MainFragment b.putBoolean(MainFragment.BUNDLE_HIDE_FAB, hideFab); tabFragment.setArguments(b); transaction.replace(R.id.content_frame, tabFragment); diff --git a/app/src/main/java/com/amaze/filemanager/ui/fragments/MainFragment.java b/app/src/main/java/com/amaze/filemanager/ui/fragments/MainFragment.java index 95ae344623..24ad0250e5 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/fragments/MainFragment.java +++ b/app/src/main/java/com/amaze/filemanager/ui/fragments/MainFragment.java @@ -143,6 +143,7 @@ public class MainFragment extends Fragment private static final Logger LOG = LoggerFactory.getLogger(MainFragment.class); private static final String KEY_FRAGMENT_MAIN = "main"; + /** Key for boolean in arguments whether to hide the FAB if this {@link MainFragment} is shown */ public static final String BUNDLE_HIDE_FAB = "hideFab"; public SwipeRefreshLayout mSwipeRefreshLayout; @@ -170,7 +171,7 @@ public class MainFragment extends Fragment private MainFragmentViewModel mainFragmentViewModel; private MainActivityViewModel mainActivityViewModel; - private boolean hideFab; + private boolean hideFab = false; private final ActivityResultLauncher handleDocumentUriForRestrictedDirectories = registerForActivityResult( @@ -1537,10 +1538,12 @@ > requireContext().getResources().getDisplayMetrics().heightPixels) { } } + /** Whether the FAB should be hidden when this MainFragment is shown */ public boolean getHideFab() { return this.hideFab; } + /** Set whether the FAB should be hidden when this MainFragment is shown */ public void setHideFab(boolean hideFab) { this.hideFab = hideFab; } diff --git a/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java b/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java index 10c1a02fe3..5c8a2950dc 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java +++ b/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java @@ -344,8 +344,10 @@ private void addNewTab(int num, String path) { * change paths in database. Calls should implement updating each tab's list for new paths. * * @param addTab whether new tabs should be added to ui or just change values in database + * @param hideFabInCurrentMainFragment whether the FAB should be hidden in the current {@link + * MainFragment} */ - public void refactorDrawerStorages(boolean addTab, boolean hideFabInCurrentTab) { + public void refactorDrawerStorages(boolean addTab, boolean hideFabInCurrentMainFragment) { TabHandler tabHandler = TabHandler.getInstance(); Tab tab1 = tabHandler.findTab(1); Tab tab2 = tabHandler.findTab(2); @@ -371,13 +373,13 @@ public void refactorDrawerStorages(boolean addTab, boolean hideFabInCurrentTab) } else { if (path != null && path.length() != 0) { if (MainActivity.currentTab == 0) { - addTab(tab1, path, hideFabInCurrentTab); + addTab(tab1, path, hideFabInCurrentMainFragment); addTab(tab2, "", false); } if (MainActivity.currentTab == 1) { addTab(tab1, "", false); - addTab(tab2, path, hideFabInCurrentTab); + addTab(tab2, path, hideFabInCurrentMainFragment); } } else { addTab(tab1, "", false); @@ -386,7 +388,6 @@ public void refactorDrawerStorages(boolean addTab, boolean hideFabInCurrentTab) } } - // TODO private void addTab(@NonNull Tab tab, String path, boolean hideFabInTab) { MainFragment main = new MainFragment(); Bundle b = new Bundle(); @@ -400,6 +401,7 @@ private void addTab(@NonNull Tab tab, String path, boolean hideFabInTab) { b.putString("home", tab.home); b.putInt("no", tab.tabNumber); + // specifies if the constructed MainFragment hides the FAB when it is shown b.putBoolean(MainFragment.BUNDLE_HIDE_FAB, hideFabInTab); main.setArguments(b); fragments.add(main); diff --git a/app/src/main/java/com/amaze/filemanager/ui/views/drawer/Drawer.java b/app/src/main/java/com/amaze/filemanager/ui/views/drawer/Drawer.java index 0a58210845..2f1f604bc8 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/views/drawer/Drawer.java +++ b/app/src/main/java/com/amaze/filemanager/ui/views/drawer/Drawer.java @@ -789,6 +789,7 @@ public void onDrawerClosed() { MainFragment mainFragment = mainActivity.getCurrentMainFragment(); if (mainFragment != null) { mainFragment.loadlist(pendingPath.getPath(), false, OpenMode.UNKNOWN, false); + // Set if the FAB should be hidden when displaying the pendingPath mainFragment.setHideFab(pendingPath.getHideFabInMainFragment()); resetPendingPath(); } else {