// 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);
}
}
}
+ @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);
@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