Closed ammargitham closed 3 years ago
Seems the kotlin version of ActionBarOnDestinationChangedListener always sets the actionBar.setDisplayHomeAsUpEnabled to true.
Below diff is from https://android.googlesource.com/platform/frameworks/support/+/5b19fddb91b129168429b3cbf77323414d638b03%5E%21/#F1
-
- @Override
- protected void setNavigationIcon(Drawable icon,
- @StringRes int contentDescription) {
- ActionBar actionBar = mActivity.getSupportActionBar();
- if (icon == null) {
- actionBar.setDisplayHomeAsUpEnabled(false);
- } else {
- actionBar.setDisplayHomeAsUpEnabled(true);
- ActionBarDrawerToggle.Delegate delegate = mActivity.getDrawerToggleDelegate();
- delegate.setActionBarUpIndicator(icon, contentDescription);
- }
- }
-
+ override fun setNavigationIcon(icon: Drawable, @StringRes contentDescription: Int) {
+ val actionBar = activity.supportActionBar
+ require(actionBar != null) {
+ "Activity $activity does not have an ActionBar set via setSupportActionBar()"
+ }
+ actionBar.setDisplayHomeAsUpEnabled(true)
+ val delegate = activity.drawerToggleDelegate
+ require(delegate != null) {
+ "Activity $activity does not have an DrawerToggleDelegate set"
+ }
+ delegate.setActionBarUpIndicator(icon, contentDescription)
+ }
Seems the parameter icon was set to non-null initially and then later made nullable in https://android.googlesource.com/platform/frameworks/support/+/d5f4ba078465516da538bcf96042a33e0cb6edd8/navigation/navigation-ui/src/main/java/androidx/navigation/ui/ActionBarOnDestinationChangedListener.kt. But the null check was not added back.
@ammargitham Guess there are some unexpected bugs in "alpha" version. waiting for "beta"
Update the navigation version to 2.4.0-alpha03
(latest as of 6/23/21)
Update the navigation version to
2.4.0-alpha03
(latest as of 6/23/21)
great!
With update to navigation 2.4.0-alpha01, even top level destinations show the up arrow.
Tested on Samsung Galaxy S8. Android 9.