summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java60
-rw-r--r--app/src/main/res/xml/preferences.xml12
-rw-r--r--build.gradle2
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java19
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java9
-rw-r--r--core/src/main/res/values/arrays.xml14
-rw-r--r--core/src/main/res/values/strings.xml6
7 files changed, 93 insertions, 29 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java
index 116272578..0e79b46ea 100644
--- a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java
+++ b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java
@@ -6,6 +6,7 @@ import android.app.Activity;
import android.app.TimePickerDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
@@ -221,6 +222,12 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
return true;
});
+ ui.findPreference(UserPreferences.PREF_NOTIFICATION_BUTTONS)
+ .setOnPreferenceClickListener(preference -> {
+ showNotificationButtonsDialog();
+ return true;
+ });
+
ui.findPreference(UserPreferences.PREF_UPDATE_INTERVAL)
.setOnPreferenceClickListener(preference -> {
showUpdateIntervalTimePreferencesDialog();
@@ -735,6 +742,59 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
builder.create().show();
}
+ private void showNotificationButtonsDialog() {
+ final Context context = ui.getActivity();
+ final List<String> preferredButtons = UserPreferences.getNotificationButtons();
+ final String[] allButtonNames = context.getResources().getStringArray(
+ R.array.notification_buttons_options);
+ final String[] allButtonIDs = context.getResources().getStringArray(
+ R.array.notification_buttons_values);
+ boolean[] checked = new boolean[allButtonIDs.length]; // booleans default to false in java
+
+ for(int i=0; i < allButtonIDs.length; i++) {
+ String id = allButtonIDs[i];
+ if(preferredButtons.contains(id)) {
+ checked[i] = true;
+ }
+ }
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
+ builder.setTitle(String.format(context.getResources().getString(
+ R.string.pref_notification_buttons_dialog_title), 2));
+ builder.setMultiChoiceItems(allButtonNames, checked,new DialogInterface.OnMultiChoiceClickListener() {
+ int count = preferredButtons.size();
+
+ public void onClick(DialogInterface dialog, int which, boolean isChecked) {
+ checked[which] = isChecked;
+ if (isChecked) {
+ if (count < 2) {
+ preferredButtons.add(allButtonIDs[which]);
+ count++;
+ } else {
+ // Only allow a maximum of two selections. This is because the notification
+ // on the lock screen can only display 3 buttons, and the play/pause button
+ // is always included.
+ checked[which] = false;
+ ((AlertDialog) dialog).getListView().setItemChecked(which, false);
+ Toast.makeText(
+ context,
+ String.format(context.getResources().getString(
+ R.string.pref_notification_buttons_dialog_error), 2),
+ Toast.LENGTH_SHORT).show();
+ }
+ } else {
+ preferredButtons.remove(allButtonIDs[which]);
+ count--;
+ }
+ }
+ });
+ builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> {
+ UserPreferences.setNotificationButtons(preferredButtons);
+ });
+ builder.setNegativeButton(R.string.cancel_label, null);
+ builder.create().show();
+ }
+
// CHOOSE DATA FOLDER
private void requestPermission() {
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index e40de7c46..b3707f023 100644
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -55,14 +55,10 @@
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"/>
+ <Preference
+ android:key="prefNotificationButtons"
+ android:summary="@string/pref_notification_buttons_sum"
+ android:title="@string/pref_notification_buttons_title"/>
<de.danoeh.antennapod.preferences.SwitchCompatPreference
android:defaultValue="true"
android:enabled="true"
diff --git a/build.gradle b/build.gradle
index 44b208aa0..046a9d4f9 100644
--- a/build.gradle
+++ b/build.gradle
@@ -38,7 +38,7 @@ subprojects {
project.ext {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
- minSdkVersion = 11
+ minSdkVersion = 10
targetSdkVersion = 23
supportVersion = "23.2.1"
diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
index 25195ee4b..5cff781de 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
@@ -22,7 +22,6 @@ 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;
@@ -53,7 +52,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_NOTIFICATION_BUTTONS = "prefNotificationButtons";
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";
@@ -168,6 +167,11 @@ public class UserPreferences {
return new ArrayList<>(Arrays.asList(TextUtils.split(hiddenItems, ",")));
}
+ public static List<String> getNotificationButtons() {
+ String hiddenItems = prefs.getString(PREF_NOTIFICATION_BUTTONS, "skip");
+ return new ArrayList<>(Arrays.asList(TextUtils.split(hiddenItems, ",")));
+ }
+
public static int getFeedOrder() {
String value = prefs.getString(PREF_DRAWER_FEED_ORDER, "0");
return Integer.parseInt(value);
@@ -182,10 +186,6 @@ 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.
*
@@ -533,6 +533,13 @@ public class UserPreferences {
.apply();
}
+ public static void setNotificationButtons(List<String> items) {
+ String str = TextUtils.join(",", items);
+ prefs.edit()
+ .putString(PREF_NOTIFICATION_BUTTONS, str)
+ .apply();
+ }
+
public static void setQueueLocked(boolean locked) {
prefs.edit()
.putBoolean(PREF_QUEUE_LOCKED, locked)
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
index 7a7c2d635..39dc35535 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
@@ -30,7 +30,6 @@ 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;
@@ -859,7 +858,7 @@ public class PlaybackService extends Service {
.setPriority(UserPreferences.getNotifyPriority()); // set notification priority
IntList compactActionList = new IntList();
- Set<String> prioritisedButtons = UserPreferences.getPrioritisedNotificationButtons();
+ final List<String> notificationButtons = UserPreferences.getNotificationButtons();
int numActions = 0; // we start and 0 and then increment by 1 for each call to addAction
// always let them rewind
@@ -868,7 +867,7 @@ public class PlaybackService extends Service {
notificationBuilder.addAction(android.R.drawable.ic_media_rew,
getString(R.string.rewind_label),
rewindButtonPendingIntent);
- if(prioritisedButtons.contains("0")) {
+ if(notificationButtons.contains("rewind")) {
// show the rewind button even on the lock screen
compactActionList.add(numActions++);
} else {
@@ -898,7 +897,7 @@ public class PlaybackService extends Service {
notificationBuilder.addAction(android.R.drawable.ic_media_ff,
getString(R.string.fast_forward_label),
ffButtonPendingIntent);
- if(prioritisedButtons.contains("1")) {
+ if(notificationButtons.contains("fastforward")) {
// show the fast forward button even on the lock screen
compactActionList.add(numActions++);
} else {
@@ -911,7 +910,7 @@ public class PlaybackService extends Service {
notificationBuilder.addAction(android.R.drawable.ic_media_next,
getString(R.string.skip_episode_label),
skipButtonPendingIntent);
- if(prioritisedButtons.contains("2")) {
+ if(notificationButtons.contains("skip")) {
// show the skip button even on the lock screen
compactActionList.add(numActions++);
} else {
diff --git a/core/src/main/res/values/arrays.xml b/core/src/main/res/values/arrays.xml
index ea2bb7a52..04e0d97cd 100644
--- a/core/src/main/res/values/arrays.xml
+++ b/core/src/main/res/values/arrays.xml
@@ -212,18 +212,18 @@
<item>500</item>
</string-array>
- <string-array name="prioritised_notification_buttons_options">
+ <string-array name="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 name="notification_buttons_values">
+ <item>rewind</item>
+ <item>fastforward</item>
+ <item>skip</item>
</string-array>
- <string-array name="prioritised_notification_buttons_default_values">
- <item>2</item>
+ <string-array name="notification_buttons_default_values">
+ <item>skip</item>
</string-array>
</resources>
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index b2f4e11f9..25da5ec1d 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -384,8 +384,10 @@
<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_notification_buttons_title">Select Notification Buttons</string>
+ <string name="pref_notification_buttons_sum">Change the playback buttons on the lock screen notification.</string>
+ <string name="pref_notification_buttons_dialog_title">Select a maximum of %1$d items</string>
+ <string name="pref_notification_buttons_dialog_error">You can only select a maximum of %1$d items.</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>