Merge pull request #1823 from TomHennen/settings_cleanup

Settings cleanup
This commit is contained in:
Tom Hennen 2016-03-25 09:14:01 -04:00
commit 163af2a632
3 changed files with 30 additions and 12 deletions

View File

@ -90,6 +90,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
public static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify"; public static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify";
public static final String PREF_PROXY = "prefProxy"; public static final String PREF_PROXY = "prefProxy";
public static final String PREF_KNOWN_ISSUES = "prefKnownIssues"; public static final String PREF_KNOWN_ISSUES = "prefKnownIssues";
public static final String PREF_FAQ = "prefFaq";
public static final String PREF_SEND_CRASH_REPORT = "prefSendCrashReport"; public static final String PREF_SEND_CRASH_REPORT = "prefSendCrashReport";
private final PreferenceUI ui; private final PreferenceUI ui;
@ -328,7 +329,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
Toast.LENGTH_SHORT); Toast.LENGTH_SHORT);
toast.show(); toast.show();
return true; return true;
}); });
ui.findPreference(PreferenceController.PREF_GPODNET_LOGOUT).setOnPreferenceClickListener( ui.findPreference(PreferenceController.PREF_GPODNET_LOGOUT).setOnPreferenceClickListener(
preference -> { preference -> {
GpodnetPreferences.logout(); GpodnetPreferences.logout();
@ -382,14 +383,11 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
return true; return true;
}); });
ui.findPreference(PREF_KNOWN_ISSUES).setOnPreferenceClickListener(preference -> { ui.findPreference(PREF_KNOWN_ISSUES).setOnPreferenceClickListener(preference -> {
String url = "https://github.com/AntennaPod/AntennaPod/labels/bug"; openInBrowser("https://github.com/AntennaPod/AntennaPod/labels/bug");
try { return true;
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); });
ui.getActivity().startActivity(myIntent); ui.findPreference(PREF_FAQ).setOnPreferenceClickListener(preference -> {
} catch (ActivityNotFoundException e) { openInBrowser("http://antennapod.org/faq.html");
Toast.makeText(ui.getActivity(), R.string.pref_no_browser_found, Toast.LENGTH_LONG).show();
Log.e(TAG, Log.getStackTraceString(e));
}
return true; return true;
}); });
ui.findPreference(PREF_SEND_CRASH_REPORT).setOnPreferenceClickListener(preference -> { ui.findPreference(PREF_SEND_CRASH_REPORT).setOnPreferenceClickListener(preference -> {
@ -410,6 +408,16 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
setSelectedNetworksEnabled(UserPreferences.isEnableAutodownloadWifiFilter()); setSelectedNetworksEnabled(UserPreferences.isEnableAutodownloadWifiFilter());
} }
private void openInBrowser(String url) {
try {
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
ui.getActivity().startActivity(myIntent);
} catch (ActivityNotFoundException e) {
Toast.makeText(ui.getActivity(), R.string.pref_no_browser_found, Toast.LENGTH_LONG).show();
Log.e(TAG, Log.getStackTraceString(e));
}
}
public void onResume() { public void onResume() {
checkItemVisibility(); checkItemVisibility();
setUpdateIntervalText(); setUpdateIntervalText();

View File

@ -254,7 +254,7 @@
android:title="@string/pref_gpodnet_sethostname_title"/> android:title="@string/pref_gpodnet_sethostname_title"/>
</PreferenceScreen> </PreferenceScreen>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/other_pref"> <PreferenceCategory android:title="@string/storage_pref">
<Preference <Preference
android:title="@string/choose_data_directory" android:title="@string/choose_data_directory"
android:key="prefChooseDataDir"/> android:key="prefChooseDataDir"/>
@ -265,15 +265,19 @@
android:key="prefImageCacheSize" android:key="prefImageCacheSize"
android:summary="@string/pref_image_cache_size_sum" android:summary="@string/pref_image_cache_size_sum"
android:defaultValue="100"/> android:defaultValue="100"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/other_pref">
<Preference <Preference
android:key="prefOpmlExport" android:key="prefOpmlExport"
android:title="@string/opml_export_label"/> android:title="@string/opml_export_label"/>
<Preference <Preference
android:key="statistics" android:key="statistics"
android:title="@string/statistics_label"/> android:title="@string/statistics_label"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/project_pref">
<Preference <Preference
android:key="prefAbout" android:key="prefFaq"
android:title="@string/about_pref"/> android:title="@string/pref_faq"/>
<Preference <Preference
android:key="prefKnownIssues" android:key="prefKnownIssues"
android:title="@string/pref_known_issues"/> android:title="@string/pref_known_issues"/>
@ -281,6 +285,9 @@
android:key="prefSendCrashReport" android:key="prefSendCrashReport"
android:title="@string/crash_report_title" android:title="@string/crash_report_title"
android:summary="@string/crash_report_sum"/> android:summary="@string/crash_report_sum"/>
<Preference
android:key="prefAbout"
android:title="@string/about_pref"/>
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View File

@ -289,6 +289,8 @@
<!-- Preferences --> <!-- Preferences -->
<string name="storage_pref">Storage</string>
<string name="project_pref">Project</string>
<string name="other_pref">Other</string> <string name="other_pref">Other</string>
<string name="about_pref">About</string> <string name="about_pref">About</string>
<string name="queue_label">Queue</string> <string name="queue_label">Queue</string>
@ -400,6 +402,7 @@
<string name="pref_current_value">Current value: %1$s</string> <string name="pref_current_value">Current value: %1$s</string>
<string name="pref_proxy_title">Proxy</string> <string name="pref_proxy_title">Proxy</string>
<string name="pref_proxy_sum">Set a network proxy</string> <string name="pref_proxy_sum">Set a network proxy</string>
<string name="pref_faq">FAQ</string>
<string name="pref_known_issues">Known issues</string> <string name="pref_known_issues">Known issues</string>
<string name="pref_no_browser_found">No web browser found.</string> <string name="pref_no_browser_found">No web browser found.</string>