From 9a29a8a8b644812149d494021852716b19354fee Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Wed, 3 Feb 2016 18:31:40 +0200 Subject: [PATCH] Underlay map menu UI. --- .../res/layout/drawer_list_material_item.xml | 28 ++++++++++ OsmAnd/res/layout/progress_list_item.xml | 33 +++++++++++ OsmAnd/res/layout/two_line_list_item.xml | 32 +++++++++++ OsmAnd/res/values/strings.xml | 2 + .../osmand/plus/dashboard/DashboardOnMap.java | 14 +++-- .../osmand/plus/dialogs/UnderlayMapMenu.java | 56 +++++++++++++++++++ .../rastermaps/OsmandRasterMapsPlugin.java | 13 ++--- 7 files changed, 163 insertions(+), 15 deletions(-) create mode 100644 OsmAnd/res/layout/drawer_list_material_item.xml create mode 100644 OsmAnd/res/layout/progress_list_item.xml create mode 100644 OsmAnd/res/layout/two_line_list_item.xml create mode 100644 OsmAnd/src/net/osmand/plus/dialogs/UnderlayMapMenu.java diff --git a/OsmAnd/res/layout/drawer_list_material_item.xml b/OsmAnd/res/layout/drawer_list_material_item.xml new file mode 100644 index 0000000000..9ffae78607 --- /dev/null +++ b/OsmAnd/res/layout/drawer_list_material_item.xml @@ -0,0 +1,28 @@ + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/progress_list_item.xml b/OsmAnd/res/layout/progress_list_item.xml new file mode 100644 index 0000000000..d1241466e4 --- /dev/null +++ b/OsmAnd/res/layout/progress_list_item.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/two_line_list_item.xml b/OsmAnd/res/layout/two_line_list_item.xml new file mode 100644 index 0000000000..57edd96cce --- /dev/null +++ b/OsmAnd/res/layout/two_line_list_item.xml @@ -0,0 +1,32 @@ + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 47b82a856d..413fa3077f 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,8 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Show polygons + Underlay transparency Find a parking Status Save changes diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index cb1241e787..6d725d1fdf 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -51,6 +51,7 @@ import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.dashboard.tools.DashboardSettingsDialogFragment; import net.osmand.plus.dashboard.tools.TransactionBuilder; import net.osmand.plus.dialogs.ConfigureMapMenu; +import net.osmand.plus.dialogs.UnderlayMapMenu; import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.WaypointDialogHelper; @@ -155,7 +156,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis CONFIGURE_MAP, LIST_MENU, ROUTE_PREFERENCES, - DASHBOARD + DASHBOARD, + UNDERLAY_MAP } private Map actionButtons = new HashMap<>(); @@ -350,6 +352,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis tv.setText(R.string.layer_map_appearance); } else if (visibleType == DashboardType.ROUTE_PREFERENCES) { tv.setText(R.string.shared_string_settings); + } else if (visibleType == DashboardType.UNDERLAY_MAP) { + tv.setText(R.string.map_underlay); } ImageView edit = (ImageView) dashboardView.findViewById(R.id.toolbar_edit); edit.setVisibility(View.GONE); @@ -689,11 +693,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis private int dpToPx(float dp) { Resources r = mapActivity.getResources(); - return (int) TypedValue.applyDimension( - COMPLEX_UNIT_DIP, - dp, - r.getDisplayMetrics() - ); + return (int) TypedValue.applyDimension(COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()); } private void updateListAdapter() { @@ -722,6 +722,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis ArrayAdapter listAdapter = routePreferencesMenu.getRoutePreferencesDrawerAdapter(nightMode); OnItemClickListener listener = routePreferencesMenu.getItemClickListener(listAdapter); updateListAdapter(listAdapter, listener); + } else if (DashboardType.UNDERLAY_MAP == visibleType) { + cm = UnderlayMapMenu.createListAdapter(mapActivity); } if (cm != null) { updateListAdapter(cm); diff --git a/OsmAnd/src/net/osmand/plus/dialogs/UnderlayMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/UnderlayMapMenu.java new file mode 100644 index 0000000000..db298af65e --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/dialogs/UnderlayMapMenu.java @@ -0,0 +1,56 @@ +package net.osmand.plus.dialogs; + +import android.util.Log; +import android.view.View; +import android.widget.ArrayAdapter; + +import net.osmand.plus.ContextMenuAdapter; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; + +public class UnderlayMapMenu { + private static final String TAG = "UnderlayMapMenu"; + + public static ContextMenuAdapter createListAdapter(final MapActivity ma) { + ContextMenuAdapter adapter = new ContextMenuAdapter(ma, false); + adapter.setDefaultLayoutId(R.layout.drawer_list_material_item); + createLayersItems(adapter, ma); + return adapter; + } + + private static void createLayersItems(ContextMenuAdapter adapter , MapActivity activity) { + OsmandApplication app = activity.getMyApplication(); + OsmandSettings settings = app.getSettings(); + ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() { + @Override + public boolean onRowItemClick(ArrayAdapter adapter, View view, int itemId, int pos) { + Log.v(TAG, "onRowItemClick(" + "adapter=" + adapter + ", view=" + view + ", itemId=" + itemId + ", pos=" + pos + ")"); + return super.onRowItemClick(adapter, view, itemId, pos); + } + + @Override + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + Log.v(TAG, "onContextMenuClick(" + "adapter=" + adapter + ", itemId=" + itemId + ", pos=" + pos + ", isChecked=" + isChecked + ")"); + return false; + } + }; + adapter.item(R.string.shared_string_show).listen(l).reg(); + // String appMode = " [" + settings.getApplicationMode().toHumanString(view.getApplication()) +"] "; + adapter.item(R.string.underlay_transparency).layout(R.layout.progress_list_item).reg(); + adapter.item(R.string.map_underlay).layout(R.layout.two_line_list_item).listen(l).reg(); + adapter.item(R.string.show_polygons).listen(l).reg(); + +// .selected(overlayLayer != null && overlayLayer.getMap() != null ? 1 : 0) + +// if(underlayLayer.getMap() != null){ +// settings.MAP_UNDERLAY.set(null); +// updateMapLayers(mapView, null, layers); +// layers.getMapControlsLayer().hideTransparencyBar(settings.MAP_TRANSPARENCY); +// } else { +// selectMapOverlayLayer(mapView, settings.MAP_UNDERLAY,settings.MAP_TRANSPARENCY, +// mapActivity); +// } + } +} diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java index 98f0781ba7..ec439323f0 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java @@ -31,6 +31,7 @@ import net.osmand.plus.Version; import net.osmand.plus.activities.DownloadTilesDialog; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivityLayers; +import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.views.MapTileLayer; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.util.Algorithms; @@ -215,14 +216,8 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { selectMapOverlayLayer(mapView, settings.MAP_OVERLAY, settings.MAP_OVERLAY_TRANSPARENCY, mapActivity); } } else if(itemId == R.string.layer_underlay){ - if(underlayLayer.getMap() != null){ - settings.MAP_UNDERLAY.set(null); - updateMapLayers(mapView, null, layers); - layers.getMapControlsLayer().hideTransparencyBar(settings.MAP_TRANSPARENCY); - } else { - selectMapOverlayLayer(mapView, settings.MAP_UNDERLAY,settings.MAP_TRANSPARENCY, - mapActivity); - } + mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.UNDERLAY_MAP); + return false; } return true; } @@ -230,7 +225,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { adapter.item(R.string.layer_overlay).selected(overlayLayer != null && overlayLayer.getMap() != null ? 1 : 0). iconColor(R.drawable.ic_layer_top_dark).listen(listener).position(14).reg(); - adapter.item(R.string.layer_underlay).selected(underlayLayer != null && underlayLayer.getMap() != null ? 1 : 0) + adapter.item(R.string.layer_underlay) .iconColor(R.drawable.ic_layer_bottom_dark).listen(listener).position(15).reg(); }