From a3ca01255d19f64ba5078bc79ced61cbecad1ee1 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Thu, 31 Mar 2016 17:50:12 +0300 Subject: [PATCH 1/3] Description initialization. --- .../net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java index 03b1094f26..04a9d9b8a5 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java @@ -129,11 +129,13 @@ public class MapWidgetRegistry { public T getSideWidget(Class cl) { for (MapWidgetRegInfo ri : leftWidgetSet) { if (cl.isInstance(ri)) { + //noinspection unchecked return (T) ri.widget; } } for (MapWidgetRegInfo ri : rightWidgetSet) { if (cl.isInstance(ri)) { + //noinspection unchecked return (T) ri.widget; } } @@ -368,11 +370,13 @@ public class MapWidgetRegistry { } final boolean selected = r.visibleCollapsed(mode) || r.visible(mode); + final String desc = mapActivity.getString(R.string.shared_string_collapse); contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(r.messageId, mapActivity) .setIcon(r.drawableMenu) .setSelected(selected) .setColor(selected ? R.color.osmand_orange : defaultColor) .setSecondaryIcon(R.drawable.ic_action_additional_option) + .setDescription(r.visibleCollapsed(mode) ? desc : null) .setListener(new ContextMenuAdapter.OnRowItemClick() { @Override public boolean onRowItemClick(final ArrayAdapter adapter, @@ -423,7 +427,6 @@ public class MapWidgetRegistry { ContextMenuItem item = adapter.getItem(position); item.setSelected(visible); item.setColorRes(visible ? R.color.osmand_orange : defaultColor); - String desc = mapActivity.getString(R.string.shared_string_collapse); item.setDescription(visible && collapsed ? desc : null); adapter.notifyDataSetChanged(); } From 15ee1beed9f1a10f1585369f776972c27765be10 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Thu, 31 Mar 2016 18:47:08 +0300 Subject: [PATCH 2/3] Made description clickable. --- OsmAnd/res/layout/list_item_text_button.xml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/OsmAnd/res/layout/list_item_text_button.xml b/OsmAnd/res/layout/list_item_text_button.xml index 7611b0883b..348c41958f 100644 --- a/OsmAnd/res/layout/list_item_text_button.xml +++ b/OsmAnd/res/layout/list_item_text_button.xml @@ -10,23 +10,21 @@ - + tools:text="topbar"/> \ No newline at end of file From 3da81e2a482ca1932c3b7c87901ce1423fb4348c Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Fri, 1 Apr 2016 11:04:21 +0300 Subject: [PATCH 3/3] Fixes #2390. And some cleanup. --- .../plus/activities/MapActivityActions.java | 68 ++----------------- 1 file changed, 5 insertions(+), 63 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index de50c71fe2..f914e1bc98 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -52,6 +52,7 @@ import net.osmand.plus.liveupdates.OsmLiveActivity; import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.views.BaseMapLayer; +import net.osmand.plus.views.MapControlsLayer; import net.osmand.plus.views.MapTileLayer; import net.osmand.plus.views.OsmandMapTileView; @@ -90,18 +91,6 @@ public class MapActivityActions implements DialogProvider { routingHelper = mapActivity.getMyApplication().getRoutingHelper(); } - /* - public void addAsWaypoint(double latitude, double longitude, PointDescription pd) { - TargetPointsHelper targets = getMyApplication().getTargetPointsHelper(); - boolean destination = (targets.getPointToNavigate() == null); - - targets.navigateToPoint(new LatLon(latitude, longitude), true, - destination ? -1 : targets.getIntermediatePoints().size(), - pd); - - openIntermediateEditPointsDialog(); - } - */ public void addAsTarget(double latitude, double longitude, PointDescription pd) { TargetPointsHelper targets = getMyApplication().getTargetPointsHelper(); targets.navigateToPoint(new LatLon(latitude, longitude), true, targets.getIntermediatePoints().size() + 1, @@ -223,6 +212,7 @@ public class MapActivityActions implements DialogProvider { @Override public void onClick(View v) { String name = edit.getText().toString(); + //noinspection ResultOfMethodCallIgnored fileDir.mkdirs(); File toSave = fileDir; if (name.length() > 0) { @@ -476,14 +466,6 @@ public class MapActivityActions implements DialogProvider { public ApplicationMode getRouteMode(LatLon from) { ApplicationMode mode = settings.DEFAULT_APPLICATION_MODE.get(); ApplicationMode selected = settings.APPLICATION_MODE.get(); - OsmandApplication app = mapActivity.getMyApplication(); - TargetPointsHelper targets = app.getTargetPointsHelper(); - if (from == null) { - Location ll = app.getLocationProvider().getLastKnownLocation(); - if (ll != null) { - from = new LatLon(ll.getLatitude(), ll.getLongitude()); - } - } if (selected != ApplicationMode.DEFAULT) { mode = selected; } else if (mode == ApplicationMode.DEFAULT) { @@ -492,18 +474,6 @@ public class MapActivityActions implements DialogProvider { settings.LAST_ROUTING_APPLICATION_MODE != ApplicationMode.DEFAULT) { mode = settings.LAST_ROUTING_APPLICATION_MODE; } - // didn't provide good results -// if (from != null && targets.getPointToNavigate() != null) { -// double dist = MapUtils.getDistance(from, targets.getPointToNavigate().getLatitude(), -// targets.getPointToNavigate().getLongitude()); -// if (dist >= 50000 && mode.isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)) { -// mode = ApplicationMode.CAR; -// } else if (dist >= 300000 && mode.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) { -// mode = ApplicationMode.CAR; -// } else if (dist < 2000 && mode.isDerivedRoutingFrom(ApplicationMode.CAR)) { -// mode = ApplicationMode.PEDESTRIAN; -// } -// } } return mode; } @@ -637,15 +607,9 @@ public class MapActivityActions implements DialogProvider { .setListener(new ContextMenuAdapter.ItemClickListener() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { - MapActivity.clearPrevActivityIntent(); - if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) { - if (settings.USE_MAP_MARKERS.get()) { - setFirstMapMarkerAsTarget(); - } - enterRoutePlanningMode(null, null); - } else { - mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode(); - mapActivity.refreshMap(); + MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer(); + if (mapControlsLayer != null) { + mapControlsLayer.doRoute(false); } return true; } @@ -791,23 +755,6 @@ public class MapActivityActions implements DialogProvider { //////////// Others OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper); - -// optionsMenuHelper.item(R.string.shared_string_exit).colorIcon(R.drawable.ic_action_quit_dark ) -// .listen(new OnContextMenuClick() { -// @Override -// public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { -// // 1. Work for almost all cases when user open apps from main menu -//// Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getMapActivity()); -//// newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); -//// // not exit -//// newIntent.putExtra(AppInitializer.APP_EXIT_KEY, AppInitializer.APP_EXIT_CODE); -//// mapActivity.startActivity(newIntent); -// // In future when map will be main screen this should change -// app.closeApplication(mapActivity); -// return true; -// } -// }).reg(); - getMyApplication().getAppCustomization().prepareOptionsMenu(mapActivity, optionsMenuHelper); return optionsMenuHelper; } @@ -820,10 +767,6 @@ public class MapActivityActions implements DialogProvider { mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.ROUTE_PREFERENCES); } - private TargetPointsHelper getTargets() { - return mapActivity.getMyApplication().getTargetPointsHelper(); - } - public void stopNavigationWithoutConfirm() { if (getMyApplication().getLocationProvider().getLocationSimulation().isRouteAnimating()) { getMyApplication().getLocationProvider().getLocationSimulation().startStopRouteAnimation(mapActivity); @@ -855,7 +798,6 @@ public class MapActivityActions implements DialogProvider { return builder.show(); } - public void whereAmIDialog() { final List items = new ArrayList<>(); items.add(getString(R.string.show_location));