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