Add option to pick lock screen playback buttons

This adds the option to pick which playback buttons to prioritise on the
notification. This allows choosing the playback buttons on the lock
screen. The default playback buttons have not changed and are still set
to play/pause (this is always displayed) and skip.

Note: This commit raises the minimum sdk version from 10 to 11!
This commit is contained in:
saqura 2016-04-02 21:37:05 +02:00
parent 13d0a3570b
commit 65bb7d9911
6 changed files with 43 additions and 7 deletions

View File

@ -55,6 +55,14 @@
android:key="prefPersistNotify"
android:summary="@string/pref_persistNotify_sum"
android:title="@string/pref_persistNotify_title"/>
<com.afollestad.materialdialogs.prefs.MaterialMultiSelectListPreference
android:entries="@array/prioritised_notification_buttons_options"
android:entryValues="@array/prioritised_notification_buttons_values"
android:defaultValue="@array/prioritised_notification_buttons_default_values"
android:title="@string/pref_prioritised_notification_buttons_title"
android:key="prefPrioritisedNotificationButtons"
android:summary="@string/pref_prioritised_notification_buttons_sum"
app:useStockLayout="true"/>
<de.danoeh.antennapod.preferences.SwitchCompatPreference
android:defaultValue="true"
android:enabled="true"

View File

@ -38,7 +38,7 @@ subprojects {
project.ext {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
minSdkVersion = 10
minSdkVersion = 11
targetSdkVersion = 23
supportVersion = "23.2.1"

View File

@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import de.danoeh.antennapod.core.R;
@ -52,6 +53,7 @@ public class UserPreferences {
public static final String PREF_DRAWER_FEED_COUNTER = "prefDrawerFeedIndicator";
public static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify";
public static final String PREF_PERSISTENT_NOTIFICATION = "prefPersistNotify";
public static final String PREF_PRIORITISED_NOTIFICATION_BUTTONS = "prefPrioritisedNotificationButtons";
public static final String PREF_LOCKSCREEN_BACKGROUND = "prefLockscreenBackground";
public static final String PREF_SHOW_DOWNLOAD_REPORT = "prefShowDownloadReport";
public static final String PREF_SHOW_SUBSCRIPTIONS_IN_DRAWER = "prefShowSubscriptionsInDrawer";
@ -180,6 +182,10 @@ public class UserPreferences {
return prefs.getBoolean(PREF_SHOW_SUBSCRIPTIONS_IN_DRAWER, true);
}
public static Set<String> getPrioritisedNotificationButtons() {
return prefs.getStringSet(PREF_PRIORITISED_NOTIFICATION_BUTTONS, null);
}
/**
* Returns notification priority.
*

View File

@ -30,6 +30,7 @@ import android.widget.Toast;
import com.bumptech.glide.Glide;
import java.util.List;
import java.util.Set;
import de.danoeh.antennapod.core.ClientConfig;
import de.danoeh.antennapod.core.R;
@ -858,7 +859,7 @@ public class PlaybackService extends Service {
.setPriority(UserPreferences.getNotifyPriority()); // set notification priority
IntList compactActionList = new IntList();
Set<String> prioritisedButtons = UserPreferences.getPrioritisedNotificationButtons();
int numActions = 0; // we start and 0 and then increment by 1 for each call to addAction
// always let them rewind
@ -867,8 +868,8 @@ public class PlaybackService extends Service {
notificationBuilder.addAction(android.R.drawable.ic_media_rew,
getString(R.string.rewind_label),
rewindButtonPendingIntent);
if(UserPreferences.showAdditionalNotificationButtons()) {
// always show the rewind button (even on the lockscreen)
if(prioritisedButtons.contains("0")) {
// show the rewind button even on the lock screen
compactActionList.add(numActions++);
} else {
numActions++;
@ -897,8 +898,8 @@ public class PlaybackService extends Service {
notificationBuilder.addAction(android.R.drawable.ic_media_ff,
getString(R.string.fast_forward_label),
ffButtonPendingIntent);
if(UserPreferences.showAdditionalNotificationButtons()) {
// always show the ff button (even on the lockscreen)
if(prioritisedButtons.contains("1")) {
// show the fast forward button even on the lock screen
compactActionList.add(numActions++);
} else {
numActions++;
@ -910,7 +911,12 @@ public class PlaybackService extends Service {
notificationBuilder.addAction(android.R.drawable.ic_media_next,
getString(R.string.skip_episode_label),
skipButtonPendingIntent);
compactActionList.add(numActions++);
if(prioritisedButtons.contains("2")) {
// show the skip button even on the lock screen
compactActionList.add(numActions++);
} else {
numActions++;
}
}
PendingIntent stopButtonPendingIntent = getPendingIntentForMediaAction(

View File

@ -212,4 +212,18 @@
<item>500</item>
</string-array>
<string-array name="prioritised_notification_buttons_options">
<item>@string/rewind_label</item>
<item>@string/fast_forward_label</item>
<item>@string/skip_episode_label</item>
</string-array>
<string-array name="prioritised_notification_buttons_values">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
<string-array name="prioritised_notification_buttons_default_values">
<item>2</item>
</string-array>
</resources>

View File

@ -384,6 +384,8 @@
<string name="pref_expandNotify_sum">Always expand the notification to show playback buttons.</string>
<string name="pref_persistNotify_title">Persistent Playback Controls</string>
<string name="pref_persistNotify_sum">Keep notification and lockscreen controls when playback is paused.</string>
<string name="pref_prioritised_notification_buttons_title">Prioritise Notification Buttons</string>
<string name="pref_prioritised_notification_buttons_sum">Change the playback buttons on the lock screen notification.</string>
<string name="pref_show_subscriptions_in_drawer_title">Show Subscriptions</string>
<string name="pref_show_subscriptions_in_drawer_sum">Show subscription list directly in navigation drawer</string>
<string name="pref_lockscreen_background_title">Set Lockscreen Background</string>