diff options
Diffstat (limited to 'app')
7 files changed, 429 insertions, 486 deletions
diff --git a/app/src/free/java/de/danoeh/antennapod/preferences/PreferenceControllerFlavorHelper.java b/app/src/free/java/de/danoeh/antennapod/preferences/PreferenceControllerFlavorHelper.java index ff39ed389..e096f883f 100644 --- a/app/src/free/java/de/danoeh/antennapod/preferences/PreferenceControllerFlavorHelper.java +++ b/app/src/free/java/de/danoeh/antennapod/preferences/PreferenceControllerFlavorHelper.java @@ -1,11 +1,12 @@ package de.danoeh.antennapod.preferences; import de.danoeh.antennapod.core.preferences.UserPreferences; +import de.danoeh.antennapod.fragment.preferences.PlaybackPreferencesFragment; /** * Implements functions from PreferenceController that are flavor dependent. */ -class PreferenceControllerFlavorHelper { +public class PreferenceControllerFlavorHelper { public static void setupFlavoredUI(PlaybackPreferencesFragment ui) { ui.findPreference(UserPreferences.PREF_CAST_ENABLED).setEnabled(false); diff --git a/app/src/main/java/de/danoeh/antennapod/activity/FeedSettingsActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/FeedSettingsActivity.java index 4698ed90e..fd526d1db 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/FeedSettingsActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/FeedSettingsActivity.java @@ -1,46 +1,26 @@ package de.danoeh.antennapod.activity; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; import android.graphics.LightingColorFilter; -import android.net.Uri; import android.os.Bundle; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentTransaction; import android.support.v7.app.AppCompatActivity; -import android.text.Editable; import android.text.TextUtils; -import android.text.TextWatcher; import android.util.Log; -import android.view.Menu; -import android.view.MenuInflater; + import android.view.MenuItem; import android.view.View; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemSelectedListener; -import android.widget.CheckBox; -import android.widget.EditText; import android.widget.ImageView; -import android.widget.RadioButton; -import android.widget.Spinner; import android.widget.TextView; - import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; - import de.danoeh.antennapod.R; -import de.danoeh.antennapod.core.dialog.ConfirmationDialog; -import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator; import de.danoeh.antennapod.core.feed.Feed; -import de.danoeh.antennapod.core.feed.FeedFilter; -import de.danoeh.antennapod.core.feed.FeedPreferences; import de.danoeh.antennapod.core.glide.ApGlideSettings; import de.danoeh.antennapod.core.glide.FastBlurTransformation; 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.core.storage.DownloadRequestException; -import de.danoeh.antennapod.core.util.IntentUtils; -import de.danoeh.antennapod.menuhandler.FeedMenuHandler; +import de.danoeh.antennapod.fragment.FeedSettingsFragment; import io.reactivex.Maybe; import io.reactivex.MaybeOnSubscribe; import io.reactivex.android.schedulers.AndroidSchedulers; @@ -51,59 +31,14 @@ import io.reactivex.schedulers.Schedulers; * Displays information about a feed. */ public class FeedSettingsActivity extends AppCompatActivity { - public static final String EXTRA_FEED_ID = "de.danoeh.antennapod.extra.feedId"; private static final String TAG = "FeedSettingsActivity"; - private boolean autoDeleteChanged = false; private Feed feed; - + private Disposable disposable; private ImageView imgvCover; private TextView txtvTitle; - private EditText etxtUsername; - private EditText etxtPassword; - private EditText etxtFilterText; - private RadioButton rdoFilterInclude; - private RadioButton rdoFilterExclude; - private CheckBox cbxAutoDownload; - private CheckBox cbxKeepUpdated; - private Spinner spnAutoDelete; - private boolean filterInclude = true; - - private Disposable disposable; - - private boolean authInfoChanged = false; - - private final TextWatcher authTextWatcher = new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - - @Override - public void afterTextChanged(Editable s) { - authInfoChanged = true; - } - }; - - private boolean filterTextChanged = false; - - private final TextWatcher filterTextWatcher = new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - - @Override - public void afterTextChanged(Editable s) { - filterTextChanged = true; - } - }; + private ImageView imgvBackground; + private TextView txtvAuthorHeader; @Override protected void onCreate(Bundle savedInstanceState) { @@ -115,138 +50,27 @@ public class FeedSettingsActivity extends AppCompatActivity { imgvCover = findViewById(R.id.imgvCover); txtvTitle = findViewById(R.id.txtvTitle); - TextView txtvAuthorHeader = findViewById(R.id.txtvAuthor); - ImageView imgvBackground = findViewById(R.id.imgvBackground); + txtvAuthorHeader = findViewById(R.id.txtvAuthor); + imgvBackground = findViewById(R.id.imgvBackground); findViewById(R.id.butShowInfo).setVisibility(View.INVISIBLE); findViewById(R.id.butShowSettings).setVisibility(View.INVISIBLE); // https://github.com/bumptech/glide/issues/529 imgvBackground.setColorFilter(new LightingColorFilter(0xff828282, 0x000000)); - cbxAutoDownload = findViewById(R.id.cbxAutoDownload); - cbxKeepUpdated = findViewById(R.id.cbxKeepUpdated); - spnAutoDelete = findViewById(R.id.spnAutoDelete); - etxtUsername = findViewById(R.id.etxtUsername); - etxtPassword = findViewById(R.id.etxtPassword); - etxtFilterText = findViewById(R.id.etxtEpisodeFilterText); - rdoFilterInclude = findViewById(R.id.radio_filter_include); - rdoFilterInclude.setOnClickListener(v -> { - filterInclude = true; - filterTextChanged = true; - }); - rdoFilterExclude = findViewById(R.id.radio_filter_exclude); - rdoFilterExclude.setOnClickListener(v -> { - filterInclude = false; - filterTextChanged = true; - }); - disposable = Maybe.create((MaybeOnSubscribe<Feed>) emitter -> { - Feed feed = DBReader.getFeed(feedId); - if (feed != null) { - emitter.onSuccess(feed); - } else { - emitter.onComplete(); - } - }) + Feed feed = DBReader.getFeed(feedId); + if (feed != null) { + emitter.onSuccess(feed); + } else { + emitter.onComplete(); + } + }) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(result -> { feed = result; - FeedPreferences prefs = feed.getPreferences(); - Glide.with(FeedSettingsActivity.this) - .load(feed.getImageLocation()) - .apply(new RequestOptions() - .placeholder(R.color.light_gray) - .error(R.color.light_gray) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate()) - .into(imgvCover); - Glide.with(FeedSettingsActivity.this) - .load(feed.getImageLocation()) - .apply(new RequestOptions() - .placeholder(R.color.image_readability_tint) - .error(R.color.image_readability_tint) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .transform(new FastBlurTransformation()) - .dontAnimate()) - .into(imgvBackground); - - txtvTitle.setText(feed.getTitle()); - - if (!TextUtils.isEmpty(feed.getAuthor())) { - txtvAuthorHeader.setText(feed.getAuthor()); - } - - cbxAutoDownload.setEnabled(UserPreferences.isEnableAutodownload()); - cbxAutoDownload.setChecked(prefs.getAutoDownload()); - cbxAutoDownload.setOnCheckedChangeListener((compoundButton, checked) -> { - feed.getPreferences().setAutoDownload(checked); - feed.savePreferences(); - updateAutoDownloadSettings(); - ApplyToEpisodesDialog dialog = new ApplyToEpisodesDialog(FeedSettingsActivity.this, - feed, checked); - dialog.createNewDialog().show(); - }); - cbxKeepUpdated.setChecked(prefs.getKeepUpdated()); - cbxKeepUpdated.setOnCheckedChangeListener((compoundButton, checked) -> { - feed.getPreferences().setKeepUpdated(checked); - feed.savePreferences(); - }); - spnAutoDelete.setOnItemSelectedListener(new OnItemSelectedListener() { - @Override - public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { - FeedPreferences.AutoDeleteAction auto_delete_action; - switch (parent.getSelectedItemPosition()) { - case 0: - auto_delete_action = FeedPreferences.AutoDeleteAction.GLOBAL; - break; - case 1: - auto_delete_action = FeedPreferences.AutoDeleteAction.YES; - break; - case 2: - auto_delete_action = FeedPreferences.AutoDeleteAction.NO; - break; - default: // TODO - add exceptions here - return; - } - feed.getPreferences().setAutoDeleteAction(auto_delete_action);// p - autoDeleteChanged = true; - } - - @Override - public void onNothingSelected(AdapterView<?> parent) { - // Another interface callback - } - }); - spnAutoDelete.setSelection(prefs.getAutoDeleteAction().ordinal()); - - etxtUsername.setText(prefs.getUsername()); - etxtPassword.setText(prefs.getPassword()); - - etxtUsername.addTextChangedListener(authTextWatcher); - etxtPassword.addTextChangedListener(authTextWatcher); - - FeedFilter filter = prefs.getFilter(); - if (filter.includeOnly()) { - etxtFilterText.setText(filter.getIncludeFilter()); - rdoFilterInclude.setChecked(true); - rdoFilterExclude.setChecked(false); - filterInclude = true; - } else if (filter.excludeOnly()) { - etxtFilterText.setText(filter.getExcludeFilter()); - rdoFilterInclude.setChecked(false); - rdoFilterExclude.setChecked(true); - filterInclude = false; - } else { - Log.d(TAG, "No filter set"); - rdoFilterInclude.setChecked(false); - rdoFilterExclude.setChecked(false); - etxtFilterText.setText(""); - } - etxtFilterText.addTextChangedListener(filterTextWatcher); - - supportInvalidateOptionsMenu(); - updateAutoDownloadSettings(); + showFragment(); + showHeader(); }, error -> { Log.d(TAG, Log.getStackTraceString(error)); finish(); @@ -256,35 +80,46 @@ public class FeedSettingsActivity extends AppCompatActivity { }); } - @Override - protected void onPause() { - super.onPause(); - if (feed != null) { - FeedPreferences prefs = feed.getPreferences(); - if (authInfoChanged) { - Log.d(TAG, "Auth info changed, saving credentials"); - prefs.setUsername(etxtUsername.getText().toString()); - prefs.setPassword(etxtPassword.getText().toString()); - } - if (filterTextChanged) { - Log.d(TAG, "Filter info changed, saving..."); - String filterText = etxtFilterText.getText().toString(); - String includeString = ""; - String excludeString = ""; - if (filterInclude) { - includeString = filterText; - } else { - excludeString = filterText; - } - prefs.setFilter(new FeedFilter(includeString, excludeString)); - } - if (authInfoChanged || autoDeleteChanged || filterTextChanged) { - DBWriter.setFeedPreferences(prefs); - } - authInfoChanged = false; - autoDeleteChanged = false; - filterTextChanged = false; + private void showFragment() { + FeedSettingsFragment fragment = new FeedSettingsFragment(); + fragment.setArguments(getIntent().getExtras()); + + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction fragmentTransaction = + fragmentManager.beginTransaction(); + fragmentTransaction.replace(R.id.settings_fragment_container, fragment); + fragmentTransaction.commit(); + } + + public Feed getFeed() { + return feed; + } + + private void showHeader() { + txtvTitle.setText(feed.getTitle()); + + if (!TextUtils.isEmpty(feed.getAuthor())) { + txtvAuthorHeader.setText(feed.getAuthor()); } + + Glide.with(FeedSettingsActivity.this) + .load(feed.getImageLocation()) + .apply(new RequestOptions() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .fitCenter() + .dontAnimate()) + .into(imgvCover); + Glide.with(FeedSettingsActivity.this) + .load(feed.getImageLocation()) + .apply(new RequestOptions() + .placeholder(R.color.image_readability_tint) + .error(R.color.image_readability_tint) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .transform(new FastBlurTransformation()) + .dontAnimate()) + .into(imgvBackground); } @Override @@ -296,69 +131,13 @@ public class FeedSettingsActivity extends AppCompatActivity { } @Override - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.feedinfo, menu); - return true; - } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - super.onPrepareOptionsMenu(menu); - menu.findItem(R.id.support_item).setVisible( - feed != null && feed.getPaymentLink() != null); - menu.findItem(R.id.share_link_item).setVisible(feed != null && feed.getLink() != null); - menu.findItem(R.id.visit_website_item).setVisible(feed != null && feed.getLink() != null && - IntentUtils.isCallable(this, new Intent(Intent.ACTION_VIEW, Uri.parse(feed.getLink())))); - return true; - } - - @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish(); return true; default: - try { - return FeedMenuHandler.onOptionsItemClicked(this, item, feed); - } catch (DownloadRequestException e) { - e.printStackTrace(); - DownloadRequestErrorDialogCreator.newRequestErrorDialog(this, - e.getMessage()); - } return super.onOptionsItemSelected(item); } } - - private void updateAutoDownloadSettings() { - if (feed != null && feed.getPreferences() != null) { - boolean enabled = feed.getPreferences().getAutoDownload() && UserPreferences.isEnableAutodownload(); - rdoFilterInclude.setEnabled(enabled); - rdoFilterExclude.setEnabled(enabled); - etxtFilterText.setEnabled(enabled); - } - } - - private static class ApplyToEpisodesDialog extends ConfirmationDialog { - - private final Feed feed; - private final boolean autoDownload; - - ApplyToEpisodesDialog(Context context, Feed feed, boolean autoDownload) { - super(context, R.string.auto_download_apply_to_items_title, - R.string.auto_download_apply_to_items_message); - this.feed = feed; - this.autoDownload = autoDownload; - setPositiveText(R.string.yes); - setNegativeText(R.string.no); - } - - @Override - public void onConfirmButtonPressed(DialogInterface dialog) { - DBWriter.setFeedsItemsAutoDownload(feed, autoDownload); - } - } - } 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); +} diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java new file mode 100644 index 000000000..a20384086 --- /dev/null +++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java @@ -0,0 +1,170 @@ +package de.danoeh.antennapod.fragment; + +import android.content.Context; +import android.content.DialogInterface; +import android.os.Bundle; +import android.support.v14.preference.SwitchPreference; +import android.support.v7.preference.ListPreference; +import android.support.v7.preference.PreferenceFragmentCompat; +import de.danoeh.antennapod.R; +import de.danoeh.antennapod.activity.FeedSettingsActivity; +import de.danoeh.antennapod.core.dialog.ConfirmationDialog; +import de.danoeh.antennapod.core.feed.Feed; +import de.danoeh.antennapod.core.feed.FeedFilter; +import de.danoeh.antennapod.core.feed.FeedPreferences; +import de.danoeh.antennapod.core.preferences.UserPreferences; +import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.dialog.AuthenticationDialog; +import de.danoeh.antennapod.dialog.EpisodeFilterDialog; + +public class FeedSettingsFragment extends PreferenceFragmentCompat { + private static final CharSequence PREF_EPISODE_FILTER = "episodeFilter"; + private Feed feed; + private FeedPreferences feedPreferences; + + @Override + public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { + addPreferencesFromResource(R.xml.feed_settings); + + feed = ((FeedSettingsActivity) getActivity()).getFeed(); + feedPreferences = feed.getPreferences(); + + setupAutoDownloadPreference(); + setupKeepUpdatedPreference(); + setupAutoDeletePreference(); + setupAuthentificationPreference(); + setupEpisodeFilterPreference(); + + updateAutoDeleteSummary(); + updateAutoDownloadEnabled(); + } + + private void setupEpisodeFilterPreference() { + findPreference(PREF_EPISODE_FILTER).setOnPreferenceClickListener(preference -> { + new EpisodeFilterDialog(getContext(), feedPreferences.getFilter()) { + @Override + protected void onConfirmed(FeedFilter filter) { + feedPreferences.setFilter(filter); + feed.savePreferences(); + } + }.show(); + return false; + }); + } + + private void setupAuthentificationPreference() { + findPreference("authentication").setOnPreferenceClickListener(preference -> { + new AuthenticationDialog(getContext(), + R.string.authentication_label, true, false, + feedPreferences.getUsername(), feedPreferences.getPassword()) { + @Override + protected void onConfirmed(String username, String password, boolean saveUsernamePassword) { + feedPreferences.setUsername(username); + feedPreferences.setPassword(password); + feed.savePreferences(); + } + }.show(); + return false; + }); + } + + private void setupAutoDeletePreference() { + ListPreference autoDeletePreference = (ListPreference) findPreference("autoDelete"); + autoDeletePreference.setOnPreferenceChangeListener((preference, newValue) -> { + switch ((String) newValue) { + case "global": + feedPreferences.setAutoDeleteAction(FeedPreferences.AutoDeleteAction.GLOBAL); + break; + case "always": + feedPreferences.setAutoDeleteAction(FeedPreferences.AutoDeleteAction.YES); + break; + case "never": + feedPreferences.setAutoDeleteAction(FeedPreferences.AutoDeleteAction.NO); + break; + } + feed.savePreferences(); + updateAutoDeleteSummary(); + return false; + }); + } + + private void updateAutoDeleteSummary() { + ListPreference autoDeletePreference = (ListPreference) findPreference("autoDelete"); + + switch (feedPreferences.getAutoDeleteAction()) { + case GLOBAL: + autoDeletePreference.setSummary(R.string.feed_auto_download_global); + autoDeletePreference.setValue("global"); + break; + case YES: + autoDeletePreference.setSummary(R.string.feed_auto_download_always); + autoDeletePreference.setValue("always"); + break; + case NO: + autoDeletePreference.setSummary(R.string.feed_auto_download_never); + autoDeletePreference.setValue("never"); + break; + } + } + + private void setupKeepUpdatedPreference() { + SwitchPreference pref = (SwitchPreference) findPreference("keepUpdated"); + + pref.setChecked(feedPreferences.getKeepUpdated()); + pref.setOnPreferenceChangeListener((preference, newValue) -> { + boolean checked = newValue == Boolean.TRUE; + feedPreferences.setKeepUpdated(checked); + feed.savePreferences(); + pref.setChecked(checked); + return false; + }); + } + + private void setupAutoDownloadPreference() { + SwitchPreference pref = (SwitchPreference) findPreference("autoDownload"); + + pref.setEnabled(UserPreferences.isEnableAutodownload()); + if (UserPreferences.isEnableAutodownload()) { + pref.setChecked(feedPreferences.getAutoDownload()); + } else { + pref.setChecked(false); + pref.setSummary(R.string.auto_download_disabled_globally); + } + + pref.setOnPreferenceChangeListener((preference, newValue) -> { + boolean checked = newValue == Boolean.TRUE; + + feedPreferences.setAutoDownload(checked); + feed.savePreferences(); + updateAutoDownloadEnabled(); + ApplyToEpisodesDialog dialog = new ApplyToEpisodesDialog(getActivity(), checked); + dialog.createNewDialog().show(); + pref.setChecked(checked); + return false; + }); + } + + private void updateAutoDownloadEnabled() { + if (feed != null && feed.getPreferences() != null) { + boolean enabled = feed.getPreferences().getAutoDownload() && UserPreferences.isEnableAutodownload(); + findPreference(PREF_EPISODE_FILTER).setEnabled(enabled); + } + } + + private class ApplyToEpisodesDialog extends ConfirmationDialog { + private final boolean autoDownload; + + ApplyToEpisodesDialog(Context context, boolean autoDownload) { + super(context, R.string.auto_download_apply_to_items_title, + R.string.auto_download_apply_to_items_message); + this.autoDownload = autoDownload; + setPositiveText(R.string.yes); + setNegativeText(R.string.no); + } + + @Override + public void onConfirmButtonPressed(DialogInterface dialog) { + DBWriter.setFeedsItemsAutoDownload(feed, autoDownload); + } + } +} diff --git a/app/src/main/res/layout/episode_filter_dialog.xml b/app/src/main/res/layout/episode_filter_dialog.xml new file mode 100644 index 000000000..6a02c82f7 --- /dev/null +++ b/app/src/main/res/layout/episode_filter_dialog.xml @@ -0,0 +1,95 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:padding="16dp"> + + <RadioGroup xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/radio_filter_group" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <RadioButton + android:id="@+id/radio_filter_include" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/episode_filters_include" /> + + <RadioButton + android:id="@+id/radio_filter_exclude" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/episode_filters_exclude" /> + </RadioGroup> + + <EditText + android:id="@+id/etxtEpisodeFilterText" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:lines="8" + android:minLines="1" + android:maxLines="20" + android:scrollbars="vertical" + android:hint="@string/episode_filters_hint" + android:focusable="true" + android:focusableInTouchMode="true" + android:cursorVisible="true" /> + </LinearLayout> + + <RelativeLayout + android:id="@+id/footer" + android:layout_width="fill_parent" + android:layout_height="48dp"> + + <View + android:layout_width="match_parent" + android:layout_height="1dip" + android:layout_alignParentTop="true" + android:background="?android:attr/dividerVertical" /> + + <View + android:id="@+id/horizontal_divider" + android:layout_width="1dip" + android:layout_height="fill_parent" + android:layout_alignParentTop="true" + android:layout_centerHorizontal="true" + android:layout_marginBottom="4dp" + android:layout_marginTop="4dp" + android:background="?android:attr/dividerVertical" /> + + <Button + android:id="@+id/butCancel" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + android:layout_alignParentTop="true" + android:layout_toLeftOf="@id/horizontal_divider" + android:layout_toStartOf="@id/horizontal_divider" + android:background="?android:attr/selectableItemBackground" + android:text="@string/cancel_label" /> + + <Button + android:id="@+id/butConfirm" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_alignParentRight="true" + android:layout_alignParentEnd="true" + android:layout_alignParentTop="true" + android:layout_toRightOf="@id/horizontal_divider" + android:layout_toEndOf="@id/horizontal_divider" + android:background="?android:attr/selectableItemBackground" + android:text="@string/confirm_label" /> + </RelativeLayout> + +</LinearLayout> diff --git a/app/src/main/res/layout/feedsettings.xml b/app/src/main/res/layout/feedsettings.xml index 9e5f2245b..b40148b00 100644 --- a/app/src/main/res/layout/feedsettings.xml +++ b/app/src/main/res/layout/feedsettings.xml @@ -1,218 +1,15 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <include layout="@layout/feeditemlist_header" /> - <ScrollView - android:id="@+id/scrollView" - android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="1" - android:scrollbarStyle="outsideOverlay" - android:paddingLeft="16dp" - android:paddingRight="16dp" - android:paddingBottom="8dp" - android:clipToPadding="false"> - - <LinearLayout + <FrameLayout android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical"> - - <android.support.v7.widget.GridLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="8dp" - app:columnCount="2" - app:rowCount="1"> - - <TextView - android:id="@+id/txtvFeedAutoDelete" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/auto_delete_label" - app:layout_row="0" - app:layout_column="0" - app:layout_gravity="center_vertical" - android:layout_marginRight="10dp" - android:layout_marginEnd="10dp" /> - - <Spinner - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:id="@+id/spnAutoDelete" - android:entries="@array/spnAutoDeleteItems" - android:layout_marginTop="8dp" - app:layout_row="0" - app:layout_column="1" - android:spinnerMode="dropdown" - app:layout_gravity="center" - android:dropDownWidth="wrap_content" - android:clickable="true" /> - </android.support.v7.widget.GridLayout> - - <CheckBox - android:id="@+id/cbxKeepUpdated" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="8dp" - android:text="@string/keep_updated" - android:enabled="true" - android:textColor="?android:attr/textColorPrimary" - tools:background="@android:color/holo_red_light" - android:checked="true" /> - - <TextView - android:id="@+id/txtvAuthentication" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="8dp" - android:text="@string/authentication_label" - android:textSize="@dimen/text_size_medium" - android:textColor="?android:attr/textColorPrimary"/> - - <TextView - android:id="@+id/txtvAuthenticationDescr" - android:text="@string/authentication_descr" - android:textSize="@dimen/text_size_small" - android:textColor="?android:attr/textColorPrimary" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="8dp"/> - - <android.support.v7.widget.GridLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="8dp" - app:columnCount="2" - app:rowCount="3" - android:layout_gravity="center_horizontal"> - - <TextView - android:id="@+id/txtvUsername" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginRight="8dp" - android:layout_marginEnd="8dp" - android:layout_marginBottom="8dp" - app:layout_row="0" - app:layout_column="0" - android:text="@string/username_label" - android:textColor="?android:attr/textColorPrimary"/> - - <EditText - android:id="@+id/etxtUsername" - android:layout_width="140sp" - android:layout_height="wrap_content" - app:layout_row="0" - app:layout_column="1" - android:hint="@string/username_label" - android:focusable="true" - android:focusableInTouchMode="true" - android:cursorVisible="true"/> - - <TextView - android:id="@+id/txtvPassword" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginRight="8dp" - android:layout_marginEnd="8dp" - android:layout_marginBottom="8dp" - app:layout_row="1" - app:layout_column="0" - android:text="@string/password_label" - android:textColor="?android:attr/textColorPrimary" /> - - <EditText - android:id="@+id/etxtPassword" - android:layout_width="140sp" - android:layout_height="wrap_content" - app:layout_row="1" - app:layout_column="1" - android:hint="@string/password_label" - android:inputType="textPassword" - android:focusable="true" - android:focusableInTouchMode="true" - android:cursorVisible="true"/> - - </android.support.v7.widget.GridLayout> - - <TextView - android:id="@+id/txtvAutoDownloadSettings" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="8dp" - android:text="@string/auto_download_settings_label" - android:textSize="@dimen/text_size_medium" - android:textColor="?android:attr/textColorPrimary"/> - - <CheckBox - android:id="@+id/cbxAutoDownload" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="8dp" - android:text="@string/auto_download_label" - android:enabled="false" - android:textColor="?android:attr/textColorPrimary" - tools:background="@android:color/holo_red_light" - android:checked="false" /> - - <TextView - android:id="@+id/txtvEpisodeFilters" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="8dp" - android:text="@string/episode_filters_label" - android:textSize="@dimen/text_size_medium" - android:textColor="?android:attr/textColorPrimary"/> - - <TextView - android:id="@+id/txtvEpisodeFiltersDescription" - android:text="@string/episode_filters_description" - android:textSize="@dimen/text_size_small" - android:textColor="?android:attr/textColorPrimary" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="8dp"/> - - <RadioGroup xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/radio_filter_group" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:layout_gravity="center" - android:gravity="center" - android:orientation="horizontal"> - <RadioButton android:id="@+id/radio_filter_include" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/episode_filters_include" /> - <RadioButton android:id="@+id/radio_filter_exclude" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/episode_filters_exclude" /> - </RadioGroup> - - <EditText - android:id="@+id/etxtEpisodeFilterText" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:layout_gravity="center" - android:lines="8" - android:minLines="1" - android:maxLines="20" - android:scrollbars="vertical" - android:hint="@string/episode_filters_hint" - android:focusable="true" - android:focusableInTouchMode="true" - android:cursorVisible="true"/> - - </LinearLayout> - - </ScrollView> + android:layout_height="0dp" + android:layout_weight="1" + android:id="@+id/settings_fragment_container" /> </LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/xml/feed_settings.xml b/app/src/main/res/xml/feed_settings.xml new file mode 100644 index 000000000..5fd6b2038 --- /dev/null +++ b/app/src/main/res/xml/feed_settings.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<PreferenceScreen + xmlns:android="http://schemas.android.com/apk/res/android"> + + <SwitchPreference + android:key="keepUpdated" + android:title="@string/keep_updated" + android:summary="@string/keep_updated_summary"/> + + <Preference + android:key="authentication" + android:title="@string/authentication_label" + android:summary="@string/authentication_descr"/> + + <ListPreference + android:entries="@array/spnAutoDeleteItems" + android:entryValues="@array/spnAutoDeleteValues" + android:title="@string/auto_delete_label" + android:key="autoDelete"/> + + <PreferenceCategory android:title="@string/auto_download_settings_label"> + <SwitchPreference + android:key="autoDownload" + android:title="@string/auto_download_label"/> + <Preference + android:key="episodeFilter" + android:title="@string/episode_filters_label" + android:summary="@string/episode_filters_description"/> + </PreferenceCategory> +</PreferenceScreen> |