From: AndyScherzinger Date: Sun, 26 Jul 2015 00:25:25 +0000 (+0200) Subject: in case of open drawer close it onBackPressed X-Git-Tag: oc-android-1.8~42^2~67 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/53bbdfb0e8a69a09958617dc5995512fdae7661b in case of open drawer close it onBackPressed --- diff --git a/src/com/owncloud/android/ui/activity/FileActivity.java b/src/com/owncloud/android/ui/activity/FileActivity.java index 516daa15..0869ba6d 100644 --- a/src/com/owncloud/android/ui/activity/FileActivity.java +++ b/src/com/owncloud/android/ui/activity/FileActivity.java @@ -289,7 +289,7 @@ public class FileActivity extends AppCompatActivity // Sync the toggle state after onRestoreInstanceState has occurred. if (mDrawerToggle != null) { mDrawerToggle.syncState(); - if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) { + if (isDrawerOpen()) { getSupportActionBar().setTitle(R.string.app_name); mDrawerToggle.setDrawerIndicatorEnabled(true); } @@ -304,6 +304,23 @@ public class FileActivity extends AppCompatActivity } } + @Override + public void onBackPressed() { + if (isDrawerOpen()) { + closeNavDrawer(); + return; + } + super.onBackPressed(); + } + + public boolean isDrawerOpen() { + return mDrawerLayout.isDrawerOpen(GravityCompat.START); + } + + public void closeNavDrawer() { + mDrawerLayout.closeDrawer(GravityCompat.START); + } + protected void initDrawer(){ // constant settings for action bar when navigation drawer is inited getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index f7d28bd9..be430aaf 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -733,22 +733,25 @@ public class FileDisplayActivity extends HookActivity @Override public void onBackPressed() { - OCFileListFragment listOfFiles = getListOfFilesFragment(); - if (mDualPane || getSecondFragment() == null) { - OCFile currentDir = getCurrentDir(); - if (currentDir == null || currentDir.getParentId() == FileDataStorageManager.ROOT_PARENT_ID) { - finish(); - return; + if (!isDrawerOpen()){ + OCFileListFragment 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 + listOfFiles.onBrowseUp(); + } } if (listOfFiles != null) { // should never be null, indeed - listOfFiles.onBrowseUp(); + setFile(listOfFiles.getCurrentFile()); } + cleanSecondFragment(); + } else { + super.onBackPressed(); } - if (listOfFiles != null) { // should never be null, indeed - setFile(listOfFiles.getCurrentFile()); - } - cleanSecondFragment(); - } @Override