Implement new colored location icon on map
This commit is contained in:
parent
8f52d72524
commit
f09c1f8d74
12 changed files with 234 additions and 88 deletions
6
OsmAnd/res/drawable/bg_select_icon_button.xml
Normal file
6
OsmAnd/res/drawable/bg_select_icon_button.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape android:shape="rectangle"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/stroked_buttons_and_links_outline_dark" />
|
||||
<corners android:radius="2dp" />
|
||||
</shape>
|
9
OsmAnd/res/drawable/bg_select_icon_button_outline.xml
Normal file
9
OsmAnd/res/drawable/bg_select_icon_button_outline.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape android:shape="rectangle"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="2dp" />
|
||||
<stroke
|
||||
android:radius="5dp"
|
||||
android:width="2dp"
|
||||
android:color="@color/A400red" />
|
||||
</shape>
|
18
OsmAnd/res/drawable/map_bicycle_location_xml.xml
Normal file
18
OsmAnd/res/drawable/map_bicycle_location_xml.xml
Normal 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_bicycle_location_bottom"
|
||||
android:gravity="bottom|center" />
|
||||
</item>
|
||||
<item android:id="@+id/center" >
|
||||
<bitmap
|
||||
android:src="@drawable/map_bicycle_location_center"
|
||||
android:gravity="bottom|center" />
|
||||
</item>
|
||||
<item android:id="@+id/top" >
|
||||
<bitmap
|
||||
android:src="@drawable/map_bicycle_location_top"
|
||||
android:gravity="bottom|center" />
|
||||
</item>
|
||||
</layer-list>
|
18
OsmAnd/res/drawable/map_car_location_xml.xml
Normal file
18
OsmAnd/res/drawable/map_car_location_xml.xml
Normal 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_location_bottom"
|
||||
android:gravity="bottom|center" />
|
||||
</item>
|
||||
<item android:id="@+id/center" >
|
||||
<bitmap
|
||||
android:src="@drawable/map_car_location_center"
|
||||
android:gravity="bottom|center" />
|
||||
</item>
|
||||
<item android:id="@+id/top" >
|
||||
<bitmap
|
||||
android:src="@drawable/map_car_location_top"
|
||||
android:gravity="bottom|center" />
|
||||
</item>
|
||||
</layer-list>
|
18
OsmAnd/res/drawable/map_default_location_xml.xml
Normal file
18
OsmAnd/res/drawable/map_default_location_xml.xml
Normal 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_default_location_bottom"
|
||||
android:gravity="bottom|center" />
|
||||
</item>
|
||||
<item android:id="@+id/center" >
|
||||
<bitmap
|
||||
android:src="@drawable/map_default_location_center"
|
||||
android:gravity="bottom|center" />
|
||||
</item>
|
||||
<item android:id="@+id/top" >
|
||||
<bitmap
|
||||
android:src="@drawable/map_default_location_top"
|
||||
android:gravity="bottom|center" />
|
||||
</item>
|
||||
</layer-list>
|
|
@ -3,7 +3,7 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="6dp">
|
||||
android:padding="7dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/outlineCircle"
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
android:id="@+id/color_items"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp" />
|
||||
android:layout_margin="4dp" />
|
||||
</LinearLayout>
|
21
OsmAnd/res/layout/preference_select_icon_button.xml
Normal file
21
OsmAnd/res/layout/preference_select_icon_button.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="6dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/outlineRect"
|
||||
android:layout_width="164dp"
|
||||
android:layout_height="128dp"
|
||||
app:srcCompat="@drawable/bg_select_icon_button_outline" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/backgroundRect"
|
||||
android:layout_width="156dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_margin="4dp"
|
||||
android:background="@drawable/bg_select_icon_button" />
|
||||
|
||||
</FrameLayout>
|
|
@ -49,15 +49,15 @@
|
|||
android:layout="@layout/simple_divider_item"
|
||||
android:selectable="false" />
|
||||
|
||||
<!--PreferenceCategory
|
||||
<PreferenceCategory
|
||||
android:key="select_map_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:layout="@layout/preference_with_descr"
|
||||
android:title="@string/select_map_icon"
|
||||
android:layout="@layout/preference_color_select"
|
||||
android:selectable="false"/>
|
||||
|
||||
<Preference
|
||||
|
@ -67,12 +67,13 @@
|
|||
<PreferenceCategory
|
||||
android:key="select_nav_icon"
|
||||
android:layout="@layout/preference_category_with_descr"
|
||||
android:summary="@string/select_nav_icon_descr"
|
||||
android:title="@string/select_navigation_icon" />
|
||||
|
||||
<Preference
|
||||
android:key="nav_icon_items"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:layout="@layout/preference_color_select"
|
||||
android:title="@string/select_navigation_icon"
|
||||
android:selectable="false"/-->
|
||||
android:selectable="false"/>
|
||||
|
||||
</PreferenceScreen>
|
|
@ -79,13 +79,13 @@ public class ApplicationMode {
|
|||
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 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 locationIconDay = R.drawable.map_pedestrian_location;
|
||||
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 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 ApplicationMode(int key, String stringKey) {
|
||||
this.keyName = key;
|
||||
|
@ -207,13 +207,13 @@ public class ApplicationMode {
|
|||
m.arrivalDistance = m.parentAppMode.arrivalDistance;
|
||||
m.offRouteDistance = m.parentAppMode.offRouteDistance;
|
||||
m.bearingIconDay = m.parentAppMode.bearingIconDay;
|
||||
m.bearingIconNight = m.parentAppMode.bearingIconNight;
|
||||
// m.bearingIconNight = m.parentAppMode.bearingIconNight;
|
||||
m.headingIconDay = m.parentAppMode.headingIconDay;
|
||||
m.headingIconNight = m.parentAppMode.headingIconNight;
|
||||
m.locationIconDay = m.parentAppMode.locationIconDay;
|
||||
m.locationIconNight = m.parentAppMode.locationIconNight;
|
||||
m.locationIconDayLost = m.parentAppMode.locationIconDayLost;
|
||||
m.locationIconNightLost = m.parentAppMode.locationIconNightLost;
|
||||
// m.headingIconNight = m.parentAppMode.headingIconNight;
|
||||
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());
|
||||
|
@ -264,47 +264,47 @@ public class ApplicationMode {
|
|||
|
||||
public ApplicationModeBuilder carLocation() {
|
||||
applicationMode.bearingIconDay = R.drawable.map_car_bearing;
|
||||
applicationMode.bearingIconNight = R.drawable.map_car_bearing_night;
|
||||
// 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.locationIconDay = R.drawable.map_car_location;
|
||||
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;
|
||||
// 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;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApplicationModeBuilder bicycleLocation() {
|
||||
applicationMode.bearingIconDay = R.drawable.map_bicycle_bearing;
|
||||
applicationMode.bearingIconNight = R.drawable.map_bicycle_bearing_night;
|
||||
// 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.locationIconDay = R.drawable.map_bicycle_location;
|
||||
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;
|
||||
// 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;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApplicationModeBuilder defLocation() {
|
||||
applicationMode.bearingIconDay = R.drawable.map_pedestrian_bearing;
|
||||
applicationMode.bearingIconNight = R.drawable.map_pedestrian_bearing_night;
|
||||
// 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.locationIconDay = R.drawable.map_pedestrian_location;
|
||||
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;
|
||||
// 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.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.locationIconDay = R.drawable.map_nautical_location;
|
||||
applicationMode.locationIconNight = R.drawable.map_nautical_location_night;
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -512,33 +512,33 @@ public class ApplicationMode {
|
|||
return bearingIconDay;
|
||||
}
|
||||
|
||||
public int getResourceBearingNight() {
|
||||
return bearingIconNight;
|
||||
}
|
||||
// public int getResourceBearingNight() {
|
||||
// return bearingIconNight;
|
||||
// }
|
||||
|
||||
public int getResourceHeadingDay() {
|
||||
return headingIconDay;
|
||||
}
|
||||
|
||||
public int getResourceHeadingNight() {
|
||||
return headingIconNight;
|
||||
}
|
||||
// public int getResourceHeadingNight() {
|
||||
// return headingIconNight;
|
||||
// }
|
||||
|
||||
public int getResourceLocationDay() {
|
||||
return locationIconDay;
|
||||
return locationIcon;
|
||||
}
|
||||
|
||||
public int getResourceLocationNight() {
|
||||
return locationIconNight;
|
||||
}
|
||||
// public int getResourceLocationNight() {
|
||||
// return locationIconNight;
|
||||
// }
|
||||
|
||||
public int getResourceLocationDayLost() {
|
||||
return locationIconDayLost;
|
||||
}
|
||||
// public int getResourceLocationDayLost() {
|
||||
// return locationIconDayLost;
|
||||
// }
|
||||
|
||||
public int getResourceLocationNightLost() {
|
||||
return locationIconNightLost;
|
||||
}
|
||||
// public int getResourceLocationNightLost() {
|
||||
// return locationIconNightLost;
|
||||
// }
|
||||
|
||||
public String getStringKey() {
|
||||
return stringKey;
|
||||
|
|
|
@ -60,8 +60,10 @@ 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 SELECT_NAV_ICON = "select_nav_icon";
|
||||
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_NAV_ICON = "select_nav_icon";
|
||||
private static final String NAV_ICON_ITEMS = "nav_icon_items";
|
||||
|
||||
public static final String PROFILE_NAME_KEY = "profile_name_key";
|
||||
public static final String PROFILE_STRINGKEY_KEY = "profile_stringkey_key";
|
||||
|
@ -76,6 +78,8 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
|
|||
private EditText profileName;
|
||||
private FlowLayout colorItems;
|
||||
private FlowLayout iconItems;
|
||||
private FlowLayout mapIconItems;
|
||||
private FlowLayout navIconItems;
|
||||
private OsmandTextFieldBoxes profileNameOtfb;
|
||||
private View saveButton;
|
||||
|
||||
|
@ -166,8 +170,8 @@ 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_NAV_ICON).setIconSpaceReserved(false);
|
||||
findPreference(SELECT_MAP_ICON).setIconSpaceReserved(false);
|
||||
findPreference(SELECT_NAV_ICON).setIconSpaceReserved(false);
|
||||
}
|
||||
|
||||
@SuppressLint("InlinedApi")
|
||||
|
@ -370,6 +374,40 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
|
|||
outlineCircle.setVisibility(View.GONE);
|
||||
}
|
||||
setIconNewColor(changedProfile.iconRes);
|
||||
} else if (MAP_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);
|
||||
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())) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,12 @@ import android.graphics.Canvas;
|
|||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
|
@ -23,6 +28,9 @@ import org.apache.commons.logging.Log;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import static android.graphics.Paint.ANTI_ALIAS_FLAG;
|
||||
import static android.graphics.Paint.FILTER_BITMAP_FLAG;
|
||||
|
||||
public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
|
||||
private static final Log LOG = PlatformUtil.getLog(PointLocationLayer.class);
|
||||
|
||||
|
@ -30,15 +38,19 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
|
|||
protected final static int RADIUS = 7;
|
||||
|
||||
private Paint locationPaint;
|
||||
private Paint headingPaint;
|
||||
private Paint area;
|
||||
private Paint aroundArea;
|
||||
|
||||
private OsmandMapTileView view;
|
||||
|
||||
private ApplicationMode appMode;
|
||||
private int color;
|
||||
private Bitmap bearingIcon;
|
||||
private Bitmap headingIcon;
|
||||
private Bitmap locationIcon;
|
||||
private Bitmap locationIconCenter;
|
||||
private Bitmap locationIconTop;
|
||||
private Bitmap locationIconBottom;
|
||||
private OsmAndLocationProvider locationProvider;
|
||||
private MapViewTrackingUtilities mapViewTrackingUtilities;
|
||||
private boolean nm;
|
||||
|
@ -53,6 +65,9 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
|
|||
locationPaint.setAntiAlias(true);
|
||||
locationPaint.setFilterBitmap(true);
|
||||
|
||||
headingPaint = new Paint(ANTI_ALIAS_FLAG | FILTER_BITMAP_FLAG);
|
||||
|
||||
|
||||
area = new Paint();
|
||||
area.setColor(view.getResources().getColor(R.color.pos_area));
|
||||
|
||||
|
@ -119,7 +134,7 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
|
|||
canvas.save();
|
||||
canvas.rotate(heading - 180, locationX, locationY);
|
||||
canvas.drawBitmap(headingIcon, locationX - headingIcon.getWidth() / 2,
|
||||
locationY - headingIcon.getHeight() / 2, locationPaint);
|
||||
locationY - headingIcon.getHeight() / 2, headingPaint);
|
||||
canvas.restore();
|
||||
|
||||
}
|
||||
|
@ -131,8 +146,18 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
|
|||
canvas.drawBitmap(bearingIcon, locationX - bearingIcon.getWidth() / 2,
|
||||
locationY - bearingIcon.getHeight() / 2, locationPaint);
|
||||
} else {
|
||||
canvas.drawBitmap(locationIcon, locationX - locationIcon.getWidth() / 2,
|
||||
locationY - locationIcon.getHeight() / 2, locationPaint);
|
||||
if (locationIconTop != null) {
|
||||
canvas.drawBitmap(locationIconTop, locationX - locationIconCenter.getWidth() / 2,
|
||||
locationY - locationIconCenter.getHeight() / 2, headingPaint);
|
||||
}
|
||||
if (locationIconCenter != null) {
|
||||
canvas.drawBitmap(locationIconCenter, locationX - locationIconCenter.getWidth() / 2,
|
||||
locationY - locationIconCenter.getHeight() / 2, locationPaint);
|
||||
}
|
||||
if (locationIconBottom != null) {
|
||||
canvas.drawBitmap(locationIconBottom, locationX - locationIconCenter.getWidth() / 2,
|
||||
locationY - locationIconCenter.getHeight() / 2, headingPaint);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -147,32 +172,24 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
|
|||
public void destroyLayer() {
|
||||
|
||||
}
|
||||
public void updateIcons(ApplicationMode appMode, boolean nighMode, boolean locationOutdated) {
|
||||
if (appMode != this.appMode || this.nm != nighMode || this.locationOutdated != locationOutdated) {
|
||||
private void updateIcons(ApplicationMode appMode, boolean nighMode, boolean locationOutdated) {
|
||||
if (appMode != this.appMode || this.nm != nighMode || this.locationOutdated != locationOutdated ||
|
||||
color != appMode.getIconColorInfo().getColor(nighMode)) {
|
||||
this.appMode = appMode;
|
||||
this.color = appMode.getIconColorInfo().getColor(nighMode);
|
||||
this.nm = nighMode;
|
||||
this.locationOutdated = locationOutdated;
|
||||
final int resourceBearingDay = appMode.getResourceBearingDay();
|
||||
final int resourceBearingNight = appMode.getResourceBearingNight();
|
||||
final int resourceBearing = nighMode ? resourceBearingNight : resourceBearingDay;
|
||||
bearingIcon = BitmapFactory.decodeResource(view.getResources(), resourceBearing);
|
||||
|
||||
final int resourceHeadingDay = appMode.getResourceHeadingDay();
|
||||
final int resourceHeadingNight = appMode.getResourceHeadingNight();
|
||||
final int resourceHeading = nighMode ? resourceHeadingNight : resourceHeadingDay;
|
||||
headingIcon = BitmapFactory.decodeResource(view.getResources(), resourceHeading);
|
||||
|
||||
final int resourceLocationDay;
|
||||
final int resourceLocationNight;
|
||||
if (locationOutdated) {
|
||||
resourceLocationDay = appMode.getResourceLocationDayLost();
|
||||
resourceLocationNight = appMode.getResourceLocationNightLost();
|
||||
} else {
|
||||
resourceLocationDay = appMode.getResourceLocationDay();
|
||||
resourceLocationNight = appMode.getResourceLocationNight();
|
||||
}
|
||||
final int resourceLocation = nighMode ? resourceLocationNight : resourceLocationDay;
|
||||
locationIcon = BitmapFactory.decodeResource(view.getResources(), resourceLocation);
|
||||
bearingIcon = BitmapFactory.decodeResource(view.getResources(), appMode.getResourceBearingDay());
|
||||
headingIcon = BitmapFactory.decodeResource(view.getResources(), appMode.getResourceHeadingDay());
|
||||
final int resourceLocation = appMode.getResourceLocationDay();
|
||||
locationPaint.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(view.getContext(), color),
|
||||
PorterDuff.Mode.SRC_IN));
|
||||
LayerDrawable layerDrawable = (LayerDrawable) ContextCompat.getDrawable(view.getContext(), resourceLocation);
|
||||
if (layerDrawable != null) {
|
||||
locationIconTop = ((BitmapDrawable) layerDrawable.getDrawable(0)).getBitmap();
|
||||
locationIconCenter = ((BitmapDrawable) layerDrawable.getDrawable(1)).getBitmap();
|
||||
locationIconBottom = ((BitmapDrawable) layerDrawable.getDrawable(2)).getBitmap();
|
||||
}
|
||||
area.setColor(view.getResources().getColor(!nm ? R.color.pos_area : R.color.pos_area_night));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue