Merge pull request #1548 from mfietz/move_cache_size_pref
Settings: Moved episode cache size to auto download sub-menu
This commit is contained in:
commit
a0488ffe37
@ -49,10 +49,11 @@ public class PlaybackSonicTest extends ActivityInstrumentationTestCase2<MainActi
|
|||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
PodDBAdapter.deleteDatabase();
|
|
||||||
|
|
||||||
context = getInstrumentation().getTargetContext();
|
context = getInstrumentation().getTargetContext();
|
||||||
|
|
||||||
|
PodDBAdapter.init(context);
|
||||||
|
PodDBAdapter.deleteDatabase();
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
prefs.edit()
|
prefs.edit()
|
||||||
.clear()
|
.clear()
|
||||||
|
@ -46,10 +46,11 @@ public class PlaybackTest extends ActivityInstrumentationTestCase2<MainActivity>
|
|||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
PodDBAdapter.deleteDatabase();
|
|
||||||
|
|
||||||
context = getInstrumentation().getTargetContext();
|
context = getInstrumentation().getTargetContext();
|
||||||
|
|
||||||
|
PodDBAdapter.init(context);
|
||||||
|
PodDBAdapter.deleteDatabase();
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
prefs.edit()
|
prefs.edit()
|
||||||
.clear()
|
.clear()
|
||||||
|
@ -3,17 +3,10 @@ package de.test.antennapod.ui;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.test.ActivityInstrumentationTestCase2;
|
import android.test.ActivityInstrumentationTestCase2;
|
||||||
import android.test.FlakyTest;
|
|
||||||
|
|
||||||
import com.robotium.solo.Condition;
|
|
||||||
import com.robotium.solo.Solo;
|
import com.robotium.solo.Solo;
|
||||||
import com.robotium.solo.Timeout;
|
import com.robotium.solo.Timeout;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
@ -230,6 +223,8 @@ public class PreferencesTest extends ActivityInstrumentationTestCase2<Preference
|
|||||||
String[] values = res.getStringArray(R.array.episode_cache_size_values);
|
String[] values = res.getStringArray(R.array.episode_cache_size_values);
|
||||||
String entry = entries[entries.length/2];
|
String entry = entries[entries.length/2];
|
||||||
final int value = Integer.valueOf(values[values.length/2]);
|
final int value = Integer.valueOf(values[values.length/2]);
|
||||||
|
solo.clickOnText(solo.getString(R.string.pref_automatic_download_title));
|
||||||
|
solo.waitForText(solo.getString(R.string.pref_automatic_download_title));
|
||||||
solo.clickOnText(solo.getString(R.string.pref_episode_cache_title));
|
solo.clickOnText(solo.getString(R.string.pref_episode_cache_title));
|
||||||
solo.waitForDialogToOpen();
|
solo.waitForDialogToOpen();
|
||||||
solo.clickOnText(entry);
|
solo.clickOnText(entry);
|
||||||
@ -241,6 +236,11 @@ public class PreferencesTest extends ActivityInstrumentationTestCase2<Preference
|
|||||||
String[] values = res.getStringArray(R.array.episode_cache_size_values);
|
String[] values = res.getStringArray(R.array.episode_cache_size_values);
|
||||||
String minEntry = entries[0];
|
String minEntry = entries[0];
|
||||||
final int minValue = Integer.valueOf(values[0]);
|
final int minValue = Integer.valueOf(values[0]);
|
||||||
|
solo.clickOnText(solo.getString(R.string.pref_automatic_download_title));
|
||||||
|
solo.waitForText(solo.getString(R.string.pref_automatic_download_title));
|
||||||
|
if(!UserPreferences.isEnableAutodownload()) {
|
||||||
|
solo.clickOnText(solo.getString(R.string.pref_automatic_download_title));
|
||||||
|
}
|
||||||
solo.clickOnText(solo.getString(R.string.pref_episode_cache_title));
|
solo.clickOnText(solo.getString(R.string.pref_episode_cache_title));
|
||||||
solo.waitForDialogToOpen(1000);
|
solo.waitForDialogToOpen(1000);
|
||||||
solo.scrollUp();
|
solo.scrollUp();
|
||||||
@ -248,12 +248,16 @@ public class PreferencesTest extends ActivityInstrumentationTestCase2<Preference
|
|||||||
assertTrue(solo.waitForCondition(() -> UserPreferences.getEpisodeCacheSize() == minValue, Timeout.getLargeTimeout()));
|
assertTrue(solo.waitForCondition(() -> UserPreferences.getEpisodeCacheSize() == minValue, Timeout.getLargeTimeout()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testSetEpisodeCacheMax() {
|
public void testSetEpisodeCacheMax() {
|
||||||
String[] entries = res.getStringArray(R.array.episode_cache_size_entries);
|
String[] entries = res.getStringArray(R.array.episode_cache_size_entries);
|
||||||
String[] values = res.getStringArray(R.array.episode_cache_size_values);
|
String[] values = res.getStringArray(R.array.episode_cache_size_values);
|
||||||
String maxEntry = entries[entries.length-1];
|
String maxEntry = entries[entries.length-1];
|
||||||
final int maxValue = Integer.valueOf(values[values.length-1]);
|
final int maxValue = Integer.valueOf(values[values.length-1]);
|
||||||
|
solo.clickOnText(solo.getString(R.string.pref_automatic_download_title));
|
||||||
|
solo.waitForText(solo.getString(R.string.pref_automatic_download_title));
|
||||||
|
if(!UserPreferences.isEnableAutodownload()) {
|
||||||
|
solo.clickOnText(solo.getString(R.string.pref_automatic_download_title));
|
||||||
|
}
|
||||||
solo.clickOnText(solo.getString(R.string.pref_episode_cache_title));
|
solo.clickOnText(solo.getString(R.string.pref_episode_cache_title));
|
||||||
solo.waitForDialogToOpen();
|
solo.waitForDialogToOpen();
|
||||||
solo.clickOnText(maxEntry);
|
solo.clickOnText(maxEntry);
|
||||||
|
@ -221,17 +221,16 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.findPreference(UserPreferences.PREF_ENABLE_AUTODL)
|
ui.findPreference(UserPreferences.PREF_ENABLE_AUTODL).setOnPreferenceChangeListener(
|
||||||
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
(preference, newValue) -> {
|
||||||
@Override
|
if (newValue instanceof Boolean) {
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
boolean enabled = (Boolean) newValue;
|
||||||
if (newValue instanceof Boolean) {
|
ui.findPreference(UserPreferences.PREF_EPISODE_CACHE_SIZE).setEnabled(enabled);
|
||||||
ui.findPreference(UserPreferences.PREF_ENABLE_AUTODL_WIFI_FILTER).setEnabled((Boolean) newValue);
|
ui.findPreference(UserPreferences.PREF_ENABLE_AUTODL_ON_BATTERY).setEnabled(enabled);
|
||||||
setSelectedNetworksEnabled((Boolean) newValue && UserPreferences.isEnableAutodownloadWifiFilter());
|
ui.findPreference(UserPreferences.PREF_ENABLE_AUTODL_WIFI_FILTER).setEnabled(enabled);
|
||||||
ui.findPreference(UserPreferences.PREF_ENABLE_AUTODL_ON_BATTERY).setEnabled((Boolean) newValue);
|
setSelectedNetworksEnabled(enabled && UserPreferences.isEnableAutodownloadWifiFilter());
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
ui.findPreference(UserPreferences.PREF_ENABLE_AUTODL_WIFI_FILTER)
|
ui.findPreference(UserPreferences.PREF_ENABLE_AUTODL_WIFI_FILTER)
|
||||||
.setOnPreferenceChangeListener(
|
.setOnPreferenceChangeListener(
|
||||||
@ -537,21 +536,17 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private void checkItemVisibility() {
|
private void checkItemVisibility() {
|
||||||
|
|
||||||
boolean hasFlattrToken = FlattrUtils.hasToken();
|
boolean hasFlattrToken = FlattrUtils.hasToken();
|
||||||
|
|
||||||
ui.findPreference(PreferenceController.PREF_FLATTR_SETTINGS).setEnabled(FlattrUtils.hasAPICredentials());
|
ui.findPreference(PreferenceController.PREF_FLATTR_SETTINGS).setEnabled(FlattrUtils.hasAPICredentials());
|
||||||
ui.findPreference(PreferenceController.PREF_FLATTR_AUTH).setEnabled(!hasFlattrToken);
|
ui.findPreference(PreferenceController.PREF_FLATTR_AUTH).setEnabled(!hasFlattrToken);
|
||||||
ui.findPreference(PreferenceController.PREF_FLATTR_REVOKE).setEnabled(hasFlattrToken);
|
ui.findPreference(PreferenceController.PREF_FLATTR_REVOKE).setEnabled(hasFlattrToken);
|
||||||
ui.findPreference(PreferenceController.PREF_AUTO_FLATTR_PREFS).setEnabled(hasFlattrToken);
|
ui.findPreference(PreferenceController.PREF_AUTO_FLATTR_PREFS).setEnabled(hasFlattrToken);
|
||||||
|
|
||||||
ui.findPreference(UserPreferences.PREF_ENABLE_AUTODL_WIFI_FILTER)
|
boolean autoDownload = UserPreferences.isEnableAutodownload();
|
||||||
.setEnabled(UserPreferences.isEnableAutodownload());
|
ui.findPreference(UserPreferences.PREF_EPISODE_CACHE_SIZE).setEnabled(autoDownload);
|
||||||
setSelectedNetworksEnabled(UserPreferences.isEnableAutodownload()
|
ui.findPreference(UserPreferences.PREF_ENABLE_AUTODL_ON_BATTERY).setEnabled(autoDownload);
|
||||||
&& UserPreferences.isEnableAutodownloadWifiFilter());
|
ui.findPreference(UserPreferences.PREF_ENABLE_AUTODL_WIFI_FILTER).setEnabled(autoDownload);
|
||||||
|
setSelectedNetworksEnabled(autoDownload && UserPreferences.isEnableAutodownloadWifiFilter());
|
||||||
ui.findPreference(UserPreferences.PREF_ENABLE_AUTODL_ON_BATTERY)
|
|
||||||
.setEnabled(UserPreferences.isEnableAutodownload());
|
|
||||||
|
|
||||||
ui.findPreference("prefSendCrashReport").setEnabled(CrashReportWriter.getFile().exists());
|
ui.findPreference("prefSendCrashReport").setEnabled(CrashReportWriter.getFile().exists());
|
||||||
|
|
||||||
|
@ -170,13 +170,6 @@
|
|||||||
android:key="prefParallelDownloads"
|
android:key="prefParallelDownloads"
|
||||||
android:title="@string/pref_parallel_downloads_title"
|
android:title="@string/pref_parallel_downloads_title"
|
||||||
app:useStockLayout="true"/>
|
app:useStockLayout="true"/>
|
||||||
<com.afollestad.materialdialogs.prefs.MaterialListPreference
|
|
||||||
android:defaultValue="20"
|
|
||||||
android:entries="@array/episode_cache_size_entries"
|
|
||||||
android:key="prefEpisodeCacheSize"
|
|
||||||
android:title="@string/pref_episode_cache_title"
|
|
||||||
android:entryValues="@array/episode_cache_size_values"
|
|
||||||
app:useStockLayout="true"/>
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:summary="@string/pref_automatic_download_sum"
|
android:summary="@string/pref_automatic_download_sum"
|
||||||
android:key="prefAutoDownloadSettings"
|
android:key="prefAutoDownloadSettings"
|
||||||
@ -185,6 +178,13 @@
|
|||||||
android:key="prefEnableAutoDl"
|
android:key="prefEnableAutoDl"
|
||||||
android:title="@string/pref_automatic_download_title"
|
android:title="@string/pref_automatic_download_title"
|
||||||
android:defaultValue="false"/>
|
android:defaultValue="false"/>
|
||||||
|
<com.afollestad.materialdialogs.prefs.MaterialListPreference
|
||||||
|
android:defaultValue="20"
|
||||||
|
android:entries="@array/episode_cache_size_entries"
|
||||||
|
android:key="prefEpisodeCacheSize"
|
||||||
|
android:title="@string/pref_episode_cache_title"
|
||||||
|
android:entryValues="@array/episode_cache_size_values"
|
||||||
|
app:useStockLayout="true"/>
|
||||||
<de.danoeh.antennapod.preferences.SwitchCompatPreference
|
<de.danoeh.antennapod.preferences.SwitchCompatPreference
|
||||||
android:key="prefEnableAutoDownloadOnBattery"
|
android:key="prefEnableAutoDownloadOnBattery"
|
||||||
android:title="@string/pref_automatic_download_on_battery_title"
|
android:title="@string/pref_automatic_download_on_battery_title"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user