Better design for Configure Screen implementation in progress.

This commit is contained in:
GaidamakUA 2016-03-17 16:36:04 +02:00
parent 52becb8fb1
commit e2be535afd
4 changed files with 45 additions and 28 deletions

View file

@ -88,5 +88,16 @@
android:src="@drawable/ic_action_edit_dark" android:src="@drawable/ic_action_edit_dark"
android:visibility="gone"/> android:visibility="gone"/>
<ImageView
android:id="@+id/toolbar_refresh"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:layout_gravity="right"
android:background="@drawable/dashboard_button_light"
android:scaleType="center"
android:src="@drawable/ic_action_refresh_dark"
tools:visibility="visible"
android:visibility="gone"/>
</android.support.v7.widget.Toolbar> </android.support.v7.widget.Toolbar>

View file

@ -36,11 +36,11 @@ public class ContextMenuAdapter {
public interface OnContextMenuClick { public interface OnContextMenuClick {
//boolean return type needed to desribe if drawer needed to be close or not //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 interface OnIntegerValueChangedListener {
public boolean onIntegerValueChangedListener(int newValue); boolean onIntegerValueChangedListener(int newValue);
} }
public static abstract class OnRowItemClick implements OnContextMenuClick { public static abstract class OnRowItemClick implements OnContextMenuClick {

View file

@ -74,6 +74,7 @@ import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener; import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
import net.osmand.plus.views.DownloadedRegionsLayer; import net.osmand.plus.views.DownloadedRegionsLayer;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.controls.DynamicListView; import net.osmand.plus.views.controls.DynamicListView;
import net.osmand.plus.views.controls.DynamicListViewCallbacks; 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;
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.DismissCallbacks; import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.DismissCallbacks;
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.Undoable; import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.Undoable;
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
@ -487,6 +489,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
backPressed(); backPressed();
} }
}); });
ImageView refreshToolbarItem = (ImageView) dashboardView.findViewById(R.id.toolbar_refresh);
refreshToolbarItem.setVisibility(View.GONE);
if (waypointsVisible && getMyApplication().getWaypointHelper().getAllPoints().size() > 0) { if (waypointsVisible && getMyApplication().getWaypointHelper().getAllPoints().size() > 0) {
if (getMyApplication().getWaypointHelper().isRouteCalculated()) { 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));
}
});
}
} }

View file

@ -1,12 +1,10 @@
package net.osmand.plus.views.mapwidgets; package net.osmand.plus.views.mapwidgets;
import java.util.Collections; import android.content.Context;
import java.util.Iterator; import android.content.DialogInterface;
import java.util.LinkedHashMap; import android.support.v7.app.AlertDialog;
import java.util.LinkedHashSet; import android.widget.ArrayAdapter;
import java.util.Map; import android.widget.LinearLayout;
import java.util.Set;
import java.util.TreeSet;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter; 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.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import android.content.Context; import java.util.Collections;
import android.content.DialogInterface; import java.util.Iterator;
import android.support.v7.app.AlertDialog; import java.util.LinkedHashMap;
import android.widget.ArrayAdapter; import java.util.LinkedHashSet;
import android.widget.LinearLayout; import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
public class MapWidgetRegistry { public class MapWidgetRegistry {
@ -488,20 +488,6 @@ public class MapWidgetRegistry {
map.getDashboard().updateListAdapter(getViewConfigureMenuAdapter(map)); 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(); final ApplicationMode mode = settings.getApplicationMode();
addControls(map, cm, mode); addControls(map, cm, mode);
return cm; return cm;