diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java index 568b56304..1253a8ad2 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java @@ -9,6 +9,7 @@ import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.preference.ListPreference; @@ -27,6 +28,7 @@ import de.danoeh.antennapod.core.feed.VolumeAdaptionSetting; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.databinding.EditTextDialogBinding; import de.danoeh.antennapod.dialog.AuthenticationDialog; import de.danoeh.antennapod.dialog.EpisodeFilterDialog; import de.danoeh.antennapod.dialog.FeedPreferenceSkipDialog; @@ -39,6 +41,8 @@ import org.greenrobot.eventbus.EventBus; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; +import java.util.Arrays; +import java.util.HashSet; import java.util.Locale; import static de.danoeh.antennapod.core.feed.FeedPreferences.SPEED_USE_GLOBAL; @@ -105,6 +109,7 @@ public class FeedSettingsFragment extends Fragment { private static final CharSequence PREF_CATEGORY_AUTO_DOWNLOAD = "autoDownloadCategory"; private static final String PREF_FEED_PLAYBACK_SPEED = "feedPlaybackSpeed"; private static final String PREF_AUTO_SKIP = "feedAutoSkip"; + private static final String PREF_TAGS = "tags"; private static final DecimalFormat SPEED_FORMAT = new DecimalFormat("0.00", DecimalFormatSymbols.getInstance(Locale.US)); @@ -159,6 +164,7 @@ public class FeedSettingsFragment extends Fragment { setupEpisodeFilterPreference(); setupPlaybackSpeedPreference(); setupFeedAutoSkipPreference(); + setupTags(); updateAutoDeleteSummary(); updateVolumeReductionValue(); @@ -394,6 +400,26 @@ public class FeedSettingsFragment extends Fragment { } } + private void setupTags() { + findPreference(PREF_TAGS).setOnPreferenceClickListener(preference -> { + EditTextDialogBinding alertViewBinding = EditTextDialogBinding.inflate(getLayoutInflater()); + alertViewBinding.urlEditText.setText(feed.getPreferences().getTagsAsString()); + new AlertDialog.Builder(getContext()) + .setView(alertViewBinding.getRoot()) + .setTitle(R.string.feed_folders_label) + .setPositiveButton(android.R.string.ok, (d, input) -> { + String foldersString = alertViewBinding.urlEditText.getText().toString(); + feedPreferences.getTags().clear(); + feedPreferences.getTags().addAll(new HashSet<>(Arrays.asList( + foldersString.split(FeedPreferences.TAG_SEPARATOR)))); + feed.savePreferences(); + }) + .setNegativeButton(R.string.cancel_label, null) + .show(); + return true; + }); + } + private class ApplyToEpisodesDialog extends ConfirmationDialog { private final boolean autoDownload; diff --git a/app/src/main/res/xml/feed_settings.xml b/app/src/main/res/xml/feed_settings.xml index 9d5ed5e8b..a0142b7b9 100644 --- a/app/src/main/res/xml/feed_settings.xml +++ b/app/src/main/res/xml/feed_settings.xml @@ -15,6 +15,12 @@ android:title="@string/authentication_label" android:summary="@string/authentication_descr"/> + + getTags() { return tags; } + + public String getTagsAsString() { + return TextUtils.join(TAG_SEPARATOR, tags); + } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java index 3f29b7822..8f47675a8 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java @@ -445,6 +445,7 @@ public class PodDBAdapter { values.put(KEY_INCLUDE_FILTER, prefs.getFilter().getIncludeFilter()); values.put(KEY_EXCLUDE_FILTER, prefs.getFilter().getExcludeFilter()); values.put(KEY_FEED_PLAYBACK_SPEED, prefs.getFeedPlaybackSpeed()); + values.put(KEY_FEED_TAGS, prefs.getTagsAsString()); values.put(KEY_FEED_SKIP_INTRO, prefs.getFeedSkipIntro()); values.put(KEY_FEED_SKIP_ENDING, prefs.getFeedSkipEnding()); db.update(TABLE_NAME_FEEDS, values, KEY_ID + "=?", new String[]{String.valueOf(prefs.getFeedID())}); diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index d32f751f4..5d6fe3078 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -707,9 +707,11 @@ Apply action Play chapter - + Authentication Change your username and password for this podcast and its episodes. + Folders + Change the folders in which this podcast is displayed. Auto Download Settings Episode Filter List of terms used to decide if an episode should be included or excluded when auto downloading