diff --git a/OsmAnd/res/layout/fragment_search_list.xml b/OsmAnd/res/layout/fragment_search_list.xml index 3a1880d00b..8cbee4ad46 100644 --- a/OsmAnd/res/layout/fragment_search_list.xml +++ b/OsmAnd/res/layout/fragment_search_list.xml @@ -34,14 +34,14 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - + + diff --git a/OsmAnd/res/layout/map_marker_item.xml b/OsmAnd/res/layout/map_marker_item.xml index 58d93922f4..bdf2138999 100644 --- a/OsmAnd/res/layout/map_marker_item.xml +++ b/OsmAnd/res/layout/map_marker_item.xml @@ -1,37 +1,46 @@ - + + + + android:layout_height="25dp" + android:layout_gravity="center_vertical" + android:src="@drawable/ic_action_fav_dark"/> + android:ellipsize="end" + android:maxLines="2" + android:textSize="@dimen/default_list_text_size"/> + android:textSize="@dimen/default_sub_text_size"/> @@ -86,28 +95,28 @@ + android:src="@drawable/map_overflow_menu_white" + android:visibility="gone"/> + android:src="@drawable/ic_action_remove_dark"/> diff --git a/OsmAnd/res/layout/map_marker_selection_fragment.xml b/OsmAnd/res/layout/map_marker_selection_fragment.xml index 8215bdb8b5..f84aaf0502 100644 --- a/OsmAnd/res/layout/map_marker_selection_fragment.xml +++ b/OsmAnd/res/layout/map_marker_selection_fragment.xml @@ -36,14 +36,16 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java index a43a8e7378..854c5cbaa4 100644 --- a/OsmAnd/src/net/osmand/AndroidUtils.java +++ b/OsmAnd/src/net/osmand/AndroidUtils.java @@ -6,6 +6,7 @@ import android.app.Activity; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; +import android.graphics.drawable.ColorDrawable; import android.os.Build; import android.text.TextUtils; import android.text.format.DateFormat; @@ -14,6 +15,7 @@ import android.util.TypedValue; import android.view.View; import android.view.ViewParent; import android.view.inputmethod.InputMethodManager; +import android.widget.ListView; import android.widget.TextView; import net.osmand.plus.R; @@ -100,6 +102,10 @@ public class AndroidUtils { setBackgroundColor(ctx, view, night, R.color.bg_color_light, R.color.bg_color_dark); } + public static void setListBackground(Context ctx, View view, boolean night) { + setBackgroundColor(ctx, view, night, R.color.ctx_menu_info_view_bg_light, R.color.ctx_menu_info_view_bg_dark); + } + public static void setTextPrimaryColor(Context ctx, TextView textView, boolean night) { textView.setTextColor(night ? ctx.getResources().getColor(R.color.primary_text_dark) diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index ee3169881c..57d518451f 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -35,13 +35,16 @@ public class MapMarkersHelper { public int pos; public int index; public boolean history; + public boolean selected; public int dist; - public MapMarker(LatLon point, PointDescription name, int colorIndex, int pos, int index) { + public MapMarker(LatLon point, PointDescription name, int colorIndex, int pos, + boolean selected, int index) { this.point = point; this.pointDescription = name; this.colorIndex = colorIndex; this.pos = pos; + this.selected = selected; this.index = index; } @@ -58,10 +61,6 @@ public class MapMarkersHelper { return pointDescription == null ? "" : pointDescription.getName(); } - public boolean isSearchingAddress(Context ctx) { - return pointDescription != null && pointDescription.isSearchingAddress(ctx); - } - public double getLatitude() { return point.getLatitude(); } @@ -95,6 +94,7 @@ public class MapMarkersHelper { List desc = settings.getMapMarkersPointDescriptions(ips.size()); List colors = settings.getMapMarkersColors(ips.size()); List positions = settings.getMapMarkersPositions(ips.size()); + List selections = settings.getMapMarkersSelections(ips.size()); int colorIndex = 0; int pos = 0; for (int i = 0; i < ips.size(); i++) { @@ -108,7 +108,7 @@ public class MapMarkersHelper { } MapMarker mapMarker = new MapMarker(ips.get(i), PointDescription.deserializeFromString(desc.get(i), ips.get(i)), colorIndex, - pos, i); + pos, selections.get(i), i); mapMarkers.add(mapMarker); lookupAddress(mapMarker, false); } @@ -117,10 +117,9 @@ public class MapMarkersHelper { ips = settings.getMapMarkersHistoryPoints(); desc = settings.getMapMarkersHistoryPointDescriptions(ips.size()); - colors = settings.getMapMarkersHistoryColors(ips.size()); for (int i = 0; i < ips.size(); i++) { MapMarker mapMarker = new MapMarker(ips.get(i), - PointDescription.deserializeFromString(desc.get(i), ips.get(i)), colors.get(i), 0, i); + PointDescription.deserializeFromString(desc.get(i), ips.get(i)), 0, 0, false, i); mapMarker.history = true; mapMarkersHistory.add(mapMarker); lookupAddress(mapMarker, true); @@ -162,7 +161,7 @@ public class MapMarkersHelper { mapMarker.pointDescription, mapMarker.colorIndex); } else { settings.updateMapMarker(mapMarker.point.getLatitude(), mapMarker.point.getLongitude(), - mapMarker.pointDescription, mapMarker.colorIndex, mapMarker.pos); + mapMarker.pointDescription, mapMarker.colorIndex, mapMarker.pos, mapMarker.selected); } updateMarker(mapMarker); } @@ -253,6 +252,7 @@ public class MapMarkersHelper { List pointDescriptions = new ArrayList<>(); int[] colorIndexes = new int[points.size()]; int[] positions = new int[points.size()]; + boolean[] selections = new boolean[points.size()]; int[] indexes = new int[points.size()]; for (int i = 0; i < points.size(); i++) { LatLon point = points.get(i); @@ -280,14 +280,19 @@ public class MapMarkersHelper { longitudes[i] = point.getLongitude(); pointDescriptions.add(pointDescription); colorIndexes[i] = colorIndex; - positions[i] = 0 - i; + positions[i] = -1 - i; + selections[i] = false; indexes[i] = 0; } + /* if (sortedMapMarkers.size() > 0) { MapMarker firstMarker = sortedMapMarkers.get(0); - settings.updateMapMarker(firstMarker.getLatitude(), firstMarker.getLongitude(), firstMarker.pointDescription, firstMarker.colorIndex, -points.size()); + settings.updateMapMarker(firstMarker.getLatitude(), firstMarker.getLongitude(), + firstMarker.pointDescription, firstMarker.colorIndex, -points.size(), firstMarker.selected); } - settings.insertMapMarkers(latitudes, longitudes, pointDescriptions, colorIndexes, positions, indexes); + */ + settings.insertMapMarkers(latitudes, longitudes, pointDescriptions, colorIndexes, positions, + selections, indexes); readFromSettings(); normalizePositions(); } @@ -323,13 +328,15 @@ public class MapMarkersHelper { List names = new ArrayList<>(markers.size()); List colors = new ArrayList<>(markers.size()); List positions = new ArrayList<>(markers.size()); + List selections = new ArrayList<>(markers.size()); for (MapMarker marker : markers) { ls.add(marker.point); names.add(PointDescription.serializeToString(marker.pointDescription)); colors.add(marker.colorIndex); positions.add(marker.pos); + selections.add(marker.selected); } - settings.saveMapMarkers(ls, names, colors, positions); + settings.saveMapMarkers(ls, names, colors, positions, selections); } if (markersHistory != null) { diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 62eca11c84..0aa2735f13 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -1520,8 +1520,8 @@ public class OsmandSettings { public final static String MAP_MARKERS_COLOR = "map_markers_color"; //$NON-NLS-1$ public final static String MAP_MARKERS_DESCRIPTION = "map_markers_description"; //$NON-NLS-1$ public final static String MAP_MARKERS_POSITION = "map_markers_position"; //$NON-NLS-1$ + public final static String MAP_MARKERS_SELECTION = "map_markers_selection"; //$NON-NLS-1$ public final static String MAP_MARKERS_HISTORY_POINT = "map_markers_history_point"; //$NON-NLS-1$ - public final static String MAP_MARKERS_HISTORY_COLOR = "map_markers_history_color"; //$NON-NLS-1$ public final static String MAP_MARKERS_HISTORY_DESCRIPTION = "map_markers_history_description"; //$NON-NLS-1$ public final static int MAP_MARKERS_HISTORY_LIMIT = 30; private MapMarkersStorage mapMarkersStorage = new MapMarkersStorage(); @@ -1576,6 +1576,7 @@ public class OsmandSettings { .remove(MAP_MARKERS_DESCRIPTION) .remove(MAP_MARKERS_COLOR) .remove(MAP_MARKERS_POSITION) + .remove(MAP_MARKERS_SELECTION) .commit(); } @@ -1583,7 +1584,6 @@ public class OsmandSettings { return settingsAPI.edit(globalPreferences) .remove(MAP_MARKERS_HISTORY_POINT) .remove(MAP_MARKERS_HISTORY_DESCRIPTION) - .remove(MAP_MARKERS_HISTORY_COLOR) .commit(); } @@ -1599,22 +1599,11 @@ public class OsmandSettings { } } - private class MapMarkersHistoryStorage extends MapMarkersStorage { + private class MapMarkersHistoryStorage extends MapPointsStorage { public MapMarkersHistoryStorage() { pointsKey = MAP_MARKERS_HISTORY_POINT; descriptionsKey = MAP_MARKERS_HISTORY_DESCRIPTION; - colorsKey = MAP_MARKERS_HISTORY_COLOR; - } - - @Override - public boolean savePoints(List ps, List ds, List cs, List ns) { - if (ps.size() > MAP_MARKERS_HISTORY_LIMIT) { - ps.remove(ps.size() - 1); - ds.remove(ds.size() - 1); - cs.remove(cs.size() - 1); - } - return super.savePoints(ps, ds, cs, ns); } } @@ -1622,12 +1611,14 @@ public class OsmandSettings { protected String colorsKey; protected String posKey; + protected String selectionKey; public MapMarkersStorage() { pointsKey = MAP_MARKERS_POINT; descriptionsKey = MAP_MARKERS_DESCRIPTION; colorsKey = MAP_MARKERS_COLOR; posKey = MAP_MARKERS_POSITION; + selectionKey = MAP_MARKERS_SELECTION; } public List getColors(int sz) { @@ -1640,79 +1631,130 @@ public class OsmandSettings { list.add(Integer.parseInt(colorStr)); } } + while (list.size() > sz) { + list.remove(list.size() - 1); + } + int i = 0; + while (list.size() < sz) { + list.add(i % MapMarkersHelper.MAP_MARKERS_COLORS_COUNT); + i++; + } return list; } public List getPositions(int sz) { List list = new ArrayList<>(); + int pos = 0; String ip = settingsAPI.getString(globalPreferences, posKey, ""); if (ip.trim().length() > 0) { StringTokenizer tok = new StringTokenizer(ip, ","); while (tok.hasMoreTokens()) { String indexStr = tok.nextToken(); - list.add(Integer.parseInt(indexStr)); + int p = Integer.parseInt(indexStr); + list.add(p); + if (p > pos) { + pos = p; + } } } + while (list.size() > sz) { + list.remove(list.size() - 1); + } + while (list.size() < sz) { + list.add(++pos); + } + return list; + } + + public List getSelections(int sz) { + List list = new ArrayList<>(); + String ip = settingsAPI.getString(globalPreferences, selectionKey, ""); + if (ip.trim().length() > 0) { + StringTokenizer tok = new StringTokenizer(ip, ","); + while (tok.hasMoreTokens()) { + String indexStr = tok.nextToken(); + list.add(Boolean.parseBoolean(indexStr)); + } + } + while (list.size() > sz) { + list.remove(list.size() - 1); + } + while (list.size() < sz) { + list.add(false); + } return list; } public boolean insertPoint(double latitude, double longitude, - PointDescription historyDescription, int colorIndex, int pos, int index) { + PointDescription historyDescription, int colorIndex, int pos, + boolean selected, int index) { List ps = getPoints(); List ds = getPointDescriptions(ps.size()); List cs = getColors(ps.size()); List ns = getPositions(ps.size()); + List bs = getSelections(ps.size()); ps.add(index, new LatLon(latitude, longitude)); ds.add(index, PointDescription.serializeToString(historyDescription)); cs.add(index, colorIndex); ns.add(index, pos); + bs.add(index, selected); if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) { SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription); } - return savePoints(ps, ds, cs, ns); + return savePoints(ps, ds, cs, ns, bs); } public boolean insertPoints(double[] latitudes, double[] longitudes, List historyDescriptions, int[] colorIndexes, - int[] positions, int[] indexes) { + int[] positions, boolean[] selections, int[] indexes) { List ps = getPoints(); List ds = getPointDescriptions(ps.size()); List cs = getColors(ps.size()); List ns = getPositions(ps.size()); + List bs = getSelections(ps.size()); for (int i = 0; i < latitudes.length; i++) { double latitude = latitudes[i]; double longitude = longitudes[i]; PointDescription historyDescription = historyDescriptions.get(i); int colorIndex = colorIndexes[i]; int pos = positions[i]; + boolean selected = selections[i]; int index = indexes[i]; ps.add(index, new LatLon(latitude, longitude)); ds.add(index, PointDescription.serializeToString(historyDescription)); cs.add(index, colorIndex); ns.add(index, pos); + bs.add(index, selected); if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) { SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription); } } - return savePoints(ps, ds, cs, ns); + return savePoints(ps, ds, cs, ns, bs); } public boolean updatePoint(double latitude, double longitude, - PointDescription historyDescription, int colorIndex, int pos) { + PointDescription historyDescription, int colorIndex, + int pos, boolean selected) { List ps = getPoints(); List ds = getPointDescriptions(ps.size()); List cs = getColors(ps.size()); List ns = getPositions(ps.size()); + List bs = getSelections(ps.size()); int index = ps.indexOf(new LatLon(latitude, longitude)); ds.set(index, PointDescription.serializeToString(historyDescription)); - cs.set(index, colorIndex); + if (cs.size() > index) { + cs.set(index, colorIndex); + } if (ns.size() > index) { ns.set(index, pos); } + if (bs.size() > index) { + bs.set(index, selected); + } if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) { SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription); } - return savePoints(ps, ds, cs, ns); + return savePoints(ps, ds, cs, ns, bs); } @Override @@ -1721,6 +1763,7 @@ public class OsmandSettings { List ds = getPointDescriptions(ps.size()); List cs = getColors(ps.size()); List ns = getPositions(ps.size()); + List bs = getSelections(ps.size()); ps.remove(index); ds.remove(index); if (cs.size() > index) { @@ -1729,10 +1772,14 @@ public class OsmandSettings { if (ns.size() > index) { ns.remove(index); } - return savePoints(ps, ds, cs, ns); + if (bs.size() > index) { + bs.remove(index); + } + return savePoints(ps, ds, cs, ns, bs); } - public boolean savePoints(List ps, List ds, List cs, List ns) { + public boolean savePoints(List ps, List ds, List cs, + List ns, List bs) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < ps.size(); i++) { if (i > 0) { @@ -1767,11 +1814,21 @@ public class OsmandSettings { nb.append(Integer.toString(ns.get(i))); } } + StringBuilder bb = new StringBuilder(); + if (bs != null) { + for (int i = 0; i < bs.size(); i++) { + if (i > 0) { + bb.append(","); + } + bb.append(Boolean.toString(bs.get(i))); + } + } return settingsAPI.edit(globalPreferences) .putString(pointsKey, sb.toString()) .putString(descriptionsKey, tb.toString()) .putString(colorsKey, cb.toString()) .putString(posKey, nb.toString()) + .putString(selectionKey, bb.toString()) .commit(); } @@ -1925,33 +1982,42 @@ public class OsmandSettings { return mapMarkersStorage.getPositions(sz); } + public List getMapMarkersSelections(int sz) { + return mapMarkersStorage.getSelections(sz); + } + public List getMapMarkersPoints() { return mapMarkersStorage.getPoints(); } public boolean insertMapMarker(double latitude, double longitude, - PointDescription historyDescription, int colorIndex, int pos, int index) { - return mapMarkersStorage.insertPoint(latitude, longitude, historyDescription, colorIndex, index, pos); + PointDescription historyDescription, int colorIndex, int pos, + boolean selected, int index) { + return mapMarkersStorage.insertPoint(latitude, longitude, historyDescription, colorIndex, + index, selected, pos); } public boolean insertMapMarkers(double[] latitudes, double[] longitudes, List historyDescriptions, int[] colorIndexes, - int[] positions, int[] indexes) { + int[] positions, boolean[] selections, int[] indexes) { return mapMarkersStorage.insertPoints(latitudes, longitudes, historyDescriptions, colorIndexes, - positions, indexes); + positions, selections, indexes); } public boolean updateMapMarker(double latitude, double longitude, - PointDescription historyDescription, int colorIndex, int pos) { - return mapMarkersStorage.updatePoint(latitude, longitude, historyDescription, colorIndex, pos); + PointDescription historyDescription, int colorIndex, + int pos, boolean selected) { + return mapMarkersStorage.updatePoint(latitude, longitude, historyDescription, colorIndex, + pos, selected); } public boolean deleteMapMarker(int index) { return mapMarkersStorage.deletePoint(index); } - public boolean saveMapMarkers(List ps, List ds, List cs, List ns) { - return mapMarkersStorage.savePoints(ps, ds, cs, ns); + public boolean saveMapMarkers(List ps, List ds, List cs, List ns, + List bs) { + return mapMarkersStorage.savePoints(ps, ds, cs, ns, bs); } @@ -1959,22 +2025,18 @@ public class OsmandSettings { return mapMarkersHistoryStorage.getPointDescriptions(sz); } - public List getMapMarkersHistoryColors(int sz) { - return mapMarkersHistoryStorage.getColors(sz); - } - public List getMapMarkersHistoryPoints() { return mapMarkersHistoryStorage.getPoints(); } public boolean insertMapMarkerHistory(double latitude, double longitude, PointDescription historyDescription, int colorIndex, int index) { - return mapMarkersHistoryStorage.insertPoint(latitude, longitude, historyDescription, colorIndex, index, 0); + return mapMarkersHistoryStorage.insertPoint(latitude, longitude, historyDescription, index); } public boolean updateMapMarkerHistory(double latitude, double longitude, PointDescription historyDescription, int colorIndex) { - return mapMarkersHistoryStorage.updatePoint(latitude, longitude, historyDescription, colorIndex, 0); + return mapMarkersHistoryStorage.updatePoint(latitude, longitude, historyDescription); } public boolean deleteMapMarkerHistory(int index) { @@ -1982,7 +2044,7 @@ public class OsmandSettings { } public boolean saveMapMarkersHistory(List ps, List ds, List cs) { - return mapMarkersHistoryStorage.savePoints(ps, ds, cs, null); + return mapMarkersHistoryStorage.savePoints(ps, ds); } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 9d153c1058..7f6d5f83f3 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -1037,8 +1037,17 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents, } ((MapActivity) activity).readLocationToShow(); } else { - prevActivityIntent = new Intent(((Activity) activity).getIntent()); - prevActivityIntent.putExtra(INTENT_KEY_PARENT_MAP_ACTIVITY, true); + if (activity instanceof Activity) { + Intent intent = ((Activity) activity).getIntent(); + if (intent != null) { + prevActivityIntent = new Intent(intent); + prevActivityIntent.putExtra(INTENT_KEY_PARENT_MAP_ACTIVITY, true); + } else { + prevActivityIntent = null; + } + } else { + prevActivityIntent = null; + } Intent newIntent = new Intent(activity, ((OsmandApplication) activity.getApplicationContext()) .getAppCustomization().getMapActivity()); diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 79146ea952..e6bfdc68b4 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -776,6 +776,11 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis listView.setDivider(null); } } + /* + listView.setOverscrollFooter(new ColorDrawable( + nightMode ? mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_dark) + : mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_light))); + */ } private int dpToPx(float dp) { diff --git a/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java index 51de11033a..57e6a264a8 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java @@ -14,6 +14,7 @@ import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; +import android.widget.CheckBox; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ListView; @@ -63,6 +64,7 @@ public class MapMarkerDialogHelper { private MapMarkersDialogHelperCallbacks helperCallbacks; private boolean sorted; private boolean nightMode; + private boolean selectionMode; private boolean useCenter; private LatLon loc; @@ -73,6 +75,7 @@ public class MapMarkerDialogHelper { public interface MapMarkersDialogHelperCallbacks { void reloadAdapter(); + void deleteMapMarker(int position); } @@ -86,6 +89,14 @@ public class MapMarkerDialogHelper { this.helperCallbacks = helperCallbacks; } + public boolean isSelectionMode() { + return selectionMode; + } + + public void setSelectionMode(boolean selectionMode) { + this.selectionMode = selectionMode; + } + public boolean isNightMode() { return nightMode; } @@ -154,8 +165,10 @@ public class MapMarkerDialogHelper { AndroidUtils.setListItemBackground(mapActivity, v, nightMode); } else if (topDividerView) { v = mapActivity.getLayoutInflater().inflate(R.layout.card_top_divider, null); + AndroidUtils.setListBackground(mapActivity, v, nightMode); } else if (bottomDividerView) { v = mapActivity.getLayoutInflater().inflate(R.layout.card_bottom_divider, null); + AndroidUtils.setListBackground(mapActivity, v, nightMode); } else if (obj instanceof MapMarker) { MapMarker marker = (MapMarker) obj; v = updateMapMarkerItemView(this, v, marker); @@ -329,7 +342,8 @@ public class MapMarkerDialogHelper { if (v == null || v.findViewById(R.id.info_close) == null) { v = mapActivity.getLayoutInflater().inflate(R.layout.map_marker_item, null); } - updateMapMarkerInfoView(mapActivity, v, loc, heading, useCenter, nightMode, screenOrientation, marker); + updateMapMarkerInfoView(mapActivity, v, loc, heading, useCenter, nightMode, screenOrientation, + selectionMode, marker); final View more = v.findViewById(R.id.all_points); final View move = v.findViewById(R.id.info_move); final View remove = v.findViewById(R.id.info_close); @@ -370,8 +384,9 @@ public class MapMarkerDialogHelper { } public static void updateMapMarkerInfoView(Context ctx, View localView, LatLon loc, - Float heading, boolean useCenter, boolean nightMode, - int screenOrientation, final MapMarker marker) { + Float heading, boolean useCenter, boolean nightMode, + int screenOrientation, boolean selectionMode, + final MapMarker marker) { TextView text = (TextView) localView.findViewById(R.id.waypoint_text); TextView textShadow = (TextView) localView.findViewById(R.id.waypoint_text_shadow); TextView textDist = (TextView) localView.findViewById(R.id.waypoint_dist); @@ -379,10 +394,13 @@ public class MapMarkerDialogHelper { ImageView waypointIcon = (ImageView) localView.findViewById(R.id.waypoint_icon); TextView waypointDeviation = (TextView) localView.findViewById(R.id.waypoint_deviation); TextView descText = (TextView) localView.findViewById(R.id.waypoint_desc_text); + CheckBox checkBox = (CheckBox) localView.findViewById(R.id.checkbox); + if (text == null || textDist == null || arrow == null || waypointIcon == null || waypointDeviation == null || descText == null) { return; } + float[] mes = new float[2]; if (loc != null && marker.point != null) { Location.distanceBetween(marker.getLatitude(), marker.getLongitude(), loc.getLatitude(), loc.getLongitude(), mes); @@ -445,6 +463,13 @@ public class MapMarkerDialogHelper { text.setText(descr); descText.setVisibility(View.GONE); + + if (selectionMode) { + checkBox.setVisibility(View.VISIBLE); + } else { + checkBox.setVisibility(View.GONE); + } + /* String pointDescription = ""; if (descText != null) { @@ -659,7 +684,8 @@ public class MapMarkerDialogHelper { Object obj = listView.getItemAtPosition(i); View v = listView.getChildAt(i - listView.getFirstVisiblePosition()); if (obj == marker) { - updateMapMarkerInfoView(mapActivity, v, loc, heading, useCenter, nightMode, screenOrientation, marker); + updateMapMarkerInfoView(mapActivity, v, loc, heading, useCenter, nightMode, + screenOrientation, selectionMode, marker); } } } catch (Exception e) { diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index 990707076f..0c8fda2e9c 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -353,8 +353,10 @@ public class WaypointDialogHelper { AndroidUtils.setListItemBackground(mapActivity, v, nightMode); } else if (topDividerView) { v = ctx.getLayoutInflater().inflate(R.layout.card_top_divider, null); + AndroidUtils.setListBackground(mapActivity, v, nightMode); } else if (bottomDividerView) { v = ctx.getLayoutInflater().inflate(R.layout.card_bottom_divider, null); + AndroidUtils.setListBackground(mapActivity, v, nightMode); } else if (obj instanceof LocationPointWrapper) { LocationPointWrapper point = (LocationPointWrapper) obj; v = updateWaypointItemView(edit, deletedPoints, app, ctx, helper, v, point, this, diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java index 892525b979..ea0c19fb46 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java @@ -3,8 +3,6 @@ package net.osmand.plus.mapmarkers; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnDismissListener; -import android.graphics.drawable.ShapeDrawable; -import android.graphics.drawable.shapes.Shape; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; @@ -27,7 +25,6 @@ import net.osmand.plus.base.BaseOsmAndDialogFragment; import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.dashboard.DashLocationFragment; import net.osmand.plus.helpers.MapMarkerDialogHelper; -import net.osmand.plus.views.controls.ListDividerShape; import java.util.List; @@ -84,18 +81,6 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment { }); ListView listView = (ListView) view.findViewById(android.R.id.list); - int color; - if (nightMode) { - color = mapActivity.getResources().getColor(R.color.dashboard_divider_dark); - } else { - color = mapActivity.getResources().getColor(R.color.dashboard_divider_light); - } - Shape dividerShape = new ListDividerShape(color, 0); - final ShapeDrawable divider = new ShapeDrawable(dividerShape); - int divHeight = AndroidUtils.dpToPx(getContext(), 1f); - divider.setIntrinsicHeight(divHeight); - listView.setDivider(divider); - final ArrayAdapter adapter = new MapMarkersListAdapter(); List markers = getMyApplication().getMapMarkersHelper().getActiveMapMarkers(); if (markers.size() > 0) { @@ -135,7 +120,7 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment { convertView = getMapActivity().getLayoutInflater().inflate(R.layout.map_marker_item, null); } MapMarkerDialogHelper.updateMapMarkerInfoView(getContext(), convertView, loc, heading, - useCenter, nightMode, screenOrientation, marker); + useCenter, nightMode, screenOrientation, false, marker); final View remove = convertView.findViewById(R.id.info_close); remove.setVisibility(View.GONE); AndroidUtils.setListItemBackground(getMapActivity(), convertView, nightMode); diff --git a/OsmAnd/src/net/osmand/plus/views/controls/DynamicListView.java b/OsmAnd/src/net/osmand/plus/views/controls/DynamicListView.java index 90c92f5f79..afc5588c2f 100644 --- a/OsmAnd/src/net/osmand/plus/views/controls/DynamicListView.java +++ b/OsmAnd/src/net/osmand/plus/views/controls/DynamicListView.java @@ -32,7 +32,6 @@ import android.support.annotation.NonNull; import android.support.v4.view.ViewCompat; import android.util.AttributeSet; import android.util.DisplayMetrics; -import android.util.Log; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View;