Tiny refactoring.

This commit is contained in:
GaidamakUA 2016-03-30 19:01:22 +03:00
parent a7a0db4fcd
commit ebe9acfbbe
3 changed files with 10 additions and 9 deletions

View file

@ -86,7 +86,7 @@ public class ContextMenuItem {
if (getColorRes() != INVALID_ID) {
return getColorRes();
} else {
return getDefaultColorRes(context);
return IconsCache.getDefaultColorRes(context);
}
}
@ -95,13 +95,6 @@ public class ContextMenuItem {
return ContextCompat.getColor(context, getThemedColorRes(context));
}
@ColorRes
public static int getDefaultColorRes(Context context) {
final OsmandApplication app = (OsmandApplication) context.getApplicationContext();
boolean light = app.getSettings().isLightContent();
return light ? R.color.icon_color : R.color.color_white;
}
@DrawableRes
public int getSecondaryIcon() {
return secondaryIcon;

View file

@ -1,5 +1,6 @@
package net.osmand.plus;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.PorterDuff;
import android.graphics.drawable.BitmapDrawable;
@ -104,4 +105,10 @@ public class IconsCache {
return getDrawable(id, light ? R.color.icon_color : 0);
}
@ColorRes
public static int getDefaultColorRes(Context context) {
final OsmandApplication app = (OsmandApplication) context.getApplicationContext();
boolean light = app.getSettings().isLightContent();
return light ? R.color.icon_color : R.color.color_white;
}
}

View file

@ -17,6 +17,7 @@ import android.widget.LinearLayout;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.MapMarkersMode;
import net.osmand.plus.OsmandSettings.OsmandPreference;
@ -381,7 +382,7 @@ public class MapWidgetRegistry {
private void addControls(final MapActivity mapActivity, final ContextMenuAdapter contextMenuAdapter,
Set<MapWidgetRegInfo> top, final ApplicationMode mode) {
@ColorRes final int defaultColor = ContextMenuItem.getDefaultColorRes(mapActivity);
@ColorRes final int defaultColor = IconsCache.getDefaultColorRes(mapActivity);
for (final MapWidgetRegInfo r : top) {
if (mode == ApplicationMode.DEFAULT) {
if ("intermediate_distance".equals(r.key) || "distance".equals(r.key) || "time".equals(r.key)) {