From e2be535afd16071c07e57a47226d2902480ddd08 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Thu, 17 Mar 2016 16:36:04 +0200 Subject: [PATCH] Better design for Configure Screen implementation in progress. --- OsmAnd/res/layout/dashboard_toolbar.xml | 11 ++++++ .../net/osmand/plus/ContextMenuAdapter.java | 4 +- .../osmand/plus/dashboard/DashboardOnMap.java | 20 ++++++++++ .../views/mapwidgets/MapWidgetRegistry.java | 38 ++++++------------- 4 files changed, 45 insertions(+), 28 deletions(-) diff --git a/OsmAnd/res/layout/dashboard_toolbar.xml b/OsmAnd/res/layout/dashboard_toolbar.xml index 105970f18a..0d447f5768 100644 --- a/OsmAnd/res/layout/dashboard_toolbar.xml +++ b/OsmAnd/res/layout/dashboard_toolbar.xml @@ -88,5 +88,16 @@ android:src="@drawable/ic_action_edit_dark" android:visibility="gone"/> + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java index a07d1ce325..15f14485d8 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java @@ -36,11 +36,11 @@ public class ContextMenuAdapter { public interface OnContextMenuClick { //boolean return type needed to desribe if drawer needed to be close or not - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked); + boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked); } public interface OnIntegerValueChangedListener { - public boolean onIntegerValueChangedListener(int newValue); + boolean onIntegerValueChangedListener(int newValue); } public static abstract class OnRowItemClick implements OnContextMenuClick { diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 0f8e10e4e9..4ba07e84fa 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -74,6 +74,7 @@ import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener; import net.osmand.plus.views.DownloadedRegionsLayer; +import net.osmand.plus.views.MapInfoLayer; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.controls.DynamicListView; import net.osmand.plus.views.controls.DynamicListViewCallbacks; @@ -81,6 +82,7 @@ import net.osmand.plus.views.controls.StableArrayAdapter; import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener; import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.DismissCallbacks; import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.Undoable; +import net.osmand.plus.views.mapwidgets.MapWidgetRegistry; import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -487,6 +489,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis backPressed(); } }); + ImageView refreshToolbarItem = (ImageView) dashboardView.findViewById(R.id.toolbar_refresh); + refreshToolbarItem.setVisibility(View.GONE); if (waypointsVisible && getMyApplication().getWaypointHelper().getAllPoints().size() > 0) { if (getMyApplication().getWaypointHelper().isRouteCalculated()) { @@ -537,6 +541,22 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis } }); } + + if (visibleType == DashboardType.CONFIGURE_SCREEN) { + refreshToolbarItem.setVisibility(View.VISIBLE); + settingsButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + MapWidgetRegistry registry = mapActivity.getMapLayers().getMapWidgetRegistry(); + registry.resetToDefault(); + MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer(); + if (mil != null) { + mil.recreateControls(); + } + updateListAdapter(registry.getViewConfigureMenuAdapter(mapActivity)); + } + }); + } } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java index b83a6ca6cc..4b2f7da614 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java @@ -1,12 +1,10 @@ package net.osmand.plus.views.mapwidgets; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; +import android.content.Context; +import android.content.DialogInterface; +import android.support.v7.app.AlertDialog; +import android.widget.ArrayAdapter; +import android.widget.LinearLayout; import net.osmand.plus.ApplicationMode; import net.osmand.plus.ContextMenuAdapter; @@ -21,11 +19,13 @@ import net.osmand.plus.views.MapInfoLayer; import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapTileView; -import android.content.Context; -import android.content.DialogInterface; -import android.support.v7.app.AlertDialog; -import android.widget.ArrayAdapter; -import android.widget.LinearLayout; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; public class MapWidgetRegistry { @@ -488,20 +488,6 @@ public class MapWidgetRegistry { map.getDashboard().updateListAdapter(getViewConfigureMenuAdapter(map)); } }); - cm.item(R.string.map_widget_reset).iconColor(R.drawable.ic_action_reset_to_default_dark) - .listen(new OnContextMenuClick() { - - @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { - resetToDefault(); - MapInfoLayer mil = map.getMapLayers().getMapInfoLayer(); - if (mil != null) { - mil.recreateControls(); - } - map.getDashboard().updateListAdapter(getViewConfigureMenuAdapter(map)); - return false; - } - }).reg(); final ApplicationMode mode = settings.getApplicationMode(); addControls(map, cm, mode); return cm;