getSupportActionBar().setHomeButtonEnabled(true); // mandatory since Android ICS,
// according to the official
// documentation
- if (getFile() != null) {
- updateActionBarTitle();
- }
setSupportProgressBarIndeterminateVisibility(mSyncInProgress
/*|| mRefreshSharesInProgress*/);
} else {
updateFragmentsVisibility(!file.isFolder());
- updateNavigationElementsInActionBar(file.isFolder() ? null : file);
+ updateActionBarTitleAndHomeButton(file.isFolder() ? null : file);
}
}
}
if (secondFragment != null) {
setSecondFragment(secondFragment);
updateFragmentsVisibility(true);
- updateNavigationElementsInActionBar(file);
+ updateActionBarTitleAndHomeButton(file);
} else {
cleanSecondFragment();
tr.commit();
}
updateFragmentsVisibility(false);
- updateNavigationElementsInActionBar(null);
+ updateActionBarTitleAndHomeButton(null);
}
protected void refreshListOfFilesFragment() {
public void onBackPressed() {
OCFileListFragment listOfFiles = getListOfFilesFragment();
if (mDualPane || getSecondFragment() == null) {
+ if (getFile() != null && getFile().getParentId() == 0) {
+ finish();
+ return;
+ }
if (listOfFiles != null) { // should never be null, indeed
listOfFiles.onBrowseUp();
}
if (listOfFiles != null) { // should never be null, indeed
setFile(listOfFiles.getCurrentFile());
}
- updateActionBarTitle();
cleanSecondFragment();
}
// listOfFiles.listDirectory(root, MainApp.getOnlyOnDevice());
setFile(listOfFiles.getCurrentFile());
startSyncFolderOperation(root, false);
- updateActionBarTitle();
}
cleanSecondFragment();
*/
@Override
public void onBrowsedDownTo(OCFile directory) {
- cleanSecondFragment();
setFile(directory);
- updateActionBarTitle();
+ cleanSecondFragment();
// Sync Folder
startSyncFolderOperation(directory, false);
-
}
/**
Fragment detailFragment = new FileDetailFragment(file, getAccount());
setSecondFragment(detailFragment);
updateFragmentsVisibility(true);
- updateNavigationElementsInActionBar(file);
+ updateActionBarTitleAndHomeButton(file);
setFile(file);
}
-
- /**
- * TODO
- */
- private void updateNavigationElementsInActionBar(OCFile chosenFile) {
- ActionBar actionBar = getSupportActionBar();
-
- // For adding content description tag to a title field in the action bar
- int actionBarTitleId = getResources().getIdentifier("action_bar_title", "id", "android");
-
- if (chosenFile == null || mDualPane) {
- // only list of files - set for browsing through folders
- OCFile currentDir = getCurrentDir();
- boolean noRoot = (currentDir != null && currentDir.getParentId() != 0);
-// actionBar.setDisplayHomeAsUpEnabled(noRoot);
-// actionBar.setDisplayShowTitleEnabled(!noRoot);
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowTitleEnabled(true);
- if (!noRoot) {
- actionBar.setTitle(getString(R.string.default_display_name_for_root_folder));
- View actionBarTitleView = getWindow().getDecorView().findViewById(actionBarTitleId);
- if (actionBarTitleView != null) { // it's null in Android 2.x
- actionBarTitleView.setContentDescription(
- getString(R.string.default_display_name_for_root_folder));
- }
- }
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
+ @Override
+ protected void updateActionBarTitleAndHomeButton(OCFile chosenFile) {
+ if (mDualPane) {
+ // in dual pane mode, keep the focus of title an action bar in the current folder
+ super.updateActionBarTitleAndHomeButton(getCurrentDir());
} else {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowTitleEnabled(true);
- actionBar.setTitle(chosenFile.getFileName());
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
- View actionBarTitleView = getWindow().getDecorView().findViewById(actionBarTitleId);
- if (actionBarTitleView != null) { // it's null in Android 2.x
- getWindow().getDecorView().findViewById(actionBarTitleId).
- setContentDescription(chosenFile.getFileName());
- }
+ super.updateActionBarTitleAndHomeButton(chosenFile);
}
+
}
autoplay);
setSecondFragment(mediaFragment);
updateFragmentsVisibility(true);
- updateNavigationElementsInActionBar(file);
+ updateActionBarTitleAndHomeButton(file);
setFile(file);
}
mWaitingToPreview = file;
requestForDownload();
updateFragmentsVisibility(true);
- updateNavigationElementsInActionBar(file);
+ updateActionBarTitleAndHomeButton(file);
setFile(file);
}