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) {
this.collator = OsmAndCollator.primaryCollator();
this.part = part.toLowerCase(Locale.getDefault());
this.part = simplifyStringAndAlignChars(part);
this.mode = mode;
}
public Collator getCollator() {
@ -123,14 +124,15 @@ public class CollatorStringMatcher implements StringMatcher {
* @param theStart
* @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) {
String searchIn = fullText.toLowerCase(Locale.getDefault());
String searchIn = simplifyStringAndAlignChars(fullTextP);
int searchInLength = searchIn.length();
int startLength = theStart.length();
if (startLength == 0) {
return true;
}
// this is not correct because of Auhofstrasse != Auhofstraße
if (startLength > searchInLength) {
return false;
}
@ -152,7 +154,8 @@ public class CollatorStringMatcher implements StringMatcher {
if (isSpace(searchIn.charAt(i - 1)) && !isSpace(searchIn.charAt(i))) {
if (collator.equals(searchIn.substring(i, i + startLength), theStart)) {
if(equals) {
if(i + startLength == searchInLength || isSpace(searchIn.charAt(i + startLength))) {
if(i + startLength == searchInLength ||
isSpace(searchIn.charAt(i + startLength))) {
return true;
}
} else {
@ -168,7 +171,17 @@ public class CollatorStringMatcher implements StringMatcher {
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){
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.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.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() +
@ -294,7 +294,7 @@ public class TestVoiceActivity extends OsmandActionBarActivity {
public void onClick(View v) {
builder.play();
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();
}
if (description.startsWith("\u25BA (11.2)")) {

View file

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