import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
+import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
// Sync the toggle state after onRestoreInstanceState has occurred.
if (mDrawerToggle != null) {
mDrawerToggle.syncState();
+ if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
+ getSupportActionBar().setTitle(R.string.app_name);
+ mDrawerToggle.setDrawerIndicatorEnabled(true);
+ }
}
}
this,
mDrawerLayout,
R.drawable.ic_drawer,
- R.string.drawer_open,
+ R.string.app_name,
R.string.drawer_close) {
/** Called when a drawer has settled in a completely closed state. */
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
- updateActionBarTitle();
+ updateActionBarTitleAndHomeButton();
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
invalidateOptionsMenu();
/** Called when a drawer has settled in a completely open state. */
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
- getSupportActionBar().setTitle(R.string.drawer_open);
+ getSupportActionBar().setTitle(R.string.app_name);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
mDrawerToggle.setDrawerIndicatorEnabled(true);
invalidateOptionsMenu();
mDrawerLayout.setDrawerListener(mDrawerToggle);
}
- protected void updateActionBarTitle(){
+ protected void updateActionBarTitleAndHomeButton(){
if (mFile.getParentId() == 0) {
getSupportActionBar().setTitle(getString(
R.string.default_display_name_for_root_folder));
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() {
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) {
+ private void updateActionBarTitleAndHomeButton(OCFile chosenFile) {
ActionBar actionBar = getSupportActionBar();
// For adding content description tag to a title field in the action bar
// 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(noRoot);
+ //actionBar.setDisplayShowTitleEnabled(!noRoot);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
+ mDrawerToggle.setDrawerIndicatorEnabled(!noRoot);
if (!noRoot) {
actionBar.setTitle(getString(R.string.default_display_name_for_root_folder));
View actionBarTitleView = getWindow().getDecorView().findViewById(actionBarTitleId);
} else {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
+ mDrawerToggle.setDrawerIndicatorEnabled(false);
actionBar.setTitle(chosenFile.getFileName());
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
View actionBarTitleView = getWindow().getDecorView().findViewById(actionBarTitleId);
autoplay);
setSecondFragment(mediaFragment);
updateFragmentsVisibility(true);
- updateNavigationElementsInActionBar(file);
+ updateActionBarTitleAndHomeButton(file);
setFile(file);
}
mWaitingToPreview = file;
requestForDownload();
updateFragmentsVisibility(true);
- updateNavigationElementsInActionBar(file);
+ updateActionBarTitleAndHomeButton(file);
setFile(file);
}