From 96d6aff02110a60e0ee35edc02812d29bcad9437 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Mon, 5 Apr 2021 09:58:00 +0300 Subject: [PATCH] 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()); } } });