From 765763e0232e67bd69507eea0c049b4ac1b062dc Mon Sep 17 00:00:00 2001 From: madwasp79 Date: Wed, 10 Jul 2019 10:04:19 +0300 Subject: [PATCH 1/4] fix for context menu scroll glich --- .../plus/mapcontextmenu/MenuBuilder.java | 20 ++++++++++++++++++- .../plus/mapcontextmenu/MenuController.java | 12 ----------- .../builders/AmenityMenuBuilder.java | 9 --------- .../FavouritePointMenuController.java | 4 +--- .../RenderedObjectMenuController.java | 1 - .../plus/osmedit/EditPOIMenuBuilder.java | 7 ------- 6 files changed, 20 insertions(+), 33 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 6fd74ac945..cc79032281 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -32,6 +32,7 @@ import android.widget.TextView; import android.widget.Toast; import net.osmand.AndroidUtils; +import net.osmand.PlatformUtil; import net.osmand.binary.BinaryMapIndexReader; import net.osmand.data.Amenity; import net.osmand.data.LatLon; @@ -65,15 +66,18 @@ import java.util.Comparator; import java.util.LinkedList; import java.util.List; import java.util.Map; +import org.apache.commons.logging.Log; import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask.GetImageCardsListener; public class MenuBuilder { - + public static final float SHADOW_HEIGHT_TOP_DP = 17f; public static final int TITLE_LIMIT = 60; protected static final String[] arrowChars = new String[]{"=>"," - "}; + private static final Log LOG = PlatformUtil.getLog(MenuBuilder.class); + protected MapActivity mapActivity; protected MapContextMenu mapContextMenu; protected OsmandApplication app; @@ -193,6 +197,7 @@ public class MenuBuilder { } public void setCollapsed(boolean collapsed) { + if (collapsedPref != null) { collapsedPref.set(collapsed); } else { @@ -309,6 +314,7 @@ public class MenuBuilder { buildPlainMenuItems(view); } buildInternal(view); + buildCoordinatesRow(view); if (showOnlinePhotos) { buildNearestPhotosRow(view); } @@ -316,6 +322,8 @@ public class MenuBuilder { // buildAfter(view); } + + private boolean showTransportRoutes() { return showLocalTransportRoutes() || showNearbyTransportRoutes(); } @@ -412,6 +420,15 @@ public class MenuBuilder { } } + private void buildCoordinatesRow(View view) { + Map locationData = PointDescription.getLocationData(mapActivity, latLon.getLatitude(), latLon.getLongitude(), true); + String title = locationData.get(PointDescription.LOCATION_LIST_HEADER); + locationData.remove(PointDescription.LOCATION_LIST_HEADER); + CollapsableView cv = getLocationCollapsableView(locationData); + buildRow(view, R.drawable.ic_action_get_my_location, null, title, 0, true, cv, false, 1, + false, null, false); + } + private void startLoadingImages() { if (onlinePhotoCardsRow == null) { return; @@ -450,6 +467,7 @@ public class MenuBuilder { } protected void buildInternal(View view) { + } protected void buildTopInternal(View view) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index f39f04d598..6f3060c392 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -282,18 +282,6 @@ public abstract class MenuController extends BaseMenuController implements Colla addAltitudeToPlainItems(); addPrecisionToPlainItems(); } - addMyLocationToPlainItems(latLon); - } - - protected void addMyLocationToPlainItems(LatLon latlon) { - final MapActivity mapActivity = getMapActivity(); - if (mapActivity != null) { - Map locationData = PointDescription.getLocationData(mapActivity, latlon.getLatitude(), latlon.getLongitude(), true); - String title = locationData.get(PointDescription.LOCATION_LIST_HEADER); - locationData.remove(PointDescription.LOCATION_LIST_HEADER); - CollapsableView cv = builder.getLocationCollapsableView(locationData); - addPlainMenuItem(R.drawable.ic_action_get_my_location, title, false, false, true, cv, null); - } } protected void addSpeedToPlainItems() { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index 664235c83e..6f5cbb0115 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -672,15 +672,6 @@ public class AmenityMenuBuilder extends MenuBuilder { buildRow(view, R.drawable.ic_action_openstreetmap_logo, null, link + (amenity.getId() >> 1), 0, false, null, true, 0, true, null, false); } - - Map locationData = PointDescription.getLocationData(mapActivity, amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(), true); - String title = locationData.get(PointDescription.LOCATION_LIST_HEADER); - locationData.remove(PointDescription.LOCATION_LIST_HEADER); - CollapsableView cv = getLocationCollapsableView(locationData); - - buildRow(view, R.drawable.ic_action_get_my_location, null, title, 0, true, cv, - true, 1, false, null, false); - } private String getFormattedInt(String value) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java index 081a59ed73..751cfef136 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java @@ -166,8 +166,6 @@ public class FavouritePointMenuController extends MenuController { if (originObject instanceof Amenity) { AmenityMenuController.addTypeMenuItem((Amenity) originObject, builder); } - } else { - addMyLocationToPlainItems(latLon); - } + } } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/RenderedObjectMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/RenderedObjectMenuController.java index 31fe449ccb..0a300013ff 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/RenderedObjectMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/RenderedObjectMenuController.java @@ -126,7 +126,6 @@ public class RenderedObjectMenuController extends MenuController { } addPlainMenuItem(R.drawable.ic_action_info_dark, null, link + (renderedObject.getId() >> MapObject.NON_AMENITY_ID_RIGHT_SHIFT), true, true, null); } - addMyLocationToPlainItems(latLon); } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java index d4838df9cb..eeb9eb4fb0 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java @@ -71,12 +71,5 @@ public class EditPOIMenuBuilder extends MenuBuilder { buildRow(view, R.drawable.ic_action_info_dark, null, text, 0, false, null, false, 0, false, null, false); } } - - Map locationData = PointDescription.getLocationData(mapActivity, osmPoint.getLatitude(), osmPoint.getLongitude(), true); - String title = locationData.get(PointDescription.LOCATION_LIST_HEADER); - locationData.remove(PointDescription.LOCATION_LIST_HEADER); - CollapsableView cv = getLocationCollapsableView(locationData); - buildRow(view, R.drawable.ic_action_get_my_location, null, title, 0, true, cv, - true, 1, false, null, false); } } From 0f6f33c690baf72595dbeecfeb9525f3b070e5e3 Mon Sep 17 00:00:00 2001 From: madwasp79 Date: Wed, 10 Jul 2019 10:16:19 +0300 Subject: [PATCH 2/4] code clean up --- .../src/net/osmand/plus/mapcontextmenu/MenuBuilder.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index cc79032281..e9a8db2b47 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -32,7 +32,6 @@ import android.widget.TextView; import android.widget.Toast; import net.osmand.AndroidUtils; -import net.osmand.PlatformUtil; import net.osmand.binary.BinaryMapIndexReader; import net.osmand.data.Amenity; import net.osmand.data.LatLon; @@ -66,7 +65,6 @@ import java.util.Comparator; import java.util.LinkedList; import java.util.List; import java.util.Map; -import org.apache.commons.logging.Log; import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask.GetImageCardsListener; @@ -76,8 +74,6 @@ public class MenuBuilder { public static final int TITLE_LIMIT = 60; protected static final String[] arrowChars = new String[]{"=>"," - "}; - private static final Log LOG = PlatformUtil.getLog(MenuBuilder.class); - protected MapActivity mapActivity; protected MapContextMenu mapContextMenu; protected OsmandApplication app; @@ -197,7 +193,6 @@ public class MenuBuilder { } public void setCollapsed(boolean collapsed) { - if (collapsedPref != null) { collapsedPref.set(collapsed); } else { @@ -321,8 +316,6 @@ public class MenuBuilder { buildPluginRows(view); // buildAfter(view); } - - private boolean showTransportRoutes() { return showLocalTransportRoutes() || showNearbyTransportRoutes(); @@ -467,7 +460,6 @@ public class MenuBuilder { } protected void buildInternal(View view) { - } protected void buildTopInternal(View view) { From 9d2538e936686bb524d930899111e25f7cd8507f Mon Sep 17 00:00:00 2001 From: madwasp79 Date: Wed, 10 Jul 2019 10:19:38 +0300 Subject: [PATCH 3/4] code clean up --- OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index e9a8db2b47..cf89d319e5 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -69,7 +69,7 @@ import java.util.Map; import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask.GetImageCardsListener; public class MenuBuilder { - + public static final float SHADOW_HEIGHT_TOP_DP = 17f; public static final int TITLE_LIMIT = 60; protected static final String[] arrowChars = new String[]{"=>"," - "}; @@ -316,7 +316,7 @@ public class MenuBuilder { buildPluginRows(view); // buildAfter(view); } - + private boolean showTransportRoutes() { return showLocalTransportRoutes() || showNearbyTransportRoutes(); } From 4fdcd2c3cb38c352a97da88177a3068cbdd085c7 Mon Sep 17 00:00:00 2001 From: madwasp79 Date: Wed, 10 Jul 2019 12:38:26 +0300 Subject: [PATCH 4/4] removed coordiantes from mapdatamenu --- .../osmand/plus/mapcontextmenu/MenuBuilder.java | 8 +++++++- .../builders/MapDataMenuBuilder.java | 17 +++++++++++++++++ .../controllers/MapDataMenuController.java | 4 ++-- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/MapDataMenuBuilder.java diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index cf89d319e5..72d9cf0f23 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -309,7 +309,9 @@ public class MenuBuilder { buildPlainMenuItems(view); } buildInternal(view); - buildCoordinatesRow(view); + if (needBuildCoordinatesRow()) { + buildCoordinatesRow(view); + } if (showOnlinePhotos) { buildNearestPhotosRow(view); } @@ -355,6 +357,10 @@ public class MenuBuilder { protected boolean needBuildPlainMenuItems() { return true; } + + protected boolean needBuildCoordinatesRow() { + return true; + } protected void buildPluginRows(View view) { for (OsmandPlugin plugin : menuPlugins) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/MapDataMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/MapDataMenuBuilder.java new file mode 100644 index 0000000000..531f6729d1 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/MapDataMenuBuilder.java @@ -0,0 +1,17 @@ +package net.osmand.plus.mapcontextmenu.builders; + +import android.support.annotation.NonNull; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.mapcontextmenu.MenuBuilder; + +public class MapDataMenuBuilder extends MenuBuilder { + + public MapDataMenuBuilder(@NonNull MapActivity mapActivity) { + super(mapActivity); + } + + @Override + protected boolean needBuildCoordinatesRow() { + return false; + } +} diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java index 1290095be7..f216a847d8 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java @@ -28,8 +28,8 @@ import net.osmand.plus.download.IndexItem; import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.plus.liveupdates.LiveUpdatesHelper; -import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuController; +import net.osmand.plus.mapcontextmenu.builders.MapDataMenuBuilder; import net.osmand.plus.srtmplugin.SRTMPlugin; import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider; import net.osmand.plus.views.DownloadedRegionsLayer.DownloadMapObject; @@ -57,7 +57,7 @@ public class MapDataMenuController extends MenuController { private DownloadIndexesThread downloadThread; public MapDataMenuController(@NonNull MapActivity mapActivity, @NonNull PointDescription pointDescription, final @NonNull DownloadMapObject mapObject) { - super(new MenuBuilder(mapActivity), pointDescription, mapActivity); + super(new MapDataMenuBuilder(mapActivity), pointDescription, mapActivity); this.mapObject = mapObject; indexItem = mapObject.getIndexItem(); localIndexInfo = mapObject.getLocalIndexInfo();