|
@@ -542,15 +542,31 @@ public class FileDisplayActivity extends FileActivity
|
|
|
return secondFragment;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
- * Replaces the second fragment managed by the activity with the received as
|
|
|
- * a parameter.
|
|
|
+ * Replaces the first fragment managed by the activity with the received as a parameter.
|
|
|
*
|
|
|
+ * @param fragment New Fragment to set.
|
|
|
+ */
|
|
|
+ private void setLeftFragment(Fragment fragment) {
|
|
|
+ if (searchView != null) {
|
|
|
+ searchView.post(() -> searchView.setQuery(searchQuery, true));
|
|
|
+ }
|
|
|
+ setDrawerIndicatorEnabled(false);
|
|
|
+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
|
|
+ transaction.addToBackStack(null);
|
|
|
+ transaction.replace(R.id.left_fragment_container, fragment, TAG_LIST_OF_FILES);
|
|
|
+ transaction.commit();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Replaces the second fragment managed by the activity with the received as a parameter.
|
|
|
+ * <p>
|
|
|
* Assumes never will be more than two fragments managed at the same time.
|
|
|
*
|
|
|
* @param fragment New second Fragment to set.
|
|
|
*/
|
|
|
+ @Deprecated // in future no dual pane
|
|
|
private void setSecondFragment(Fragment fragment) {
|
|
|
if (searchView != null) {
|
|
|
searchView.post(new Runnable() {
|
|
@@ -594,11 +610,15 @@ public class FileDisplayActivity extends FileActivity
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public @androidx.annotation.Nullable
|
|
|
+ Fragment getLeftFragment() {
|
|
|
+ return getSupportFragmentManager().findFragmentByTag(FileDisplayActivity.TAG_LIST_OF_FILES);
|
|
|
+ }
|
|
|
|
|
|
public @androidx.annotation.Nullable
|
|
|
OCFileListFragment getListOfFilesFragment() {
|
|
|
Fragment listOfFiles = getSupportFragmentManager().findFragmentByTag(
|
|
|
- FileDisplayActivity.TAG_LIST_OF_FILES);
|
|
|
+ FileDisplayActivity.TAG_LIST_OF_FILES);
|
|
|
if (listOfFiles != null) {
|
|
|
return (OCFileListFragment) listOfFiles;
|
|
|
}
|
|
@@ -785,10 +805,13 @@ public class FileDisplayActivity extends FileActivity
|
|
|
OCFile currentDir = getCurrentDir();
|
|
|
if (isDrawerOpen()) {
|
|
|
closeDrawer();
|
|
|
- } else if ((currentDir != null && currentDir.getParentId() != 0) ||
|
|
|
- (second != null && second.getFile() != null) || isSearchOpen()) {
|
|
|
+ } else if (
|
|
|
+ (currentDir != null && currentDir.getParentId() != 0) ||
|
|
|
+ (second != null && second.getFile() != null) ||
|
|
|
+ isSearchOpen() ||
|
|
|
+ second == null
|
|
|
+ ) {
|
|
|
onBackPressed();
|
|
|
-
|
|
|
} else {
|
|
|
openDrawer();
|
|
|
}
|
|
@@ -1022,45 +1045,45 @@ public class FileDisplayActivity extends FileActivity
|
|
|
boolean isDrawerOpen = isDrawerOpen();
|
|
|
boolean isSearchOpen = isSearchOpen();
|
|
|
|
|
|
- OCFileListFragment listOfFiles = getListOfFilesFragment();
|
|
|
+ Fragment leftFragment = getLeftFragment();
|
|
|
|
|
|
- if (isSearchOpen && searchView != null) {
|
|
|
- searchView.setQuery("", true);
|
|
|
- searchView.onActionViewCollapsed();
|
|
|
- searchView.clearFocus();
|
|
|
+ if (leftFragment instanceof OCFileListFragment) {
|
|
|
+ OCFileListFragment listOfFiles = (OCFileListFragment) leftFragment;
|
|
|
|
|
|
- // Remove the list to the original state
|
|
|
- if (listOfFiles != null) {
|
|
|
- listOfFiles.performSearch("", true);
|
|
|
- }
|
|
|
+ if (isSearchOpen && searchView != null) {
|
|
|
+ searchView.setQuery("", true);
|
|
|
+ searchView.onActionViewCollapsed();
|
|
|
+ searchView.clearFocus();
|
|
|
|
|
|
- hideSearchView(getCurrentDir());
|
|
|
+ // Remove the list to the original state
|
|
|
+ listOfFiles.performSearch("", true);
|
|
|
|
|
|
- setDrawerIndicatorEnabled(isDrawerIndicatorAvailable());
|
|
|
- } else if (isDrawerOpen) {
|
|
|
- // close drawer first
|
|
|
- super.onBackPressed();
|
|
|
- } else {
|
|
|
- // all closed
|
|
|
+ hideSearchView(getCurrentDir());
|
|
|
|
|
|
- listOfFiles = getListOfFilesFragment();
|
|
|
- if (mDualPane || getSecondFragment() == null) {
|
|
|
- OCFile currentDir = getCurrentDir();
|
|
|
- if (currentDir == null || currentDir.getParentId() == FileDataStorageManager.ROOT_PARENT_ID) {
|
|
|
- finish();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (listOfFiles != null) { // should never be null, indeed
|
|
|
+ setDrawerIndicatorEnabled(isDrawerIndicatorAvailable());
|
|
|
+ } else if (isDrawerOpen) {
|
|
|
+ // close drawer first
|
|
|
+ super.onBackPressed();
|
|
|
+ } else {
|
|
|
+ // all closed
|
|
|
+ if (mDualPane || getSecondFragment() == null) {
|
|
|
+ OCFile currentDir = getCurrentDir();
|
|
|
+ if (currentDir == null || currentDir.getParentId() == FileDataStorageManager.ROOT_PARENT_ID) {
|
|
|
+ finish();
|
|
|
+ return;
|
|
|
+ }
|
|
|
listOfFiles.onBrowseUp();
|
|
|
}
|
|
|
- }
|
|
|
- if (listOfFiles != null) { // should never be null, indeed
|
|
|
setFile(listOfFiles.getCurrentFile());
|
|
|
listOfFiles.setFabVisible(true);
|
|
|
listOfFiles.registerFabListener();
|
|
|
showSortListGroup(true);
|
|
|
+ cleanSecondFragment();
|
|
|
}
|
|
|
- cleanSecondFragment();
|
|
|
+ } else {
|
|
|
+ // pop back
|
|
|
+ hideSearchView(getCurrentDir());
|
|
|
+ super.onBackPressed();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1565,6 +1588,7 @@ public class FileDisplayActivity extends FileActivity
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Deprecated // in future no dual pane
|
|
|
public void updateActionBarTitleAndHomeButton(OCFile chosenFile) {
|
|
|
if (chosenFile == null) {
|
|
|
chosenFile = getFile(); // if no file is passed, current file decides
|
|
@@ -1576,7 +1600,6 @@ public class FileDisplayActivity extends FileActivity
|
|
|
} else {
|
|
|
super.updateActionBarTitleAndHomeButton(chosenFile);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -2181,10 +2204,12 @@ public class FileDisplayActivity extends FileActivity
|
|
|
args.putString(EXTRA_SEARCH_QUERY, searchQuery);
|
|
|
Fragment textPreviewFragment = Fragment.instantiate(getApplicationContext(),
|
|
|
PreviewTextFileFragment.class.getName(), args);
|
|
|
- setSecondFragment(textPreviewFragment);
|
|
|
- updateFragmentsVisibility(true);
|
|
|
- updateActionBarTitleAndHomeButton(file);
|
|
|
- setFile(file);
|
|
|
+ setLeftFragment(textPreviewFragment);
|
|
|
+ binding.rightFragmentContainer.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ //updateFragmentsVisibility(true);
|
|
|
+ super.updateActionBarTitleAndHomeButton(file);
|
|
|
+ //setFile(file);
|
|
|
} else {
|
|
|
Intent previewIntent = new Intent();
|
|
|
previewIntent.putExtra(EXTRA_FILE, file);
|