add settings options for persistent and expanded notifications
This commit is contained in:
parent
fb4ccb381b
commit
baf980951e
|
@ -251,6 +251,11 @@
|
|||
<string name="pref_seek_delta_sum">Seek this many seconds when rewinding or fast-forwarding</string>
|
||||
<string name="pref_gpodnet_sethostname_title">Set hostname</string>
|
||||
<string name="pref_gpodnet_sethostname_use_default_host">Use default host</string>
|
||||
<string name="pref_expandNotify_title">Expand Notification</string>
|
||||
<string name="pref_expandNotify_sum">Always expand the notification to show playback buttons.</string>
|
||||
<string name="pref_persistNotify_title">Persistent Notification</string>
|
||||
<string name="pref_persistNotify_sum">Keep notification when playback is paused.</string>
|
||||
|
||||
|
||||
<!-- Auto-Flattr dialog -->
|
||||
<string name="auto_flattr_enable">Enable automatic flattring</string>
|
||||
|
|
|
@ -9,6 +9,18 @@
|
|||
android:key="prefTheme"
|
||||
android:summary="@string/pref_set_theme_sum"
|
||||
android:defaultValue="0"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:enabled="true"
|
||||
android:key="prefExpandNotify"
|
||||
android:summary="@string/pref_expandNotify_sum"
|
||||
android:title="@string/pref_expandNotify_title"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:enabled="true"
|
||||
android:key="prefPersistNotify"
|
||||
android:summary="@string/pref_persistNotify_sum"
|
||||
android:title="@string/pref_persistNotify_title"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/playback_pref">
|
||||
<CheckBoxPreference
|
||||
|
|
|
@ -53,6 +53,8 @@ public class UserPreferences implements
|
|||
private static final String PREF_PLAYBACK_SPEED_ARRAY = "prefPlaybackSpeedArray";
|
||||
public static final String PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS = "prefPauseForFocusLoss";
|
||||
private static final String PREF_SEEK_DELTA_SECS = "prefSeekDeltaSecs";
|
||||
private static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify";
|
||||
private static final String PREF_PERSISTENT_NOTIFICATION = "prefPersistNotify";
|
||||
|
||||
// TODO: Make this value configurable
|
||||
private static final float PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD_DEFAULT = 0.8f;
|
||||
|
@ -82,6 +84,8 @@ public class UserPreferences implements
|
|||
private boolean pauseForFocusLoss;
|
||||
private int seekDeltaSecs;
|
||||
private boolean isFreshInstall;
|
||||
private int notifyPriority;
|
||||
private boolean persistNotify;
|
||||
|
||||
private UserPreferences(Context context) {
|
||||
this.context = context;
|
||||
|
@ -138,6 +142,13 @@ public class UserPreferences implements
|
|||
PREF_PLAYBACK_SPEED_ARRAY, null));
|
||||
pauseForFocusLoss = sp.getBoolean(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS, false);
|
||||
seekDeltaSecs = Integer.valueOf(sp.getString(PREF_SEEK_DELTA_SECS, "30"));
|
||||
if (sp.getBoolean(PREF_EXPANDED_NOTIFICATION, false)) {
|
||||
notifyPriority = 2; // max priority
|
||||
}
|
||||
else {
|
||||
notifyPriority = 0; // default priority
|
||||
}
|
||||
persistNotify = sp.getBoolean(PREF_PERSISTENT_NOTIFICATION, false);
|
||||
}
|
||||
|
||||
private int readThemeValue(String valueFromPrefs) {
|
||||
|
@ -243,6 +254,17 @@ public class UserPreferences implements
|
|||
return instance.autoFlattr;
|
||||
}
|
||||
|
||||
public static int getNotifyPriority() {
|
||||
instanceAvailable();
|
||||
return instance.notifyPriority;
|
||||
}
|
||||
|
||||
public static boolean isPersistNotify() {
|
||||
instanceAvailable();
|
||||
return instance.persistNotify;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the time after which an episode should be auto-flattr'd in percent of the episode's
|
||||
* duration.
|
||||
|
@ -366,6 +388,15 @@ public class UserPreferences implements
|
|||
} else if (key.equals(PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD)) {
|
||||
autoFlattrPlayedDurationThreshold = sp.getFloat(PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD,
|
||||
PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD_DEFAULT);
|
||||
} else if (key.equals(PREF_EXPANDED_NOTIFICATION)) {
|
||||
if (sp.getBoolean(PREF_EXPANDED_NOTIFICATION, false)) {
|
||||
notifyPriority = 2; // max priority
|
||||
}
|
||||
else {
|
||||
notifyPriority = 0; // default priority
|
||||
}
|
||||
} else if (key.equals(PREF_PERSISTENT_NOTIFICATION)) {
|
||||
persistNotify = sp.getBoolean(PREF_PERSISTENT_NOTIFICATION, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -402,7 +402,13 @@ public class PlaybackService extends Service {
|
|||
taskManager.cancelPositionSaver();
|
||||
saveCurrentPosition(false, 0);
|
||||
taskManager.cancelWidgetUpdater();
|
||||
// stopForeground(true); // do not remove notification on pause
|
||||
if (UserPreferences.isPersistNotify()) {
|
||||
// do not remove notification on pause
|
||||
}
|
||||
else {
|
||||
// remove notifcation on pause
|
||||
stopForeground(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case STOPPED:
|
||||
|
@ -744,13 +750,14 @@ public class PlaybackService extends Service {
|
|||
.setContentIntent(pIntent)
|
||||
.setLargeIcon(icon)
|
||||
.setSmallIcon(R.drawable.ic_stat_antenna)
|
||||
.addAction(android.R.drawable.ic_media_pause, //pause action
|
||||
getString(R.string.pause_label),
|
||||
pauseButtonPendingIntent)
|
||||
.setPriority(UserPreferences.getNotifyPriority()) // set notification priority
|
||||
.addAction(android.R.drawable.ic_media_play, //play action
|
||||
getString(R.string.play_label),
|
||||
playButtonPendingIntent)
|
||||
.addAction(android.R.drawable.ic_media_stop, // stop action
|
||||
.addAction(android.R.drawable.ic_media_pause, //pause action
|
||||
getString(R.string.pause_label),
|
||||
pauseButtonPendingIntent)
|
||||
.addAction(android.R.drawable.ic_menu_close_clear_cancel, // stop action
|
||||
getString(R.string.stop_label),
|
||||
stopButtonPendingIntent);
|
||||
notification = notificationBuilder.build();
|
||||
|
|
Loading…
Reference in New Issue