From 540971005b3299cc301d3b4e91ba896ba39c90e2 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 29 Oct 2019 15:04:22 +0200 Subject: [PATCH] Inverted start up messages ui and change several prefs defaults --- OsmAnd/res/xml/global_settings.xml | 1 + OsmAnd/src/net/osmand/plus/OsmandSettings.java | 7 +++++-- .../SendAnalyticsBottomSheetDialogFragment.java | 12 ++++++++++-- .../plus/settings/GlobalSettingsFragment.java | 13 +++++++++++++ 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/OsmAnd/res/xml/global_settings.xml b/OsmAnd/res/xml/global_settings.xml index 2e95524c79..db5b667f2d 100644 --- a/OsmAnd/res/xml/global_settings.xml +++ b/OsmAnd/res/xml/global_settings.xml @@ -46,6 +46,7 @@ android:icon="@drawable/ic_action_notification" android:key="do_not_show_startup_messages" android:layout="@layout/preference_switch_with_descr" + android:persistent="false" android:summaryOff="@string/shared_string_off" android:summaryOn="@string/shared_string_on" android:title="@string/start_up_message_pref" /> diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index b44add42a8..0d7a9d5b56 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -1391,7 +1391,7 @@ public class OsmandSettings { public final OsmandPreference SEND_ANONYMOUS_DATA_REQUESTS_COUNT = new IntPreference("send_anonymous_data_requests_count", 0).makeGlobal().cache(); public final OsmandPreference SEND_ANONYMOUS_DATA_LAST_REQUEST_NS = new IntPreference("send_anonymous_data_last_request_ns", -1).makeGlobal().cache(); - public final OsmandPreference MAP_EMPTY_STATE_ALLOWED = new BooleanPreference("map_empty_state_allowed", true).makeProfile().makeGeneral().cache(); + public final OsmandPreference MAP_EMPTY_STATE_ALLOWED = new BooleanPreference("map_empty_state_allowed", false).makeProfile().makeGeneral().cache(); public final CommonPreference TEXT_SCALE = new FloatPreference("text_scale", 1f).makeProfile().cache(); @@ -3020,9 +3020,12 @@ public class OsmandSettings { return false; } - ; }; + { + RENDERER.setModeDefaultValue(ApplicationMode.BOAT, RendererRegistry.NAUTICAL_RENDER); + RENDERER.setModeDefaultValue(ApplicationMode.SKI, RendererRegistry.WINTER_SKI_RENDER); + } Map> customRendersProps = new LinkedHashMap>(); diff --git a/OsmAnd/src/net/osmand/plus/dialogs/SendAnalyticsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/SendAnalyticsBottomSheetDialogFragment.java index 2509402319..d212b7e76d 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/SendAnalyticsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/SendAnalyticsBottomSheetDialogFragment.java @@ -54,8 +54,16 @@ public class SendAnalyticsBottomSheetDialogFragment extends MenuBottomSheetDialo items.add(new SubtitleDividerItem(context)); - sendAnonymousMapDownloadsData = app.getSettings().SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.get(); - sendAnonymousAppUsageData = app.getSettings().SEND_ANONYMOUS_APP_USAGE_DATA.get(); + if (app.getSettings().SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.isSet()) { + sendAnonymousMapDownloadsData = app.getSettings().SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.get(); + } else { + sendAnonymousMapDownloadsData = true; + } + if (app.getSettings().SEND_ANONYMOUS_APP_USAGE_DATA.isSet()) { + sendAnonymousAppUsageData = app.getSettings().SEND_ANONYMOUS_APP_USAGE_DATA.get(); + } else { + sendAnonymousAppUsageData = true; + } final BottomSheetItemWithCompoundButton[] downloadedMapsItem = new BottomSheetItemWithCompoundButton[1]; downloadedMapsItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() .setChecked(sendAnonymousMapDownloadsData) diff --git a/OsmAnd/src/net/osmand/plus/settings/GlobalSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/GlobalSettingsFragment.java index 1eb702376b..aaff3a914a 100644 --- a/OsmAnd/src/net/osmand/plus/settings/GlobalSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/GlobalSettingsFragment.java @@ -30,6 +30,7 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send setupExternalStorageDirPref(); setupSendAnonymousDataPref(); + setupShowStartupMessagesPref(); setupEnableProxyPref(); } @@ -66,6 +67,11 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send } } return false; + } else if (prefId.equals(settings.DO_NOT_SHOW_STARTUP_MESSAGES.getId())) { + if (newValue instanceof Boolean) { + boolean enabled = !(Boolean) newValue; + return settings.DO_NOT_SHOW_STARTUP_MESSAGES.set(enabled); + } } return super.onPreferenceChange(preference, newValue); @@ -165,6 +171,13 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send sendAnonymousData.setChecked(enabled); } + private void setupShowStartupMessagesPref() { + boolean enabled = !settings.DO_NOT_SHOW_STARTUP_MESSAGES.get(); // pref ui was inverted + + SwitchPreferenceCompat sendAnonymousData = (SwitchPreferenceCompat) findPreference(settings.DO_NOT_SHOW_STARTUP_MESSAGES.getId()); + sendAnonymousData.setChecked(enabled); + } + private void setupEnableProxyPref() { SwitchPreferenceEx enableProxy = (SwitchPreferenceEx) findPreference(settings.ENABLE_PROXY.getId()); enableProxy.setIcon(getContentIcon(R.drawable.ic_action_proxy));