Task color (color of bar in recents entry) will match the palette color of the artist/album detail, now playing, and tag editor activities.

This commit is contained in:
Aidan Follestad 2015-04-19 12:25:47 -05:00
commit 0747e8837c
5 changed files with 36 additions and 1 deletions

View file

@ -207,6 +207,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
toolbarColor = swatch.getRgb();
albumTitleView.setBackgroundColor(toolbarColor);
albumTitleView.setTextColor(swatch.getTitleTextColor());
notifyTaskColorChange(toolbarColor);
if (Util.hasLollipopSDK() && PreferenceUtils.getInstance(AlbumDetailActivity.this).coloredNavigationBarAlbumEnabled())
getWindow().setNavigationBarColor(toolbarColor);
}
@ -214,6 +215,11 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
});
}
@Override
protected boolean overrideTaskColor() {
return true;
}
@Override
public int getPaletteColor() {
return toolbarColor;

View file

@ -302,6 +302,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
toolbarColor = swatch.getRgb();
artistNameTv.setBackgroundColor(swatch.getRgb());
artistNameTv.setTextColor(swatch.getTitleTextColor());
notifyTaskColorChange(toolbarColor);
if (Util.hasLollipopSDK() && PreferenceUtils.getInstance(ArtistDetailActivity.this).coloredNavigationBarArtistEnabled())
getWindow().setNavigationBarColor(swatch.getRgb());
} else {
@ -311,6 +312,11 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
});
}
@Override
protected boolean overrideTaskColor() {
return true;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

View file

@ -288,6 +288,11 @@ public class MusicControllerActivity extends AbsFabActivity {
songArtist.setText(song.artistName);
}
@Override
protected boolean overrideTaskColor() {
return true;
}
private void setUpAlbumArtAndApplyPalette() {
albumArt.post(new Runnable() {
@Override
@ -323,6 +328,7 @@ public class MusicControllerActivity extends AbsFabActivity {
animateColorChange(swatch.getRgb());
songTitle.setTextColor(swatch.getTitleTextColor());
songArtist.setTextColor(swatch.getBodyTextColor());
notifyTaskColorChange(swatch.getRgb());
} else {
resetColors();
}

View file

@ -66,12 +66,22 @@ public abstract class ThemeBaseActivity extends ActionBarActivity implements Kab
// Dark theme
ThemeSingleton.get().darkTheme = PreferenceUtils.getInstance(this).getGeneralTheme() == R.style.Theme_MaterialMusic;
if (!overrideTaskColor()) {
notifyTaskColorChange(PreferenceUtils.getInstance(this).getThemeColorPrimary());
}
}
protected boolean overrideTaskColor() {
return false;
}
protected void notifyTaskColorChange(int color) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// Sets color of entry in the system recents page
ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(
getString(R.string.app_name),
BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher),
PreferenceUtils.getInstance(this).getThemeColorPrimary());
color);
setTaskDescription(td);
}
}

View file

@ -290,12 +290,14 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
private void applyPalette(final Bitmap bitmap) {
if (bitmap != null) {
Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void onGenerated(Palette palette) {
final int vibrantColor = palette.getVibrantColor(DialogUtils.resolveColor(AbsTagEditorActivity.this, R.attr.default_bar_color));
paletteColorPrimary = vibrantColor;
observableScrollViewCallbacks.onScrollChanged(scrollView.getCurrentScrollY(), false, false);
setStatusBarColor(ColorChooserDialog.shiftColorDown(vibrantColor), false);
notifyTaskColorChange(paletteColorPrimary);
if (Util.hasLollipopSDK() && PreferenceUtils.getInstance(AbsTagEditorActivity.this).coloredNavigationBarTagEditorEnabled())
getWindow().setNavigationBarColor(vibrantColor);
}
@ -305,6 +307,11 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
}
}
@Override
protected boolean overrideTaskColor() {
return true;
}
protected void writeValuesToFiles(final Map<FieldKey, String> fieldKeyValueMap) {
writeValuesToFiles(fieldKeyValueMap, null, false);
}