Merge pull request #9378 from osmandapp/Canada_speed_limit
Fix #9192 [Feature request] add new icons for the Canadian road signs
This commit is contained in:
commit
d0db94c132
4 changed files with 47 additions and 33 deletions
BIN
OsmAnd/res/drawable-large/warnings_speed_limit_ca.png
Normal file
BIN
OsmAnd/res/drawable-large/warnings_speed_limit_ca.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
|
@ -25,9 +25,10 @@
|
||||||
<dimen name="map_alarm_size">116dp</dimen>
|
<dimen name="map_alarm_size">116dp</dimen>
|
||||||
<dimen name="map_alarm_bottom_text_margin">12dp</dimen>
|
<dimen name="map_alarm_bottom_text_margin">12dp</dimen>
|
||||||
<dimen name="map_alarm_text_size">35sp</dimen>
|
<dimen name="map_alarm_text_size">35sp</dimen>
|
||||||
|
<dimen name="map_alarm_text_top_padding">30dp</dimen>
|
||||||
<dimen name="map_alarm_bottom_text_size">22sp</dimen>
|
<dimen name="map_alarm_bottom_text_size">22sp</dimen>
|
||||||
|
<dimen name="map_alarm_bottom_si_text_size">12sp</dimen>
|
||||||
<dimen name="map_alarm_bottom_margin">140dp</dimen>
|
<dimen name="map_alarm_bottom_margin">131dp</dimen>
|
||||||
<dimen name="map_alarm_bottom_margin_land">81dp</dimen>
|
<dimen name="map_alarm_bottom_margin_land">81dp</dimen>
|
||||||
|
|
||||||
<dimen name="map_widget_icon">36dp</dimen>
|
<dimen name="map_widget_icon">36dp</dimen>
|
||||||
|
|
|
@ -141,15 +141,14 @@
|
||||||
<dimen name="map_route_planning_land_width_minus_shadow">306dp</dimen>
|
<dimen name="map_route_planning_land_width_minus_shadow">306dp</dimen>
|
||||||
<dimen name="map_route_planning_max_height">330dp</dimen>
|
<dimen name="map_route_planning_max_height">330dp</dimen>
|
||||||
<dimen name="map_minwidth_widget">100dp</dimen>
|
<dimen name="map_minwidth_widget">100dp</dimen>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dimen name="map_widget_text_size">23sp</dimen>
|
<dimen name="map_widget_text_size">23sp</dimen>
|
||||||
<dimen name="map_top_widget_text_size">22sp</dimen>
|
<dimen name="map_top_widget_text_size">22sp</dimen>
|
||||||
<dimen name="map_widget_text_size_small">15sp</dimen>
|
<dimen name="map_widget_text_size_small">15sp</dimen>
|
||||||
<dimen name="map_button_text_size">18sp</dimen>
|
<dimen name="map_button_text_size">18sp</dimen>
|
||||||
<dimen name="map_alarm_text_size">25sp</dimen>
|
<dimen name="map_alarm_text_size">25sp</dimen>
|
||||||
|
<dimen name="map_alarm_text_top_padding">20dp</dimen>
|
||||||
<dimen name="map_alarm_bottom_text_size">16sp</dimen>
|
<dimen name="map_alarm_bottom_text_size">16sp</dimen>
|
||||||
|
<dimen name="map_alarm_bottom_si_text_size">8sp</dimen>
|
||||||
<dimen name="map_widget_text_bottom_margin">1sp</dimen>
|
<dimen name="map_widget_text_bottom_margin">1sp</dimen>
|
||||||
<dimen name="map_widget_text_small_bottom_margin">3sp</dimen>
|
<dimen name="map_widget_text_small_bottom_margin">3sp</dimen>
|
||||||
<dimen name="map_widget_icon_margin">2dp</dimen>
|
<dimen name="map_widget_icon_margin">2dp</dimen>
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.ColorFilter;
|
import android.graphics.ColorFilter;
|
||||||
|
@ -24,7 +25,6 @@ import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.binary.RouteDataObject;
|
import net.osmand.binary.RouteDataObject;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
@ -62,6 +62,8 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static android.util.TypedValue.COMPLEX_UNIT_PX;
|
||||||
|
|
||||||
public class RouteInfoWidgetsFactory {
|
public class RouteInfoWidgetsFactory {
|
||||||
|
|
||||||
public NextTurnInfoWidget createNextInfoControl(final Activity activity,
|
public NextTurnInfoWidget createNextInfoControl(final Activity activity,
|
||||||
|
@ -1230,32 +1232,32 @@ public class RouteInfoWidgetsFactory {
|
||||||
AndroidUiHelper.updateVisibility(layout, visible);
|
AndroidUiHelper.updateVisibility(layout, visible);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVisibility(boolean visibility) {
|
public void setVisibility(boolean visibility) {
|
||||||
layout.setVisibility(visibility ? View.VISIBLE : View.GONE);
|
layout.setVisibility(visibility ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AlarmWidget {
|
public static class AlarmWidget {
|
||||||
|
|
||||||
private View layout;
|
private View layout;
|
||||||
private ImageView icon;
|
private ImageView icon;
|
||||||
private TextView text;
|
private TextView widgetText;
|
||||||
private TextView bottomText;
|
private TextView widgetBottomText;
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
private RoutingHelper rh;
|
private RoutingHelper rh;
|
||||||
private MapViewTrackingUtilities trackingUtilities;
|
private MapViewTrackingUtilities trackingUtilities;
|
||||||
private OsmAndLocationProvider locationProvider;
|
private OsmAndLocationProvider locationProvider;
|
||||||
private WaypointHelper wh;
|
private WaypointHelper wh;
|
||||||
private int imgId;
|
private int imgId;
|
||||||
private String textString;
|
private String cachedText;
|
||||||
private String bottomTextString;
|
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);
|
||||||
icon = (ImageView) ma.findViewById(R.id.map_alarm_warning_icon);
|
icon = (ImageView) ma.findViewById(R.id.map_alarm_warning_icon);
|
||||||
text = (TextView) ma.findViewById(R.id.map_alarm_warning_text);
|
widgetText = (TextView) ma.findViewById(R.id.map_alarm_warning_text);
|
||||||
bottomText = (TextView) ma.findViewById(R.id.map_alarm_warning_text_bottom);
|
widgetBottomText = (TextView) ma.findViewById(R.id.map_alarm_warning_text_bottom);
|
||||||
settings = app.getSettings();
|
settings = app.getSettings();
|
||||||
rh = ma.getRoutingHelper();
|
rh = ma.getRoutingHelper();
|
||||||
trackingUtilities = ma.getMapViewTrackingUtilities();
|
trackingUtilities = ma.getMapViewTrackingUtilities();
|
||||||
|
@ -1292,15 +1294,17 @@ 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 == OsmandSettings.DrivingRegion.CANADA) {
|
if (alarm.getType() == AlarmInfoType.SPEED_LIMIT) {
|
||||||
|
if (isCanadianRegion) {
|
||||||
locimgId = R.drawable.warnings_speed_limit_ca;
|
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;
|
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) {
|
} 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;
|
||||||
|
@ -1357,23 +1361,33 @@ public class RouteInfoWidgetsFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(visible) {
|
if(visible) {
|
||||||
if(locimgId != imgId) {
|
if (locimgId != imgId) {
|
||||||
imgId = locimgId;
|
imgId = locimgId;
|
||||||
icon.setImageResource(locimgId);
|
icon.setImageResource(locimgId);
|
||||||
}
|
}
|
||||||
if (!Algorithms.objectEquals(text, this.textString)) {
|
Resources res = layout.getContext().getResources();
|
||||||
textString = text;
|
if (!Algorithms.objectEquals(text, cachedText)) {
|
||||||
this.text.setText(this.textString);
|
cachedText = text;
|
||||||
if (alarm.getType() == AlarmInfoType.SPEED_LIMIT && americanType) {
|
widgetText.setText(cachedText);
|
||||||
this.text.setPadding(0, AndroidUtils.dpToPx(layout.getContext(), 20f), 0, 0);
|
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 {
|
} else {
|
||||||
this.text.setPadding(0, 0, 0, 0);
|
widgetText.setPadding(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!Algorithms.objectEquals(bottomText, this.bottomTextString)) {
|
if (!Algorithms.objectEquals(bottomText, cachedBottomText)) {
|
||||||
bottomTextString = bottomText;
|
cachedBottomText = bottomText;
|
||||||
this.bottomText.setText(this.bottomTextString);
|
widgetBottomText.setText(cachedBottomText);
|
||||||
this.bottomText.setTextColor(ContextCompat.getColor(layout.getContext(),
|
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));
|
americanType ? R.color.color_black : R.color.color_white));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue