diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2023-04-15 17:33:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-15 17:33:21 +0200 |
commit | 8396a346707677ce22373a96e905bb1763d5cfb9 (patch) | |
tree | 58e714b91ce072bbba6f361eb694eea2d68d97c6 /app/src/main/java | |
parent | 84e1ff248f6e6c437dd5ecaf8217a7ee6b5c1af5 (diff) | |
download | AntennaPod-8396a346707677ce22373a96e905bb1763d5cfb9.zip |
Replace Network+Storage preferences with Downloads (#6434)
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java | 15 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/preferences/DownloadsPreferencesFragment.java (renamed from app/src/main/java/de/danoeh/antennapod/fragment/preferences/NetworkPreferencesFragment.java) | 25 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java | 21 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/preferences/StoragePreferencesFragment.java | 58 |
4 files changed, 36 insertions, 83 deletions
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 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()); - } - } -} |