From cb8ab2819e9eedc16e531fda29a159d7d2685659 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Fri, 27 Dec 2024 18:39:14 +0200 Subject: [PATCH 1/4] Fix Turn Drawable problems after UI Review --- .../plus/views/mapwidgets/TurnDrawable.java | 6 ++++-- .../widgets/NextTurnBaseWidget.java | 21 +++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/TurnDrawable.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/TurnDrawable.java index 47d8015ffd0..c982904f995 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/TurnDrawable.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/TurnDrawable.java @@ -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 @@ -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; } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/NextTurnBaseWidget.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/NextTurnBaseWidget.java index e92181c92d4..1c26c892f13 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/NextTurnBaseWidget.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/NextTurnBaseWidget.java @@ -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 { @@ -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(); } } @@ -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); } From 9caa0dfdc1552e014a87c59a4b26aef8980ed286 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Mon, 30 Dec 2024 17:36:15 +0200 Subject: [PATCH 2/4] Fix Turn Drawable problems after Code Review --- .../plus/views/mapwidgets/widgets/NextTurnBaseWidget.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/NextTurnBaseWidget.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/NextTurnBaseWidget.java index 1c26c892f13..22c591a2401 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/NextTurnBaseWidget.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/NextTurnBaseWidget.java @@ -174,8 +174,8 @@ private void findViews() { public void setTurnType(TurnType turnType) { this.turnType = turnType; - boolean shouldUpdate = verticalWidget || updateVisibility(turnType != null); - if (turnDrawable.setTurnType(turnType) && shouldUpdate) { + boolean visibilityUpdated = !verticalWidget && updateVisibility(turnType != null); + if (turnDrawable.setTurnType(turnType) || visibilityUpdated) { turnDrawable.updateColors(isNightMode()); if (verticalWidget) { setVerticalImage(turnDrawable); From ce1903a723741fd29ffd21cf25ab0745d6605574 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Fri, 3 Jan 2025 18:16:12 +0200 Subject: [PATCH 3/4] Call 'invalidateSelf' at the end of 'updateColors' --- OsmAnd/src/net/osmand/plus/views/mapwidgets/TurnDrawable.java | 1 + .../plus/views/mapwidgets/widgets/NextTurnBaseWidget.java | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/TurnDrawable.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/TurnDrawable.java index c982904f995..06fec64b45e 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/TurnDrawable.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/TurnDrawable.java @@ -139,6 +139,7 @@ public void updateColors(boolean nightMode) { ? R.color.nav_arrow_circle_color_dark : R.color.nav_arrow_circle_color_light); paintTurnOutlayFill.setColor(outlayFillColor); + invalidateSelf(); } } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/NextTurnBaseWidget.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/NextTurnBaseWidget.java index 22c591a2401..58a55eacaaf 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/NextTurnBaseWidget.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/NextTurnBaseWidget.java @@ -350,7 +350,6 @@ public void updateColors(@NonNull TextState textState) { textPaint.setColor(textState.textColor); turnDrawable.updateTextPaint(textPaint, isNightMode()); turnDrawable.updateColors(isNightMode()); - turnDrawable.invalidateSelf(); } } @@ -371,7 +370,6 @@ protected void updateVerticalWidgetColors(@NonNull TextState textState) { streetView.setTypeface(Typeface.DEFAULT, typefaceStyle); turnDrawable.updateColors(isNightMode()); - turnDrawable.invalidateSelf(); bg.setBackgroundResource(textState.widgetBackgroundId); } From 824228713e9d5bbc64ef11c11b37ec8976b84b93 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Mon, 6 Jan 2025 10:57:04 +0200 Subject: [PATCH 4/4] Call 'invalidateSelf' at the end of 'updateColors' v2 --- OsmAnd/src/net/osmand/plus/views/mapwidgets/TurnDrawable.java | 1 - .../plus/views/mapwidgets/widgets/NextTurnBaseWidget.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/TurnDrawable.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/TurnDrawable.java index 06fec64b45e..c982904f995 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/TurnDrawable.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/TurnDrawable.java @@ -139,7 +139,6 @@ public void updateColors(boolean nightMode) { ? R.color.nav_arrow_circle_color_dark : R.color.nav_arrow_circle_color_light); paintTurnOutlayFill.setColor(outlayFillColor); - invalidateSelf(); } } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/NextTurnBaseWidget.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/NextTurnBaseWidget.java index 58a55eacaaf..0be19976523 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/NextTurnBaseWidget.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/NextTurnBaseWidget.java @@ -351,6 +351,7 @@ public void updateColors(@NonNull TextState textState) { turnDrawable.updateTextPaint(textPaint, isNightMode()); turnDrawable.updateColors(isNightMode()); } + turnDrawable.invalidateSelf(); } protected void updateVerticalWidgetColors(@NonNull TextState textState) { @@ -370,7 +371,6 @@ protected void updateVerticalWidgetColors(@NonNull TextState textState) { streetView.setTypeface(Typeface.DEFAULT, typefaceStyle); turnDrawable.updateColors(isNightMode()); - bg.setBackgroundResource(textState.widgetBackgroundId); }