From 163e6864b977fa8b745d58febd567a4f196f7a7d Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 3 Jul 2020 13:03:27 +0300 Subject: [PATCH 1/2] Fix #9192 [Feature request] add new icons for the Canadian road signs --- .../warnings_speed_limit_ca.png | Bin 0 -> 6718 bytes OsmAnd/res/values-large/sizes.xml | 5 +- OsmAnd/res/values/sizes.xml | 5 +- .../plus/settings/backend/OsmandSettings.java | 4 ++ .../mapwidgets/RouteInfoWidgetsFactory.java | 62 ++++++++++-------- 5 files changed, 45 insertions(+), 31 deletions(-) create mode 100644 OsmAnd/res/drawable-large/warnings_speed_limit_ca.png 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 0000000000000000000000000000000000000000..987c7c4b3fa4b8186e89189226b27154eeb789e9 GIT binary patch literal 6718 zcmV-E8o}j>P)z1^@s6nnk%<00009a7bBm000o2 z000o20Vd5lGynhq0drDELIAGL9O(c600d`2O+f$vv5yPi%FZyLvW>;oA)0L%(pA?mq8Ici@ z886>^@!~~0UT*IIH^A(8(XaXLPg z?&X(Xo(Qk=OZETtd6>7VV@uaB_#dX5$jT?Ek1tD?pI3(si<2dPY7dXX@#vpWc#{ zUgERz%PUWxZ;tBwgKpt4y?5{4 zX&faiFE7u~QNpxJGZVz=^J#q#Uw20d5-)jWloiI$sCuQ!ll;T7gZNaO&NnC{tNiJl z@&?|6igWK%h*#b>AB6*jVs&H$6Y3&DDDow2!HeLBo8_?e@y8$EO2=&oOG`^QZs+sV zF^JP4bq(n_ZC;++bK?AcyLRo`o|hkot#V!B^6r)A)7P`=9bQvqZqKWSx`r~g?%ut7 z7Qrx~GT{j)Yjc~VxXr_Gn9bhkwDNb}c?X1&knA*P&Ybaz77<9R+wCUTu3c-Xa+1Zx z#pLGAn{w_jKR=(`zJ1%u`NG12xpnK79Ffij^|d;kz7H=#^2&-A$aR$_m9I{NIJ#z4 zoqT#-hSV2nR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hkZx@<5p;{{d`I#pB605-?|$dbolXp)O-NmEgu)heX+yIaZ0;^I$YD&M z%Ot{Oh-eb5KZnJCs9T*NT)leLr^Sw1@CU`0AU&jEGX`)^fpkMfQJ7w4D`0UxwdPtX zPRiH+^XejTdGT3w#XacZfFloi&XgFTkJ8Y4&9dwQUYQkQDXXVc3G@{cyFMJ?dqo&S zBE`zjE24lQf-NvNv&k7@S_OAb!voWjE{LC2@%kQ}ZVTeoz3!Nom#RlzI)6PVcRDOr zoo|tP=sL@JcntGW?pF!r7E`UUSfm3E6szD zVQ|D05LP=Nwn@3B(_{smkNn3`|CgiAPs$6g7Y$+k3xvrc`GxgS=acGv`rc;-fi#Cu z1kxK5rBb+!3|IyK9q}kaY6VCCWgu|66!C>eeSeT|D~NBYVT-Jz`=5~}74)-6J#|2w z)LYk4dKApigX07*qoM6N<$f>WFNSpWb4 literal 0 HcmV?d00001 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/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index eb9308efa2..b92d1b2907 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -4172,6 +4172,10 @@ public class OsmandSettings { this == OsmandSettings.DrivingRegion.CANADA; } + public boolean isCanada() { + return this == OsmandSettings.DrivingRegion.CANADA; + } + public String getDescription(Context ctx) { return ctx.getString(leftHandDriving ? R.string.left_side_navigation : R.string.right_side_navigation) + ", " + diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java index 75c6fb9bef..9b22297628 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 textOld; + private String bottomTextOld; 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(); @@ -1293,13 +1295,14 @@ public class RouteInfoWidgetsFactory { OsmandSettings.DrivingRegion region = settings.DRIVING_REGION.get(); boolean americanType = region.isAmericanTypeSigns(); if(alarm.getType() == AlarmInfoType.SPEED_LIMIT) { - if(region == OsmandSettings.DrivingRegion.CANADA) { + if (region.isCanada()) { 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() +""; + text = alarm.getIntValue() + ""; } else if(alarm.getType() == AlarmInfoType.SPEED_CAMERA) { locimgId = R.drawable.warnings_speed_camera; } else if(alarm.getType() == AlarmInfoType.BORDER_CONTROL) { @@ -1357,23 +1360,30 @@ 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, textOld)) { + textOld = text; + widgetText.setText(textOld); + if (alarm.getType() == AlarmInfoType.SPEED_LIMIT && americanType && !region.isCanada()) { + 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, bottomTextOld)) { + bottomTextOld = bottomText; + widgetBottomText.setText(bottomTextOld); + if (alarm.getType() == AlarmInfoType.SPEED_LIMIT && region.isCanada()) { + 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)); + } + widgetBottomText.setTextColor(ContextCompat.getColor(layout.getContext(), americanType ? R.color.color_black : R.color.color_white)); } } From 00632e50db13a5bb4183808429659572065b6c0f Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 3 Jul 2020 17:15:40 +0300 Subject: [PATCH 2/2] Fix review --- .../plus/settings/backend/OsmandSettings.java | 4 --- .../mapwidgets/RouteInfoWidgetsFactory.java | 30 +++++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index b92d1b2907..eb9308efa2 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -4172,10 +4172,6 @@ public class OsmandSettings { this == OsmandSettings.DrivingRegion.CANADA; } - public boolean isCanada() { - return this == OsmandSettings.DrivingRegion.CANADA; - } - public String getDescription(Context ctx) { return ctx.getString(leftHandDriving ? R.string.left_side_navigation : R.string.right_side_navigation) + ", " + diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java index 9b22297628..7ee0d1c4c6 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java @@ -1250,8 +1250,8 @@ public class RouteInfoWidgetsFactory { private OsmAndLocationProvider locationProvider; private WaypointHelper wh; private int imgId; - private String textOld; - private String bottomTextOld; + private String cachedText; + private String cachedBottomText; public AlarmWidget(final OsmandApplication app, MapActivity ma) { layout = ma.findViewById(R.id.map_alarm_warning); @@ -1294,8 +1294,9 @@ public class RouteInfoWidgetsFactory { String bottomText = ""; OsmandSettings.DrivingRegion region = settings.DRIVING_REGION.get(); boolean americanType = region.isAmericanTypeSigns(); - if(alarm.getType() == AlarmInfoType.SPEED_LIMIT) { - if (region.isCanada()) { + boolean isCanadianRegion = region == OsmandSettings.DrivingRegion.CANADA; + if (alarm.getType() == AlarmInfoType.SPEED_LIMIT) { + if (isCanadianRegion) { locimgId = R.drawable.warnings_speed_limit_ca; bottomText = settings.SPEED_SYSTEM.get().toShortString(settings.getContext()); } else if (americanType) { @@ -1303,7 +1304,7 @@ public class RouteInfoWidgetsFactory { //else case is done by drawing red ring } text = alarm.getIntValue() + ""; - } else if(alarm.getType() == AlarmInfoType.SPEED_CAMERA) { + } 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; @@ -1365,23 +1366,26 @@ public class RouteInfoWidgetsFactory { icon.setImageResource(locimgId); } Resources res = layout.getContext().getResources(); - if (!Algorithms.objectEquals(text, textOld)) { - textOld = text; - widgetText.setText(textOld); - if (alarm.getType() == AlarmInfoType.SPEED_LIMIT && americanType && !region.isCanada()) { + 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 { widgetText.setPadding(0, 0, 0, 0); } } - if (!Algorithms.objectEquals(bottomText, bottomTextOld)) { - bottomTextOld = bottomText; - widgetBottomText.setText(bottomTextOld); - if (alarm.getType() == AlarmInfoType.SPEED_LIMIT && region.isCanada()) { + 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));