Fix map markers widget icon
This commit is contained in:
parent
fc583bd5c5
commit
542dd99d23
3 changed files with 21 additions and 6 deletions
|
@ -4,6 +4,7 @@ import android.graphics.Bitmap;
|
|||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.DrawableRes;
|
||||
|
@ -78,6 +79,15 @@ public class IconsCache {
|
|||
return getDrawable(id, colorId, scale);
|
||||
}
|
||||
|
||||
public Drawable getIcon(@DrawableRes int backgroundId, @DrawableRes int id, @ColorRes int colorId) {
|
||||
Drawable b = getDrawable(backgroundId, 0);
|
||||
Drawable f = getDrawable(id, colorId);
|
||||
Drawable[] layers = new Drawable[2];
|
||||
layers[0] = b;
|
||||
layers[1] = f;
|
||||
return new LayerDrawable(layers);
|
||||
}
|
||||
|
||||
public Drawable getContentIcon(@DrawableRes int id) {
|
||||
return getDrawable(id, app.getSettings().isLightContent() ? R.color.icon_color : 0);
|
||||
}
|
||||
|
|
|
@ -287,6 +287,7 @@ public class MapMarkersWidgetsFactory {
|
|||
public TextInfoWidget createMapMarkerControl(final MapActivity map, final boolean firstMarker) {
|
||||
DistanceToPointInfoControl ctrl = new DistanceToPointInfoControl(map, 0, 0) {
|
||||
private int cachedMarkerColorIndex = -1;
|
||||
private Boolean cachedNightMode = null;
|
||||
|
||||
@Override
|
||||
public LatLon getPointToNavigate() {
|
||||
|
@ -321,11 +322,14 @@ public class MapMarkersWidgetsFactory {
|
|||
boolean res = super.updateInfo(drawSettings);
|
||||
|
||||
if (marker.colorIndex != -1) {
|
||||
if (marker.colorIndex != cachedMarkerColorIndex) {
|
||||
if (marker.colorIndex != cachedMarkerColorIndex
|
||||
|| cachedNightMode == null || cachedNightMode != isNight()) {
|
||||
setImageDrawable(map.getMyApplication().getIconsCache()
|
||||
.getIcon(R.drawable.widget_marker_day,
|
||||
.getIcon(isNight() ? R.drawable.widget_marker_night : R.drawable.widget_marker_day,
|
||||
R.drawable.widget_marker_triangle,
|
||||
MapMarkerDialogHelper.getMapMarkerColorId(marker.colorIndex)));
|
||||
cachedMarkerColorIndex = marker.colorIndex;
|
||||
cachedNightMode = isNight();
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
|
|
@ -85,10 +85,11 @@ public class TextInfoWidget {
|
|||
nightIcon = widgetNightIcon;
|
||||
setImageDrawable(!isNight ? dayIcon : nightIcon);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean isNight() {
|
||||
return isNight;
|
||||
}
|
||||
|
||||
public void setContentDescription(CharSequence text) {
|
||||
if (contentTitle != null) {
|
||||
view.setContentDescription(contentTitle + " " + text); //$NON-NLS-1$
|
||||
|
|
Loading…
Reference in a new issue