enable/disable controls based on auto-download setting

This commit is contained in:
Tom Hennen 2016-01-25 12:27:42 -05:00
parent 3912f33342
commit 672c03e41a
3 changed files with 33 additions and 13 deletions

View File

@ -173,6 +173,7 @@ public class FeedInfoActivity extends ActionBarActivity {
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
feed.getPreferences().setAutoDownload(checked); feed.getPreferences().setAutoDownload(checked);
feed.savePreferences(FeedInfoActivity.this); feed.savePreferences(FeedInfoActivity.this);
updateAutoDownloadSettings();
ApplyToEpisodesDialog dialog = new ApplyToEpisodesDialog(FeedInfoActivity.this, ApplyToEpisodesDialog dialog = new ApplyToEpisodesDialog(FeedInfoActivity.this,
feed, checked); feed, checked);
dialog.createNewDialog().show(); dialog.createNewDialog().show();
@ -233,7 +234,7 @@ public class FeedInfoActivity extends ActionBarActivity {
etxtFilterText.addTextChangedListener(filterTextWatcher); etxtFilterText.addTextChangedListener(filterTextWatcher);
supportInvalidateOptionsMenu(); supportInvalidateOptionsMenu();
updateAutoDownloadSettings();
} else { } else {
Log.e(TAG, "Activity was started with invalid arguments"); Log.e(TAG, "Activity was started with invalid arguments");
} }
@ -349,6 +350,15 @@ public class FeedInfoActivity extends ActionBarActivity {
} }
} }
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 class ApplyToEpisodesDialog extends ConfirmationDialog { private class ApplyToEpisodesDialog extends ConfirmationDialog {
private final Feed feed; private final Feed feed;

View File

@ -150,17 +150,6 @@
android:text="@string/podcast_settings_label" android:text="@string/podcast_settings_label"
android:layout_marginTop="8dp"/> android:layout_marginTop="8dp"/>
<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" />
<android.support.v7.widget.GridLayout <android.support.v7.widget.GridLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -265,6 +254,25 @@
</android.support.v7.widget.GridLayout> </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 <TextView
android:id="@+id/txtvEpisodeFilters" android:id="@+id/txtvEpisodeFilters"
@ -285,6 +293,7 @@
android:layout_marginTop="8dp"/> android:layout_marginTop="8dp"/>
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android" <RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/radio_filter_group"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"

View File

@ -530,8 +530,9 @@
<!-- Feed information screen --> <!-- Feed information screen -->
<string name="authentication_label">Authentication</string> <string name="authentication_label">Authentication</string>
<string name="authentication_descr">Change your username and password for this podcast and its episodes.</string> <string name="authentication_descr">Change your username and password for this podcast and its episodes.</string>
<string name="auto_download_settings_label">Auto Download Settings</string>
<string name="episode_filters_label">Episode Filter</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 from being autodownloaded</string> <string name="episode_filters_description">List of terms used to decide if an episode should be included or excluded when auto downloading</string>
<string name="episode_filters_include">Include</string> <string name="episode_filters_include">Include</string>
<string name="episode_filters_exclude">Exclude</string> <string name="episode_filters_exclude">Exclude</string>
<string name="episode_filters_hint">Filter text</string> <string name="episode_filters_hint">Filter text</string>