From 6d87a3353590be25496c06e13c0bf334ce84c77e Mon Sep 17 00:00:00 2001 From: cepprice Date: Mon, 15 Mar 2021 19:49:31 +0500 Subject: [PATCH 1/2] Fix summary of Dialogs and notifications preference --- OsmAnd/res/xml/global_settings.xml | 1 - .../fragments/GlobalSettingsFragment.java | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/xml/global_settings.xml b/OsmAnd/res/xml/global_settings.xml index 1cb0e2e93d..98ad2a1312 100644 --- a/OsmAnd/res/xml/global_settings.xml +++ b/OsmAnd/res/xml/global_settings.xml @@ -48,7 +48,6 @@ android:layout="@layout/preference_with_descr" android:persistent="false" android:title="@string/dialogs_and_notifications_title" - android:summary="@string/shared_string_all" app:fragment="net.osmand.plus.settings.fragments.DialogsAndNotificationsSettingsFragment" tools:icon="@drawable/ic_action_notification" /> diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/GlobalSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/GlobalSettingsFragment.java index b9e398aa07..4cf57ce66b 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/GlobalSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/GlobalSettingsFragment.java @@ -21,6 +21,8 @@ import net.osmand.plus.profiles.SelectProfileBottomSheet; import net.osmand.plus.profiles.SelectProfileBottomSheet.DialogMode; import net.osmand.plus.profiles.SelectProfileBottomSheet.OnSelectProfileCallback; import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.settings.backend.BooleanPreference; +import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.datastorage.DataStorageHelper; import net.osmand.plus.settings.datastorage.item.StorageItem; @@ -38,6 +40,8 @@ public class GlobalSettingsFragment extends BaseSettingsFragment private static final String SEND_ANONYMOUS_DATA_PREF_ID = "send_anonymous_data"; private static final String DIALOGS_AND_NOTIFICATIONS_PREF_ID = "dialogs_and_notifications"; + private static final String DONT_SHOW_STARTUP_MESSAGES = "do_not_show_startup_messages"; + private static final String SHOW_DOWNLOAD_MAP_DIALOG = "show_download_map_dialog"; @Override protected void setupPreferences() { @@ -213,6 +217,20 @@ public class GlobalSettingsFragment extends BaseSettingsFragment private void setupDialogsAndNotificationsPref() { Preference dialogsAndNotifications = (Preference) findPreference(DIALOGS_AND_NOTIFICATIONS_PREF_ID); dialogsAndNotifications.setIcon(getPersistentPrefIcon(R.drawable.ic_action_notification)); + if (getSettings() == null) { + return; + } + CommonPreference startupMessages = (BooleanPreference) getSettings().getPreference(DONT_SHOW_STARTUP_MESSAGES); + CommonPreference downloadMapDialog = (BooleanPreference) getSettings().getPreference(SHOW_DOWNLOAD_MAP_DIALOG); + String summary; + if (!startupMessages.get() && downloadMapDialog.get()) { + summary = app.getString(R.string.shared_string_all); + } else if (!startupMessages.get() || downloadMapDialog.get()) { + summary = "1/2"; + } else { + summary = app.getString(R.string.shared_string_disabled); + } + dialogsAndNotifications.setSummary(summary); } private void setupEnableProxyPref() { From c640e6a79a2222031559192e8779c3e040503af4 Mon Sep 17 00:00:00 2001 From: cepprice Date: Mon, 15 Mar 2021 21:28:06 +0500 Subject: [PATCH 2/2] Small edit --- .../fragments/GlobalSettingsFragment.java | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/GlobalSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/GlobalSettingsFragment.java index 4cf57ce66b..2646218e50 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/GlobalSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/GlobalSettingsFragment.java @@ -6,11 +6,6 @@ import android.os.Bundle; import android.util.Pair; import android.widget.ImageView; -import androidx.fragment.app.FragmentManager; -import androidx.preference.Preference; -import androidx.preference.PreferenceViewHolder; -import androidx.preference.SwitchPreferenceCompat; - import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.dialogs.ConfigureMapMenu; @@ -21,14 +16,17 @@ import net.osmand.plus.profiles.SelectProfileBottomSheet; import net.osmand.plus.profiles.SelectProfileBottomSheet.DialogMode; import net.osmand.plus.profiles.SelectProfileBottomSheet.OnSelectProfileCallback; import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.BooleanPreference; -import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.datastorage.DataStorageHelper; import net.osmand.plus.settings.datastorage.item.StorageItem; import net.osmand.plus.settings.preferences.ListPreferenceEx; import net.osmand.plus.settings.preferences.SwitchPreferenceEx; +import androidx.fragment.app.FragmentManager; +import androidx.preference.Preference; +import androidx.preference.PreferenceViewHolder; +import androidx.preference.SwitchPreferenceCompat; + import static net.osmand.plus.profiles.SelectProfileBottomSheet.PROFILE_KEY_ARG; import static net.osmand.plus.profiles.SelectProfileBottomSheet.USE_LAST_PROFILE_ARG; @@ -40,8 +38,6 @@ public class GlobalSettingsFragment extends BaseSettingsFragment private static final String SEND_ANONYMOUS_DATA_PREF_ID = "send_anonymous_data"; private static final String DIALOGS_AND_NOTIFICATIONS_PREF_ID = "dialogs_and_notifications"; - private static final String DONT_SHOW_STARTUP_MESSAGES = "do_not_show_startup_messages"; - private static final String SHOW_DOWNLOAD_MAP_DIALOG = "show_download_map_dialog"; @Override protected void setupPreferences() { @@ -220,15 +216,15 @@ public class GlobalSettingsFragment extends BaseSettingsFragment if (getSettings() == null) { return; } - CommonPreference startupMessages = (BooleanPreference) getSettings().getPreference(DONT_SHOW_STARTUP_MESSAGES); - CommonPreference downloadMapDialog = (BooleanPreference) getSettings().getPreference(SHOW_DOWNLOAD_MAP_DIALOG); + boolean showStartupMessages = !getSettings().DO_NOT_SHOW_STARTUP_MESSAGES.get(); + boolean showDownloadMapDialog = getSettings().SHOW_DOWNLOAD_MAP_DIALOG.get(); String summary; - if (!startupMessages.get() && downloadMapDialog.get()) { - summary = app.getString(R.string.shared_string_all); - } else if (!startupMessages.get() || downloadMapDialog.get()) { - summary = "1/2"; + if (showStartupMessages && showDownloadMapDialog) { + summary = getString(R.string.shared_string_all); + } else if (showStartupMessages || showDownloadMapDialog) { + summary = getString(R.string.ltr_or_rtl_combine_via_slash, "1", "2"); } else { - summary = app.getString(R.string.shared_string_disabled); + summary = getString(R.string.shared_string_disabled); } dialogsAndNotifications.setSummary(summary); }