From f1b754760913593187f35c6260c924e0e5cfc6d7 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Tue, 22 Sep 2020 18:03:41 +0300 Subject: [PATCH 1/5] Fix invisible alert dialog buttons when no animation --- OsmAnd/res/values/styles.xml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/OsmAnd/res/values/styles.xml b/OsmAnd/res/values/styles.xml index e52dbdfd56..ea305b19d2 100644 --- a/OsmAnd/res/values/styles.xml +++ b/OsmAnd/res/values/styles.xml @@ -355,12 +355,12 @@ - - From c65e91561f2267705d151249fcb1c9dd9f663ba0 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Tue, 22 Sep 2020 19:53:19 +0300 Subject: [PATCH 2/5] Fix initial search radius for nearest POIs --- .../java/net/osmand/search/core/SearchCoreFactory.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java index 360fafbdf9..e5c791a780 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java @@ -923,6 +923,7 @@ public class SearchCoreFactory { public static class SearchAmenityByTypeAPI extends SearchBaseAPI { private static final int BBOX_RADIUS = 10000; + private static final int BBOX_RADIUS_NEAREST = 1000; private SearchAmenityTypesAPI searchAmenityTypesAPI; private MapPoiTypes types; private AbstractPoiType unselectedPoiType; @@ -1007,7 +1008,14 @@ public class SearchCoreFactory { } this.nameFilter = nameFilter; if (poiTypeFilter != null) { - QuadRect bbox = phrase.getRadiusBBoxToSearch(BBOX_RADIUS); + int radius = BBOX_RADIUS; + if (phrase.getRadiusLevel() == 1 && poiTypeFilter instanceof CustomSearchPoiFilter) { + String name = ((CustomSearchPoiFilter) poiTypeFilter).getFilterId(); + if ("std_null".equals(name)) { + radius = BBOX_RADIUS_NEAREST; + } + } + QuadRect bbox = phrase.getRadiusBBoxToSearch(radius); List offlineIndexes = phrase.getOfflineIndexes(); Set searchedPois = new TreeSet<>(); for (BinaryMapIndexReader r : offlineIndexes) { From 0f0c0870023f170245010f85766d28d38fd44761 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Wed, 23 Sep 2020 11:42:28 +0300 Subject: [PATCH 3/5] Fix UI track sort by --- OsmAnd/res/layout/popup_menu_item.xml | 2 + OsmAnd/res/menu/track_sort_menu_item.xml | 9 +++ .../plus/SimplePopUpMenuItemAdapter.java | 13 ++++ OsmAnd/src/net/osmand/plus/UiUtilities.java | 17 ++++- .../SelectFileBottomSheet.java | 61 ++++++--------- .../plus/myplaces/AvailableGPXFragment.java | 74 ++++++++++++------- 6 files changed, 112 insertions(+), 64 deletions(-) create mode 100644 OsmAnd/res/menu/track_sort_menu_item.xml diff --git a/OsmAnd/res/layout/popup_menu_item.xml b/OsmAnd/res/layout/popup_menu_item.xml index 66509ffa4d..9e160fcc14 100644 --- a/OsmAnd/res/layout/popup_menu_item.xml +++ b/OsmAnd/res/layout/popup_menu_item.xml @@ -22,7 +22,9 @@ android:textColor="?android:textColorPrimary" android:layout_gravity="center_vertical" android:paddingLeft="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" android:paddingRight="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding" android:paddingTop="@dimen/content_padding_small" android:paddingBottom="@dimen/content_padding_small" android:textSize="@dimen/default_list_text_size" diff --git a/OsmAnd/res/menu/track_sort_menu_item.xml b/OsmAnd/res/menu/track_sort_menu_item.xml new file mode 100644 index 0000000000..8344782092 --- /dev/null +++ b/OsmAnd/res/menu/track_sort_menu_item.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/SimplePopUpMenuItemAdapter.java b/OsmAnd/src/net/osmand/plus/SimplePopUpMenuItemAdapter.java index 4619e6a3e9..a646b7a416 100644 --- a/OsmAnd/src/net/osmand/plus/SimplePopUpMenuItemAdapter.java +++ b/OsmAnd/src/net/osmand/plus/SimplePopUpMenuItemAdapter.java @@ -12,6 +12,8 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import net.osmand.AndroidUtils; + import static net.osmand.plus.SimplePopUpMenuItemAdapter.SimplePopUpMenuItem; import java.util.List; @@ -50,6 +52,10 @@ public class SimplePopUpMenuItemAdapter } else { ivIcon.setVisibility(View.GONE); } + if (item.selected) { + convertView.setBackgroundColor(UiUtilities.getColorWithAlpha( + AndroidUtils.getColorFromAttr(getContext(), R.attr.active_color_basic), 0.1f)); + } } return convertView; } @@ -64,6 +70,7 @@ public class SimplePopUpMenuItemAdapter private CharSequence title; private Drawable icon; private View.OnClickListener onClickListener; + boolean selected; public SimplePopUpMenuItem(CharSequence title, Drawable icon) { this.title = title; @@ -75,6 +82,12 @@ public class SimplePopUpMenuItemAdapter this.onClickListener = onClickListener; } + public SimplePopUpMenuItem(CharSequence title, Drawable icon, View.OnClickListener onClickListener, + boolean selected) { + this(title, icon, onClickListener); + this.selected = selected; + } + public CharSequence getTitle() { return title; } diff --git a/OsmAnd/src/net/osmand/plus/UiUtilities.java b/OsmAnd/src/net/osmand/plus/UiUtilities.java index 5af06d9f23..f818716730 100644 --- a/OsmAnd/src/net/osmand/plus/UiUtilities.java +++ b/OsmAnd/src/net/osmand/plus/UiUtilities.java @@ -784,7 +784,7 @@ public class UiUtilities { titles.add(String.valueOf(item.getTitle())); hasIcon = hasIcon || item.getIcon() != null; } - float itemWidth = AndroidUtils.getTextMaxWidth(defaultListTextSize, titles) + contentPadding; + float itemWidth = AndroidUtils.getTextMaxWidth(defaultListTextSize, titles) + contentPadding * 2; float iconPartWidth = hasIcon ? standardIconSize + contentPaddingHalf : 0; int totalWidth = (int) (Math.max(itemWidth, minWidth) + iconPartWidth); @@ -808,4 +808,19 @@ public class UiUtilities { }); return listPopupWindow; } + + public static void showPopUpMenu(View v, final List items) { + UiUtilities.createListPopupWindow( + v.getContext(), v, v.getWidth(), items, new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + if (position < items.size()) { + View.OnClickListener listener = items.get(position).getOnClickListener(); + if (listener != null) { + listener.onClick(view); + } + } + } + }).show(); + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SelectFileBottomSheet.java b/OsmAnd/src/net/osmand/plus/measurementtool/SelectFileBottomSheet.java index cd84845584..d808f8f5e6 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/SelectFileBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/SelectFileBottomSheet.java @@ -3,8 +3,6 @@ package net.osmand.plus.measurementtool; import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; import android.view.View; import android.widget.ImageButton; import android.widget.TextView; @@ -19,6 +17,7 @@ import net.osmand.AndroidUtils; import net.osmand.IndexConstants; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; import net.osmand.plus.base.BottomSheetBehaviourDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.helpers.GpxTrackAdapter; @@ -26,7 +25,6 @@ import net.osmand.plus.helpers.GpxTrackAdapter.OnItemClickListener; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionAdapterListener; -import net.osmand.plus.widgets.IconPopupMenu; import java.io.File; import java.util.ArrayList; @@ -36,6 +34,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import static net.osmand.plus.SimplePopUpMenuItemAdapter.*; import static net.osmand.plus.helpers.GpxUiHelper.getSortedGPXFilesInfo; import static net.osmand.plus.settings.backend.OsmandSettings.*; import static net.osmand.util.Algorithms.collectDirs; @@ -73,7 +72,7 @@ public class SelectFileBottomSheet extends BottomSheetBehaviourDialogFragment { private Mode fragmentMode; private String selectedFolder; private String allFilesFolder; - TracksSortByMode tracksSortBy = TracksSortByMode.BY_DATE; + TracksSortByMode sortByMode = TracksSortByMode.BY_DATE; public void setFragmentMode(Mode fragmentMode) { this.fragmentMode = fragmentMode; @@ -105,30 +104,29 @@ public class SelectFileBottomSheet extends BottomSheetBehaviourDialogFragment { ? R.color.inactive_buttons_and_links_bg_dark : R.color.inactive_buttons_and_links_bg_light); AndroidUtils.setBackground(sortButton, background); - sortButton.setImageResource(tracksSortBy.getIconId()); + sortButton.setImageResource(sortByMode.getIconId()); sortButton.setVisibility(View.VISIBLE); sortButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - IconPopupMenu popup = new IconPopupMenu(v.getContext(), v); - final Menu menu = popup.getMenu(); - MenuItem mi; + final List items = new ArrayList<>(); for (final TracksSortByMode mode : TracksSortByMode.values()) { - mi = createMenuItem(app, menu, mode.getNameId(), mode.getNameId(), mode.getIconId(), - MenuItem.SHOW_AS_ACTION_ALWAYS, false, R.color.icon_color_default_light); - mi.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(MenuItem item) { - tracksSortBy = mode; - sortButton.setImageResource(mode.getIconId()); - updateDescription(descriptionView); - sortFileList(); - adapter.notifyDataSetChanged(); - return false; - } - }); + items.add(new SimplePopUpMenuItem( + getString(mode.getNameId()), + app.getUIUtilities().getThemedIcon(mode.getIconId()), + new View.OnClickListener() { + @Override + public void onClick(View v) { + sortByMode = mode; + sortButton.setImageResource(mode.getIconId()); + updateDescription(descriptionView); + sortFileList(); + adapter.notifyDataSetChanged(); + } + }, sortByMode == mode + )); } - popup.show(); + UiUtilities.showPopUpMenu(v, items); } }); } @@ -202,25 +200,12 @@ public class SelectFileBottomSheet extends BottomSheetBehaviourDialogFragment { } private void updateDescription(TextView descriptionView) { - String string = getString(tracksSortBy.getNameId()); + String string = getString(sortByMode.getNameId()); descriptionView.setText(String.format(getString(R.string.ltr_or_rtl_combine_via_space), getString(fragmentMode.description), Character.toLowerCase(string.charAt(0)) + string.substring(1))); } - public MenuItem createMenuItem(OsmandApplication app, Menu m, int id, int titleRes, int iconId, int menuItemType, - boolean flipIconForRtl, int iconColor) { - Drawable d = iconId == 0 ? null : app.getUIUtilities().getIcon(iconId, iconColor); - MenuItem menuItem = m.add(0, id, 0, titleRes); - if (d != null) { - if (flipIconForRtl) { - d = AndroidUtils.getDrawableForDirection(app, d); - } - menuItem.setIcon(d); - } - return menuItem; - } - private void updateFileList(HorizontalSelectionAdapter folderAdapter) { sortFileList(); adapter.setShowFolderName(showFoldersName()); @@ -238,9 +223,9 @@ public class SelectFileBottomSheet extends BottomSheetBehaviourDialogFragment { Collections.sort(gpxInfoList, new Comparator() { @Override public int compare(GPXInfo i1, GPXInfo i2) { - if (tracksSortBy == TracksSortByMode.BY_NAME_ASCENDING) { + if (sortByMode == TracksSortByMode.BY_NAME_ASCENDING) { return i1.getFileName().toLowerCase().compareTo(i2.getFileName().toLowerCase()); - } else if (tracksSortBy == TracksSortByMode.BY_NAME_DESCENDING) { + } else if (sortByMode == TracksSortByMode.BY_NAME_DESCENDING) { return -i1.getFileName().toLowerCase().compareTo(i2.getFileName().toLowerCase()); } else { long time1 = i1.getLastModified(); diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index ef184307e6..47e4343a31 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -19,7 +19,6 @@ import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; -import android.view.SubMenu; import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; @@ -70,7 +69,7 @@ import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; -import net.osmand.plus.SimplePopUpMenuItemAdapter; +import net.osmand.plus.SimplePopUpMenuItemAdapter.SimplePopUpMenuItem; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; @@ -475,24 +474,26 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement } }); - menu.addSubMenu(Menu.NONE, R.string.shared_string_sort, Menu.NONE, R.string.shared_string_sort); - final SubMenu sortMenu = menu.findItem(R.string.shared_string_sort).getSubMenu(); - mi = sortMenu.getItem(); +// menu.addSubMenu(Menu.NONE, R.string.shared_string_sort, Menu.NONE, R.string.shared_string_sort); + inflater.inflate(R.menu.track_sort_menu_item, menu); + mi = menu.findItem(R.id.action_sort); +// mi = sortMenu.getItem(); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); - final int iconColorId = isLightActionBar() ? R.color.active_buttons_and_links_text_light + int iconColorId = isLightActionBar() ? R.color.active_buttons_and_links_text_light : R.color.active_buttons_and_links_text_dark; mi.setIcon(getIcon(sortByMode.getIconId(), iconColorId)); + final List items = new ArrayList<>(); for (final TracksSortByMode mode : TracksSortByMode.values()) { - mi = createMenuItem(sortMenu, mode.getNameId(), mode.getNameId(), mode.getIconId(), - MenuItem.SHOW_AS_ACTION_ALWAYS, false, R.color.icon_color_default_light); - mi.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(MenuItem item) { - updateTracksSort(mode); - sortMenu.setIcon(getIcon(mode.getIconId(), iconColorId)); - return false; - } - }); +// mi = createMenuItem(sortMenu, mode.getNameId(), mode.getNameId(), mode.getIconId(), +// MenuItem.SHOW_AS_ACTION_ALWAYS, false, R.color.icon_color_default_light); +// mi.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { +// @Override +// public boolean onMenuItemClick(MenuItem item) { +// updateTracksSort(mode); +// sortMenu.setIcon(getIcon(mode.getIconId(), iconColorId)); +// return false; +// } +// }); } if (AndroidUiHelper.isOrientationPortrait(getActivity())) { @@ -578,7 +579,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(final MenuItem item) { int itemId = item.getItemId(); for (int i = 0; i < optionsMenuAdapter.length(); i++) { ContextMenuItem contextMenuItem = optionsMenuAdapter.getItem(i); @@ -587,6 +588,29 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement return true; } } + if (itemId == R.id.action_sort) { + Activity activity = getActivity(); + if (activity != null) { + View menuSortItemView = getActivity().findViewById(R.id.action_sort); + final List items = new ArrayList<>(); + for (final TracksSortByMode mode : TracksSortByMode.values()) { + items.add(new SimplePopUpMenuItem( + getString(mode.getNameId()), + app.getUIUtilities().getThemedIcon(mode.getIconId()), + new View.OnClickListener() { + @Override + public void onClick(View v) { + updateTracksSort(mode); + int iconColorId = isLightActionBar() ? R.color.active_buttons_and_links_text_light + : R.color.active_buttons_and_links_text_dark; + item.setIcon(getIcon(mode.getIconId(), iconColorId)); + } + }, sortByMode == mode + )); + } + UiUtilities.showPopUpMenu(menuSortItemView, items); + } + } return super.onOptionsItemSelected(item); } @@ -1492,10 +1516,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement } private void openPopUpMenu(View v, final GpxInfo gpxInfo) { - final List items = new ArrayList<>(); + final List items = new ArrayList<>(); UiUtilities iconsCache = getMyApplication().getUIUtilities(); - items.add(new SimplePopUpMenuItemAdapter.SimplePopUpMenuItem( + items.add(new SimplePopUpMenuItem( getString(R.string.shared_string_show_on_map), iconsCache.getThemedIcon(R.drawable.ic_show_on_map), new View.OnClickListener() { @@ -1509,7 +1533,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement GPXTrackAnalysis analysis; if ((analysis = getGpxTrackAnalysis(gpxInfo, app, null)) != null) { if (analysis.totalDistance != 0 && !gpxInfo.currentlyRecordingTrack) { - items.add(new SimplePopUpMenuItemAdapter.SimplePopUpMenuItem( + items.add(new SimplePopUpMenuItem( getString(R.string.analyze_on_map), iconsCache.getThemedIcon(R.drawable.ic_action_info_dark), new View.OnClickListener() { @@ -1522,7 +1546,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement } } - items.add(new SimplePopUpMenuItemAdapter.SimplePopUpMenuItem( + items.add(new SimplePopUpMenuItem( getString(R.string.shared_string_move), iconsCache.getThemedIcon(R.drawable.ic_action_folder_stroke), new View.OnClickListener() { @@ -1533,7 +1557,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement } )); - items.add(new SimplePopUpMenuItemAdapter.SimplePopUpMenuItem( + items.add(new SimplePopUpMenuItem( getString(R.string.shared_string_rename), iconsCache.getThemedIcon(R.drawable.ic_action_edit_dark), new View.OnClickListener() { @@ -1551,7 +1575,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement )); Drawable shareIcon = iconsCache.getThemedIcon((R.drawable.ic_action_gshare_dark)); - items.add(new SimplePopUpMenuItemAdapter.SimplePopUpMenuItem( + items.add(new SimplePopUpMenuItem( getString(R.string.shared_string_share), AndroidUtils.getDrawableForDirection(app, shareIcon), new View.OnClickListener() { @@ -1569,7 +1593,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement final OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class); if (osmEditingPlugin != null && osmEditingPlugin.isActive()) { - items.add(new SimplePopUpMenuItemAdapter.SimplePopUpMenuItem( + items.add(new SimplePopUpMenuItem( getString(R.string.shared_string_export), iconsCache.getThemedIcon(R.drawable.ic_action_export), new View.OnClickListener() { @@ -1581,7 +1605,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement )); } - items.add(new SimplePopUpMenuItemAdapter.SimplePopUpMenuItem( + items.add(new SimplePopUpMenuItem( getString(R.string.shared_string_delete), iconsCache.getThemedIcon(R.drawable.ic_action_delete_dark), new View.OnClickListener() { From c5415febeb264cb6bdccdb2551f03af0be7d4ad1 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Wed, 23 Sep 2020 11:54:21 +0300 Subject: [PATCH 4/5] Fix UI track sort by --- .../plus/myplaces/AvailableGPXFragment.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index 47e4343a31..9596bafb89 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -474,27 +474,12 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement } }); -// menu.addSubMenu(Menu.NONE, R.string.shared_string_sort, Menu.NONE, R.string.shared_string_sort); inflater.inflate(R.menu.track_sort_menu_item, menu); mi = menu.findItem(R.id.action_sort); -// mi = sortMenu.getItem(); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); int iconColorId = isLightActionBar() ? R.color.active_buttons_and_links_text_light : R.color.active_buttons_and_links_text_dark; mi.setIcon(getIcon(sortByMode.getIconId(), iconColorId)); - final List items = new ArrayList<>(); - for (final TracksSortByMode mode : TracksSortByMode.values()) { -// mi = createMenuItem(sortMenu, mode.getNameId(), mode.getNameId(), mode.getIconId(), -// MenuItem.SHOW_AS_ACTION_ALWAYS, false, R.color.icon_color_default_light); -// mi.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { -// @Override -// public boolean onMenuItemClick(MenuItem item) { -// updateTracksSort(mode); -// sortMenu.setIcon(getIcon(mode.getIconId(), iconColorId)); -// return false; -// } -// }); - } if (AndroidUiHelper.isOrientationPortrait(getActivity())) { menu = ((FavoritesActivity) getActivity()).getClearToolbar(true).getMenu(); From 8a59bfe127fac273200bc38a91328dc9655fe52a Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 24 Sep 2020 11:07:28 +0300 Subject: [PATCH 5/5] Use a new arrow for track direction --- .../views/layers/geometry/GpxGeometryWay.java | 4 +-- .../geometry/GpxGeometryWayContext.java | 2 +- .../layers/geometry/GpxGeometryWayDrawer.java | 36 ++++++++++--------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/layers/geometry/GpxGeometryWay.java b/OsmAnd/src/net/osmand/plus/views/layers/geometry/GpxGeometryWay.java index 76bee7cdf2..24d49df0b1 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/geometry/GpxGeometryWay.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/geometry/GpxGeometryWay.java @@ -132,7 +132,7 @@ public class GpxGeometryWay extends GeometryWay { - private static final float DIRECTION_ARROW_CIRCLE_MULTIPLIER = 1.5f; - public GpxGeometryWayDrawer(GpxGeometryWayContext context) { super(context); } @@ -33,16 +30,23 @@ public class GpxGeometryWayDrawer extends GeometryWayDrawer arrowsWayStyle.getTrackWidth()) { - Paint paint = context.getPaintIcon(); - paint.setColor(arrowsWayStyle.getTrackColor()); - paint.setStrokeWidth(arrowWidth * DIRECTION_ARROW_CIRCLE_MULTIPLIER); - canvas.drawPoint(x, y, paint); - } + float newWidth = arrowsWayStyle.getTrackWidth() / 2f; + float paintH2 = bitmap.getHeight() / 2f; + float paintW2 = newWidth / 2f; + + Matrix matrix = getMatrix(); + matrix.reset(); + matrix.postScale(newWidth / bitmap.getWidth(), 1); + matrix.postRotate((float) angle, paintW2, paintH2); + matrix.postTranslate(x - paintW2, y - paintH2); + + Paint paint = context.getPaintIconCustom(); + Integer pointColor = style.getPointColor(); + paint.setColorFilter(new PorterDuffColorFilter(pointColor, PorterDuff.Mode.SRC_IN)); + canvas.drawBitmap(bitmap, matrix, paint); } - super.draw(canvas, context); } } -} +} \ No newline at end of file