Fix review

This commit is contained in:
Dima-1 2020-07-03 17:15:40 +03:00
parent 163e6864b9
commit 00632e50db
2 changed files with 17 additions and 17 deletions

View file

@ -4172,10 +4172,6 @@ public class OsmandSettings {
this == OsmandSettings.DrivingRegion.CANADA; this == OsmandSettings.DrivingRegion.CANADA;
} }
public boolean isCanada() {
return this == OsmandSettings.DrivingRegion.CANADA;
}
public String getDescription(Context ctx) { public String getDescription(Context ctx) {
return ctx.getString(leftHandDriving ? R.string.left_side_navigation : R.string.right_side_navigation) + return ctx.getString(leftHandDriving ? R.string.left_side_navigation : R.string.right_side_navigation) +
", " + ", " +

View file

@ -1250,8 +1250,8 @@ public class RouteInfoWidgetsFactory {
private OsmAndLocationProvider locationProvider; private OsmAndLocationProvider locationProvider;
private WaypointHelper wh; private WaypointHelper wh;
private int imgId; private int imgId;
private String textOld; private String cachedText;
private String bottomTextOld; private String cachedBottomText;
public AlarmWidget(final OsmandApplication app, MapActivity ma) { public AlarmWidget(final OsmandApplication app, MapActivity ma) {
layout = ma.findViewById(R.id.map_alarm_warning); layout = ma.findViewById(R.id.map_alarm_warning);
@ -1294,8 +1294,9 @@ public class RouteInfoWidgetsFactory {
String bottomText = ""; String bottomText = "";
OsmandSettings.DrivingRegion region = settings.DRIVING_REGION.get(); OsmandSettings.DrivingRegion region = settings.DRIVING_REGION.get();
boolean americanType = region.isAmericanTypeSigns(); boolean americanType = region.isAmericanTypeSigns();
if(alarm.getType() == AlarmInfoType.SPEED_LIMIT) { boolean isCanadianRegion = region == OsmandSettings.DrivingRegion.CANADA;
if (region.isCanada()) { if (alarm.getType() == AlarmInfoType.SPEED_LIMIT) {
if (isCanadianRegion) {
locimgId = R.drawable.warnings_speed_limit_ca; locimgId = R.drawable.warnings_speed_limit_ca;
bottomText = settings.SPEED_SYSTEM.get().toShortString(settings.getContext()); bottomText = settings.SPEED_SYSTEM.get().toShortString(settings.getContext());
} else if (americanType) { } else if (americanType) {
@ -1303,7 +1304,7 @@ public class RouteInfoWidgetsFactory {
//else case is done by drawing red ring //else case is done by drawing red ring
} }
text = alarm.getIntValue() + ""; text = alarm.getIntValue() + "";
} else if(alarm.getType() == AlarmInfoType.SPEED_CAMERA) { } else if (alarm.getType() == AlarmInfoType.SPEED_CAMERA) {
locimgId = R.drawable.warnings_speed_camera; locimgId = R.drawable.warnings_speed_camera;
} else if(alarm.getType() == AlarmInfoType.BORDER_CONTROL) { } else if(alarm.getType() == AlarmInfoType.BORDER_CONTROL) {
locimgId = R.drawable.warnings_border_control; locimgId = R.drawable.warnings_border_control;
@ -1365,23 +1366,26 @@ public class RouteInfoWidgetsFactory {
icon.setImageResource(locimgId); icon.setImageResource(locimgId);
} }
Resources res = layout.getContext().getResources(); Resources res = layout.getContext().getResources();
if (!Algorithms.objectEquals(text, textOld)) { if (!Algorithms.objectEquals(text, cachedText)) {
textOld = text; cachedText = text;
widgetText.setText(textOld); widgetText.setText(cachedText);
if (alarm.getType() == AlarmInfoType.SPEED_LIMIT && americanType && !region.isCanada()) { if (alarm.getType() == AlarmInfoType.SPEED_LIMIT && americanType && !isCanadianRegion) {
int topPadding = res.getDimensionPixelSize(R.dimen.map_alarm_text_top_padding); int topPadding = res.getDimensionPixelSize(R.dimen.map_alarm_text_top_padding);
widgetText.setPadding(0, topPadding, 0, 0); widgetText.setPadding(0, topPadding, 0, 0);
} else { } else {
widgetText.setPadding(0, 0, 0, 0); widgetText.setPadding(0, 0, 0, 0);
} }
} }
if (!Algorithms.objectEquals(bottomText, bottomTextOld)) { if (!Algorithms.objectEquals(bottomText, cachedBottomText)) {
bottomTextOld = bottomText; cachedBottomText = bottomText;
widgetBottomText.setText(bottomTextOld); widgetBottomText.setText(cachedBottomText);
if (alarm.getType() == AlarmInfoType.SPEED_LIMIT && region.isCanada()) { if (alarm.getType() == AlarmInfoType.SPEED_LIMIT && isCanadianRegion) {
int bottomPadding = res.getDimensionPixelSize(R.dimen.map_button_margin); int bottomPadding = res.getDimensionPixelSize(R.dimen.map_button_margin);
widgetBottomText.setPadding(0, 0, 0, bottomPadding); widgetBottomText.setPadding(0, 0, 0, bottomPadding);
widgetBottomText.setTextSize(COMPLEX_UNIT_PX, res.getDimensionPixelSize(R.dimen.map_alarm_bottom_si_text_size)); widgetBottomText.setTextSize(COMPLEX_UNIT_PX, res.getDimensionPixelSize(R.dimen.map_alarm_bottom_si_text_size));
} else {
widgetBottomText.setPadding(0, 0, 0, 0);
widgetBottomText.setTextSize(COMPLEX_UNIT_PX, res.getDimensionPixelSize(R.dimen.map_alarm_bottom_text_size));
} }
widgetBottomText.setTextColor(ContextCompat.getColor(layout.getContext(), widgetBottomText.setTextColor(ContextCompat.getColor(layout.getContext(),
americanType ? R.color.color_black : R.color.color_white)); americanType ? R.color.color_black : R.color.color_white));