diff --git a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java index 144403863ed0..f7947c1535f4 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java @@ -270,11 +270,17 @@ public void onDrawerOpened(View drawerView) { mDrawerLayout.addDrawerListener(mDrawerToggle); mDrawerToggle.setDrawerIndicatorEnabled(true); mDrawerToggle.setDrawerSlideAnimationEnabled(true); + setActionBarLeadingIcon(R.drawable.ic_arrow_back); + } + + public void setActionBarLeadingIcon(int id) { Drawable backArrow = ResourcesCompat.getDrawable(getResources(), - R.drawable.ic_arrow_back, + id, null); - viewThemeUtils.platform.tintToolbarArrowDrawable(this, mDrawerToggle, backArrow); + if (backArrow != null) { + viewThemeUtils.platform.tintToolbarArrowDrawable(this, mDrawerToggle, backArrow); + } } /** diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java index 241310d2ebff..c8ce538334fd 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -1020,18 +1020,25 @@ public void onBackPressed() { final Fragment leftFragment = getLeftFragment(); if (leftFragment instanceof OCFileListFragment listOfFiles) { OCFile currentDir = getCurrentDir(); - OCFile parentDir = fileDataStorageManager.getFileById(currentDir.getParentId()); - if (isRoot(currentDir)) { finish(); - } else if (parentDir != null && parentDir.isRoot()) { - openDrawer(); - } else { - browseUp(listOfFiles); + return; + } - OCFile secondParentDir = fileDataStorageManager.getNthParent(currentDir, 2); - if (secondParentDir != null && secondParentDir.isRoot()) { - filterCurrentDirectory(); + browseUp(listOfFiles); + + if (menuItemId == R.id.nav_favorites || menuItemId == R.id.nav_shared) { + OCFile parentDir = fileDataStorageManager.getFileById(currentDir.getParentId()); + if (parentDir != null && parentDir.isRoot()) { + openDrawer(); + } else { + browseUp(listOfFiles); + + OCFile secondParentDir = fileDataStorageManager.getNthParent(currentDir, 2); + if (secondParentDir != null && secondParentDir.isRoot()) { + filterCurrentDirectory(); + setActionBarLeadingIcon(R.drawable.ic_menu); + } } } } else { diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index 2370560a907e..1d3eee670191 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -1115,6 +1115,10 @@ private void fileOnItemClick(OCFile file) { @Override @OptIn(markerClass = UnstableApi.class) public void onItemClicked(OCFile file) { + if (mContainerActivity != null && mContainerActivity instanceof FileActivity fileActivity) { + fileActivity.setActionBarLeadingIcon(R.drawable.ic_arrow_back); + } + if (getCommonAdapter() != null && getCommonAdapter().isMultiSelect()) { toggleItemToCheckedList(file); } else {