Fix showing sw back button on nested stack on Android. (#308)

This change fixes a problem with native stack on Android where we'd display a sw back button on screens that are nested stack navigatodespite the fact those screens were the initial screens in the whole container stack. In #306 we introuced a change that would allow for displaying sw back in nested stacks, however that change did not handle the case where screen is a root screen of a container that is nested and placed as an initial screen in another container.
This commit is contained in:
Krzysztof Magiera
2020-02-05 16:22:10 +01:00
committed by GitHub
parent acb038e213
commit 06b928f5c1
2 changed files with 22 additions and 4 deletions

View File

@@ -139,9 +139,6 @@ public class ScreenStackHeaderConfig extends ViewGroup {
return;
}
boolean isRoot = stack == null ? true : stack.getRootScreen() == parent;
boolean isNested = (parent.getFragment().getParentFragment() instanceof ScreenStackFragment);
if (mToolbar.getParent() == null) {
getScreenFragment().setToolbar(mToolbar);
}
@@ -151,7 +148,7 @@ public class ScreenStackHeaderConfig extends ViewGroup {
ActionBar actionBar = activity.getSupportActionBar();
// hide back button
actionBar.setDisplayHomeAsUpEnabled((isRoot && !isNested) ? false : !mIsBackButtonHidden);
actionBar.setDisplayHomeAsUpEnabled(getScreenFragment().canNavigateBack() ? !mIsBackButtonHidden : false);
// when setSupportActionBar is called a toolbar wrapper gets initialized that overwrites
// navigation click listener. The default behavior set in the wrapper is to call into