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