diff options
author | ByteHamster <info@bytehamster.com> | 2019-06-14 10:34:55 +0200 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2019-06-14 10:34:55 +0200 |
commit | 5a7cbdfaca008e9049aaa3a0506e23aabd1a66a7 (patch) | |
tree | 48f7ef587d93c56f64753a3e61bd924d610b1020 /app/src/main/java/de/danoeh/antennapod/dialog | |
parent | 8f11f8a27149ce3a25bed7c2f97a0e03301929f1 (diff) | |
download | AntennaPod-5a7cbdfaca008e9049aaa3a0506e23aabd1a66a7.zip |
Added authentication and episode filter dialogs
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/dialog')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/dialog/EpisodeFilterDialog.java | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/EpisodeFilterDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/EpisodeFilterDialog.java new file mode 100644 index 000000000..ba778be56 --- /dev/null +++ b/app/src/main/java/de/danoeh/antennapod/dialog/EpisodeFilterDialog.java @@ -0,0 +1,71 @@ +package de.danoeh.antennapod.dialog; + +import android.app.Dialog; +import android.content.Context; +import android.os.Bundle; +import android.widget.Button; +import android.widget.EditText; +import android.widget.RadioButton; +import de.danoeh.antennapod.R; +import de.danoeh.antennapod.core.feed.FeedFilter; + +/** + * Displays a dialog with a text box for filtering episodes and two radio buttons for exclusion/inclusion + */ +public abstract class EpisodeFilterDialog extends Dialog { + + private final FeedFilter initialFilter; + + public EpisodeFilterDialog(Context context, FeedFilter filter) { + super(context); + this.initialFilter = filter; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.episode_filter_dialog); + final EditText etxtEpisodeFilterText = findViewById(R.id.etxtEpisodeFilterText); + final RadioButton radioInclude = findViewById(R.id.radio_filter_include); + final RadioButton radioExclude = findViewById(R.id.radio_filter_exclude); + final Button butConfirm = findViewById(R.id.butConfirm); + final Button butCancel = findViewById(R.id.butCancel); + + setTitle(R.string.episode_filters_label); + setOnCancelListener(dialog -> onCancelled()); + + if (initialFilter.includeOnly()) { + radioInclude.setChecked(true); + etxtEpisodeFilterText.setText(initialFilter.getIncludeFilter()); + } else if(initialFilter.excludeOnly()) { + radioExclude.setChecked(true); + etxtEpisodeFilterText.setText(initialFilter.getExcludeFilter()); + } else { + radioExclude.setChecked(false); + radioInclude.setChecked(false); + etxtEpisodeFilterText.setText(""); + } + + + butCancel.setOnClickListener(v -> cancel()); + butConfirm.setOnClickListener(v -> { + + String includeString = ""; + String excludeString = ""; + if (radioInclude.isChecked()) { + includeString = etxtEpisodeFilterText.getText().toString(); + } else { + excludeString = etxtEpisodeFilterText.getText().toString(); + } + + onConfirmed(new FeedFilter(includeString, excludeString)); + dismiss(); + }); + } + + protected void onCancelled() { + + } + + protected abstract void onConfirmed(FeedFilter filter); +} |