Translucent status bar in artist and album detail view on KitKat/Lollipop

This commit is contained in:
Aidan Follestad 2015-04-18 01:26:42 -05:00
commit a573e58261
3 changed files with 29 additions and 9 deletions

View file

@ -65,6 +65,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
private int titleViewHeight;
private int albumArtViewHeight;
private int toolbarColor;
private final SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
@Override
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
@ -105,9 +106,11 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
App.bus.register(this);
if (Util.hasLollipopSDK()) postponeEnterTransition();
if (Util.hasLollipopSDK() && PreferenceUtils.getInstance(this).coloredNavigationBarAlbumEnabled())
getWindow().setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
if (Util.hasLollipopSDK()) {
postponeEnterTransition();
if (PreferenceUtils.getInstance(this).coloredNavigationBarAlbumEnabled())
getWindow().setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
}
Bundle intentExtras = getIntent().getExtras();
int albumId = -1;
@ -125,6 +128,11 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
setUpViews();
}
@Override
protected boolean translucentStatusBarOnLollipop() {
return true;
}
@Override
protected boolean shouldColorStatusBar() {
return false;
@ -155,7 +163,8 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
int toolbarHeight = Util.getActionBarSize(this);
titleViewHeight = getResources().getDimensionPixelSize(R.dimen.title_view_height);
headerOffset = toolbarHeight;
headerOffset += getResources().getDimensionPixelSize(R.dimen.statusMargin);
if (Util.hasKitKatSDK())
headerOffset += getResources().getDimensionPixelSize(R.dimen.statusMargin);
}
private void setUpViews() {

View file

@ -133,8 +133,15 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
getSupportActionBar().setTitle(null);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (Util.hasLollipopSDK()) fixLollipopTransitionImageWrongSize();
if (Util.hasLollipopSDK()) startPostponedEnterTransition();
if (Util.hasLollipopSDK()) {
fixLollipopTransitionImageWrongSize();
startPostponedEnterTransition();
}
}
@Override
protected boolean translucentStatusBarOnLollipop() {
return true;
}
@Override
@ -165,7 +172,8 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
int toolbarHeight = Util.getActionBarSize(this);
titleViewHeight = getResources().getDimensionPixelSize(R.dimen.title_view_height);
headerOffset = toolbarHeight;
headerOffset += getResources().getDimensionPixelSize(R.dimen.statusMargin);
if (Util.hasKitKatSDK())
headerOffset += getResources().getDimensionPixelSize(R.dimen.statusMargin);
}
@Override

View file

@ -76,8 +76,7 @@ public abstract class ThemeBaseActivity extends ActionBarActivity implements Kab
protected void setUpTranslucence(boolean statusBarTranslucent, boolean navigationBarTranslucent) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
// Not needed on Lollipop
if (translucentStatusBarOnLollipop() || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
Util.setStatusBarTranslucent(getWindow(), statusBarTranslucent);
}
if (Util.isInPortraitMode(this) || Util.isTablet(this)) {
@ -88,6 +87,10 @@ public abstract class ThemeBaseActivity extends ActionBarActivity implements Kab
}
}
protected boolean translucentStatusBarOnLollipop() {
return false;
}
protected abstract boolean shouldColorStatusBar();
protected abstract boolean shouldColorNavBar();