Skip to content

Commit

Permalink
Merge pull request #13624 from nextcloud/simplify-on-back-pressed-logic
Browse files Browse the repository at this point in the history
Simplify FileDisplayActivity onBackPressed
  • Loading branch information
alperozturk96 authored Oct 7, 2024
2 parents 05ed5fe + b057344 commit ff3a3bf
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1019,24 +1019,22 @@ private Boolean isRootDirectory() {
@SuppressFBWarnings("ITC_INHERITANCE_TYPE_CHECKING")
@Override
public void onBackPressed() {
final boolean isDrawerOpen = isDrawerOpen();
final boolean isSearchOpen = isSearchOpen();

final Fragment leftFragment = getLeftFragment();

if (isSearchOpen) {
if (isSearchOpen()) {
resetSearchAction();
} else if (isDrawerOpen) {
return;
}

if (isDrawerOpen()) {
super.onBackPressed();
} else if (leftFragment instanceof OCFileListFragment listOfFiles) {
return;
}

// all closed
OCFile currentDir = getCurrentDir();
if (isRoot(currentDir)) {
if (getLeftFragment() instanceof OCFileListFragment listOfFiles) {
if (isRoot(getCurrentDir())) {
finish();
return;
} else {
browseUp(listOfFiles);
}
browseUp(listOfFiles);
} else {
popBack();
}
Expand Down

0 comments on commit ff3a3bf

Please sign in to comment.