commit
00edc64b24
3 changed files with 12 additions and 1 deletions
|
@ -170,6 +170,7 @@
|
|||
|
||||
|
||||
<color name="color_transparent">#0000</color>
|
||||
<color name="color_black_transparent">#90000000</color>
|
||||
<color name="widgettext_night">#ffC8C8C8</color>
|
||||
<!-- widgettext_shadow_night is the same as widget background color for non-transparent night skin (from box_night_free_simple.9.png) -->
|
||||
<color name="widgettext_shadow_night">#dc262626</color>
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.osmand.Location;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.views.DirectionDrawable;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.hardware.Sensor;
|
||||
|
@ -97,6 +98,12 @@ public class UiUtilities {
|
|||
return light ? R.color.icon_color : R.color.color_white;
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public static int getContrastColor(Context context, @ColorInt int color, boolean transparent) {
|
||||
// Counting the perceptive luminance - human eye favors green color...
|
||||
double luminance = 1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255;
|
||||
return luminance < 0.5 ? transparent ? ContextCompat.getColor(context, R.color.color_black_transparent) : Color.BLACK : Color.WHITE;
|
||||
}
|
||||
|
||||
public UpdateLocationViewCache getUpdateLocationViewCache(){
|
||||
UpdateLocationViewCache uvc = new UpdateLocationViewCache();
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.widget.TextView;
|
|||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.transport.TransportStopRoute;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -43,7 +44,9 @@ public class TransportStopRouteAdapter extends ArrayAdapter<TransportStopRoute>
|
|||
TextView transportStopRouteTextView = (TextView) convertView.findViewById(R.id.transport_stop_route_text);
|
||||
transportStopRouteTextView.setText(getAdjustedRouteRef(transportStopRoute.route.getRef()));
|
||||
GradientDrawable gradientDrawableBg = (GradientDrawable) transportStopRouteTextView.getBackground();
|
||||
gradientDrawableBg.setColor(transportStopRoute.getColor(app, nightMode));
|
||||
int bgColor = transportStopRoute.getColor(app, nightMode);
|
||||
gradientDrawableBg.setColor(bgColor);
|
||||
transportStopRouteTextView.setTextColor(UiUtilities.getContrastColor(app, bgColor, true));
|
||||
}
|
||||
|
||||
convertView.setOnClickListener(new View.OnClickListener() {
|
||||
|
|
Loading…
Reference in a new issue