Added colored notification (as an option). Relabeled some vars.
This commit is contained in:
parent
f1fd604ac2
commit
554bc25f83
15 changed files with 55 additions and 41 deletions
|
|
@ -187,7 +187,7 @@ public class AlbumAdapter extends AbsMultiSelectAdapter<AlbumAdapter.ViewHolder,
|
|||
public AlbumAdapter(AppCompatActivity activity, @Nullable CabHolder cabHolder) {
|
||||
super(activity, cabHolder, R.menu.menu_media_selection);
|
||||
this.activity = activity;
|
||||
usePalette = PreferenceUtils.getInstance(activity).coloredAlbumFootersEnabled();
|
||||
usePalette = PreferenceUtils.getInstance(activity).coloredAlbumFooters();
|
||||
loadDataSet();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,14 +12,17 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.support.v4.media.session.MediaSessionCompat;
|
||||
import android.support.v7.app.NotificationCompat;
|
||||
import android.support.v7.graphics.Palette;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.service.MusicService;
|
||||
import com.kabouzeid.gramophone.ui.activities.MusicControllerActivity;
|
||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
|
||||
public class PlayingNotificationHelper {
|
||||
|
|
@ -39,6 +42,9 @@ public class PlayingNotificationHelper {
|
|||
if (albumArt == null) {
|
||||
albumArt = BitmapFactory.decodeResource(context.getResources(), R.drawable.default_album_art);
|
||||
}
|
||||
int notificationColor = PreferenceUtils.getInstance(context).coloredNotification() ?
|
||||
Palette.from(albumArt).generate().getVibrantColor(Color.TRANSPARENT) :
|
||||
Color.TRANSPARENT;
|
||||
|
||||
return new NotificationCompat.Builder(context)
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
|
|
@ -65,6 +71,7 @@ public class PlayingNotificationHelper {
|
|||
retrievePlaybackAction(context, 1))
|
||||
|
||||
.setOnlyAlertOnce(true)
|
||||
.setColor(notificationColor)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
@ -100,22 +107,4 @@ public class PlayingNotificationHelper {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// private void loadAlbumArt() {
|
||||
// currentAlbumArtUri = MusicUtil.getAlbumArtUri(currentSong.albumId).toString();
|
||||
// ImageLoader.getInstance().displayImage(currentAlbumArtUri, new NonViewAware(new ImageSize(-1, -1), ViewScaleType.CROP), new SimpleImageLoadingListener() {
|
||||
// @Override
|
||||
// public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
// if (currentAlbumArtUri.equals(imageUri))
|
||||
// // copy() prevents the original bitmap in the memory cache from being recycled by the remote views
|
||||
// setAlbumArt(loadedImage.copy(loadedImage.getConfig(), true));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
|
||||
// if (currentAlbumArtUri.equals(imageUri))
|
||||
// setAlbumArt(null);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
postponeEnterTransition();
|
||||
if (PreferenceUtils.getInstance(this).coloredNavigationBarAlbumEnabled())
|
||||
if (PreferenceUtils.getInstance(this).coloredNavigationBarAlbum())
|
||||
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
}
|
||||
|
||||
|
|
@ -236,7 +236,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
toolbarColor = vibrantSwatch.getRgb();
|
||||
albumTitleView.setBackgroundColor(toolbarColor);
|
||||
albumTitleView.setTextColor(Util.getOpaqueColor(vibrantSwatch.getTitleTextColor()));
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(AlbumDetailActivity.this).coloredNavigationBarAlbumEnabled())
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(AlbumDetailActivity.this).coloredNavigationBarAlbum())
|
||||
setNavigationBarColor(toolbarColor);
|
||||
notifyTaskColorChange(toolbarColor);
|
||||
} else {
|
||||
|
|
@ -258,7 +258,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
albumTitleView.setBackgroundColor(defaultBarColor);
|
||||
albumTitleView.setTextColor(titleTextColor);
|
||||
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarArtistEnabled())
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarArtist())
|
||||
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
|
||||
notifyTaskColorChange(toolbarColor);
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
postponeEnterTransition();
|
||||
if (PreferenceUtils.getInstance(this).coloredNavigationBarArtistEnabled())
|
||||
if (PreferenceUtils.getInstance(this).coloredNavigationBarArtist())
|
||||
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
}
|
||||
|
||||
|
|
@ -317,7 +317,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
toolbarColor = vibrantSwatch.getRgb();
|
||||
artistNameTv.setBackgroundColor(vibrantSwatch.getRgb());
|
||||
artistNameTv.setTextColor(Util.getOpaqueColor(vibrantSwatch.getTitleTextColor()));
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(ArtistDetailActivity.this).coloredNavigationBarArtistEnabled())
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(ArtistDetailActivity.this).coloredNavigationBarArtist())
|
||||
setNavigationBarColor(vibrantSwatch.getRgb());
|
||||
notifyTaskColorChange(toolbarColor);
|
||||
} else {
|
||||
|
|
@ -356,7 +356,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
artistNameTv.setBackgroundColor(defaultBarColor);
|
||||
artistNameTv.setTextColor(titleTextColor);
|
||||
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarArtistEnabled())
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarArtist())
|
||||
setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||
|
||||
notifyTaskColorChange(toolbarColor);
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public class MainActivity extends AbsFabActivity
|
|||
setUpToolbar();
|
||||
setUpViewPager();
|
||||
|
||||
if (PreferenceUtils.getInstance(this).coloredNavigationBarOtherScreensEnabled())
|
||||
if (PreferenceUtils.getInstance(this).coloredNavigationBarOtherScreens())
|
||||
setNavigationBarThemeColor();
|
||||
|
||||
handlePlaybackIntent(getIntent());
|
||||
|
|
|
|||
|
|
@ -417,7 +417,7 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
if (opaqueStatusBar) setStatusBarColor(newColor);
|
||||
else setStatusBarColor(Color.TRANSPARENT);
|
||||
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarCurrentPlayingEnabled())
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarCurrentPlaying())
|
||||
setNavigationBarColor(newColor);
|
||||
lastFooterColor = newColor;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class PlaylistDetailActivity extends AbsFabActivity implements CabHolder
|
|||
getSupportActionBar().setTitle(playlist.name);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if (PreferenceUtils.getInstance(this).coloredNavigationBarPlaylistEnabled())
|
||||
if (PreferenceUtils.getInstance(this).coloredNavigationBarPlaylist())
|
||||
setNavigationBarThemeColor();
|
||||
setStatusBarThemeColor();
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
if (savedInstanceState == null)
|
||||
getFragmentManager().beginTransaction().replace(R.id.content_frame, new SettingsFragment()).commit();
|
||||
|
||||
if (PreferenceUtils.getInstance(this).coloredNavigationBarOtherScreensEnabled())
|
||||
if (PreferenceUtils.getInstance(this).coloredNavigationBarOtherScreens())
|
||||
setNavigationBarThemeColor();
|
||||
setStatusBarThemeColor();
|
||||
}
|
||||
|
|
@ -136,6 +136,13 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
});
|
||||
}
|
||||
|
||||
Preference coloredNotification = findPreference("colored_notification");
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
coloredNotification.setEnabled(false);
|
||||
coloredNotification.setWidgetLayoutResource(0);
|
||||
coloredNotification.setSummary(R.string.pref_only_lollipop);
|
||||
}
|
||||
|
||||
equalizer = findPreference("equalizer");
|
||||
resolveEqualizer();
|
||||
equalizer.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
paletteColorPrimary = primaryColor;
|
||||
observableScrollViewCallbacks.onScrollChanged(scrollView.getCurrentScrollY(), false, false);
|
||||
setStatusBarColor(paletteColorPrimary);
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarTagEditorEnabled())
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(this).coloredNavigationBarTagEditor())
|
||||
setNavigationBarColor(paletteColorPrimary);
|
||||
header.setBackgroundColor(paletteColorPrimary);
|
||||
notifyTaskColorChange(paletteColorPrimary);
|
||||
|
|
@ -246,7 +246,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
header.setBackgroundColor(paletteColorPrimary);
|
||||
|
||||
setStatusBarColor(paletteColorPrimary);
|
||||
if (PreferenceUtils.getInstance(this).coloredNavigationBarTagEditorEnabled())
|
||||
if (PreferenceUtils.getInstance(this).coloredNavigationBarTagEditor())
|
||||
setNavigationBarColor(paletteColorPrimary);
|
||||
}
|
||||
|
||||
|
|
@ -289,7 +289,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
paletteColorPrimary = vibrantColor;
|
||||
observableScrollViewCallbacks.onScrollChanged(scrollView.getCurrentScrollY(), false, false);
|
||||
setStatusBarColor(paletteColorPrimary);
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(AbsTagEditorActivity.this).coloredNavigationBarTagEditorEnabled())
|
||||
if (Util.isAtLeastLollipop() && PreferenceUtils.getInstance(AbsTagEditorActivity.this).coloredNavigationBarTagEditor())
|
||||
setNavigationBarColor(paletteColorPrimary);
|
||||
header.setBackgroundColor(paletteColorPrimary);
|
||||
notifyTaskColorChange(paletteColorPrimary);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ public final class PreferenceUtils {
|
|||
public static final String ALTERNATIVE_PROGRESS_SLIDER_NOW_PLAYING = "alternative_progress_slider_now_playing";
|
||||
public static final String PLAYBACK_CONTROLLER_CARD_NOW_PLAYING = "playback_controller_card_now_playing";
|
||||
public static final String FADE_PLAY_PAUSE = "fade_play_pause";
|
||||
public static final String COLORED_NOTIFICATION = "colored_notification";
|
||||
|
||||
private static PreferenceUtils sInstance;
|
||||
|
||||
|
|
@ -110,31 +111,35 @@ public final class PreferenceUtils {
|
|||
// return mPreferences.getBoolean(ONLY_ON_WIFI, false);
|
||||
// }
|
||||
|
||||
public final boolean coloredAlbumFootersEnabled() {
|
||||
public final boolean coloredAlbumFooters() {
|
||||
return mPreferences.getBoolean(COLORED_ALBUM_FOOTERS, true);
|
||||
}
|
||||
|
||||
public final boolean coloredNavigationBarAlbumEnabled() {
|
||||
public final boolean coloredNotification() {
|
||||
return mPreferences.getBoolean(COLORED_NOTIFICATION, true);
|
||||
}
|
||||
|
||||
public final boolean coloredNavigationBarAlbum() {
|
||||
return coloredNavigationBarFor(COLORED_NAVIGATION_BAR_ALBUM);
|
||||
}
|
||||
|
||||
public final boolean coloredNavigationBarArtistEnabled() {
|
||||
public final boolean coloredNavigationBarArtist() {
|
||||
return coloredNavigationBarFor(COLORED_NAVIGATION_BAR_ARTIST);
|
||||
}
|
||||
|
||||
public final boolean coloredNavigationBarCurrentPlayingEnabled() {
|
||||
public final boolean coloredNavigationBarCurrentPlaying() {
|
||||
return coloredNavigationBarFor(COLORED_NAVIGATION_BAR_CURRENT_PLAYING);
|
||||
}
|
||||
|
||||
public final boolean coloredNavigationBarPlaylistEnabled() {
|
||||
public final boolean coloredNavigationBarPlaylist() {
|
||||
return coloredNavigationBarFor(COLORED_NAVIGATION_BAR_PLAYIST);
|
||||
}
|
||||
|
||||
public final boolean coloredNavigationBarTagEditorEnabled() {
|
||||
public final boolean coloredNavigationBarTagEditor() {
|
||||
return coloredNavigationBarFor(COLORED_NAVIGATION_BAR_TAG_EDITOR);
|
||||
}
|
||||
|
||||
public final boolean coloredNavigationBarOtherScreensEnabled() {
|
||||
public final boolean coloredNavigationBarOtherScreens() {
|
||||
return coloredNavigationBarFor(COLORED_NAVIGATION_BAR_OTHER_SCREENS);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.kabouzeid.gramophone.views;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import android.support.v7.widget.AppCompatCheckBox;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue