Fixed back navigation

Fixes #6
This commit is contained in:
M66B 2018-08-06 14:40:21 +00:00
parent 73b5c9cbea
commit 601d63482d
1 changed files with 8 additions and 12 deletions

View File

@ -131,7 +131,6 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
Log.i(Helper.TAG, "View post create"); Log.i(Helper.TAG, "View post create");
super.onPostCreate(savedInstanceState); super.onPostCreate(savedInstanceState);
drawerToggle.syncState(); drawerToggle.syncState();
syncState();
} }
@Override @Override
@ -172,7 +171,8 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
Log.i(Helper.TAG, "View configuration changed"); Log.i(Helper.TAG, "View configuration changed");
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
drawerToggle.onConfigurationChanged(newConfig); drawerToggle.onConfigurationChanged(newConfig);
int count = getSupportFragmentManager().getBackStackEntryCount();
drawerToggle.setDrawerIndicatorEnabled(count == 1);
} }
@Override @Override
@ -193,8 +193,10 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
@Override @Override
public void onBackStackChanged() { public void onBackStackChanged() {
if (getSupportFragmentManager().getBackStackEntryCount() == 0) int count = getSupportFragmentManager().getBackStackEntryCount();
if (count == 0)
finish(); finish();
drawerToggle.setDrawerIndicatorEnabled(count == 1);
} }
@Override @Override
@ -224,6 +226,9 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
return true; return true;
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home:
getSupportFragmentManager().popBackStack();
return true;
case R.id.menu_folders: case R.id.menu_folders:
onMenuFolders(); onMenuFolders();
return true; return true;
@ -232,16 +237,7 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
} }
} }
private void syncState() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean eula = prefs.getBoolean("eula", false);
drawerToggle.setDrawerIndicatorEnabled(eula);
getSupportActionBar().setDisplayHomeAsUpEnabled(eula);
getSupportActionBar().setHomeButtonEnabled(eula);
}
private void init() { private void init() {
syncState();
invalidateOptionsMenu(); invalidateOptionsMenu();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);