Remove iconMapRes
This commit is contained in:
parent
73af038d30
commit
32e9d6e314
6 changed files with 26 additions and 41 deletions
|
@ -64,7 +64,6 @@ public class ApplicationMode {
|
|||
|
||||
private ApplicationMode parentAppMode;
|
||||
private int iconRes = R.drawable.ic_world_globe_dark;
|
||||
private int iconMapRes = R.drawable.ic_world_globe_dark;
|
||||
|
||||
private int minDistanceForTurn = 50;
|
||||
private int arrivalDistance = 90;
|
||||
|
@ -80,40 +79,40 @@ public class ApplicationMode {
|
|||
*/
|
||||
public static final ApplicationMode DEFAULT = createBase(R.string.app_mode_default, "default")
|
||||
.distanceForTurn(5).arrivalDistance(90)
|
||||
.icon(R.drawable.ic_world_globe_dark, R.drawable.ic_world_globe_dark).reg();
|
||||
.icon(R.drawable.ic_world_globe_dark).reg();
|
||||
|
||||
public static final ApplicationMode CAR = createBase(R.string.app_mode_car, "car")
|
||||
.distanceForTurn(35)
|
||||
.icon(R.drawable.ic_action_car_dark, R.drawable.ic_action_car_dark)
|
||||
.icon(R.drawable.ic_action_car_dark)
|
||||
.description(R.string.base_profile_descr_car).reg();
|
||||
|
||||
public static final ApplicationMode BICYCLE = createBase(R.string.app_mode_bicycle, "bicycle")
|
||||
.distanceForTurn(15).arrivalDistance(60).offRouteDistance(50)
|
||||
.icon(R.drawable.ic_action_bicycle_dark, R.drawable.ic_action_bicycle_dark)
|
||||
.icon(R.drawable.ic_action_bicycle_dark)
|
||||
.description(R.string.base_profile_descr_bicycle).reg();
|
||||
|
||||
public static final ApplicationMode PEDESTRIAN = createBase(R.string.app_mode_pedestrian, "pedestrian")
|
||||
.distanceForTurn(5).arrivalDistance(45).offRouteDistance(20)
|
||||
.icon(R.drawable.ic_action_pedestrian_dark, R.drawable.ic_action_pedestrian_dark)
|
||||
.icon(R.drawable.ic_action_pedestrian_dark)
|
||||
.description(R.string.base_profile_descr_pedestrian).reg();
|
||||
|
||||
public static final ApplicationMode PUBLIC_TRANSPORT = createBase(R.string.app_mode_public_transport, "public_transport")
|
||||
.icon(R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_dark)
|
||||
.icon(R.drawable.ic_action_bus_dark)
|
||||
.description(R.string.base_profile_descr_public_transport).reg();
|
||||
|
||||
public static final ApplicationMode BOAT = createBase(R.string.app_mode_boat, "boat")
|
||||
.distanceForTurn(20)
|
||||
.icon(R.drawable.ic_action_sail_boat_dark, R.drawable.ic_action_sail_boat_dark)
|
||||
.icon(R.drawable.ic_action_sail_boat_dark)
|
||||
.description(R.string.base_profile_descr_boat).reg();
|
||||
|
||||
public static final ApplicationMode AIRCRAFT = createBase(R.string.app_mode_aircraft, "aircraft")
|
||||
.distanceForTurn(100)
|
||||
.icon(R.drawable.ic_action_aircraft, R.drawable.ic_action_aircraft)
|
||||
.icon(R.drawable.ic_action_aircraft)
|
||||
.description(R.string.base_profile_descr_aircraft).reg();
|
||||
|
||||
public static final ApplicationMode SKI = createBase(R.string.app_mode_skiing, "ski")
|
||||
.distanceForTurn(15).arrivalDistance(60).offRouteDistance(50)
|
||||
.icon(R.drawable.ic_action_skiing, R.drawable.ic_action_skiing)
|
||||
.icon(R.drawable.ic_action_skiing)
|
||||
.description(R.string.base_profile_descr_ski).reg();
|
||||
|
||||
public static List<ApplicationMode> values(OsmandApplication app) {
|
||||
|
@ -347,11 +346,6 @@ public class ApplicationMode {
|
|||
return iconRes;
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
public int getMapIconRes() {
|
||||
return iconMapRes;
|
||||
}
|
||||
|
||||
public void setIconResName(String iconResName) {
|
||||
if (!Algorithms.isEmpty(iconResName)) {
|
||||
app.getSettings().ICON_RES_NAME.setModeValue(this, iconResName);
|
||||
|
@ -362,11 +356,8 @@ public class ApplicationMode {
|
|||
String iconResName = app.getSettings().ICON_RES_NAME.getModeValue(this);
|
||||
try {
|
||||
int iconRes = app.getResources().getIdentifier(iconResName, "drawable", app.getPackageName());
|
||||
// int iconMapRes = app.getResources().getIdentifier(iconResName.replace("ic_", "map_"), "drawable", app.getPackageName());
|
||||
int iconMapRes = iconRes; //app.getResources().getIdentifier(iconResName.replace("ic_", "map_"), "drawable", app.getPackageName());
|
||||
if (iconRes != 0 && iconMapRes != 0) {
|
||||
if (iconRes != 0) {
|
||||
this.iconRes = iconRes;
|
||||
this.iconMapRes = iconMapRes;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// return R.drawable.map_world_globe_dark;
|
||||
|
@ -730,8 +721,7 @@ public class ApplicationMode {
|
|||
return applicationMode;
|
||||
}
|
||||
|
||||
public ApplicationModeBuilder icon(int iconRes, int iconMapRes) {
|
||||
applicationMode.iconMapRes = iconMapRes;
|
||||
public ApplicationModeBuilder icon(int iconRes) {
|
||||
applicationMode.iconRes = iconRes;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -960,20 +960,18 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
if (model.isAddressSpecified()) {
|
||||
distanceText.setText(String.format(getString(R.string.ltr_or_rtl_combine_via_comma), distance.trim(), model.getAddress()));
|
||||
}
|
||||
int iconSize = (int) getResources().getDimension(R.dimen.favorites_icon_size);
|
||||
if(model.getBackgroundType().equals(FavouritePoint.BackgroundType.CIRCLE)){
|
||||
int color = visible ? model.getColor() : getResources().getColor(disabledIconColor);
|
||||
int col = color == 0 || color == Color.BLACK ? getResources().getColor(R.color.color_favorite) : color;
|
||||
int iconSize = (int) getResources().getDimension(R.dimen.standard_icon_size);
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(iconSize, iconSize, CENTER);
|
||||
icon.setLayoutParams(lp);
|
||||
icon.setImageDrawable(UiUtilities.createTintedDrawable(getActivity(),model.getIconId(),col));
|
||||
iconSize = (int) getResources().getDimension(R.dimen.standard_icon_size);
|
||||
}else {
|
||||
int iconSize = (int) getResources().getDimension(R.dimen.favorites_icon_size);
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(iconSize, iconSize, CENTER);
|
||||
icon.setLayoutParams(lp);
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(),
|
||||
visible ? model.getColor() : getResources().getColor(disabledIconColor), false, model));
|
||||
}
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(iconSize, iconSize, CENTER);
|
||||
icon.setLayoutParams(lp);
|
||||
if (visible) {
|
||||
distanceText.setTextColor(getResources().getColor(R.color.color_distance));
|
||||
} else {
|
||||
|
|
|
@ -664,7 +664,7 @@ public class PlanRouteFragment extends BaseOsmAndFragment implements OsmAndLocat
|
|||
if (mapActivity != null) {
|
||||
final ImageButton appModesBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button);
|
||||
appModesBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle);
|
||||
appModesBtn.setImageDrawable(getActiveIcon(planRouteContext.getSnappedMode().getMapIconRes()));
|
||||
appModesBtn.setImageDrawable(getActiveIcon(planRouteContext.getSnappedMode().getIconRes()));
|
||||
appModesBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
|
|
@ -805,7 +805,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
|
||||
ImageButton snapToRoadBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button);
|
||||
snapToRoadBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle);
|
||||
snapToRoadBtn.setImageDrawable(getIcon(appMode.getMapIconRes(), appMode.getIconColorInfo().getColor(nightMode)));
|
||||
snapToRoadBtn.setImageDrawable(getIcon(appMode.getIconRes(), appMode.getIconColorInfo().getColor(nightMode)));
|
||||
snapToRoadBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
|
|
@ -2292,7 +2292,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
case ROUTE_INFO:
|
||||
return 0;
|
||||
case ROUTE_DETAILS:
|
||||
return app != null ? app.getRoutingHelper().getAppMode().getMapIconRes() : R.drawable.map_directions;
|
||||
return app != null ? app.getRoutingHelper().getAppMode().getIconRes() : R.drawable.map_directions;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -821,7 +821,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
|
||||
ApplicationMode appMode = settings.getApplicationMode();
|
||||
layersHud.setIconColorId(appMode.getIconColorInfo().getColor(isNight));
|
||||
if (layersHud.setIconResId(appMode.getMapIconRes())) {
|
||||
if (layersHud.setIconResId(appMode.getIconRes())) {
|
||||
layersHud.update(app, isNight);
|
||||
}
|
||||
layersHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode() && !isInPlanRouteMode()
|
||||
|
@ -1162,20 +1162,18 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
} else if (resId != 0) {
|
||||
d = ctx.getUIUtilities().getIcon(resId, nightMode ? resClrDark : resClrLight);
|
||||
}
|
||||
|
||||
if (iv instanceof ImageView) {
|
||||
int iconSize = (int) ctx.getResources().getDimension(R.dimen.standard_icon_size);
|
||||
Bitmap bitmap = Bitmap.createBitmap(iconSize, iconSize, Bitmap.Config.ARGB_8888);
|
||||
if (d != null) {
|
||||
bitmap = Bitmap.createBitmap(iconSize, iconSize, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
canvas.drawColor(0, PorterDuff.Mode.CLEAR);
|
||||
d.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
d.draw(canvas);
|
||||
}
|
||||
if (compass) {
|
||||
((ImageView) iv).setImageDrawable(new CompassDrawable(d));
|
||||
} else {
|
||||
int iconSize = (int) ctx.getResources().getDimension(R.dimen.standard_icon_size);
|
||||
Bitmap bitmap = Bitmap.createBitmap(iconSize, iconSize, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
canvas.drawColor(0, PorterDuff.Mode.CLEAR);
|
||||
if (d != null) {
|
||||
d.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
d.draw(canvas);
|
||||
}
|
||||
((ImageView) iv).setImageDrawable(new BitmapDrawable(ctx.getResources(), bitmap));
|
||||
}
|
||||
} else if (iv instanceof TextView) {
|
||||
|
@ -1183,7 +1181,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
d, null, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String getZoomLevel(@NonNull RotatedTileBox tb) {
|
||||
|
|
Loading…
Reference in a new issue