Merge pull request #9188 from osmandapp/master

update test branch
This commit is contained in:
Hardy 2020-06-09 19:59:42 +02:00 committed by GitHub
commit 6719f6f63f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 8 deletions

View file

@ -33,8 +33,9 @@ public class CollatorStringMatcher implements StringMatcher {
public CollatorStringMatcher(String part, StringMatcherMode mode) { public CollatorStringMatcher(String part, StringMatcherMode mode) {
this.collator = OsmAndCollator.primaryCollator(); this.collator = OsmAndCollator.primaryCollator();
this.part = part.toLowerCase(Locale.getDefault()); this.part = simplifyStringAndAlignChars(part);
this.mode = mode; this.mode = mode;
} }
public Collator getCollator() { public Collator getCollator() {
@ -123,14 +124,15 @@ public class CollatorStringMatcher implements StringMatcher {
* @param theStart * @param theStart
* @return true if searchIn starts with token * @return true if searchIn starts with token
*/ */
public static boolean cstartsWith(Collator collator, String fullText, String theStart, public static boolean cstartsWith(Collator collator, String fullTextP, String theStart,
boolean checkBeginning, boolean checkSpaces, boolean equals) { boolean checkBeginning, boolean checkSpaces, boolean equals) {
String searchIn = fullText.toLowerCase(Locale.getDefault()); String searchIn = simplifyStringAndAlignChars(fullTextP);
int searchInLength = searchIn.length(); int searchInLength = searchIn.length();
int startLength = theStart.length(); int startLength = theStart.length();
if (startLength == 0) { if (startLength == 0) {
return true; return true;
} }
// this is not correct because of Auhofstrasse != Auhofstraße
if (startLength > searchInLength) { if (startLength > searchInLength) {
return false; return false;
} }
@ -152,7 +154,8 @@ public class CollatorStringMatcher implements StringMatcher {
if (isSpace(searchIn.charAt(i - 1)) && !isSpace(searchIn.charAt(i))) { if (isSpace(searchIn.charAt(i - 1)) && !isSpace(searchIn.charAt(i))) {
if (collator.equals(searchIn.substring(i, i + startLength), theStart)) { if (collator.equals(searchIn.substring(i, i + startLength), theStart)) {
if(equals) { if(equals) {
if(i + startLength == searchInLength || isSpace(searchIn.charAt(i + startLength))) { if(i + startLength == searchInLength ||
isSpace(searchIn.charAt(i + startLength))) {
return true; return true;
} }
} else { } else {
@ -168,7 +171,17 @@ public class CollatorStringMatcher implements StringMatcher {
return false; return false;
} }
private static String simplifyStringAndAlignChars(String fullText) {
int i;
fullText = fullText.toLowerCase(Locale.getDefault());
while( (i = fullText.indexOf('ß') ) != -1 ) {
fullText = fullText.substring(0, i) + "ss" + fullText.substring(i+1);
}
return fullText;
}
private static boolean isSpace(char c){ private static boolean isSpace(char c){
return !Character.isLetter(c) && !Character.isDigit(c); return !Character.isLetter(c) && !Character.isDigit(c);
} }
} }

View file

@ -38,4 +38,5 @@ public class OsmAndCollator {
} }
}; };
} }
} }

View file

@ -235,7 +235,7 @@ public class TestVoiceActivity extends OsmandActionBarActivity {
addButton(ll, "\u25BA (10.3) You have been off the route for 1050m", builder(p).offRoute(1050)); addButton(ll, "\u25BA (10.3) You have been off the route for 1050m", builder(p).offRoute(1050));
addButton(ll, "\u25BA (10.4) You are back on the route", builder(p).backOnRoute()); addButton(ll, "\u25BA (10.4) You are back on the route", builder(p).backOnRoute());
addButton(ll, "Voice system info:", builder(p)); addButton(ll, "System info and settings:", builder(p));
addButton(ll, "\u25BA (11.1) (TAP TO FULLY POPULATE)\n" + getVoiceSystemInfo(), builder(p).attention("")); addButton(ll, "\u25BA (11.1) (TAP TO FULLY POPULATE)\n" + getVoiceSystemInfo(), builder(p).attention(""));
addButton(ll, "\u25BA (11.2) (TAP TO CHANGE)\n \u25CF Voice prompt delay for selected output: " + addButton(ll, "\u25BA (11.2) (TAP TO CHANGE)\n \u25CF Voice prompt delay for selected output: " +
((OsmandApplication) getApplication()).getSettings().VOICE_PROMPT_DELAY[((OsmandApplication) getApplication()).getSettings().AUDIO_MANAGER_STREAM.get()].get() + ((OsmandApplication) getApplication()).getSettings().VOICE_PROMPT_DELAY[((OsmandApplication) getApplication()).getSettings().AUDIO_MANAGER_STREAM.get()].get() +
@ -294,7 +294,7 @@ public class TestVoiceActivity extends OsmandActionBarActivity {
public void onClick(View v) { public void onClick(View v) {
builder.play(); builder.play();
if (description.startsWith("\u25BA (11.1)")) { if (description.startsWith("\u25BA (11.1)")) {
buttonInfo.setText("\u25BA (11.1) Info detected:\n" + getVoiceSystemInfo()); buttonInfo.setText("\u25BA (11.1) Voice system info:\n" + getVoiceSystemInfo());
// Toast.makeText(TestVoiceActivity.this, "Info refreshed.", Toast.LENGTH_LONG).show(); // Toast.makeText(TestVoiceActivity.this, "Info refreshed.", Toast.LENGTH_LONG).show();
} }
if (description.startsWith("\u25BA (11.2)")) { if (description.startsWith("\u25BA (11.2)")) {

View file

@ -57,8 +57,8 @@ public class VehicleParametersBottomSheet extends BasePreferenceBottomSheet {
VehicleSizeAssets vehicleSizeAssets = VehicleSizeAssets.getAssets(parameterName); VehicleSizeAssets vehicleSizeAssets = VehicleSizeAssets.getAssets(parameterName);
if (vehicleSizeAssets != null) { if (vehicleSizeAssets != null) {
ImageView imageView = mainView.findViewById(R.id.image_view); ImageView imageView = mainView.findViewById(R.id.image_view);
imageView.setImageDrawable(ContextCompat.getDrawable(app, imageView.setImageDrawable(app.getUIUtilities()
!nightMode ? vehicleSizeAssets.getDayIconId() : vehicleSizeAssets.getNightIconId())); .getIcon(!nightMode ? vehicleSizeAssets.getDayIconId() : vehicleSizeAssets.getNightIconId()));
TextView description = mainView.findViewById(R.id.description); TextView description = mainView.findViewById(R.id.description);
description.setText(app.getString(vehicleSizeAssets.getDescriptionRes())); description.setText(app.getString(vehicleSizeAssets.getDescriptionRes()));
} }