Add navigation icon

This commit is contained in:
Dima-1 2020-01-13 19:08:21 +02:00
parent f18c8c8f77
commit 3b71bf4371
7 changed files with 246 additions and 145 deletions

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/bottom">
<bitmap
android:src="@drawable/map_car_bearing_bottom"
android:gravity="bottom|center" />
</item>
<item android:id="@+id/center">
<bitmap
android:src="@drawable/map_car_bearing_center"
android:gravity="bottom|center" />
</item>
<item android:id="@+id/top">
<bitmap
android:src="@drawable/map_car_bearing_top"
android:gravity="bottom|center" />
</item>
</layer-list>

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/bottom">
<bitmap
android:src="@drawable/map_nautical_bearing_bottom"
android:gravity="bottom|center" />
</item>
<item android:id="@+id/center">
<bitmap
android:src="@drawable/map_nautical_bearing_center"
android:gravity="bottom|center" />
</item>
<item android:id="@+id/top">
<bitmap
android:src="@drawable/map_nautical_bearing_top"
android:gravity="bottom|center" />
</item>
</layer-list>

View file

@ -18,4 +18,16 @@
android:layout_margin="4dp"
android:background="@drawable/bg_select_icon_button" />
<ImageView
android:id="@+id/headingIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical" />
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical" />
</FrameLayout>

View file

@ -50,13 +50,13 @@
android:selectable="false" />
<PreferenceCategory
android:key="select_map_icon"
android:key="select_location_icon"
android:layout="@layout/preference_category_with_descr"
android:summary="@string/select_map_icon_descr"
android:title="@string/select_map_icon" />
<Preference
android:key="map_icon_items"
android:key="location_icon_items"
android:layout="@layout/preference_color_select"
android:selectable="false"/>

View file

