From 4f35297d73a367825b1e320afc1e8c1b314bdbc5 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Thu, 1 Apr 2021 21:16:28 +0300 Subject: [PATCH 1/5] First iteration: 3 items done Rearrange items in the "Voice prompts" menu. Divide it into groups: "Announce", "User points", "Speed limit", 'Options", "Output". Rename current "Sped limit" switch to "Announce when exceeded" --- ...profile_preference_toolbar_with_switch.xml | 1 + OsmAnd/res/values/strings.xml | 6 +- OsmAnd/res/xml/voice_announces.xml | 102 ++++++++++++------ .../net/osmand/plus/routing/VoiceRouter.java | 33 +++--- .../plus/settings/backend/OsmandSettings.java | 1 + .../fragments/VoiceAnnouncesFragment.java | 73 +++++++++---- 6 files changed, 150 insertions(+), 66 deletions(-) diff --git a/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml b/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml index 33a93fc70e..14672b52df 100644 --- a/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml +++ b/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml @@ -71,6 +71,7 @@ + Output + User points + Announce when exceeded + Exit number Update all maps added to %1$s? • OsmAnd Live updates moved to \"Downloads > Updates\"\n\n @@ -2476,7 +2480,7 @@ Traffic calming Speed camera Traffic warning - Favorites nearby + Nearby favorites Nearby POI Traffic warnings OsmAnd background service still running. Stop it, too? diff --git a/OsmAnd/res/xml/voice_announces.xml b/OsmAnd/res/xml/voice_announces.xml index a7dfad299b..51ce54c40b 100644 --- a/OsmAnd/res/xml/voice_announces.xml +++ b/OsmAnd/res/xml/voice_announces.xml @@ -11,11 +11,41 @@ android:title="@string/voice_announces_info" tools:icon="@drawable/ic_action_info_dark" /> + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + - - + android:title="@string/output" /> diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java index b9032e26e4..70c8443701 100644 --- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java +++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java @@ -27,6 +27,8 @@ import net.osmand.router.TurnType; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; +import org.apache.commons.lang3.StringUtils; + import java.io.IOException; import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -663,24 +665,29 @@ public class VoiceRouter { } private String getSpeakableExitRef(String exit) { - StringBuilder sb = new StringBuilder(); - if (exit != null) { - exit = exit.replace('-', ' '); - exit = exit.replace(':', ' '); - // Add spaces between digits and letters for better pronunciation - int length = exit.length(); - for (int i = 0; i < length; i++) { - if (i + 1 < length && Character.isDigit(exit.charAt(i)) && Character.isLetter(exit.charAt(i + 1))) { - sb.append(exit.charAt(i)); - sb.append(' '); - } else { - sb.append(exit.charAt(i)); + boolean showStartDialog = settings.EXIT_NUMBER_NAMES_SHOWED.get(); + if (showStartDialog) { + StringBuilder sb = new StringBuilder(); + if (exit != null) { + exit = exit.replace('-', ' '); + exit = exit.replace(':', ' '); + // Add spaces between digits and letters for better pronunciation + int length = exit.length(); + for (int i = 0; i < length; i++) { + if (i + 1 < length && Character.isDigit(exit.charAt(i)) && Character.isLetter(exit.charAt(i + 1))) { + sb.append(exit.charAt(i)); + sb.append(' '); + } else { + sb.append(exit.charAt(i)); + } } } + return sb.toString(); } - return sb.toString(); + return StringUtils.EMPTY; } + private int getIntRef(String stringRef) { int intRef = Algorithms.findFirstNumberEndIndex(stringRef); if (intRef > 0) { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index 39f3cf3d92..72a692a8cc 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -1358,6 +1358,7 @@ public class OsmandSettings { public final OsmandPreference SPEED_CAMERAS_UNINSTALLED = new BooleanPreference(this, "speed_cameras_uninstalled", false).makeGlobal().makeShared(); public final OsmandPreference SPEED_CAMERAS_ALERT_SHOWED = new BooleanPreference(this, "speed_cameras_alert_showed", false).makeGlobal().makeShared(); + public final OsmandPreference EXIT_NUMBER_NAMES_SHOWED = new BooleanPreference(this, "exit_number_names", false).makeGlobal().makeShared(); public Set getForbiddenTypes() { Set typeNames = new HashSet<>(); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/VoiceAnnouncesFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/VoiceAnnouncesFragment.java index fb617ab01f..ada65814b5 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/VoiceAnnouncesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/VoiceAnnouncesFragment.java @@ -5,22 +5,26 @@ import android.content.Intent; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.media.AudioManager; +import android.net.Uri; import android.view.LayoutInflater; import android.view.View; +import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; import androidx.appcompat.widget.SwitchCompat; import androidx.core.content.ContextCompat; +import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; import androidx.preference.Preference; import androidx.preference.PreferenceViewHolder; import androidx.preference.SwitchPreferenceCompat; +import com.google.android.material.appbar.AppBarLayout; + import net.osmand.AndroidUtils; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; -import net.osmand.plus.Version; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.dialogs.SpeedCamerasBottomSheet; import net.osmand.plus.download.DownloadActivity; @@ -31,6 +35,8 @@ import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.bottomsheets.AnnouncementTimeBottomSheet; import net.osmand.plus.settings.preferences.ListPreferenceEx; +import net.osmand.plus.settings.preferences.SwitchPreferenceEx; +import net.osmand.plus.wikipedia.WikipediaDialogFragment; import java.util.Set; @@ -43,11 +49,35 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment implements OnPr private static final String MORE_VALUE = "MORE_VALUE"; + private static final String OSMAND_VOICE_NAVIGATION_URL = "https://docs.osmand.net/en/main@latest/osmand/troubleshooting/navigation#voice-navigation"; + @Override protected void createToolbar(LayoutInflater inflater, View view) { - super.createToolbar(inflater, view); + AppBarLayout appbar = view.findViewById(R.id.appbar); + View toolbar = UiUtilities.getInflater(getContext(), isNightMode()).inflate(R.layout.profile_preference_toolbar_with_switch, appbar, false); - view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() { + View iconToolbarContainer = toolbar.findViewById(R.id.toolbar_icon); + ImageView icon = iconToolbarContainer.findViewById(R.id.profile_icon); + icon.setImageResource(R.drawable.ic_action_help_online); + icon.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (getContext() != null) { + WikipediaDialogFragment.showFullArticle(getContext(), Uri.parse(OSMAND_VOICE_NAVIGATION_URL), true); + } + } + }); + ImageButton backButton = toolbar.findViewById(R.id.close_button); + backButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + FragmentActivity fragmentActivity = getActivity(); + if (fragmentActivity != null) { + fragmentActivity.onBackPressed(); + } + } + }); + toolbar.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ApplicationMode selectedMode = getSelectedAppMode(); @@ -59,6 +89,9 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment implements OnPr updateMenu(); } }); + TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title); + toolbarTitle.setText(getString(R.string.voice_announces)); + appbar.addView(toolbar); } @Override @@ -78,7 +111,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment implements OnPr View switchContainer = view.findViewById(R.id.toolbar_switch_container); AndroidUtils.setBackground(switchContainer, new ColorDrawable(color)); - SwitchCompat switchView = (SwitchCompat) switchContainer.findViewById(R.id.switchWidget); + SwitchCompat switchView = switchContainer.findViewById(R.id.switchWidget); switchView.setChecked(checked); UiUtilities.setupCompoundButton(switchView, isNightMode(), TOOLBAR); @@ -102,13 +135,13 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment implements OnPr enableDisablePreferences(!settings.VOICE_MUTE.getModeValue(getSelectedAppMode())); setupSpeakCamerasPref(); - setupSpeedCamerasAlert(); + setupTurnScreenOnNavigationInstructionsPref(); } private void setupSpeedLimitExceedPref() { //array size must be equal! - Float[] valuesKmh = new Float[] {-10f, -7f, -5f, 0f, 5f, 7f, 10f, 15f, 20f}; - Float[] valuesMph = new Float[] {-7f, -5f, -3f, 0f, 3f, 5f, 7f, 10f, 15f}; + Float[] valuesKmh = new Float[]{-10f, -7f, -5f, 0f, 5f, 7f, 10f, 15f, 20f}; + Float[] valuesMph = new Float[]{-7f, -5f, -3f, 0f, 3f, 5f, 7f, 10f, 15f}; String[] names; if (settings.METRIC_SYSTEM.getModeValue(getSelectedAppMode()) == MetricsConstants.KILOMETERS_AND_METERS) { names = new String[valuesKmh.length]; @@ -121,34 +154,34 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment implements OnPr names[i] = valuesMph[i].intValue() + " " + getString(R.string.mile_per_hour); } } - ListPreferenceEx voiceProvider = (ListPreferenceEx) findPreference(settings.SPEED_LIMIT_EXCEED_KMH.getId()); + ListPreferenceEx voiceProvider = findPreference(settings.SPEED_LIMIT_EXCEED_KMH.getId()); voiceProvider.setEntries(names); voiceProvider.setEntryValues(valuesKmh); } private void setupKeepInformingPref() { - Integer[] keepInformingValues = new Integer[] {0, 1, 2, 3, 5, 7, 10, 15, 20, 25, 30}; + Integer[] keepInformingValues = new Integer[]{0, 1, 2, 3, 5, 7, 10, 15, 20, 25, 30}; String[] keepInformingNames = new String[keepInformingValues.length]; keepInformingNames[0] = getString(R.string.keep_informing_never); for (int i = 1; i < keepInformingValues.length; i++) { keepInformingNames[i] = keepInformingValues[i] + " " + getString(R.string.int_min); } - ListPreferenceEx keepInforming = (ListPreferenceEx) findPreference(settings.KEEP_INFORMING.getId()); + ListPreferenceEx keepInforming = findPreference(settings.KEEP_INFORMING.getId()); keepInforming.setEntries(keepInformingNames); keepInforming.setEntryValues(keepInformingValues); } private void setupArrivalAnnouncementPref() { - Float[] arrivalValues = new Float[] {1.5f, 1f, 0.5f, 0.25f}; - String[] arrivalNames = new String[] { + Float[] arrivalValues = new Float[]{1.5f, 1f, 0.5f, 0.25f}; + String[] arrivalNames = new String[]{ getString(R.string.arrival_distance_factor_early), getString(R.string.arrival_distance_factor_normally), getString(R.string.arrival_distance_factor_late), getString(R.string.arrival_distance_factor_at_last) }; - ListPreferenceEx arrivalDistanceFactor = (ListPreferenceEx) findPreference(settings.ARRIVAL_DISTANCE_FACTOR.getId()); + ListPreferenceEx arrivalDistanceFactor = findPreference(settings.ARRIVAL_DISTANCE_FACTOR.getId()); arrivalDistanceFactor.setEntries(arrivalNames); arrivalDistanceFactor.setEntryValues(arrivalValues); } @@ -178,21 +211,21 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment implements OnPr Drawable enabled = getActiveIcon(R.drawable.ic_action_volume_up); Drawable icon = getPersistentPrefIcon(enabled, disabled); - ListPreferenceEx voiceProvider = (ListPreferenceEx) findPreference(settings.VOICE_PROVIDER.getId()); + ListPreferenceEx voiceProvider = findPreference(settings.VOICE_PROVIDER.getId()); voiceProvider.setEntries(entries); voiceProvider.setEntryValues(entryValues); voiceProvider.setIcon(icon); } private void setupAudioStreamGuidancePref() { - String[] streamTypes = new String[] { + String[] streamTypes = new String[]{ getString(R.string.voice_stream_music), getString(R.string.voice_stream_notification), getString(R.string.voice_stream_voice_call) }; //getString(R.string.shared_string_default)}; - Integer[] streamIntTypes = new Integer[] { + Integer[] streamIntTypes = new Integer[]{ AudioManager.STREAM_MUSIC, AudioManager.STREAM_NOTIFICATION, AudioManager.STREAM_VOICE_CALL @@ -208,6 +241,11 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment implements OnPr getPreferenceScreen().addPreference(interruptMusicPref); } + private void setupTurnScreenOnNavigationInstructionsPref() { + SwitchPreferenceEx turnScreenOnNavigationInstructions = findPreference(settings.TURN_SCREEN_ON_NAVIGATION_INSTRUCTIONS.getId()); + turnScreenOnNavigationInstructions.setDescription(R.string.turn_screen_on_navigation_instructions_descr); + } + private void updateMenu() { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { @@ -319,12 +357,11 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment implements OnPr public void onPreferenceChanged(String prefId) { if (prefId.equals(settings.SPEED_CAMERAS_UNINSTALLED.getId())) { setupSpeakCamerasPref(); - setupSpeedCamerasAlert(); } } private void setupSpeakCamerasPref() { - SwitchPreferenceCompat showCameras = (SwitchPreferenceCompat) findPreference(settings.SPEAK_SPEED_CAMERA.getId()); + SwitchPreferenceCompat showCameras = findPreference(settings.SPEAK_SPEED_CAMERA.getId()); showCameras.setVisible(!settings.SPEED_CAMERAS_UNINSTALLED.get()); } } \ No newline at end of file From 9f40195d76d1cb53d83d40a7a71bfb3ae21c0d04 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Fri, 2 Apr 2021 22:59:20 +0300 Subject: [PATCH 2/5] Remove unnecessary code from toolbar, boolean exit number setting --- ...profile_preference_toolbar_with_switch.xml | 26 +++++----- .../fragments/VoiceAnnouncesFragment.java | 47 +++++++------------ 2 files changed, 29 insertions(+), 44 deletions(-) diff --git a/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml b/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml index 14672b52df..c9ddd04254 100644 --- a/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml +++ b/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml @@ -5,10 +5,10 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="0dp" - osmand:contentInsetLeft="0dp" - osmand:contentInsetStart="0dp" - osmand:contentInsetRight="0dp" osmand:contentInsetEnd="0dp" + osmand:contentInsetLeft="0dp" + osmand:contentInsetRight="0dp" + osmand:contentInsetStart="0dp" osmand:theme="@style/ThemeOverlay.AppCompat.ActionBar"> + android:tint="?attr/default_icon_color" + osmand:srcCompat="@drawable/ic_arrow_back" /> + android:orientation="vertical" + android:paddingTop="@dimen/content_padding_half" + android:paddingBottom="@dimen/content_padding_half"> Date: Mon, 5 Apr 2021 09:58:00 +0300 Subject: [PATCH 3/5] Review --- .../net/osmand/plus/routing/VoiceRouter.java | 37 ++++++++----------- .../plus/settings/backend/OsmandSettings.java | 2 +- .../fragments/VoiceAnnouncesFragment.java | 9 ++--- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java index 70c8443701..3d6318ca48 100644 --- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java +++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java @@ -27,8 +27,6 @@ import net.osmand.router.TurnType; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; -import org.apache.commons.lang3.StringUtils; - import java.io.IOException; import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -665,29 +663,26 @@ public class VoiceRouter { } private String getSpeakableExitRef(String exit) { - boolean showStartDialog = settings.EXIT_NUMBER_NAMES_SHOWED.get(); - if (showStartDialog) { - StringBuilder sb = new StringBuilder(); - if (exit != null) { - exit = exit.replace('-', ' '); - exit = exit.replace(':', ' '); - // Add spaces between digits and letters for better pronunciation - int length = exit.length(); - for (int i = 0; i < length; i++) { - if (i + 1 < length && Character.isDigit(exit.charAt(i)) && Character.isLetter(exit.charAt(i + 1))) { - sb.append(exit.charAt(i)); - sb.append(' '); - } else { - sb.append(exit.charAt(i)); - } + StringBuilder sb = new StringBuilder(); + if (exit != null) { + exit = exit.replace('-', ' '); + exit = exit.replace(':', ' '); + // Add spaces between digits and letters for better pronunciation + int length = exit.length(); + for (int i = 0; i < length; i++) { + if (i + 1 < length && Character.isDigit(exit.charAt(i)) && Character.isLetter(exit.charAt(i + 1))) { + sb.append(exit.charAt(i)); + sb.append(' '); + } else { + sb.append(exit.charAt(i)); } } - return sb.toString(); } - return StringUtils.EMPTY; + return sb.toString(); } + private int getIntRef(String stringRef) { int intRef = Algorithms.findFirstNumberEndIndex(stringRef); if (intRef > 0) { @@ -707,7 +702,7 @@ public class VoiceRouter { boolean isPlay = true; ExitInfo exitInfo = next.getExitInfo(); if (tParam != null) { - if (exitInfo != null && !Algorithms.isEmpty(exitInfo.getRef())) { + if (exitInfo != null && !Algorithms.isEmpty(exitInfo.getRef()) && !settings.SPEAK_EXIT_NUMBER_NAMES.get()) { String stringRef = getSpeakableExitRef(exitInfo.getRef()); p.takeExit(tParam, dist, stringRef, getIntRef(exitInfo.getRef()), getSpeakableExitName(next, exitInfo, true)); } else { @@ -782,7 +777,7 @@ public class VoiceRouter { ExitInfo exitInfo = next.getExitInfo(); boolean isplay = true; if (tParam != null) { - if (exitInfo != null && !Algorithms.isEmpty(exitInfo.getRef())) { + if (exitInfo != null && !Algorithms.isEmpty(exitInfo.getRef()) && !settings.SPEAK_EXIT_NUMBER_NAMES.get()) { String stringRef = getSpeakableExitRef(exitInfo.getRef()); p.takeExit(tParam, stringRef, getIntRef(exitInfo.getRef()), getSpeakableExitName(next, exitInfo, !suppressDest)); } else { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index 72a692a8cc..e9339ccda4 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -1355,10 +1355,10 @@ public class OsmandSettings { public final OsmandPreference SPEAK_SPEED_LIMIT = new BooleanPreference(this, "speak_speed_limit", false).makeProfile().cache(); public final OsmandPreference SPEAK_SPEED_CAMERA = new BooleanPreference(this, "speak_cameras", false).makeProfile().cache(); public final OsmandPreference SPEAK_TUNNELS = new BooleanPreference(this, "speak_tunnels", false).makeProfile().cache(); + public final OsmandPreference SPEAK_EXIT_NUMBER_NAMES = new BooleanPreference(this, "exit_number_names", true).makeProfile().cache(); public final OsmandPreference SPEED_CAMERAS_UNINSTALLED = new BooleanPreference(this, "speed_cameras_uninstalled", false).makeGlobal().makeShared(); public final OsmandPreference SPEED_CAMERAS_ALERT_SHOWED = new BooleanPreference(this, "speed_cameras_alert_showed", false).makeGlobal().makeShared(); - public final OsmandPreference EXIT_NUMBER_NAMES_SHOWED = new BooleanPreference(this, "exit_number_names", false).makeGlobal().makeShared(); public Set getForbiddenTypes() { Set typeNames = new HashSet<>(); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/VoiceAnnouncesFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/VoiceAnnouncesFragment.java index edce5b859c..f041572b91 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/VoiceAnnouncesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/VoiceAnnouncesFragment.java @@ -69,16 +69,13 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment implements OnPr protected void updateToolbar() { super.updateToolbar(); View view = getView(); - final boolean nightMode = !settings.isLightContentForMode(getSelectedAppMode()); - int iconColor = getResources().getColor(nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light); - ImageView profileIcon = (ImageView) view.findViewById(R.id.profile_icon); - profileIcon.setImageResource(R.drawable.ic_action_help_online); - profileIcon.setColorFilter(iconColor); + ImageView profileIcon = view.findViewById(R.id.profile_icon); + profileIcon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_help_online, isNightMode() ? R.color.icon_color_default_dark : R.color.icon_color_default_light)); profileIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (getContext() != null) { - WikipediaDialogFragment.showFullArticle(getContext(), Uri.parse(OSMAND_VOICE_NAVIGATION_URL), nightMode); + WikipediaDialogFragment.showFullArticle(getContext(), Uri.parse(OSMAND_VOICE_NAVIGATION_URL), isNightMode()); } } }); From 8c37068918dab38f526d65c2785ecb44ea2ec19c Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Mon, 5 Apr 2021 13:00:16 +0300 Subject: [PATCH 4/5] Undo inverting setting, remove method from BaseSettingsFragment --- OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java | 4 ++-- .../plus/settings/fragments/BaseSettingsFragment.java | 6 ------ .../plus/settings/fragments/ScreenAlertsFragment.java | 6 ++++++ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java index 3d6318ca48..e4f34943d9 100644 --- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java +++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java @@ -702,7 +702,7 @@ public class VoiceRouter { boolean isPlay = true; ExitInfo exitInfo = next.getExitInfo(); if (tParam != null) { - if (exitInfo != null && !Algorithms.isEmpty(exitInfo.getRef()) && !settings.SPEAK_EXIT_NUMBER_NAMES.get()) { + if (exitInfo != null && !Algorithms.isEmpty(exitInfo.getRef()) && settings.SPEAK_EXIT_NUMBER_NAMES.get()) { String stringRef = getSpeakableExitRef(exitInfo.getRef()); p.takeExit(tParam, dist, stringRef, getIntRef(exitInfo.getRef()), getSpeakableExitName(next, exitInfo, true)); } else { @@ -777,7 +777,7 @@ public class VoiceRouter { ExitInfo exitInfo = next.getExitInfo(); boolean isplay = true; if (tParam != null) { - if (exitInfo != null && !Algorithms.isEmpty(exitInfo.getRef()) && !settings.SPEAK_EXIT_NUMBER_NAMES.get()) { + if (exitInfo != null && !Algorithms.isEmpty(exitInfo.getRef()) && settings.SPEAK_EXIT_NUMBER_NAMES.get()) { String stringRef = getSpeakableExitRef(exitInfo.getRef()); p.takeExit(tParam, stringRef, getIntRef(exitInfo.getRef()), getSpeakableExitName(next, exitInfo, !suppressDest)); } else { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java index 6eeea74426..05c4c7e323 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java @@ -924,12 +924,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl } } - public void setupSpeedCamerasAlert() { - Preference speedCamerasAlert = findPreference(settings.SPEED_CAMERAS_UNINSTALLED.getId()); - speedCamerasAlert.setIcon(getContentIcon(R.drawable.ic_action_alert)); - speedCamerasAlert.setVisible(!settings.SPEED_CAMERAS_UNINSTALLED.get()); - } - public void setupPrefRoundedBg(PreferenceViewHolder holder) { View selectableView = holder.itemView.findViewById(R.id.selectable_list_item); if (selectableView != null) { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ScreenAlertsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ScreenAlertsFragment.java index a312253aee..b10d149342 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ScreenAlertsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ScreenAlertsFragment.java @@ -164,4 +164,10 @@ public class ScreenAlertsFragment extends BaseSettingsFragment implements OnPref showCameras.setIcon(getIcon(R.drawable.list_warnings_speed_camera)); showCameras.setVisible(!settings.SPEED_CAMERAS_UNINSTALLED.get()); } + + public void setupSpeedCamerasAlert() { + Preference speedCamerasAlert = findPreference(settings.SPEED_CAMERAS_UNINSTALLED.getId()); + speedCamerasAlert.setIcon(getContentIcon(R.drawable.ic_action_alert)); + speedCamerasAlert.setVisible(!settings.SPEED_CAMERAS_UNINSTALLED.get()); + } } \ No newline at end of file From 38d05b1f452bcb5735b32300d2dbbf50e07a1d8e Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Mon, 5 Apr 2021 13:17:58 +0300 Subject: [PATCH 5/5] Update VoiceRouter.java --- OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java index e4f34943d9..290ff960c8 100644 --- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java +++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java @@ -681,8 +681,6 @@ public class VoiceRouter { return sb.toString(); } - - private int getIntRef(String stringRef) { int intRef = Algorithms.findFirstNumberEndIndex(stringRef); if (intRef > 0) {