summaryrefslogtreecommitdiff
path: root/app/src/main/java/de/danoeh/antennapod
diff options
context:
space:
mode:
authororionlee <orionlee@yahoo.com>2019-10-28 12:40:56 -0700
committerorionlee <orionlee@yahoo.com>2019-11-05 12:34:11 -0800
commit52521ecddb7d7e66e5e132def7341d451c1dbee2 (patch)
tree7514b2571cd1bbf06246b5a0065c75fa06587569 /app/src/main/java/de/danoeh/antennapod
parent406f1cceb838be0dc468cdaa4c09224bebf27124 (diff)
downloadAntennaPod-52521ecddb7d7e66e5e132def7341d451c1dbee2.zip
#2652 the UI of a new setting enqueue location
- replaced existing enqueue at front - the option after current episode will replace Keep In-Progress in Queue that was in the PR (30f104f4).
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/preferences/PlaybackPreferencesFragment.java52
1 files changed, 41 insertions, 11 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/PlaybackPreferencesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/PlaybackPreferencesFragment.java
index 64ac1b8ed..5d9af14bd 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/PlaybackPreferencesFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/PlaybackPreferencesFragment.java
@@ -4,8 +4,15 @@ import android.app.Activity;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
+
+import androidx.annotation.NonNull;
+import androidx.collection.ArrayMap;
import androidx.preference.ListPreference;
+import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
+
+import java.util.Map;
+
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MediaplayerActivity;
import de.danoeh.antennapod.activity.PreferenceActivity;
@@ -64,19 +71,42 @@ public class PlaybackPreferencesFragment extends PreferenceFragmentCompat {
behaviour.setEntryValues(R.array.video_background_behavior_values_without_pip);
}
- findPreference(UserPreferences.PREF_QUEUE_ADD_TO_FRONT).setOnPreferenceChangeListener(
- (preference, newValue) -> {
- if (newValue instanceof Boolean) {
- boolean enableKeepInProgressAtFront = ((Boolean) newValue);
- checkKeepInProgressAtFrontItemVisibility(enableKeepInProgressAtFront);
- }
- return true;
- });
- checkKeepInProgressAtFrontItemVisibility(UserPreferences.enqueueAtFront());
+ buildEnqueueLocationPreference();
+ }
+
+ private void buildEnqueueLocationPreference() {
+ final Resources res = requireActivity().getResources();
+ final Map<String, String> options = new ArrayMap<>();
+ {
+ String[] keys = res.getStringArray(R.array.enqueue_location_values);
+ String[] values = res.getStringArray(R.array.enqueue_location_options);
+ for (int i = 0; i < keys.length; i++) {
+ options.put(keys[i], values[i]);
+ }
+ }
+
+ ListPreference pref = requirePreference(UserPreferences.PREF_ENQUEUE_LOCATION);
+ pref.setSummary(res.getString(R.string.pref_enqueue_location_sum, options.get(pref.getValue())));
+
+ pref.setOnPreferenceChangeListener((preference, newValue) -> {
+ if (!(newValue instanceof String)) {
+ return false;
+ }
+ String newValStr = (String)newValue;
+ pref.setSummary(res.getString(R.string.pref_enqueue_location_sum, options.get(newValStr)));
+ return true;
+ });
}
- private void checkKeepInProgressAtFrontItemVisibility(boolean enabled) {
- findPreference(UserPreferences.PREF_QUEUE_KEEP_IN_PROGESS_AT_FRONT).setEnabled(enabled);
+ @NonNull
+ private <T extends Preference> T requirePreference(@NonNull CharSequence key) {
+ // Possibly put it to a common method in abstract base class
+ T result = findPreference(key);
+ if (result == null) {
+ throw new IllegalArgumentException("Preference with key '" + key + "' is not found");
+
+ }
+ return result;
}
private void buildSmartMarkAsPlayedPreference() {