More fixes for translucent UI with newer correct status bar coloring implementation on Lollipop. The status bar color is still slightly miscolored in the artist and album viewer since the translucent status bar darkens it .
This commit is contained in:
parent
a573e58261
commit
2d822cdbc9
9 changed files with 56 additions and 34 deletions
|
|
@ -71,4 +71,5 @@ dependencies {
|
|||
compile 'com.jpardogo.materialtabstrip:library:1.0.9'
|
||||
compile 'com.android.support:support-v4:22.0.0'
|
||||
compile 'com.koushikdutta.ion:ion:2.1.3'
|
||||
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.kabouzeid.gramophone.App;
|
|||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.adapter.songadapter.AlbumSongAdapter;
|
||||
import com.kabouzeid.gramophone.comparator.SongTrackNumberComparator;
|
||||
import com.kabouzeid.gramophone.dialogs.ColorChooserDialog;
|
||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||
import com.kabouzeid.gramophone.interfaces.PaletteColorHolder;
|
||||
import com.kabouzeid.gramophone.loader.AlbumLoader;
|
||||
|
|
@ -56,7 +57,6 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
private Album album;
|
||||
|
||||
private ObservableRecyclerView recyclerView;
|
||||
private View statusBar;
|
||||
private ImageView albumArtImageView;
|
||||
private View songsBackgroundView;
|
||||
private TextView albumTitleView;
|
||||
|
|
@ -82,7 +82,10 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
// Change alpha of overlay
|
||||
float alpha = Math.max(0, Math.min(1, (float) scrollY / flexibleRange));
|
||||
ViewUtil.setBackgroundAlpha(toolbar, alpha, toolbarColor);
|
||||
ViewUtil.setBackgroundAlpha(statusBar, alpha, toolbarColor);
|
||||
// Status bar color is a darker shade of the toolbar color with equal opacity
|
||||
int a = Math.min(255, Math.max(0, (int) (alpha * 255))) << 24;
|
||||
int rgb = 0x00ffffff & ColorChooserDialog.shiftColorDown(toolbarColor);
|
||||
setStatusBarColor(a + rgb, true);
|
||||
|
||||
// Translate name text
|
||||
int maxTitleTranslationY = albumArtViewHeight;
|
||||
|
|
@ -154,7 +157,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
recyclerView = (ObservableRecyclerView) findViewById(R.id.list);
|
||||
albumTitleView = (TextView) findViewById(R.id.album_title);
|
||||
songsBackgroundView = findViewById(R.id.list_background);
|
||||
statusBar = findViewById(R.id.statusBar);
|
||||
// statusBar = findViewById(R.id.statusBar);
|
||||
}
|
||||
|
||||
private void setUpObservableListViewParams() {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.kabouzeid.gramophone.App;
|
|||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.adapter.ArtistAlbumAdapter;
|
||||
import com.kabouzeid.gramophone.adapter.songadapter.ArtistSongAdapter;
|
||||
import com.kabouzeid.gramophone.dialogs.ColorChooserDialog;
|
||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||
import com.kabouzeid.gramophone.interfaces.PaletteColorHolder;
|
||||
import com.kabouzeid.gramophone.lastfm.artist.LastFMArtistBiographyLoader;
|
||||
|
|
@ -65,7 +66,6 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
private Artist artist;
|
||||
|
||||
private ObservableListView songListView;
|
||||
private View statusBar;
|
||||
private ImageView artistImage;
|
||||
private View songsBackgroundView;
|
||||
private TextView artistNameTv;
|
||||
|
|
@ -95,7 +95,10 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
// Change alpha of overlay
|
||||
float alpha = Math.max(0, Math.min(1, (float) scrollY / flexibleRange));
|
||||
ViewUtil.setBackgroundAlpha(toolbar, alpha, toolbarColor);
|
||||
ViewUtil.setBackgroundAlpha(statusBar, alpha, toolbarColor);
|
||||
// Status bar color is a darker shade of the toolbar color with equal opacity
|
||||
int a = Math.min(255, Math.max(0, (int) (alpha * 255))) << 24;
|
||||
int rgb = 0x00ffffff & ColorChooserDialog.shiftColorDown(toolbarColor);
|
||||
setStatusBarColor(a + rgb, true);
|
||||
|
||||
// Translate name text
|
||||
int maxTitleTranslationY = artistImageViewHeight;
|
||||
|
|
@ -160,7 +163,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
songListView = (ObservableListView) findViewById(R.id.list);
|
||||
artistNameTv = (TextView) findViewById(R.id.artist_name);
|
||||
songsBackgroundView = findViewById(R.id.list_background);
|
||||
statusBar = findViewById(R.id.statusBar);
|
||||
// statusBar = findViewById(R.id.statusBar);
|
||||
|
||||
songListHeader = LayoutInflater.from(this).inflate(R.layout.artist_detail_header, songListView, false);
|
||||
albumRecyclerView = (RecyclerView) songListHeader.findViewById(R.id.recycler_view);
|
||||
|
|
|
|||
|
|
@ -94,6 +94,11 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean translucentStatusBarOnLollipop() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldColorStatusBar() {
|
||||
return false; // let other code handle this below
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import com.kabouzeid.gramophone.R;
|
|||
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||
import com.kabouzeid.gramophone.util.Util;
|
||||
import com.readystatesoftware.systembartint.SystemBarTintManager;
|
||||
|
||||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
|
|
@ -34,12 +35,12 @@ public abstract class ThemeBaseActivity extends ActionBarActivity implements Kab
|
|||
// Apply colors to system UI if necessary
|
||||
final int primaryDark = PreferenceUtils.getInstance(this).getThemeColorPrimaryDarker();
|
||||
if (Util.hasLollipopSDK()) {
|
||||
if (shouldColorStatusBar())
|
||||
getWindow().setStatusBarColor(primaryDark);
|
||||
if (shouldColorNavBar())
|
||||
getWindow().setNavigationBarColor(primaryDark);
|
||||
}
|
||||
|
||||
setStatusBarColor(primaryDark, false);
|
||||
|
||||
// Persist current values so the Activity knows if they change
|
||||
// mLastDarkTheme = PreferenceUtils.getInstance(this).getGeneralTheme() == 1;
|
||||
// mLastPrimary = PreferenceUtils.getInstance(this).getThemeColorPrimary();
|
||||
|
|
@ -94,4 +95,14 @@ public abstract class ThemeBaseActivity extends ActionBarActivity implements Kab
|
|||
protected abstract boolean shouldColorStatusBar();
|
||||
|
||||
protected abstract boolean shouldColorNavBar();
|
||||
|
||||
protected final void setStatusBarColor(int color, boolean forceSystemBarTint) {
|
||||
if (!forceSystemBarTint && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
getWindow().setStatusBarColor(color);
|
||||
} else {
|
||||
SystemBarTintManager tintManager = new SystemBarTintManager(this);
|
||||
tintManager.setStatusBarTintEnabled(true);
|
||||
tintManager.setStatusBarTintColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -203,10 +203,9 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
final int vibrantColor = DialogUtils.resolveColor(this, R.attr.colorPrimary);
|
||||
paletteColorPrimary = vibrantColor;
|
||||
observableScrollViewCallbacks.onScrollChanged(scrollView.getCurrentScrollY(), false, false);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
getWindow().setStatusBarColor(ColorChooserDialog.shiftColorDown(vibrantColor));
|
||||
setStatusBarColor(ColorChooserDialog.shiftColorDown(vibrantColor), false);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||
getWindow().setNavigationBarColor(vibrantColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void getIntentExtras() {
|
||||
|
|
@ -254,11 +253,11 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
PreferenceUtils.getInstance(this).getThemeColorPrimary());
|
||||
toolBar.setBackgroundColor(primary);
|
||||
header.setBackgroundColor(primary);
|
||||
if (Util.hasLollipopSDK()) {
|
||||
int primaryDark = ColorChooserDialog.shiftColorDown(primary);
|
||||
getWindow().setStatusBarColor(primaryDark);
|
||||
|
||||
int primaryDark = ColorChooserDialog.shiftColorDown(primary);
|
||||
setStatusBarColor(primaryDark, false);
|
||||
if (Util.hasLollipopSDK())
|
||||
getWindow().setNavigationBarColor(primaryDark);
|
||||
}
|
||||
}
|
||||
|
||||
protected void dataChanged() {
|
||||
|
|
@ -295,10 +294,9 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
final int vibrantColor = palette.getVibrantColor(DialogUtils.resolveColor(AbsTagEditorActivity.this, R.attr.default_bar_color));
|
||||
paletteColorPrimary = vibrantColor;
|
||||
observableScrollViewCallbacks.onScrollChanged(scrollView.getCurrentScrollY(), false, false);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
getWindow().setStatusBarColor(ColorChooserDialog.shiftColorDown(vibrantColor));
|
||||
setStatusBarColor(ColorChooserDialog.shiftColorDown(vibrantColor), false);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||
getWindow().setNavigationBarColor(vibrantColor);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:elevation="@dimen/toolbar_elevation"
|
||||
tools:ignore="UnusedAttribute">
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/album_title"
|
||||
|
|
@ -40,7 +38,6 @@
|
|||
android:layout_height="@dimen/title_view_height"
|
||||
android:height="@dimen/title_view_height"
|
||||
android:background="?default_bar_color"
|
||||
android:elevation="@dimen/toolbar_elevation"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="72dp"
|
||||
|
|
@ -48,6 +45,7 @@
|
|||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Title"
|
||||
android:textColor="?attr/title_text_color"
|
||||
android:elevation="@dimen/toolbar_elevation"
|
||||
tools:ignore="UnusedAttribute" />
|
||||
|
||||
<View
|
||||
|
|
@ -62,16 +60,17 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/statusBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/statusMargin"
|
||||
android:background="@android:color/transparent"
|
||||
tools:ignore="ContentDescription" />
|
||||
<!--<ImageView-->
|
||||
<!--android:id="@+id/statusBar"-->
|
||||
<!--android:layout_width="match_parent"-->
|
||||
<!--android:layout_height="@dimen/statusMargin"-->
|
||||
<!--android:background="@android:color/transparent"-->
|
||||
<!--tools:ignore="ContentDescription" />-->
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
style="@style/Toolbar"
|
||||
android:layout_marginTop="@dimen/statusMargin"
|
||||
android:background="@android:color/transparent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -60,16 +60,17 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/statusBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/statusMargin"
|
||||
android:background="@android:color/transparent"
|
||||
tools:ignore="ContentDescription" />
|
||||
<!--<ImageView-->
|
||||
<!--android:id="@+id/statusBar"-->
|
||||
<!--android:layout_width="match_parent"-->
|
||||
<!--android:layout_height="@dimen/statusMargin"-->
|
||||
<!--android:background="@android:color/transparent"-->
|
||||
<!--tools:ignore="ContentDescription" />-->
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
style="@style/Toolbar"
|
||||
android:layout_marginTop="@dimen/statusMargin"
|
||||
android:background="@android:color/transparent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -201,6 +201,7 @@
|
|||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
style="@style/Toolbar"
|
||||
android:layout_marginTop="@dimen/statusMargin"
|
||||
android:background="@android:color/transparent" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue