Do not display navigation icon if unneccessary

This commit is contained in:
ByteHamster 2020-07-17 11:04:21 +02:00
parent 6d4af947a5
commit 8480db8dc1
2 changed files with 15 additions and 3 deletions

View File

@ -31,6 +31,7 @@ import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.event.MessageEvent;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.util.StorageUtils;
import de.danoeh.antennapod.core.util.ThemeUtils;
import de.danoeh.antennapod.core.util.download.AutoUpdateManager;
import de.danoeh.antennapod.dialog.RatingDialog;
import de.danoeh.antennapod.fragment.AddFeedFragment;
@ -98,8 +99,11 @@ public class MainActivity extends CastEnabledActivity {
final FragmentManager fm = getSupportFragmentManager();
fm.addOnBackStackChangedListener(() -> {
boolean showArrow = fm.getBackStackEntryCount() != 0;
if (drawerToggle != null) { // Tablet layout does not have a drawer
drawerToggle.setDrawerIndicatorEnabled(fm.getBackStackEntryCount() == 0);
drawerToggle.setDrawerIndicatorEnabled(!showArrow);
} else if (getActionBar() != null) {
getActionBar().setDisplayHomeAsUpEnabled(showArrow);
}
});
@ -161,6 +165,10 @@ public class MainActivity extends CastEnabledActivity {
drawerLayout.addDrawerListener(drawerToggle);
drawerToggle.syncState();
drawerToggle.setDrawerIndicatorEnabled(getSupportFragmentManager().getBackStackEntryCount() == 0);
} else if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
toolbar.setNavigationIcon(null);
} else {
toolbar.setNavigationIcon(ThemeUtils.getDrawableFromAttr(this, R.attr.homeAsUpIndicator));
}
super.setSupportActionBar(toolbar);
}

View File

@ -33,11 +33,15 @@ public abstract class ToolbarIconTintManager implements AppBarLayout.OnOffsetCha
public void updateTint() {
if (isTinted) {
doTint(new ContextThemeWrapper(context, R.style.Theme_AntennaPod_Dark));
toolbar.getNavigationIcon().setColorFilter(0xffffffff, PorterDuff.Mode.SRC_ATOP);
if (toolbar.getNavigationIcon() != null) { // Tablets do not show a navigation icon
toolbar.getNavigationIcon().setColorFilter(0xffffffff, PorterDuff.Mode.SRC_ATOP);
}
toolbar.getOverflowIcon().setColorFilter(0xffffffff, PorterDuff.Mode.SRC_ATOP);
} else {
doTint(context);
toolbar.getNavigationIcon().clearColorFilter();
if (toolbar.getNavigationIcon() != null) { // Tablets do not show a navigation icon
toolbar.getNavigationIcon().clearColorFilter();
}
toolbar.getOverflowIcon().clearColorFilter();
}
}