|
9 | 9 | import android.view.ViewGroup; |
10 | 10 | import androidx.annotation.NonNull; |
11 | 11 | import androidx.annotation.Nullable; |
| 12 | +import androidx.appcompat.app.AlertDialog; |
12 | 13 | import androidx.appcompat.widget.Toolbar; |
13 | 14 | import androidx.fragment.app.Fragment; |
14 | 15 | import androidx.preference.ListPreference; |
|
27 | 28 | import de.danoeh.antennapod.core.preferences.UserPreferences; |
28 | 29 | import de.danoeh.antennapod.core.storage.DBReader; |
29 | 30 | import de.danoeh.antennapod.core.storage.DBWriter; |
| 31 | +import de.danoeh.antennapod.databinding.EditTextDialogBinding; |
30 | 32 | import de.danoeh.antennapod.dialog.AuthenticationDialog; |
31 | 33 | import de.danoeh.antennapod.dialog.EpisodeFilterDialog; |
32 | 34 | import de.danoeh.antennapod.dialog.FeedPreferenceSkipDialog; |
|
39 | 41 |
|
40 | 42 | import java.text.DecimalFormat; |
41 | 43 | import java.text.DecimalFormatSymbols; |
| 44 | +import java.util.Arrays; |
| 45 | +import java.util.HashSet; |
42 | 46 | import java.util.Locale; |
43 | 47 |
|
44 | 48 | import static de.danoeh.antennapod.core.feed.FeedPreferences.SPEED_USE_GLOBAL; |
@@ -105,6 +109,7 @@ public static class FeedSettingsPreferenceFragment extends PreferenceFragmentCom |
105 | 109 | private static final CharSequence PREF_CATEGORY_AUTO_DOWNLOAD = "autoDownloadCategory"; |
106 | 110 | private static final String PREF_FEED_PLAYBACK_SPEED = "feedPlaybackSpeed"; |
107 | 111 | private static final String PREF_AUTO_SKIP = "feedAutoSkip"; |
| 112 | + private static final String PREF_TAGS = "tags"; |
108 | 113 | private static final DecimalFormat SPEED_FORMAT = |
109 | 114 | new DecimalFormat("0.00", DecimalFormatSymbols.getInstance(Locale.US)); |
110 | 115 |
|
@@ -159,6 +164,7 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { |
159 | 164 | setupEpisodeFilterPreference(); |
160 | 165 | setupPlaybackSpeedPreference(); |
161 | 166 | setupFeedAutoSkipPreference(); |
| 167 | + setupTags(); |
162 | 168 |
|
163 | 169 | updateAutoDeleteSummary(); |
164 | 170 | updateVolumeReductionValue(); |
@@ -394,6 +400,26 @@ private void updateAutoDownloadEnabled() { |
394 | 400 | } |
395 | 401 | } |
396 | 402 |
|
| 403 | + private void setupTags() { |
| 404 | + findPreference(PREF_TAGS).setOnPreferenceClickListener(preference -> { |
| 405 | + EditTextDialogBinding alertViewBinding = EditTextDialogBinding.inflate(getLayoutInflater()); |
| 406 | + alertViewBinding.urlEditText.setText(feed.getPreferences().getTagsAsString()); |
| 407 | + new AlertDialog.Builder(getContext()) |
| 408 | + .setView(alertViewBinding.getRoot()) |
| 409 | + .setTitle(R.string.feed_folders_label) |
| 410 | + .setPositiveButton(android.R.string.ok, (d, input) -> { |
| 411 | + String foldersString = alertViewBinding.urlEditText.getText().toString(); |
| 412 | + feedPreferences.getTags().clear(); |
| 413 | + feedPreferences.getTags().addAll(new HashSet<>(Arrays.asList( |
| 414 | + foldersString.split(FeedPreferences.TAG_SEPARATOR)))); |
| 415 | + feed.savePreferences(); |
| 416 | + }) |
| 417 | + .setNegativeButton(R.string.cancel_label, null) |
| 418 | + .show(); |
| 419 | + return true; |
| 420 | + }); |
| 421 | + } |
| 422 | + |
397 | 423 | private class ApplyToEpisodesDialog extends ConfirmationDialog { |
398 | 424 | private final boolean autoDownload; |
399 | 425 |
|
|
0 commit comments