diff --git a/OsmAnd/res/drawable-large/warnings_speed_limit_ca.png b/OsmAnd/res/drawable-large/warnings_speed_limit_ca.png new file mode 100644 index 0000000000..987c7c4b3f Binary files /dev/null and b/OsmAnd/res/drawable-large/warnings_speed_limit_ca.png differ diff --git a/OsmAnd/res/values-large/sizes.xml b/OsmAnd/res/values-large/sizes.xml index 94f7f9000f..d30012865a 100644 --- a/OsmAnd/res/values-large/sizes.xml +++ b/OsmAnd/res/values-large/sizes.xml @@ -25,9 +25,10 @@ 116dp 12dp 35sp + 30dp 22sp - - 140dp + 12sp + 131dp 81dp 36dp diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index 19d8397db7..d3eb9bf16d 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -141,15 +141,14 @@ 306dp 330dp 100dp - - - 23sp 22sp 15sp 18sp 25sp + 20dp 16sp + 8sp 1sp 3sp 2dp diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java index 75c6fb9bef..7ee0d1c4c6 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java @@ -5,6 +5,7 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.ColorFilter; @@ -24,7 +25,6 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; -import net.osmand.AndroidUtils; import net.osmand.Location; import net.osmand.binary.RouteDataObject; import net.osmand.data.LatLon; @@ -62,6 +62,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import static android.util.TypedValue.COMPLEX_UNIT_PX; + public class RouteInfoWidgetsFactory { public NextTurnInfoWidget createNextInfoControl(final Activity activity, @@ -1230,32 +1232,32 @@ public class RouteInfoWidgetsFactory { AndroidUiHelper.updateVisibility(layout, visible); return true; } - + public void setVisibility(boolean visibility) { layout.setVisibility(visibility ? View.VISIBLE : View.GONE); } } - - public static class AlarmWidget { - + + public static class AlarmWidget { + private View layout; private ImageView icon; - private TextView text; - private TextView bottomText; + private TextView widgetText; + private TextView widgetBottomText; private OsmandSettings settings; private RoutingHelper rh; private MapViewTrackingUtilities trackingUtilities; private OsmAndLocationProvider locationProvider; private WaypointHelper wh; private int imgId; - private String textString; - private String bottomTextString; + private String cachedText; + private String cachedBottomText; public AlarmWidget(final OsmandApplication app, MapActivity ma) { layout = ma.findViewById(R.id.map_alarm_warning); icon = (ImageView) ma.findViewById(R.id.map_alarm_warning_icon); - text = (TextView) ma.findViewById(R.id.map_alarm_warning_text); - bottomText = (TextView) ma.findViewById(R.id.map_alarm_warning_text_bottom); + widgetText = (TextView) ma.findViewById(R.id.map_alarm_warning_text); + widgetBottomText = (TextView) ma.findViewById(R.id.map_alarm_warning_text_bottom); settings = app.getSettings(); rh = ma.getRoutingHelper(); trackingUtilities = ma.getMapViewTrackingUtilities(); @@ -1292,15 +1294,17 @@ public class RouteInfoWidgetsFactory { String bottomText = ""; OsmandSettings.DrivingRegion region = settings.DRIVING_REGION.get(); boolean americanType = region.isAmericanTypeSigns(); - if(alarm.getType() == AlarmInfoType.SPEED_LIMIT) { - if(region == OsmandSettings.DrivingRegion.CANADA) { + boolean isCanadianRegion = region == OsmandSettings.DrivingRegion.CANADA; + if (alarm.getType() == AlarmInfoType.SPEED_LIMIT) { + if (isCanadianRegion) { locimgId = R.drawable.warnings_speed_limit_ca; - } else if(americanType){ + bottomText = settings.SPEED_SYSTEM.get().toShortString(settings.getContext()); + } else if (americanType) { locimgId = R.drawable.warnings_speed_limit_us; - //else case is done by drawing red ring + //else case is done by drawing red ring } - text = alarm.getIntValue() +""; - } else if(alarm.getType() == AlarmInfoType.SPEED_CAMERA) { + text = alarm.getIntValue() + ""; + } else if (alarm.getType() == AlarmInfoType.SPEED_CAMERA) { locimgId = R.drawable.warnings_speed_camera; } else if(alarm.getType() == AlarmInfoType.BORDER_CONTROL) { locimgId = R.drawable.warnings_border_control; @@ -1357,23 +1361,33 @@ public class RouteInfoWidgetsFactory { } } if(visible) { - if(locimgId != imgId) { + if (locimgId != imgId) { imgId = locimgId; icon.setImageResource(locimgId); } - if (!Algorithms.objectEquals(text, this.textString)) { - textString = text; - this.text.setText(this.textString); - if (alarm.getType() == AlarmInfoType.SPEED_LIMIT && americanType) { - this.text.setPadding(0, AndroidUtils.dpToPx(layout.getContext(), 20f), 0, 0); + Resources res = layout.getContext().getResources(); + if (!Algorithms.objectEquals(text, cachedText)) { + cachedText = text; + widgetText.setText(cachedText); + if (alarm.getType() == AlarmInfoType.SPEED_LIMIT && americanType && !isCanadianRegion) { + int topPadding = res.getDimensionPixelSize(R.dimen.map_alarm_text_top_padding); + widgetText.setPadding(0, topPadding, 0, 0); } else { - this.text.setPadding(0, 0, 0, 0); + widgetText.setPadding(0, 0, 0, 0); } } - if (!Algorithms.objectEquals(bottomText, this.bottomTextString)) { - bottomTextString = bottomText; - this.bottomText.setText(this.bottomTextString); - this.bottomText.setTextColor(ContextCompat.getColor(layout.getContext(), + if (!Algorithms.objectEquals(bottomText, cachedBottomText)) { + cachedBottomText = bottomText; + widgetBottomText.setText(cachedBottomText); + if (alarm.getType() == AlarmInfoType.SPEED_LIMIT && isCanadianRegion) { + int bottomPadding = res.getDimensionPixelSize(R.dimen.map_button_margin); + widgetBottomText.setPadding(0, 0, 0, bottomPadding); + 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(), americanType ? R.color.color_black : R.color.color_white)); } }