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

Try to fix direction arrows color #21058

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
24 changes: 4 additions & 20 deletions OsmAnd/src/net/osmand/plus/views/layers/PreviewRouteLineLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,19 @@

import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Path;
import android.graphics.PointF;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.*;
import android.graphics.drawable.LayerDrawable;

import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.graphics.drawable.DrawableCompat;

import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.graphics.drawable.DrawableCompat;

import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.graphics.drawable.DrawableCompat;
import net.osmand.PlatformUtil;
import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.OsmandApplication;
import net.osmand.shared.routing.ColoringType;
import net.osmand.plus.routing.PreviewRouteLineInfo;
import net.osmand.shared.gpx.GradientScaleType;
import net.osmand.plus.utils.AndroidUtils;
import net.osmand.plus.utils.ColorUtilities;
import net.osmand.plus.views.layers.base.BaseRouteLayer;
Expand All @@ -53,6 +35,8 @@
import net.osmand.render.RenderingRulesStorage;
import net.osmand.router.RouteStatisticsHelper;
import net.osmand.shared.ColorPalette;
import net.osmand.shared.gpx.GradientScaleType;
import net.osmand.shared.routing.ColoringType;
import net.osmand.shared.routing.RouteColorize;
import net.osmand.util.Algorithms;

Expand Down Expand Up @@ -150,7 +134,7 @@ private void drawRouteLinePreview(Canvas canvas,
points.add(new GeometryWayPoint(points.size(), endX, endY));

previewLineGeometry.setRouteStyleParams(getRouteLineColor(), getRouteLineWidth(tileBox),
true, directionArrowsColor, routeColoringType, routeInfoAttribute, routeGradientPalette);
true, getDirectionArrowsColor(), routeColoringType, routeInfoAttribute, routeGradientPalette);
fillPreviewLineArrays(points);
canvas.rotate(+tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
previewLineGeometry.drawRouteSegment(tileBox, canvas, points, 0);
Expand Down
2 changes: 1 addition & 1 deletion OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ public void drawLocations(@NonNull RotatedTileBox tb, @Nullable Canvas canvas,
boolean shouldShowDirectionArrows = previewRouteLineInfo == null
|| previewRouteLineInfo.shouldShowDirectionArrows();
routeGeometry.setRouteStyleParams(routeLineColor, routeLineWidth, shouldShowDirectionArrows,
directionArrowsColor, actualColoringType, routeInfoAttribute, routeGradientPalette);
getDirectionArrowsColor(), actualColoringType, routeInfoAttribute, routeGradientPalette);
boolean routeUpdated = routeGeometry.updateRoute(tb, route);
boolean shouldShowTurnArrows = shouldShowTurnArrows();

Expand Down
25 changes: 14 additions & 11 deletions OsmAnd/src/net/osmand/plus/views/layers/base/BaseRouteLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
import static net.osmand.plus.configmap.ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.*;
import android.graphics.drawable.Drawable;

import androidx.annotation.ColorInt;
Expand All @@ -24,7 +17,6 @@
import net.osmand.plus.R;
import net.osmand.plus.card.color.palette.gradient.PaletteGradientColor;
import net.osmand.plus.render.OsmandRenderer;
import net.osmand.shared.routing.ColoringType;
import net.osmand.plus.routing.PreviewRouteLineInfo;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings;
Expand All @@ -35,6 +27,7 @@
import net.osmand.render.RenderingRuleProperty;
import net.osmand.render.RenderingRuleSearchRequest;
import net.osmand.render.RenderingRulesStorage;
import net.osmand.shared.routing.ColoringType;
import net.osmand.util.Algorithms;

import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -121,7 +114,7 @@ protected void updateRouteColors(boolean night) {
if (routeColoringType.isCustomColor()) {
updateCustomColor(night);
} else {
directionArrowsColor = null;
setDirectionArrowsColor(null);
updateAttrs(new DrawSettings(night), view.getCurrentRotatedTileBox());
routeLineColor = attrs.paint.getColor();
}
Expand All @@ -140,7 +133,7 @@ private void updateCustomColor(boolean night) {
}

if (routeLineColor != customColor) {
directionArrowsColor = ColorUtilities.getContrastColor(getContext(), customColor, false);
setDirectionArrowsColor(ColorUtilities.getContrastColor(getContext(), customColor, false));
}
routeLineColor = customColor;
}
Expand Down Expand Up @@ -181,6 +174,16 @@ public int getRouteLineColor() {
return routeLineColor;
}

@ColorInt
@Nullable
public Integer getDirectionArrowsColor() {
return directionArrowsColor;
}

public void setDirectionArrowsColor(@Nullable Integer directionArrowsColor) {
this.directionArrowsColor = directionArrowsColor;
}

protected float getRouteLineWidth(@NonNull RotatedTileBox tileBox) {
String widthKey;
if (previewRouteLineInfo != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ public boolean setNightMode(boolean nightMode) {

public void updatePaints(boolean nightMode, @NonNull RenderingLineAttributes attrs) {
this.attrs = attrs;
paintIcon.setColorFilter(new PorterDuffColorFilter(attrs.paint2.getColor(), PorterDuff.Mode.MULTIPLY));
int color = attrs.paint2.getColor();
paintIcon.setColor(color);
paintIcon.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
this.nightMode = nightMode;
recreateBitmapsInternal();
}
Expand Down
Loading