From 4613ad230cf188d333aaa220bfb7e92183a7761e Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 13 Jul 2016 17:12:15 +0200 Subject: [PATCH] update the Actionbar title with current path --- .../filemanager/activities/MainActivity.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/simplemobiletools/filemanager/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/filemanager/activities/MainActivity.java index 5ca88a47..372ae1cc 100644 --- a/app/src/main/java/com/simplemobiletools/filemanager/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/filemanager/activities/MainActivity.java @@ -42,19 +42,27 @@ public class MainActivity extends AppCompatActivity implements ItemsFragment.Ite private void openPath(String path) { final Bundle bundle = new Bundle(); bundle.putString(Constants.PATH, path); + if (getSupportFragmentManager().getBackStackEntryCount() > 0) + setTitle(path); final ItemsFragment fragment = new ItemsFragment(); fragment.setArguments(bundle); fragment.setListener(this); - getSupportFragmentManager().beginTransaction().replace(R.id.fragment_holder, fragment).addToBackStack("").commit(); + getSupportFragmentManager().beginTransaction().replace(R.id.fragment_holder, fragment).addToBackStack(path).commit(); } @Override public void onBackPressed() { final FragmentManager manager = getSupportFragmentManager(); - if (manager.getBackStackEntryCount() == 1) + final int cnt = manager.getBackStackEntryCount(); + if (cnt == 1) finish(); else { + if (cnt == 2) { + setTitle(getResources().getString(R.string.app_name)); + } else { + setTitle(manager.getBackStackEntryAt(cnt - 2).getName()); + } super.onBackPressed(); } }