Merge pull request #7117 from osmandapp/ui_issues

Ui issues fix #6948 #6912
This commit is contained in:
vshcherb 2019-06-27 17:55:21 +02:00 committed by GitHub
commit 215f9531a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 8 deletions

View file

@ -440,7 +440,8 @@ public class AmenityMenuBuilder extends MenuBuilder {
} else if (Amenity.OPENING_HOURS.equals(key) ||
Amenity.COLLECTION_TIMES.equals(key) || Amenity.SERVICE_TIMES.equals(key)) {
iconId = R.drawable.ic_action_time;
collapsableView = getCollapsableTextView(view.getContext(), true, amenity.getAdditionalInfo(key));
collapsableView = getCollapsableTextView(view.getContext(), true,
amenity.getAdditionalInfo(key).replace("; ", "\n").replace(",", ", "));
collapsable = true;
OpeningHoursParser.OpeningHours rs = OpeningHoursParser.parseOpenedHours(amenity.getAdditionalInfo(key));
if (rs != null) {
@ -454,6 +455,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
textColor = R.color.color_invalid;
}
}
vl = vl.replace("; ", "\n");
needLinks = false;
} else if (Amenity.PHONE.equals(key)) {

View file

@ -1,5 +1,6 @@
package net.osmand.plus.views;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
@ -17,6 +18,7 @@ import java.util.Map;
import java.util.TreeMap;
import gnu.trove.set.hash.TIntHashSet;
import net.osmand.plus.R;
public class MapTextLayer extends OsmandMapLayer {
@ -106,6 +108,7 @@ public class MapTextLayer extends OsmandMapLayer {
}
private void drawWrappedText(Canvas cv, String text, float textSize, float x, float y, int lines) {
boolean nightMode = view.getApplication().getDaynightHelper().isNightMode();
if (text.length() > TEXT_WRAP) {
int start = 0;
int end = text.length();
@ -123,14 +126,14 @@ public class MapTextLayer extends OsmandMapLayer {
pos++;
}
if (lastSpace == -1 || (pos == end)) {
drawShadowText(cv, text.substring(start, pos), x, y + line * (textSize + 2));
drawShadowText(cv, text.substring(start, pos), x, y + line * (textSize + 2), nightMode);
start = pos;
} else {
String subtext = text.substring(start, lastSpace);
if (line + 1 == lines) {
subtext += "..";
}
drawShadowText(cv, subtext, x, y + line * (textSize + 2));
drawShadowText(cv, subtext, x, y + line * (textSize + 2), nightMode);
start = lastSpace + 1;
limit += (start - pos) - 1;
@ -139,20 +142,24 @@ public class MapTextLayer extends OsmandMapLayer {
line++;
}
} else {
drawShadowText(cv, text, x, y);
drawShadowText(cv, text, x, y, nightMode);
}
}
private void drawShadowText(Canvas cv, String text, float centerX, float centerY) {
int c = paintTextIcon.getColor();
private void drawShadowText(Canvas cv, String text, float centerX, float centerY, boolean nightMode) {
Resources r = view.getApplication().getResources();
paintTextIcon.setStyle(Style.STROKE);
paintTextIcon.setColor(Color.WHITE);
paintTextIcon.setColor(nightMode
? r.getColor(R.color.widgettext_shadow_night)
: r.getColor(R.color.widgettext_shadow_day));
paintTextIcon.setStrokeWidth(2);
cv.drawText(text, centerX, centerY, paintTextIcon);
// reset
paintTextIcon.setStrokeWidth(2);
paintTextIcon.setStyle(Style.FILL);
paintTextIcon.setColor(c);
paintTextIcon.setColor(nightMode
? r.getColor(R.color.widgettext_night)
: r.getColor(R.color.widgettext_day));
cv.drawText(text, centerX, centerY, paintTextIcon);
}