diff --git a/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java b/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java index be947bc1e..5940d511b 100644 --- a/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java +++ b/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java @@ -193,7 +193,7 @@ public class PreferencesTest { @Test public void testAutoDelete() { - clickPreference(R.string.storage_pref); + clickPreference(R.string.downloads_pref); final boolean autoDelete = UserPreferences.isAutoDelete(); onView(withText(R.string.pref_auto_delete_title)).perform(click()); Awaitility.await().atMost(1000, MILLISECONDS) @@ -225,7 +225,7 @@ public class PreferencesTest { @Test public void testSetSequentialDownload() { - clickPreference(R.string.network_pref); + clickPreference(R.string.downloads_pref); clickPreference(R.string.pref_parallel_downloads_title); onView(isRoot()).perform(waitForView(withClassName(endsWith("EditText")), 1000)); onView(withClassName(endsWith("EditText"))).perform(replaceText("1")); @@ -236,7 +236,7 @@ public class PreferencesTest { @Test public void testSetParallelDownloads() { - clickPreference(R.string.network_pref); + clickPreference(R.string.downloads_pref); clickPreference(R.string.pref_parallel_downloads_title); onView(isRoot()).perform(waitForView(withClassName(endsWith("EditText")), 1000)); onView(withClassName(endsWith("EditText"))).perform(replaceText("10")); @@ -248,7 +248,7 @@ public class PreferencesTest { @Test public void testSetParallelDownloadsInvalidInput() { - clickPreference(R.string.network_pref); + clickPreference(R.string.downloads_pref); clickPreference(R.string.pref_parallel_downloads_title); onView(isRoot()).perform(waitForView(withClassName(endsWith("EditText")), 1000)); onView(withClassName(endsWith("EditText"))).perform(replaceText("0")); @@ -263,7 +263,7 @@ public class PreferencesTest { String[] values = res.getStringArray(R.array.episode_cache_size_values); String entry = entries[entries.length / 2]; final int value = Integer.parseInt(values[values.length / 2]); - clickPreference(R.string.network_pref); + clickPreference(R.string.downloads_pref); clickPreference(R.string.pref_automatic_download_title); clickPreference(R.string.pref_episode_cache_title); onView(isRoot()).perform(waitForView(withText(entry), 1000)); @@ -279,7 +279,7 @@ public class PreferencesTest { String minEntry = entries[0]; final int minValue = Integer.parseInt(values[0]); - clickPreference(R.string.network_pref); + clickPreference(R.string.downloads_pref); clickPreference(R.string.pref_automatic_download_title); clickPreference(R.string.pref_episode_cache_title); onView(withId(R.id.select_dialog_listview)).perform(swipeDown()); @@ -294,7 +294,7 @@ public class PreferencesTest { String[] values = res.getStringArray(R.array.episode_cache_size_values); String maxEntry = entries[entries.length - 1]; final int maxValue = Integer.parseInt(values[values.length - 1]); - onView(withText(R.string.network_pref)).perform(click()); + onView(withText(R.string.downloads_pref)).perform(click()); onView(withText(R.string.pref_automatic_download_title)).perform(click()); onView(withText(R.string.pref_episode_cache_title)).perform(click()); onView(withId(R.id.select_dialog_listview)).perform(swipeUp()); @@ -306,7 +306,7 @@ public class PreferencesTest { @Test public void testAutomaticDownload() { final boolean automaticDownload = UserPreferences.isEnableAutodownload(); - clickPreference(R.string.network_pref); + clickPreference(R.string.downloads_pref); clickPreference(R.string.pref_automatic_download_title); clickPreference(R.string.pref_automatic_download_title); Awaitility.await().atMost(1000, MILLISECONDS) @@ -327,7 +327,7 @@ public class PreferencesTest { @Test public void testEpisodeCleanupFavoriteOnly() { - clickPreference(R.string.network_pref); + clickPreference(R.string.downloads_pref); onView(withText(R.string.pref_automatic_download_title)).perform(click()); onView(withText(R.string.pref_episode_cleanup_title)).perform(click()); onView(withId(R.id.select_dialog_listview)).perform(swipeDown()); @@ -338,7 +338,7 @@ public class PreferencesTest { @Test public void testEpisodeCleanupQueueOnly() { - clickPreference(R.string.network_pref); + clickPreference(R.string.downloads_pref); onView(withText(R.string.pref_automatic_download_title)).perform(click()); onView(withText(R.string.pref_episode_cleanup_title)).perform(click()); onView(withId(R.id.select_dialog_listview)).perform(swipeDown()); @@ -349,7 +349,7 @@ public class PreferencesTest { @Test public void testEpisodeCleanupNeverAlg() { - clickPreference(R.string.network_pref); + clickPreference(R.string.downloads_pref); onView(withText(R.string.pref_automatic_download_title)).perform(click()); onView(withText(R.string.pref_episode_cleanup_title)).perform(click()); onView(withId(R.id.select_dialog_listview)).perform(swipeUp()); @@ -360,7 +360,7 @@ public class PreferencesTest { @Test public void testEpisodeCleanupClassic() { - clickPreference(R.string.network_pref); + clickPreference(R.string.downloads_pref); onView(withText(R.string.pref_automatic_download_title)).perform(click()); onView(withText(R.string.pref_episode_cleanup_title)).perform(click()); onView(withText(R.string.episode_cleanup_after_listening)).perform(click()); @@ -377,7 +377,7 @@ public class PreferencesTest { @Test public void testEpisodeCleanupNumDays() { - clickPreference(R.string.network_pref); + clickPreference(R.string.downloads_pref); clickPreference(R.string.pref_automatic_download_title); clickPreference(R.string.pref_episode_cleanup_title); String search = res.getQuantityString(R.plurals.episode_cleanup_days_after_listening, 3, 3); @@ -437,7 +437,7 @@ public class PreferencesTest { @Test public void testDeleteRemovesFromQueue() { - clickPreference(R.string.storage_pref); + clickPreference(R.string.downloads_pref); if (!UserPreferences.shouldDeleteRemoveFromQueue()) { clickPreference(R.string.pref_delete_removes_from_queue_title); Awaitility.await().atMost(1000, MILLISECONDS) diff --git a/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java index af8db0d79..b101c20c0 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java @@ -23,10 +23,9 @@ import de.danoeh.antennapod.databinding.SettingsActivityBinding; import de.danoeh.antennapod.fragment.preferences.AutoDownloadPreferencesFragment; import de.danoeh.antennapod.fragment.preferences.ImportExportPreferencesFragment; import de.danoeh.antennapod.fragment.preferences.MainPreferencesFragment; -import de.danoeh.antennapod.fragment.preferences.NetworkPreferencesFragment; +import de.danoeh.antennapod.fragment.preferences.DownloadsPreferencesFragment; import de.danoeh.antennapod.fragment.preferences.NotificationPreferencesFragment; import de.danoeh.antennapod.fragment.preferences.PlaybackPreferencesFragment; -import de.danoeh.antennapod.fragment.preferences.StoragePreferencesFragment; import de.danoeh.antennapod.fragment.preferences.synchronization.SynchronizationPreferencesFragment; import de.danoeh.antennapod.fragment.preferences.SwipePreferencesFragment; import de.danoeh.antennapod.fragment.preferences.UserInterfacePreferencesFragment; @@ -69,10 +68,8 @@ public class PreferenceActivity extends AppCompatActivity implements SearchPrefe if (screen == R.xml.preferences_user_interface) { prefFragment = new UserInterfacePreferencesFragment(); - } else if (screen == R.xml.preferences_network) { - prefFragment = new NetworkPreferencesFragment(); - } else if (screen == R.xml.preferences_storage) { - prefFragment = new StoragePreferencesFragment(); + } else if (screen == R.xml.preferences_downloads) { + prefFragment = new DownloadsPreferencesFragment(); } else if (screen == R.xml.preferences_import_export) { prefFragment = new ImportExportPreferencesFragment(); } else if (screen == R.xml.preferences_autodownload) { @@ -90,14 +87,12 @@ public class PreferenceActivity extends AppCompatActivity implements SearchPrefe } public static int getTitleOfPage(int preferences) { - if (preferences == R.xml.preferences_network) { - return R.string.network_pref; + if (preferences == R.xml.preferences_downloads) { + return R.string.downloads_pref; } else if (preferences == R.xml.preferences_autodownload) { return R.string.pref_automatic_download_title; } else if (preferences == R.xml.preferences_playback) { return R.string.playback_pref; - } else if (preferences == R.xml.preferences_storage) { - return R.string.storage_pref; } else if (preferences == R.xml.preferences_import_export) { return R.string.import_export_pref; } else if (preferences == R.xml.preferences_user_interface) { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/NetworkPreferencesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/DownloadsPreferencesFragment.java similarity index 76% rename from app/src/main/java/de/danoeh/antennapod/fragment/preferences/NetworkPreferencesFragment.java rename to app/src/main/java/de/danoeh/antennapod/fragment/preferences/DownloadsPreferencesFragment.java index 94c85abfe..c486089fc 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/NetworkPreferencesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/DownloadsPreferencesFragment.java @@ -8,25 +8,29 @@ import androidx.preference.PreferenceManager; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.PreferenceActivity; import de.danoeh.antennapod.core.util.download.FeedUpdateManager; +import de.danoeh.antennapod.dialog.ChooseDataFolderDialog; import de.danoeh.antennapod.dialog.ProxyDialog; import de.danoeh.antennapod.storage.preferences.UserPreferences; +import java.io.File; -public class NetworkPreferencesFragment extends PreferenceFragmentCompat + +public class DownloadsPreferencesFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener { private static final String PREF_SCREEN_AUTODL = "prefAutoDownloadSettings"; private static final String PREF_PROXY = "prefProxy"; + private static final String PREF_CHOOSE_DATA_DIR = "prefChooseDataDir"; @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { - addPreferencesFromResource(R.xml.preferences_network); + addPreferencesFromResource(R.xml.preferences_downloads); setupNetworkScreen(); } @Override public void onStart() { super.onStart(); - ((PreferenceActivity) getActivity()).getSupportActionBar().setTitle(R.string.network_pref); + ((PreferenceActivity) getActivity()).getSupportActionBar().setTitle(R.string.downloads_pref); PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this); } @@ -40,6 +44,7 @@ public class NetworkPreferencesFragment extends PreferenceFragmentCompat public void onResume() { super.onResume(); setParallelDownloadsText(UserPreferences.getParallelDownloads()); + setDataFolderText(); } private void setupNetworkScreen() { @@ -59,6 +64,13 @@ public class NetworkPreferencesFragment extends PreferenceFragmentCompat dialog.show(); return true; }); + findPreference(PREF_CHOOSE_DATA_DIR).setOnPreferenceClickListener(preference -> { + ChooseDataFolderDialog.showDialog(getContext(), path -> { + UserPreferences.setDataFolder(path); + setDataFolderText(); + }); + return true; + }); } private void setParallelDownloadsText(int downloads) { @@ -67,6 +79,13 @@ public class NetworkPreferencesFragment extends PreferenceFragmentCompat findPreference(UserPreferences.PREF_PARALLEL_DOWNLOADS).setSummary(s); } + private void setDataFolderText() { + File f = UserPreferences.getDataFolder(null); + if (f != null) { + findPreference(PREF_CHOOSE_DATA_DIR).setSummary(f.getAbsolutePath()); + } + } + @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (UserPreferences.PREF_UPDATE_INTERVAL.equals(key)) { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java index 7f5205db4..4d7313247 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java @@ -29,9 +29,9 @@ public class MainPreferencesFragment extends PreferenceFragmentCompat { private static final String PREF_SCREEN_USER_INTERFACE = "prefScreenInterface"; private static final String PREF_SCREEN_PLAYBACK = "prefScreenPlayback"; - private static final String PREF_SCREEN_NETWORK = "prefScreenNetwork"; + private static final String PREF_SCREEN_DOWNLOADS = "prefScreenDownloads"; + private static final String PREF_SCREEN_IMPORT_EXPORT = "prefScreenImportExport"; private static final String PREF_SCREEN_SYNCHRONIZATION = "prefScreenSynchronization"; - private static final String PREF_SCREEN_STORAGE = "prefScreenStorage"; private static final String PREF_DOCUMENTATION = "prefDocumentation"; private static final String PREF_VIEW_FORUM = "prefViewForum"; private static final String PREF_SEND_BUG_REPORT = "prefSendBugReport"; @@ -88,16 +88,16 @@ public class MainPreferencesFragment extends PreferenceFragmentCompat { ((PreferenceActivity) getActivity()).openScreen(R.xml.preferences_playback); return true; }); - findPreference(PREF_SCREEN_NETWORK).setOnPreferenceClickListener(preference -> { - ((PreferenceActivity) getActivity()).openScreen(R.xml.preferences_network); + findPreference(PREF_SCREEN_DOWNLOADS).setOnPreferenceClickListener(preference -> { + ((PreferenceActivity) getActivity()).openScreen(R.xml.preferences_downloads); return true; }); findPreference(PREF_SCREEN_SYNCHRONIZATION).setOnPreferenceClickListener(preference -> { ((PreferenceActivity) getActivity()).openScreen(R.xml.preferences_synchronization); return true; }); - findPreference(PREF_SCREEN_STORAGE).setOnPreferenceClickListener(preference -> { - ((PreferenceActivity) getActivity()).openScreen(R.xml.preferences_storage); + findPreference(PREF_SCREEN_IMPORT_EXPORT).setOnPreferenceClickListener(preference -> { + ((PreferenceActivity) getActivity()).openScreen(R.xml.preferences_import_export); return true; }); findPreference(PREF_NOTIFICATION).setOnPreferenceClickListener(preference -> { @@ -155,15 +155,12 @@ public class MainPreferencesFragment extends PreferenceFragmentCompat { .addBreadcrumb(PreferenceActivity.getTitleOfPage(R.xml.preferences_user_interface)); config.index(R.xml.preferences_playback) .addBreadcrumb(PreferenceActivity.getTitleOfPage(R.xml.preferences_playback)); - config.index(R.xml.preferences_network) - .addBreadcrumb(PreferenceActivity.getTitleOfPage(R.xml.preferences_network)); - config.index(R.xml.preferences_storage) - .addBreadcrumb(PreferenceActivity.getTitleOfPage(R.xml.preferences_storage)); + config.index(R.xml.preferences_downloads) + .addBreadcrumb(PreferenceActivity.getTitleOfPage(R.xml.preferences_downloads)); config.index(R.xml.preferences_import_export) - .addBreadcrumb(PreferenceActivity.getTitleOfPage(R.xml.preferences_storage)) .addBreadcrumb(PreferenceActivity.getTitleOfPage(R.xml.preferences_import_export)); config.index(R.xml.preferences_autodownload) - .addBreadcrumb(PreferenceActivity.getTitleOfPage(R.xml.preferences_network)) + .addBreadcrumb(PreferenceActivity.getTitleOfPage(R.xml.preferences_downloads)) .addBreadcrumb(R.string.automation) .addBreadcrumb(PreferenceActivity.getTitleOfPage(R.xml.preferences_autodownload)); config.index(R.xml.preferences_synchronization) diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/StoragePreferencesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/StoragePreferencesFragment.java deleted file mode 100644 index 1801b107f..000000000 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/StoragePreferencesFragment.java +++ /dev/null @@ -1,58 +0,0 @@ -package de.danoeh.antennapod.fragment.preferences; - -import android.os.Bundle; -import androidx.preference.PreferenceFragmentCompat; -import de.danoeh.antennapod.R; -import de.danoeh.antennapod.activity.PreferenceActivity; -import de.danoeh.antennapod.storage.preferences.UserPreferences; -import de.danoeh.antennapod.dialog.ChooseDataFolderDialog; - -import java.io.File; - -public class StoragePreferencesFragment extends PreferenceFragmentCompat { - private static final String PREF_CHOOSE_DATA_DIR = "prefChooseDataDir"; - private static final String PREF_IMPORT_EXPORT = "prefImportExport"; - - @Override - public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { - addPreferencesFromResource(R.xml.preferences_storage); - setupStorageScreen(); - } - - @Override - public void onStart() { - super.onStart(); - ((PreferenceActivity) getActivity()).getSupportActionBar().setTitle(R.string.storage_pref); - } - - @Override - public void onResume() { - super.onResume(); - setDataFolderText(); - } - - private void setupStorageScreen() { - findPreference(PREF_CHOOSE_DATA_DIR).setOnPreferenceClickListener( - preference -> { - ChooseDataFolderDialog.showDialog(getContext(), path -> { - UserPreferences.setDataFolder(path); - setDataFolderText(); - }); - return true; - } - ); - findPreference(PREF_IMPORT_EXPORT).setOnPreferenceClickListener( - preference -> { - ((PreferenceActivity) getActivity()).openScreen(R.xml.preferences_import_export); - return true; - } - ); - } - - private void setDataFolderText() { - File f = UserPreferences.getDataFolder(null); - if (f != null) { - findPreference(PREF_CHOOSE_DATA_DIR).setSummary(f.getAbsolutePath()); - } - } -} diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 9967d7fd1..24d50cc45 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -22,10 +22,10 @@ android:icon="@drawable/ic_play_24dp" /> + android:key="prefScreenDownloads" + android:title="@string/downloads_pref" + android:summary="@string/downloads_pref_sum" + android:icon="@drawable/ic_download_black" /> + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/xml/preferences_network.xml b/app/src/main/res/xml/preferences_network.xml deleted file mode 100644 index f9cd15e68..000000000 --- a/app/src/main/res/xml/preferences_network.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - diff --git a/app/src/main/res/xml/preferences_storage.xml b/app/src/main/res/xml/preferences_storage.xml deleted file mode 100644 index 89e8c4cf5..000000000 --- a/app/src/main/res/xml/preferences_storage.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - diff --git a/core/src/main/res/drawable/ic_network.xml b/core/src/main/res/drawable/ic_network.xml deleted file mode 100644 index 52f5889b8..000000000 --- a/core/src/main/res/drawable/ic_network.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml index 1d11d4557..68bde475c 100644 --- a/ui/i18n/src/main/res/values/strings.xml +++ b/ui/i18n/src/main/res/values/strings.xml @@ -370,8 +370,6 @@ To subscribe to a podcast, press the plus icon below. - Storage - Episode auto delete, Import, Export Project Synchronization Synchronize with other devices @@ -411,8 +409,8 @@ Keep Favorite Episodes Playback Headphone controls, Skip intervals, Queue - Network - Update interval, Download controls, Mobile data + Downloads + Update interval, Mobile data, Automatic download, Automatic deletion Refresh podcasts Specify an interval at which AntennaPod looks for new episodes automatically Never