Fix kabouzeid/phonograph-issue-tracker#51: Shuffle button in now playing becomes hard to tell

We check for the difference between the default and the activated colors. If the difference value is less than 55000, the activated color is shifted up.
This commit is contained in:
Ihsan Isik 2015-09-22 20:11:25 +03:00
commit a1fb2d3c9d
2 changed files with 31 additions and 2 deletions

View file

@ -722,7 +722,9 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
private void updateShuffleState() {
switch (MusicPlayerRemote.getShuffleMode()) {
case MusicService.SHUFFLE_MODE_SHUFFLE:
int activatedColor = colorPlaybackControls ? lastPlaybackControlsColor : ThemeSingleton.get().positiveColor.getDefaultColor();
int activatedColor = colorPlaybackControls
? getFixedShuffleRepeatButtonColor(lastPlaybackControlsColor)
: ThemeSingleton.get().positiveColor.getDefaultColor();
shuffleButton.setImageDrawable(Util.getTintedDrawable(this, R.drawable.ic_shuffle_white_36dp,
activatedColor));
break;
@ -745,7 +747,9 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
}
private void updateRepeatState() {
int activatedColor = colorPlaybackControls ? lastPlaybackControlsColor : ThemeSingleton.get().positiveColor.getDefaultColor();
int activatedColor = colorPlaybackControls
? getFixedShuffleRepeatButtonColor(lastPlaybackControlsColor)
: ThemeSingleton.get().positiveColor.getDefaultColor();
switch (MusicPlayerRemote.getRepeatMode()) {
case MusicService.REPEAT_MODE_ALL:
repeatButton.setImageDrawable(Util.getTintedDrawable(this, R.drawable.ic_repeat_white_36dp,
@ -763,6 +767,18 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
}
}
/**
* Checks whether the default color and the activated color are similar. If true, returns a darker
* activated color. Else, returns the given color as-is.
*/
private int getFixedShuffleRepeatButtonColor(int activatedColor) {
if (ColorUtil.calculateColorDistance(activatedColor,
ColorUtil.resolveColor(this, android.R.attr.textColorSecondary))) {
return ColorUtil.shiftColor(activatedColor, 0.6f);
}
return activatedColor;
}
private void setUpAlbumArtViews() {
albumArtBackground.setAlpha(0.7f);
albumArt.forceSquare(forceSquareAlbumArt);