Added basic UI for editing tags
This commit is contained in:
parent
19e427b524
commit
f4bbc5535c
|
@ -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;
|
||||
|
||||
|
|
|
@ -15,6 +15,12 @@
|
|||
android:title="@string/authentication_label"
|
||||
android:summary="@string/authentication_descr"/>
|
||||
|
||||
<Preference
|
||||
android:key="tags"
|
||||
android:icon="?attr/ic_folder"
|
||||
android:title="@string/feed_folders_label"
|
||||
android:summary="@string/feed_folders_summary"/>
|
||||
|
||||
<ListPreference
|
||||
android:key="feedPlaybackSpeed"
|
||||
android:icon="?attr/ic_settings_speed"
|
||||
|
|
|
@ -261,4 +261,8 @@ public class FeedPreferences {
|
|||
public Set<String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public String getTagsAsString() {
|
||||
return TextUtils.join(TAG_SEPARATOR, tags);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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())});
|
||||
|
|
|
@ -707,9 +707,11 @@
|
|||
<string name="apply_action">Apply action</string>
|
||||
<string name="play_chapter">Play chapter</string>
|
||||
|
||||
<!-- Feed information screen -->
|
||||
<!-- Feed settings/information screen -->
|
||||
<string name="authentication_label">Authentication</string>
|
||||
<string name="authentication_descr">Change your username and password for this podcast and its episodes.</string>
|
||||
<string name="feed_folders_label">Folders</string>
|
||||
<string name="feed_folders_summary">Change the folders in which this podcast is displayed.</string>
|
||||
<string name="auto_download_settings_label">Auto Download Settings</string>
|
||||
<string name="episode_filters_label">Episode Filter</string>
|
||||
<string name="episode_filters_description">List of terms used to decide if an episode should be included or excluded when auto downloading</string>
|
||||
|
|
Loading…
Reference in New Issue