Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Turn Drawable problems after the 1st UI Review #21633

Merged
merged 4 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
nazar-kutz marked this conversation as resolved.
Show resolved Hide resolved
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 visibilityUpdated = !verticalWidget && updateVisibility(turnType != null);
if (turnDrawable.setTurnType(turnType) || visibilityUpdated) {
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();
nazar-kutz marked this conversation as resolved.
Show resolved Hide resolved

bg.setBackgroundResource(textState.widgetBackgroundId);
}

Expand Down
Loading