implement verbose notifications (nag)
This commit is contained in:
parent
4a534ce2e2
commit
9375969eee
@ -186,6 +186,9 @@ THE SOFTWARE.
|
||||
<string name="notification_invert_color_title">Invert Notification Color</string>
|
||||
<string name="notification_invert_color_summary">Use white text instead of black text</string>
|
||||
|
||||
<string name="notification_nag">Very verbose notification</string>
|
||||
<string name="notification_nag_summary">Announce song changes using a \'Heads-Up-Notification\'</string>
|
||||
|
||||
<string name="playback_screen">Playback Screen</string>
|
||||
<string name="playback_on_startup_title">Open on Startup</string>
|
||||
<string name="playback_on_startup_summary">Open playback view on startup</string>
|
||||
|
@ -35,4 +35,9 @@ THE SOFTWARE.
|
||||
android:entries="@array/notification_action_entries"
|
||||
android:entryValues="@array/entry_values"
|
||||
android:defaultValue="0" />
|
||||
<CheckBoxPreference
|
||||
android:key="notification_nag"
|
||||
android:title="@string/notification_nag"
|
||||
android:defaultValue="false"
|
||||
android:summary="@string/notification_nag_summary" />
|
||||
</PreferenceScreen>
|
||||
|
@ -282,7 +282,14 @@ public final class PlaybackService extends Service
|
||||
* music player.
|
||||
*/
|
||||
private boolean mStockBroadcast;
|
||||
/**
|
||||
* Behaviour of the notification
|
||||
*/
|
||||
private int mNotificationMode;
|
||||
/**
|
||||
* If true, create a notification with ticker text or heads up display
|
||||
*/
|
||||
private boolean mNotificationNag;
|
||||
/**
|
||||
* If true, audio will not be played through the speaker.
|
||||
*/
|
||||
@ -421,6 +428,7 @@ public final class PlaybackService extends Service
|
||||
SharedPreferences settings = getSettings(this);
|
||||
settings.registerOnSharedPreferenceChangeListener(this);
|
||||
mNotificationMode = Integer.parseInt(settings.getString(PrefKeys.NOTIFICATION_MODE, "1"));
|
||||
mNotificationNag = settings.getBoolean(PrefKeys.NOTIFICATION_NAG, false);
|
||||
mScrobble = settings.getBoolean(PrefKeys.SCROBBLE, false);
|
||||
mIdleTimeout = settings.getBoolean(PrefKeys.USE_IDLE_TIMEOUT, false) ? settings.getInt(PrefKeys.IDLE_TIMEOUT, 3600) : 0;
|
||||
|
||||
@ -789,6 +797,9 @@ public final class PlaybackService extends Service
|
||||
// mode.
|
||||
stopForeground(true);
|
||||
updateNotification();
|
||||
} else if (PrefKeys.NOTIFICATION_NAG.equals(key)) {
|
||||
mNotificationNag = settings.getBoolean(PrefKeys.NOTIFICATION_NAG, false);
|
||||
// no need to update notification: happens on next event
|
||||
} else if (PrefKeys.SCROBBLE.equals(key)) {
|
||||
mScrobble = settings.getBoolean(PrefKeys.SCROBBLE, false);
|
||||
} else if (PrefKeys.MEDIA_BUTTON.equals(key) || PrefKeys.MEDIA_BUTTON_BEEP.equals(key)) {
|
||||
@ -1931,8 +1942,6 @@ public final class PlaybackService extends Service
|
||||
expanded.setImageViewBitmap(R.id.cover, cover);
|
||||
}
|
||||
|
||||
String title = song.title;
|
||||
|
||||
int playButton = ThemeHelper.getPlayButtonResource(playing);
|
||||
|
||||
views.setImageViewResource(R.id.play_pause, playButton);
|
||||
@ -1959,9 +1968,9 @@ public final class PlaybackService extends Service
|
||||
views.setOnClickPendingIntent(R.id.close, PendingIntent.getService(this, 0, close, 0));
|
||||
expanded.setOnClickPendingIntent(R.id.close, PendingIntent.getService(this, 0, close, 0));
|
||||
|
||||
views.setTextViewText(R.id.title, title);
|
||||
views.setTextViewText(R.id.title, song.title);
|
||||
views.setTextViewText(R.id.artist, song.artist);
|
||||
expanded.setTextViewText(R.id.title, title);
|
||||
expanded.setTextViewText(R.id.title, song.title);
|
||||
expanded.setTextViewText(R.id.album, song.album);
|
||||
expanded.setTextViewText(R.id.artist, song.artist);
|
||||
|
||||
@ -1973,11 +1982,20 @@ public final class PlaybackService extends Service
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
// expanded view is available since 4.1
|
||||
notification.bigContentView = expanded;
|
||||
notification.priority = 42;
|
||||
}
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
notification.visibility = Notification.VISIBILITY_PUBLIC;
|
||||
}
|
||||
|
||||
if(mNotificationNag) {
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
notification.priority = Notification.PRIORITY_MAX;
|
||||
notification.vibrate = new long[0]; // needed to get headsup
|
||||
} else {
|
||||
notification.tickerText = song.title + " - " + song.artist;
|
||||
}
|
||||
}
|
||||
|
||||
return notification;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2013 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
* Copyright (C) 2012-2015 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
* Copyright (C) 2012 Christopher Eby <kreed@kreed.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@ -47,6 +47,7 @@ public class PrefKeys {
|
||||
public static final String MEDIA_BUTTON_BEEP = "media_button_beep";
|
||||
public static final String NOTIFICATION_ACTION = "notification_action";
|
||||
public static final String NOTIFICATION_MODE = "notification_mode";
|
||||
public static final String NOTIFICATION_NAG = "notification_nag";
|
||||
public static final String PLAYBACK_ON_STARTUP = "playback_on_startup";
|
||||
public static final String SCROBBLE = "scrobble";
|
||||
public static final String SHAKE_ACTION = "shake_action";
|
||||
|
Loading…
x
Reference in New Issue
Block a user