Skip to content

Commit c964a79

Browse files
committed
clean up and add documentation
1 parent 5b81154 commit c964a79

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,12 @@ public void goToMain(String path) {
10021002
goToMain(path, false);
10031003
}
10041004

1005+
/**
1006+
* Sets up the main view with the {@link MainFragment}
1007+
*
1008+
* @param path The path to which to go in the {@link MainFragment}
1009+
* @param hideFab Whether the FAB should be hidden in the new created {@link MainFragment} or not
1010+
*/
10051011
public void goToMain(String path, boolean hideFab) {
10061012
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
10071013
// title.setText(R.string.app_name);
@@ -1017,6 +1023,7 @@ public void goToMain(String path, boolean hideFab) {
10171023
if (path != null && path.length() > 0) {
10181024
b.putString("path", path);
10191025
}
1026+
// This boolean will be given to the newly created MainFragment
10201027
b.putBoolean(MainFragment.BUNDLE_HIDE_FAB, hideFab);
10211028
tabFragment.setArguments(b);
10221029
transaction.replace(R.id.content_frame, tabFragment);

app/src/main/java/com/amaze/filemanager/ui/fragments/MainFragment.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ public class MainFragment extends Fragment
143143
private static final Logger LOG = LoggerFactory.getLogger(MainFragment.class);
144144
private static final String KEY_FRAGMENT_MAIN = "main";
145145

146+
/** Key for boolean in arguments whether to hide the FAB if this {@link MainFragment} is shown */
146147
public static final String BUNDLE_HIDE_FAB = "hideFab";
147148

148149
public SwipeRefreshLayout mSwipeRefreshLayout;
@@ -170,7 +171,7 @@ public class MainFragment extends Fragment
170171
private MainFragmentViewModel mainFragmentViewModel;
171172
private MainActivityViewModel mainActivityViewModel;
172173

173-
private boolean hideFab;
174+
private boolean hideFab = false;
174175

175176
private final ActivityResultLauncher<Intent> handleDocumentUriForRestrictedDirectories =
176177
registerForActivityResult(
@@ -1537,10 +1538,12 @@ > requireContext().getResources().getDisplayMetrics().heightPixels) {
15371538
}
15381539
}
15391540

1541+
/** Whether the FAB should be hidden when this MainFragment is shown */
15401542
public boolean getHideFab() {
15411543
return this.hideFab;
15421544
}
15431545

1546+
/** Set whether the FAB should be hidden when this MainFragment is shown */
15441547
public void setHideFab(boolean hideFab) {
15451548
this.hideFab = hideFab;
15461549
}

app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,10 @@ private void addNewTab(int num, String path) {
344344
* change paths in database. Calls should implement updating each tab's list for new paths.
345345
*
346346
* @param addTab whether new tabs should be added to ui or just change values in database
347+
* @param hideFabInCurrentMainFragment whether the FAB should be hidden in the current {@link
348+
* MainFragment}
347349
*/
348-
public void refactorDrawerStorages(boolean addTab, boolean hideFabInCurrentTab) {
350+
public void refactorDrawerStorages(boolean addTab, boolean hideFabInCurrentMainFragment) {
349351
TabHandler tabHandler = TabHandler.getInstance();
350352
Tab tab1 = tabHandler.findTab(1);
351353
Tab tab2 = tabHandler.findTab(2);
@@ -371,13 +373,13 @@ public void refactorDrawerStorages(boolean addTab, boolean hideFabInCurrentTab)
371373
} else {
372374
if (path != null && path.length() != 0) {
373375
if (MainActivity.currentTab == 0) {
374-
addTab(tab1, path, hideFabInCurrentTab);
376+
addTab(tab1, path, hideFabInCurrentMainFragment);
375377
addTab(tab2, "", false);
376378
}
377379

378380
if (MainActivity.currentTab == 1) {
379381
addTab(tab1, "", false);
380-
addTab(tab2, path, hideFabInCurrentTab);
382+
addTab(tab2, path, hideFabInCurrentMainFragment);
381383
}
382384
} else {
383385
addTab(tab1, "", false);
@@ -386,7 +388,6 @@ public void refactorDrawerStorages(boolean addTab, boolean hideFabInCurrentTab)
386388
}
387389
}
388390

389-
// TODO
390391
private void addTab(@NonNull Tab tab, String path, boolean hideFabInTab) {
391392
MainFragment main = new MainFragment();
392393
Bundle b = new Bundle();
@@ -400,6 +401,7 @@ private void addTab(@NonNull Tab tab, String path, boolean hideFabInTab) {
400401

401402
b.putString("home", tab.home);
402403
b.putInt("no", tab.tabNumber);
404+
// specifies if the constructed MainFragment hides the FAB when it is shown
403405
b.putBoolean(MainFragment.BUNDLE_HIDE_FAB, hideFabInTab);
404406
main.setArguments(b);
405407
fragments.add(main);

app/src/main/java/com/amaze/filemanager/ui/views/drawer/Drawer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ public void onDrawerClosed() {
789789
MainFragment mainFragment = mainActivity.getCurrentMainFragment();
790790
if (mainFragment != null) {
791791
mainFragment.loadlist(pendingPath.getPath(), false, OpenMode.UNKNOWN, false);
792+
// Set if the FAB should be hidden when displaying the pendingPath
792793
mainFragment.setHideFab(pendingPath.getHideFabInMainFragment());
793794
resetPendingPath();
794795
} else {

0 commit comments

Comments
 (0)