Skip to content

Commit

Permalink
Fix Turn Drawable problems after UI Review
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-kutz committed Dec 27, 2024
1 parent 9c11031 commit cb8ab28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
6 changes: 4 additions & 2 deletions OsmAnd/src/net/osmand/plus/views/mapwidgets/TurnDrawable.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,13 @@ public void draw(@NonNull Canvas canvas) {
}
}

public void updateColors(@NonNull TextPaint textPaint, boolean nightMode) {
public void updateTextPaint(@NonNull TextPaint textPaint, boolean nightMode) {
this.textPaint = textPaint;
this.textPaint.setTextAlign(Paint.Align.CENTER);
this.textPaint.setColor(ColorUtilities.getPrimaryTextColor(ctx, nightMode));
}

public void updateColors(boolean nightMode) {
if (this.nightMode == null || this.nightMode != nightMode) {
this.nightMode = nightMode;
int outlayFillColor = ctx.getColor(nightMode
Expand All @@ -149,7 +151,7 @@ public boolean setTurnType(@Nullable TurnType turnType) {
if (turnType != this.turnType && !getBounds().isEmpty()) {
this.turnType = turnType;
TurnPathHelper.calcTurnPath(originalPathForTurn, originalPathForTurnOutlay, turnType, null,
centerText, mini, false, true, false);
centerText, false, false, true, false);
onBoundsChange(getBounds());
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,14 @@ private void findViews() {
}

public void setTurnType(TurnType turnType) {
if (verticalWidget) {
this.turnType = turnType;
if (turnDrawable.setTurnType(turnType)) {
this.turnType = turnType;
boolean shouldUpdate = verticalWidget || updateVisibility(turnType != null);
if (turnDrawable.setTurnType(turnType) && shouldUpdate) {
turnDrawable.updateColors(isNightMode());
if (verticalWidget) {
setVerticalImage(turnDrawable);
}
} else {
boolean vis = updateVisibility(turnType != null);
if (turnDrawable.setTurnType(turnType) || vis) {
turnDrawable.updateColors(textPaint, isNightMode());
} else {
turnDrawable.updateTextPaint(textPaint, nightMode);
if (horizontalMini) {
setImageDrawable(turnDrawable, false);
} else {
Expand Down Expand Up @@ -349,7 +348,8 @@ public void updateColors(@NonNull TextState textState) {

textPaint.set(topTextView.getPaint());
textPaint.setColor(textState.textColor);
turnDrawable.updateColors(textPaint, isNightMode());
turnDrawable.updateTextPaint(textPaint, isNightMode());
turnDrawable.updateColors(isNightMode());
turnDrawable.invalidateSelf();
}
}
Expand All @@ -370,6 +370,9 @@ protected void updateVerticalWidgetColors(@NonNull TextState textState) {
distanceSubView.setTypeface(Typeface.DEFAULT, typefaceStyle);
streetView.setTypeface(Typeface.DEFAULT, typefaceStyle);

turnDrawable.updateColors(isNightMode());
turnDrawable.invalidateSelf();

bg.setBackgroundResource(textState.widgetBackgroundId);
}

Expand Down

0 comments on commit cb8ab28

Please sign in to comment.