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

Fixed #1171: Changed OTP Routes Color Logic #1172

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import org.onebusaway.android.BuildConfig;

import android.graphics.Color;

import java.util.Locale;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -74,6 +76,8 @@ public class OTPConstants {
// flag to indicate intent sent by or on behalf of TripPlanActivity
public static final String INTENT_SOURCE = "org.onebusaway.android.INTENT_SOURCE";

public static final int OTP_TRANSIT_COLOR = Color.parseColor("#006500");

public enum Source {ACTIVITY, NOTIFICATION}

;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.onebusaway.android.map;

import org.onebusaway.android.directions.util.OTPConstants;
import org.onebusaway.android.io.elements.ObaShape;
import org.onebusaway.android.io.elements.ObaShapeElement;
import org.onebusaway.android.util.LocationUtils;
Expand Down Expand Up @@ -191,6 +192,12 @@ private void zoom() {
}

private static int resolveColor(Leg leg) {
// Color for transit routes when planning a trip
if (TraverseMode.valueOf(leg.mode).isTransit()) {
return OTPConstants.OTP_TRANSIT_COLOR;
}

// Calculates color for non-trip planning situations
if (leg.routeColor != null) {
try {
return Long.decode("0xFF" + leg.routeColor).intValue();
Expand All @@ -199,10 +206,7 @@ private static int resolveColor(Leg leg) {
}
}

if (TraverseMode.valueOf(leg.mode).isTransit()) {
return Color.BLUE;
}

// Color defaults to grey which represents walking
return Color.GRAY;
}

Expand Down