Skip to content

Commit

Permalink
Fix Next Turn Widget colors
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-kutz committed Dec 24, 2024
1 parent 476b948 commit 3e2be3f
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 10 deletions.
1 change: 1 addition & 0 deletions OsmAnd/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
<attr name="bottom_bar_background_color" format="color" />

<attr name="bottom_nav_shadow" format="reference"/>
<attr name="nav_arrow_circle_color" format="color"/>

<attr name="text_rounded_bg_regular" format="reference" />
<attr name="text_rounded_bg_active" format="reference" />
Expand Down
2 changes: 2 additions & 0 deletions OsmAnd/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@
<color name="nav_arrow_distant">#C0C0C0</color>
<color name="nav_arrow">#FADE23</color>
<color name="nav_arrow_imminent">#2EFF00</color>
<color name="nav_arrow_circle_color_light">#D9D9D9</color>
<color name="nav_arrow_circle_color_dark">#737373</color>

<color name="nav_point">#FA5050</color>
<color name="poi_background">#A0FF8000</color>
Expand Down
1 change: 1 addition & 0 deletions OsmAnd/res/values/osmand_dark_style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
<item name="purchase_pro_badge_icon">@drawable/img_button_pro_night</item>

<item name="bottom_nav_shadow">@drawable/bg_bottom_bar_shadow_with_line_night</item>
<item name="nav_arrow_circle_color">@color/nav_arrow_circle_color_dark</item>

<item name="text_rounded_bg_active">@drawable/text_rounded_bg_active_dark</item>
<item name="text_rounded_bg_regular">@drawable/text_rounded_bg_regular_dark</item>
Expand Down
1 change: 1 addition & 0 deletions OsmAnd/res/values/osmand_light_style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
<item name="purchase_pro_badge_icon">@drawable/img_button_pro_day</item>

<item name="bottom_nav_shadow">@drawable/bg_bottom_bar_shadow_with_line_day</item>
<item name="nav_arrow_circle_color">@color/nav_arrow_circle_color_light</item>

<item name="text_rounded_bg_active">@drawable/text_rounded_bg_active_light</item>
<item name="text_rounded_bg_regular">@drawable/text_rounded_bg_regular_light</item>
Expand Down
4 changes: 2 additions & 2 deletions OsmAnd/src/net/osmand/plus/views/layers/MapInfoLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,8 @@ private TextState calculateTextState(boolean verticalWidget) {
if (verticalWidget) {
ts.textColor = ColorUtilities.getPrimaryTextColor(getContext(), nightMode);
} else {
ts.textColor = nightMode ? ContextCompat.getColor(getContext(), R.color.widgettext_night) :
ContextCompat.getColor(getContext(), R.color.widgettext_day);
int textColorId = nightMode ? R.color.widgettext_night : R.color.widgettext_day;
ts.textColor = ColorUtilities.getColor(getContext(), textColorId);
}
ts.secondaryTextColor = ColorUtilities.getSecondaryTextColor(getContext(), nightMode);

Expand Down
36 changes: 28 additions & 8 deletions OsmAnd/src/net/osmand/plus/views/mapwidgets/TurnDrawable.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import net.osmand.PlatformUtil;
import net.osmand.plus.R;
import net.osmand.plus.utils.AndroidUtils;
import net.osmand.plus.views.TurnPathHelper;
import net.osmand.router.TurnType;

Expand All @@ -21,7 +22,8 @@ public class TurnDrawable extends Drawable {

protected static final Log log = PlatformUtil.getLog(TurnDrawable.class);

protected Paint paintBlack;
protected Paint paintTurnOutlayStroke;
protected Paint paintTurnOutlayFill;
protected Paint paintRouteDirection;
protected Path pathForTurn = new Path();
protected Path pathForTurnOutlay = new Path();
Expand All @@ -34,17 +36,24 @@ public class TurnDrawable extends Drawable {
private final boolean mini;
private final PointF centerText;
private TextPaint textPaint;
private Boolean nightMode;
private int clr;

public TurnDrawable(Context ctx, boolean mini) {
this.ctx = ctx;
this.mini = mini;
centerText = new PointF();
paintBlack = new Paint();
paintBlack.setStyle(Paint.Style.STROKE);
paintBlack.setColor(Color.BLACK);
paintBlack.setAntiAlias(true);
paintBlack.setStrokeWidth(2.5f);
paintTurnOutlayStroke = new Paint();
paintTurnOutlayStroke.setStyle(Paint.Style.STROKE);
paintTurnOutlayStroke.setColor(Color.BLACK);
paintTurnOutlayStroke.setAntiAlias(true);
paintTurnOutlayStroke.setStrokeWidth(2.5f);

int fillColor = AndroidUtils.getColorFromAttr(ctx, R.attr.nav_arrow_circle_color);
paintTurnOutlayFill = new Paint();
paintTurnOutlayFill.setStyle(Paint.Style.FILL);
paintTurnOutlayFill.setColor(fillColor);
paintTurnOutlayFill.setAntiAlias(true);

paintRouteDirection = new Paint();
paintRouteDirection.setStyle(Paint.Style.FILL);
Expand Down Expand Up @@ -104,9 +113,10 @@ public void setTurnImminent(int turnImminent, boolean deviatedFromRoute) {
public void draw(@NonNull Canvas canvas) {
/// small indent
// canvas.translate(0, 3 * scaleCoefficient);
canvas.drawPath(pathForTurnOutlay, paintBlack);
canvas.drawPath(pathForTurnOutlay, paintTurnOutlayFill);
canvas.drawPath(pathForTurnOutlay, paintTurnOutlayStroke);
canvas.drawPath(pathForTurn, paintRouteDirection);
canvas.drawPath(pathForTurn, paintBlack);
canvas.drawPath(pathForTurn, paintTurnOutlayStroke);
if (textPaint != null) {
if (turnType != null && !mini && turnType.getExitOut() > 0) {
canvas.drawText(turnType.getExitOut() + "", centerText.x,
Expand All @@ -120,6 +130,16 @@ public void setTextPaint(@NonNull TextPaint textPaint) {
this.textPaint.setTextAlign(Paint.Align.CENTER);
}

public void updateNightMode(boolean nightMode) {
if (this.nightMode == null || this.nightMode != nightMode) {
this.nightMode = nightMode;
int fillColor = ctx.getColor(nightMode
? R.color.nav_arrow_circle_color_dark
: R.color.nav_arrow_circle_color_light);
paintTurnOutlayFill.setColor(fillColor);
}
}

@Override
public void setAlpha(int alpha) {
paintRouteDirection.setAlpha(alpha);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public void setTurnType(TurnType turnType) {
boolean vis = updateVisibility(turnType != null);
if (turnDrawable.setTurnType(turnType) || vis) {
turnDrawable.setTextPaint(textPaint);
turnDrawable.updateNightMode(isNightMode());
if (horizontalMini) {
setImageDrawable(turnDrawable, false);
} else {
Expand Down Expand Up @@ -350,6 +351,7 @@ public void updateColors(@NonNull TextState textState) {
textPaint.set(topTextView.getPaint());
textPaint.setColor(textState.textColor);
turnDrawable.setTextPaint(textPaint);
turnDrawable.updateNightMode(isNightMode());
turnDrawable.invalidateSelf();
}
}
Expand Down

0 comments on commit 3e2be3f

Please sign in to comment.