Fixed cab (contextual action bar) content not visible with light primary colors.

This commit is contained in:
Karim Abou Zeid 2015-09-08 12:03:00 +02:00
commit c0b41f63cc
7 changed files with 27 additions and 5 deletions

View file

@ -25,6 +25,12 @@
<p>You can view the changelog dialog again at any time from the <i>about</i> section.</p>
<h3>Version 0.9.46 beta 2</h3>
<ol>
<li><b>FIX:</b> Cab (contextual action bar) content not visible with light primary colors</li>
</ol>
<h3>Version 0.9.46 beta 1</h3>
<ol>

View file

@ -384,7 +384,7 @@ public class AlbumDetailActivity extends AbsSlidingMusicPanelActivity implements
cab = new MaterialCab(this, R.id.cab_stub)
.setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
.setBackgroundColor(getPaletteColor())
.setBackgroundColor(ColorUtil.shiftBackgroundColorForLightText(getPaletteColor()))
.start(new MaterialCab.Callback() {
@Override
public boolean onCabCreated(MaterialCab materialCab, Menu menu) {

View file

@ -448,7 +448,7 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
cab = new MaterialCab(this, R.id.cab_stub)
.setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
.setBackgroundColor(getPaletteColor())
.setBackgroundColor(ColorUtil.shiftBackgroundColorForLightText(getPaletteColor()))
.start(new MaterialCab.Callback() {
@Override
public boolean onCabCreated(MaterialCab materialCab, Menu menu) {

View file

@ -541,7 +541,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
cab = new MaterialCab(this, R.id.cab_stub)
.setMenu(menu)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
.setBackgroundColor(getThemeColorPrimary())
.setBackgroundColor(ColorUtil.shiftBackgroundColorForLightText(getThemeColorPrimary()))
.start(callback);
return cab;
}

View file

@ -191,7 +191,7 @@ public class PlaylistDetailActivity extends AbsSlidingMusicPanelActivity impleme
cab = new MaterialCab(this, R.id.cab_stub)
.setMenu(menu)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
.setBackgroundColor(getThemeColorPrimary())
.setBackgroundColor(ColorUtil.shiftBackgroundColorForLightText(getThemeColorPrimary()))
.start(callback);
return cab;
}

View file

@ -121,4 +121,20 @@ public class ColorUtil {
public static int getSecondaryTextColorForBackground(final Context context, @ColorInt int backgroundColor) {
return getSecondaryTextColor(context, useDarkTextColorOnBackground(backgroundColor));
}
@ColorInt
public static int shiftBackgroundColorForLightText(@ColorInt int backgroundColor) {
while (ColorUtil.useDarkTextColorOnBackground(backgroundColor)) {
backgroundColor = ColorUtil.shiftColorDown(backgroundColor);
}
return backgroundColor;
}
@ColorInt
public static int shiftBackgroundColorForDarkText(@ColorInt int backgroundColor) {
while (!ColorUtil.useDarkTextColorOnBackground(backgroundColor)) {
backgroundColor = ColorUtil.shiftColorUp(backgroundColor);
}
return backgroundColor;
}
}

View file

@ -22,7 +22,6 @@ import android.view.View;
import android.view.ViewTreeObserver;
import android.view.animation.PathInterpolator;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RadioButton;
@ -160,6 +159,7 @@ public class ViewUtil {
setToolbarIconColor(context, toolbar, getToolbarIconColor(context, dark));
}
@ColorInt
public static int getToolbarIconColor(Context context, boolean dark) {
if (dark) {
return ColorUtil.getSecondaryTextColor(context, true);