@ -78,14 +78,8 @@ public class ApplicationMode {
private int minDistanceForTurn = 50;
private int arrivalDistance = 90;
private int offRouteDistance = 350;
private int bearingIconDay = R.drawable.map_pedestrian_bearing;
// private int bearingIconNight = R.drawable.map_pedestrian_bearing_night;
private int headingIconDay = R.drawable.map_pedestrian_location_view_angle;
// private int headingIconNight = R.drawable.map_pedestrian_location_view_angle_night;
private int locationIcon = R.drawable.map_default_location_xml;
// private int locationIconNight = R.drawable.map_pedestrian_location_night;
// private int locationIconDayLost = R.drawable.map_pedestrian_location_lost;
// private int locationIconNightLost = R.drawable.map_pedestrian_location_lost_night;
private NavigationIcon bearingIcon = NavigationIcon.CAR;
private LocationIcon locationIcon = LocationIcon.DEFAULT;
private ApplicationMode(int key, String stringKey) {
this.keyName = key;
@ -96,29 +90,42 @@ public class ApplicationMode {
/*
* DEFAULT("Browse map"), CAR("Car"), BICYCLE("Bicycle"), PEDESTRIAN("Pedestrian"); NAUTICAL("boat"); PUBLIC_TRANSPORT("Public transport"); AIRCRAFT("Aircraft")
*/
public static final ApplicationMode DEFAULT = createBase(R.string.app_mode_default, "default").speed(1.5f, 5).arrivalDistance(90).defLocation().
icon(R.drawable.ic_world_globe_dark, R.drawable.map_world_globe_dark, "ic_world_globe_dark").reg();
public static final ApplicationMode DEFAULT = createBase(R.string.app_mode_default, "default").speed(1.5f, 5).arrivalDistance(90)
.locationIcon(LocationIcon.DEFAULT).navigationIcon(NavigationIcon.CAR)
.icon(R.drawable.ic_world_globe_dark, R.drawable.map_world_globe_dark, "ic_world_globe_dark").reg();
public static final ApplicationMode CAR = createBase(R.string.app_mode_car, "car").speed(12.5f, 35).carLocation().
icon(R.drawable.ic_action_car_dark, R.drawable.map_action_car_dark, "ic_action_car_dark").setRoutingProfile("car").description(R.string.base_profile_descr_car).reg();
public static final ApplicationMode CAR = createBase(R.string.app_mode_car, "car").speed(12.5f, 35)
.locationIcon(LocationIcon.CAR).navigationIcon(NavigationIcon.CAR)
.icon(R.drawable.ic_action_car_dark, R.drawable.map_action_car_dark, "ic_action_car_dark")
.setRoutingProfile("car").description(R.string.base_profile_descr_car).reg();
public static final ApplicationMode BICYCLE = createBase(R.string.app_mode_bicycle, "bicycle").speed(2.77f, 15).arrivalDistance(60).offRouteDistance(50).bicycleLocation().
icon(R.drawable.ic_action_bicycle_dark, R.drawable.map_action_bicycle_dark,"ic_action_bicycle_dark").setRoutingProfile("bicycle").description(R.string.base_profile_descr_bicycle).reg();
public static final ApplicationMode BICYCLE = createBase(R.string.app_mode_bicycle, "bicycle").speed(2.77f, 15).arrivalDistance(60).offRouteDistance(50)
.locationIcon(LocationIcon.BICYCLE).navigationIcon(NavigationIcon.CAR)
.icon(R.drawable.ic_action_bicycle_dark, R.drawable.map_action_bicycle_dark,"ic_action_bicycle_dark")
.setRoutingProfile("bicycle").description(R.string.base_profile_descr_bicycle).reg();
public static final ApplicationMode PEDESTRIAN = createBase(R.string.app_mode_pedestrian, "pedestrian").speed(1.11f, 5).arrivalDistance(45).offRouteDistance(20).
icon(R.drawable.ic_action_pedestrian_dark, R.drawable.map_action_pedestrian_dark, "ic_action_pedestrian_dark").setRoutingProfile("pedestrian").description(R.string.base_profile_descr_pedestrian).reg();
public static final ApplicationMode PEDESTRIAN = createBase(R.string.app_mode_pedestrian, "pedestrian").speed(1.11f, 5).arrivalDistance(45).offRouteDistance(20)
.icon(R.drawable.ic_action_pedestrian_dark, R.drawable.map_action_pedestrian_dark, "ic_action_pedestrian_dark")
.setRoutingProfile("pedestrian").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.map_action_bus_dark,"ic_action_bus_dark").setRoutingProfile("public_transport").description(R.string.base_profile_descr_public_transport).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.map_action_bus_dark,"ic_action_bus_dark")
.setRoutingProfile("public_transport").description(R.string.base_profile_descr_public_transport).reg();
public static final ApplicationMode BOAT = createBase(R.string.app_mode_boat, "boat").speed(1.38f, 20).nauticalLocation().
icon(R.drawable.ic_action_sail_boat_dark, R.drawable.map_action_sail_boat_dark, "ic_action_sail_boat_dark").setRoutingProfile("boat").description(R.string.base_profile_descr_boat).reg();
public static final ApplicationMode BOAT = createBase(R.string.app_mode_boat, "boat").speed(1.38f, 20)
.locationIcon(LocationIcon.DEFAULT).navigationIcon(NavigationIcon.NAUTICAL)
.icon(R.drawable.ic_action_sail_boat_dark, R.drawable.map_action_sail_boat_dark, "ic_action_sail_boat_dark")
.setRoutingProfile("boat").description(R.string.base_profile_descr_boat).reg();
public static final ApplicationMode AIRCRAFT = createBase(R.string.app_mode_aircraft, "aircraft").speed(40f, 100).carLocation().
icon(R.drawable.ic_action_aircraft, R.drawable.map_action_aircraft,"ic_action_aircraft").setRouteService(RouteService.STRAIGHT).setRoutingProfile("STRAIGHT_LINE_MODE").description(R.string.base_profile_descr_aircraft).reg();
public static final ApplicationMode AIRCRAFT = createBase(R.string.app_mode_aircraft, "aircraft").speed(40f, 100)
.locationIcon(LocationIcon.CAR).navigationIcon(NavigationIcon.CAR)
.icon(R.drawable.ic_action_aircraft, R.drawable.map_action_aircraft,"ic_action_aircraft").setRouteService(RouteService.STRAIGHT)
.setRoutingProfile("STRAIGHT_LINE_MODE").description(R.string.base_profile_descr_aircraft).reg();
public static final ApplicationMode SKI = createBase(R.string.app_mode_skiing, "ski").speed(1.38f, 15).arrivalDistance(60).offRouteDistance(50).bicycleLocation().
icon(R.drawable.ic_action_skiing, R.drawable.ic_action_skiing,"ic_action_skiing").setRoutingProfile("ski").description(R.string.base_profile_descr_ski).reg();
public static final ApplicationMode SKI = createBase(R.string.app_mode_skiing, "ski").speed(1.38f, 15).arrivalDistance(60).offRouteDistance(50)
.locationIcon(LocationIcon.BICYCLE).navigationIcon(NavigationIcon.CAR)
.icon(R.drawable.ic_action_skiing, R.drawable.ic_action_skiing,"ic_action_skiing")
.setRoutingProfile("ski").description(R.string.base_profile_descr_ski).reg();
private static class ApplicationModeBean {
@ -206,14 +213,8 @@ public class ApplicationMode {
m.minDistanceForTurn = m.parentAppMode.minDistanceForTurn;
m.arrivalDistance = m.parentAppMode.arrivalDistance;
m.offRouteDistance = m.parentAppMode.offRouteDistance;
m.bearingIconDay = m.parentAppMode.bearingIconDay;
// m.bearingIconNight = m.parentAppMode.bearingIconNight;
m.headingIconDay = m.parentAppMode.headingIconDay;
// m.headingIconNight = m.parentAppMode.headingIconNight;
m.bearingIcon = m.parentAppMode.bearingIcon;
m.locationIcon = m.parentAppMode.locationIcon;
// m.locationIconNight = m.parentAppMode.locationIconNight;
// m.locationIconDayLost = m.parentAppMode.locationIconDayLost;
// m.locationIconNightLost = m.parentAppMode.locationIconNightLost;
values.add(applicationMode);
if (applicationMode.getOrder() == 0 && !values.isEmpty()) {
applicationMode.setOrder(values.size());
@ -250,63 +251,44 @@ public class ApplicationMode {
public ApplicationModeBuilder parent(ApplicationMode parent) {
applicationMode.parentAppMode = parent;
if (parent == CAR || parent == AIRCRAFT) {
this.carLocation();
} else if (parent == BICYCLE || parent == SKI) {
this.bicycleLocation();
} else if (parent == BOAT) {
this.nauticalLocation();
} else {
this.defLocation();
}
applicationMode.locationIcon=parent.locationIcon;
applicationMode.bearingIcon=parent.bearingIcon;
return this;
}
public ApplicationModeBuilder carLocation() {
applicationMode.bearingIconDay = R.drawable.map_car_bearing;
// applicationMode.bearingIconNight = R.drawable.map_car_bearing_night;
applicationMode.headingIconDay = R.drawable.map_car_location_view_angle;
// applicationMode.headingIconNight = R.drawable.map_car_location_view_angle_night;
applicationMode.locationIcon = R.drawable.map_car_location_xml;
// applicationMode.locationIconNight = R.drawable.map_car_location_night;
// applicationMode.locationIconDayLost = R.drawable.map_car_location_lost;
// applicationMode.locationIconNightLost = R.drawable.map_car_location_lost_night;
ApplicationModeBuilder locationIcon(LocationIcon locationIcon){
applicationMode.locationIcon = locationIcon;
return this;
}
public ApplicationModeBuilder bicycleLocation() {
applicationMode.bearingIconDay = R.drawable.map_bicycle_bearing;
// applicationMode.bearingIconNight = R.drawable.map_bicycle_bearing_night;
applicationMode.headingIconDay = R.drawable.map_bicycle_location_view_angle;
// applicationMode.headingIconNight = R.drawable.map_bicycle_location_view_angle_night;
applicationMode.locationIcon = R.drawable.map_bicycle_location_xml;
// applicationMode.locationIconNight = R.drawable.map_bicycle_location_night;
// applicationMode.locationIconDayLost = R.drawable.map_bicycle_location_lost;
// applicationMode.locationIconNightLost = R.drawable.map_bicycle_location_lost_night;
ApplicationModeBuilder navigationIcon(NavigationIcon navigationIcon){
applicationMode.bearingIcon = navigationIcon;
return this;
}
public ApplicationModeBuilder defLocation() {
applicationMode.bearingIconDay = R.drawable.map_pedestrian_bearing;
// applicationMode.bearingIconNight = R.drawable.map_pedestrian_bearing_night;
applicationMode.headingIconDay = R.drawable.map_default_location_view_angle;
// applicationMode.headingIconNight = R.drawable.map_default_location_view_angle_night;
applicationMode.locationIcon = R.drawable.map_default_location_xml;
// applicationMode.locationIconNight = R.drawable.map_pedestrian_location_night;
// applicationMode.locationIconDayLost = R.drawable.map_pedestrian_location_lost;
// applicationMode.locationIconNightLost = R.drawable.map_pedestrian_location_lost_night;
return this;
}
public ApplicationModeBuilder nauticalLocation() {
applicationMode.bearingIconDay = R.drawable.map_nautical_bearing;
// applicationMode.bearingIconNight = R.drawable.map_nautical_bearing_night;
applicationMode.headingIconDay = R.drawable.map_nautical_location_view_angle;
// applicationMode.headingIconNight = R.drawable.map_nautical_location_view_angle_night;
applicationMode.locationIcon = R.drawable.map_nautical_location;
// applicationMode.locationIconNight = R.drawable.map_nautical_location_night;
return this;
}
// public ApplicationModeBuilder carLocation() {
// applicationMode.bearingIcon = NavigationIcon.CAR;
// applicationMode.locationIcon = LocationIcon.CAR;
// return this;
// }
//
// public ApplicationModeBuilder bicycleLocation() {
// applicationMode.bearingIcon = NavigationIcon.CAR;
// applicationMode.locationIcon =LocationIcon.BICYCLE;
// return this;
// }
//
// public ApplicationModeBuilder defLocation() {
// applicationMode.bearingIcon = NavigationIcon.CAR;
// applicationMode.locationIcon = LocationIcon.DEFAULT;
// return this;
// }
//
// public ApplicationModeBuilder nauticalLocation() {
// applicationMode.bearingIcon =NavigationIcon.NAUTICAL;
// applicationMode.locationIcon = LocationIcon.DEFAULT;
// return this;
// }
public ApplicationModeBuilder speed(float defSpeed, int distForTurn) {
applicationMode.defaultSpeed = defSpeed;
@ -508,38 +490,14 @@ public class ApplicationMode {
return getDefaultSpeed() > 10;
}
public int getResourceBearingDay() {
return bearingIconDay;
public NavigationIcon getNavigationIcon() {
return bearingIcon;
}
// public int getResourceBearingNight() {
// return bearingIconNight;
// }
public int getResourceHeadingDay() {
return headingIconDay;
}
// public int getResourceHeadingNight() {
// return headingIconNight;
// }
public int getResourceLocationDay() {
public LocationIcon getLocationIcon() {
return locationIcon;
}
// public int getResourceLocationNight() {
// return locationIconNight;
// }
// public int getResourceLocationDayLost() {
// return locationIconDayLost;
// }
// public int getResourceLocationNightLost() {
// return locationIconNightLost;
// }
public String getStringKey() {
return stringKey;
}
@ -955,4 +913,43 @@ public class ApplicationMode {
return CAR.getResStringId();
}
}
public enum LocationIcon{
DEFAULT(R.drawable.map_default_location_xml,R.drawable.map_default_location_view_angle),
CAR(R.drawable.map_car_location_xml,R.drawable.map_car_location_view_angle),
BICYCLE(R.drawable.map_bicycle_location_xml,R.drawable.map_bicycle_location_view_angle);
LocationIcon(@DrawableRes int iconId, @DrawableRes int headingIconId){
this.iconId = iconId;
this.headingIconId = headingIconId;
}
@DrawableRes
private final int iconId;
@DrawableRes
private final int headingIconId;
public int getIconId() {
return iconId;
}
public int getHeadingIconId() {
return headingIconId;
}
}
public enum NavigationIcon{
CAR(R.drawable.map_car_navigation_xml),
NAUTICAL(R.drawable.map_nautical_navigation_xml);
NavigationIcon(@DrawableRes int iconId){
this.iconId = iconId;
}
@DrawableRes
private final int iconId;
public int getIconId() {
return iconId;
}
}
}

View file

@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Matrix;
import android.graphics.PorterDuff;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
@ -25,6 +26,7 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
@ -60,8 +62,8 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
private static final String SELECT_ICON = "select_icon";
private static final String COLOR_ITEMS = "color_items";
private static final String ICON_ITEMS = "icon_items";
private static final String SELECT_MAP_ICON = "select_map_icon";
private static final String MAP_ICON_ITEMS = "map_icon_items";
private static final String SELECT_LOCATION_ICON = "select_location_icon";
private static final String LOCATION_ICON_ITEMS = "location_icon_items";
private static final String SELECT_NAV_ICON = "select_nav_icon";
private static final String NAV_ICON_ITEMS = "nav_icon_items";
@ -170,7 +172,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
protected void setupPreferences() {
findPreference(SELECT_COLOR).setIconSpaceReserved(false);
findPreference(SELECT_ICON).setIconSpaceReserved(false);
findPreference(SELECT_MAP_ICON).setIconSpaceReserved(false);
findPreference(SELECT_LOCATION_ICON).setIconSpaceReserved(false);
findPreference(SELECT_NAV_ICON).setIconSpaceReserved(false);
}
@ -370,44 +372,23 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
for (int iconRes : icons) {
View iconItem = createIconItemView(iconRes, iconItems);
iconItems.addView(iconItem, new FlowLayout.LayoutParams(0, 0));
ImageView outlineCircle = iconItem.findViewById(R.id.outlineCircle);
outlineCircle.setVisibility(View.GONE);
}
setIconNewColor(changedProfile.iconRes);
} else if (MAP_ICON_ITEMS.equals(preference.getKey())) {
} else if (LOCATION_ICON_ITEMS.equals(preference.getKey())) {
mapIconItems = (FlowLayout) holder.findViewById(R.id.color_items);
mapIconItems.removeAllViews();
ArrayList<Integer> icons = ApplicationMode.ProfileIcons.getIcons();
for(int iconRes:icons) {
FrameLayout iconItemView = (FrameLayout) UiUtilities.getInflater(getContext(), isNightMode())
.inflate(R.layout.preference_select_icon_button, mapIconItems, false);
for (ApplicationMode.LocationIcon iconRes : ApplicationMode.LocationIcon.values()) {
View iconItemView = createLocationIconView(iconRes, mapIconItems);
mapIconItems.addView(iconItemView, new FlowLayout.LayoutParams(0, 0));
ImageView coloredRect = mapIconItems.findViewById(R.id.backgroundRect);
AndroidUtils.setBackground(coloredRect,
UiUtilities.tintDrawable(ContextCompat.getDrawable(app, R.drawable.bg_select_icon_button),
UiUtilities.getColorWithAlpha(ContextCompat.getColor(app, R.color.icon_color_default_light), 0.1f)));
coloredRect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// if (iconRes != changedProfile.iconRes) {
// updateIconSelector(iconRes);
// }
}
});
ImageView outlineCircle = mapIconItems.findViewById(R.id.outlineRect);
GradientDrawable circleContourDrawable = (GradientDrawable) ContextCompat.getDrawable(app, R.drawable.bg_select_icon_button_outline);
int changedProfileColor = ContextCompat.getColor(app, changedProfile.color.getColor(
app.getDaynightHelper().isNightModeForMapControls()));
if (circleContourDrawable != null) {
circleContourDrawable.setStroke(AndroidUtils.dpToPx(app, 2), changedProfileColor);
}
outlineCircle.setImageDrawable(circleContourDrawable);
outlineCircle.setVisibility(View.VISIBLE);
}
} else if (NAV_ICON_ITEMS.equals(preference.getKey())) {
navIconItems = (FlowLayout) holder.findViewById(R.id.color_items);
navIconItems.removeAllViews();
for (ApplicationMode.NavigationIcon iconRes : ApplicationMode.NavigationIcon.values()) {
View iconItemView = createNavigationIconView(iconRes, navIconItems);
navIconItems.addView(iconItemView, new FlowLayout.LayoutParams(0, 0));
}
}
}
@ -465,6 +446,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
}
}
});
iconItemView.findViewById(R.id.outlineCircle).setVisibility(View.GONE);
iconItemView.setTag(iconRes);
return iconItemView;
}
@ -477,9 +459,83 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
checkMark.setImageDrawable(app.getUIUtilities().getIcon(changedProfile.iconRes, R.color.icon_color_default_light));
AndroidUtils.setBackground(iconItem.findViewById(R.id.backgroundCircle),
UiUtilities.tintDrawable(ContextCompat.getDrawable(app, R.drawable.circle_background_light),
UiUtilities.getColorWithAlpha(ContextCompat.getColor(app, R.color.icon_color_default_light), 0.1f)));
UiUtilities.getColorWithAlpha(ContextCompat.getColor(app, R.color.icon_color_default_light), 0.1f)));
changedProfile.iconRes = iconRes;
updateProfileButton();
updateLocationIconSelector();
}
private View createLocationIconView(ApplicationMode.LocationIcon locationIcon, ViewGroup rootView) {
FrameLayout locationIconView = (FrameLayout) UiUtilities.getInflater(getContext(), isNightMode())
.inflate(R.layout.preference_select_icon_button, rootView, false);
locationIconView.<ImageView>findViewById(R.id.icon)
.setImageDrawable(ContextCompat.getDrawable(app, locationIcon.getIconId()));
locationIconView.<ImageView>findViewById(R.id.headingIcon)
.setImageDrawable(ContextCompat.getDrawable(app, locationIcon.getHeadingIconId()));
ImageView coloredRect = locationIconView.findViewById(R.id.backgroundRect);
AndroidUtils.setBackground(coloredRect,
UiUtilities.tintDrawable(ContextCompat.getDrawable(app, R.drawable.bg_select_icon_button),
UiUtilities.getColorWithAlpha(ContextCompat.getColor(app, R.color.icon_color_default_light), 0.1f)));
coloredRect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// if (locationIcon != changedProfile.locationIcon) {
// updateIconSelector(locationIcon);
// }
}
});
ImageView outlineRect = locationIconView.findViewById(R.id.outlineRect);
GradientDrawable rectContourDrawable = (GradientDrawable) ContextCompat.getDrawable(app, R.drawable.bg_select_icon_button_outline);
int changedProfileColor = ContextCompat.getColor(app, changedProfile.color.getColor(
app.getDaynightHelper().isNightModeForMapControls()));
if (rectContourDrawable != null) {
rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 2), changedProfileColor);
}
outlineRect.setImageDrawable(rectContourDrawable);
outlineRect.setVisibility(View.GONE);
return locationIconView;
}
private void updateLocationIconSelector() {
}
private View createNavigationIconView(ApplicationMode.NavigationIcon navigationIcon, ViewGroup rootView) {
FrameLayout navigationIconView = (FrameLayout) UiUtilities.getInflater(getContext(), isNightMode())
.inflate(R.layout.preference_select_icon_button, rootView, false);
ImageView imageView = navigationIconView.findViewById(R.id.icon);
imageView.setImageDrawable(ContextCompat.getDrawable(app, navigationIcon.getIconId()));
Matrix matrix = new Matrix();
imageView.setScaleType(ImageView.ScaleType.MATRIX);
matrix.postRotate((float) -90, imageView.getDrawable().getIntrinsicWidth() / 2,
imageView.getDrawable().getIntrinsicHeight() / 2);
imageView.setImageMatrix(matrix);
ImageView coloredRect = navigationIconView.findViewById(R.id.backgroundRect);
AndroidUtils.setBackground(coloredRect,
UiUtilities.tintDrawable(ContextCompat.getDrawable(app, R.drawable.bg_select_icon_button),
UiUtilities.getColorWithAlpha(ContextCompat.getColor(app, R.color.icon_color_default_light), 0.1f)));
coloredRect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// if (navigationIcon != changedProfile.navigationIcon) {
// updateIconSelector(navigationIcon);
// }
}
});
ImageView outlineRect = navigationIconView.findViewById(R.id.outlineRect);
GradientDrawable rectContourDrawable = (GradientDrawable) ContextCompat.getDrawable(app, R.drawable.bg_select_icon_button_outline);
int changedProfileColor = ContextCompat.getColor(app, changedProfile.color.getColor(
app.getDaynightHelper().isNightModeForMapControls()));
if (rectContourDrawable != null) {
rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 2), changedProfileColor);
}
outlineRect.setImageDrawable(rectContourDrawable);
outlineRect.setVisibility(View.GONE);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(164, AndroidUtils.dpToPx(app, 80));
navigationIconView.setLayoutParams(params);
return navigationIconView;
}
private void updateNavigationIconSelector() {
}
private void setIconNewColor(int iconRes) {

View file

@ -171,8 +171,8 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
this.color = appMode.getIconColorInfo().getColor(nighMode);
this.nm = nighMode;
this.locationOutdated = locationOutdated;
bearingIcon = BitmapFactory.decodeResource(view.getResources(), appMode.getResourceBearingDay());
headingIcon = BitmapFactory.decodeResource(view.getResources(), appMode.getResourceHeadingDay());
bearingIcon = BitmapFactory.decodeResource(view.getResources(), appMode.getNavigationIcon().getIconId());
headingIcon = BitmapFactory.decodeResource(view.getResources(), appMode.getLocationIcon().getHeadingIconId());
if (locationOutdated) {
locationPaint.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(view.getContext(),
R.color.icon_color_secondary_light), PorterDuff.Mode.SRC_IN));
@ -180,7 +180,7 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
locationPaint.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(view.getContext(), color),
PorterDuff.Mode.SRC_IN));
}
LayerDrawable layerDrawable = (LayerDrawable) ContextCompat.getDrawable(view.getContext(), appMode.getResourceLocationDay());
LayerDrawable layerDrawable = (LayerDrawable) ContextCompat.getDrawable(view.getContext(), appMode.getLocationIcon().getIconId());
if (layerDrawable != null) {
locationIconTop = ((BitmapDrawable) layerDrawable.getDrawable(0)).getBitmap();
locationIconCenter = ((BitmapDrawable) layerDrawable.getDrawable(1)).getBitmap();