This commit is contained in:
androiddevkotlin 2021-04-05 09:58:00 +03:00
parent 9f40195d76
commit 96d6aff021
3 changed files with 20 additions and 28 deletions

View file

@ -27,8 +27,6 @@ import net.osmand.router.TurnType;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException; import java.io.IOException;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
@ -665,29 +663,26 @@ public class VoiceRouter {
} }
private String getSpeakableExitRef(String exit) { private String getSpeakableExitRef(String exit) {
boolean showStartDialog = settings.EXIT_NUMBER_NAMES_SHOWED.get(); StringBuilder sb = new StringBuilder();
if (showStartDialog) { if (exit != null) {
StringBuilder sb = new StringBuilder(); exit = exit.replace('-', ' ');
if (exit != null) { exit = exit.replace(':', ' ');
exit = exit.replace('-', ' '); // Add spaces between digits and letters for better pronunciation
exit = exit.replace(':', ' '); int length = exit.length();
// Add spaces between digits and letters for better pronunciation for (int i = 0; i < length; i++) {
int length = exit.length(); if (i + 1 < length && Character.isDigit(exit.charAt(i)) && Character.isLetter(exit.charAt(i + 1))) {
for (int i = 0; i < length; i++) { sb.append(exit.charAt(i));
if (i + 1 < length && Character.isDigit(exit.charAt(i)) && Character.isLetter(exit.charAt(i + 1))) { sb.append(' ');
sb.append(exit.charAt(i)); } else {
sb.append(' '); sb.append(exit.charAt(i));
} else {
sb.append(exit.charAt(i));
}
} }
} }
return sb.toString();
} }
return StringUtils.EMPTY; return sb.toString();
} }
private int getIntRef(String stringRef) { private int getIntRef(String stringRef) {
int intRef = Algorithms.findFirstNumberEndIndex(stringRef); int intRef = Algorithms.findFirstNumberEndIndex(stringRef);
if (intRef > 0) { if (intRef > 0) {
@ -707,7 +702,7 @@ public class VoiceRouter {
boolean isPlay = true; boolean isPlay = true;
ExitInfo exitInfo = next.getExitInfo(); ExitInfo exitInfo = next.getExitInfo();
if (tParam != null) { 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()); String stringRef = getSpeakableExitRef(exitInfo.getRef());
p.takeExit(tParam, dist, stringRef, getIntRef(exitInfo.getRef()), getSpeakableExitName(next, exitInfo, true)); p.takeExit(tParam, dist, stringRef, getIntRef(exitInfo.getRef()), getSpeakableExitName(next, exitInfo, true));
} else { } else {
@ -782,7 +777,7 @@ public class VoiceRouter {
ExitInfo exitInfo = next.getExitInfo(); ExitInfo exitInfo = next.getExitInfo();
boolean isplay = true; boolean isplay = true;
if (tParam != null) { 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()); String stringRef = getSpeakableExitRef(exitInfo.getRef());
p.takeExit(tParam, stringRef, getIntRef(exitInfo.getRef()), getSpeakableExitName(next, exitInfo, !suppressDest)); p.takeExit(tParam, stringRef, getIntRef(exitInfo.getRef()), getSpeakableExitName(next, exitInfo, !suppressDest));
} else { } else {

View file

@ -1355,10 +1355,10 @@ public class OsmandSettings {
public final OsmandPreference<Boolean> SPEAK_SPEED_LIMIT = new BooleanPreference(this, "speak_speed_limit", false).makeProfile().cache(); public final OsmandPreference<Boolean> SPEAK_SPEED_LIMIT = new BooleanPreference(this, "speak_speed_limit", false).makeProfile().cache();
public final OsmandPreference<Boolean> SPEAK_SPEED_CAMERA = new BooleanPreference(this, "speak_cameras", false).makeProfile().cache(); public final OsmandPreference<Boolean> SPEAK_SPEED_CAMERA = new BooleanPreference(this, "speak_cameras", false).makeProfile().cache();
public final OsmandPreference<Boolean> SPEAK_TUNNELS = new BooleanPreference(this, "speak_tunnels", false).makeProfile().cache(); public final OsmandPreference<Boolean> SPEAK_TUNNELS = new BooleanPreference(this, "speak_tunnels", false).makeProfile().cache();
public final OsmandPreference<Boolean> SPEAK_EXIT_NUMBER_NAMES = new BooleanPreference(this, "exit_number_names", true).makeProfile().cache();
public final OsmandPreference<Boolean> SPEED_CAMERAS_UNINSTALLED = new BooleanPreference(this, "speed_cameras_uninstalled", false).makeGlobal().makeShared(); public final OsmandPreference<Boolean> SPEED_CAMERAS_UNINSTALLED = new BooleanPreference(this, "speed_cameras_uninstalled", false).makeGlobal().makeShared();
public final OsmandPreference<Boolean> SPEED_CAMERAS_ALERT_SHOWED = new BooleanPreference(this, "speed_cameras_alert_showed", false).makeGlobal().makeShared(); public final OsmandPreference<Boolean> SPEED_CAMERAS_ALERT_SHOWED = new BooleanPreference(this, "speed_cameras_alert_showed", false).makeGlobal().makeShared();
public final OsmandPreference<Boolean> EXIT_NUMBER_NAMES_SHOWED = new BooleanPreference(this, "exit_number_names", false).makeGlobal().makeShared();
public Set<String> getForbiddenTypes() { public Set<String> getForbiddenTypes() {
Set<String> typeNames = new HashSet<>(); Set<String> typeNames = new HashSet<>();

View file

@ -69,16 +69,13 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment implements OnPr
protected void updateToolbar() { protected void updateToolbar() {
super.updateToolbar(); super.updateToolbar();
View view = getView(); View view = getView();
final boolean nightMode = !settings.isLightContentForMode(getSelectedAppMode()); ImageView profileIcon = view.findViewById(R.id.profile_icon);
int iconColor = getResources().getColor(nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light); profileIcon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_help_online, isNightMode() ? 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);
profileIcon.setOnClickListener(new View.OnClickListener() { profileIcon.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (getContext() != null) { if (getContext() != null) {
WikipediaDialogFragment.showFullArticle(getContext(), Uri.parse(OSMAND_VOICE_NAVIGATION_URL), nightMode); WikipediaDialogFragment.showFullArticle(getContext(), Uri.parse(OSMAND_VOICE_NAVIGATION_URL), isNightMode());
} }
} }
}); });