Map markers selection for route in progress
This commit is contained in:
parent
bd995b20ef
commit
67fdfbbefb
6 changed files with 192 additions and 88 deletions
|
@ -1,37 +1,46 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/view_transparent_selection"
|
||||
android:id="@+id/package_delivered_layout"
|
||||
android:minHeight="50dp"
|
||||
android:descendantFocusability="blocksDescendants">
|
||||
<LinearLayout
|
||||
android:id="@+id/package_delivered_layout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/view_transparent_selection"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:minHeight="50dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/waypoint_icon"
|
||||
android:src="@drawable/ic_action_fav_dark"
|
||||
android:layout_height="25dp"
|
||||
android:layout_width="56dp"
|
||||
android:layout_gravity="center_vertical" />
|
||||
android:layout_height="25dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@drawable/ic_action_fav_dark"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/waypoint_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textSize="@dimen/default_list_text_size" />
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textSize="@dimen/default_list_text_size"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -53,8 +62,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:textColor="@color/color_myloc_distance"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/color_myloc_distance"
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
|
||||
<TextView
|
||||
|
@ -62,22 +71,22 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:textColor="@color/secondary_text_dark"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:drawablePadding="2dp"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/secondary_text_dark"
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/waypoint_desc_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/secondary_text_dark"
|
||||
android:textSize="@dimen/default_sub_text_size" />
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -86,28 +95,28 @@
|
|||
|
||||
<ImageButton
|
||||
android:id="@+id/all_points"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:contentDescription="@string/shared_string_more"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="2dp"
|
||||
android:visibility="gone"
|
||||
android:contentDescription="@string/shared_string_more"
|
||||
android:focusable="false"
|
||||
android:scaleType="center"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:src="@drawable/map_overflow_menu_white" />
|
||||
android:src="@drawable/map_overflow_menu_white"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/info_close"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:contentDescription="@string/shared_string_close"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="2dp"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:contentDescription="@string/shared_string_close"
|
||||
android:focusable="false"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_action_remove_dark" />
|
||||
android:src="@drawable/ic_action_remove_dark"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/info_move"
|
||||
|
@ -115,8 +124,8 @@
|
|||
android:layout_height="48dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="2dp"
|
||||
android:focusable="false"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_flat_list_dark"
|
||||
android:visibility="gone"/>
|
||||
|
|
|
@ -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<String> desc = settings.getMapMarkersPointDescriptions(ips.size());
|
||||
List<Integer> colors = settings.getMapMarkersColors(ips.size());
|
||||
List<Integer> positions = settings.getMapMarkersPositions(ips.size());
|
||||
List<Boolean> 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<PointDescription> 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<String> names = new ArrayList<>(markers.size());
|
||||
List<Integer> colors = new ArrayList<>(markers.size());
|
||||
List<Integer> positions = new ArrayList<>(markers.size());
|
||||
List<Boolean> 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) {
|
||||
|
|
|
@ -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<LatLon> ps, List<String> ds, List<Integer> cs, List<Integer> 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<Integer> 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<Integer> getPositions(int sz) {
|
||||
List<Integer> 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<Boolean> getSelections(int sz) {
|
||||
List<Boolean> 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<LatLon> ps = getPoints();
|
||||
List<String> ds = getPointDescriptions(ps.size());
|
||||
List<Integer> cs = getColors(ps.size());
|
||||
List<Integer> ns = getPositions(ps.size());
|
||||
List<Boolean> 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<PointDescription> historyDescriptions, int[] colorIndexes,
|
||||
int[] positions, int[] indexes) {
|
||||
int[] positions, boolean[] selections, int[] indexes) {
|
||||
List<LatLon> ps = getPoints();
|
||||
List<String> ds = getPointDescriptions(ps.size());
|
||||
List<Integer> cs = getColors(ps.size());
|
||||
List<Integer> ns = getPositions(ps.size());
|
||||
List<Boolean> 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<LatLon> ps = getPoints();
|
||||
List<String> ds = getPointDescriptions(ps.size());
|
||||
List<Integer> cs = getColors(ps.size());
|
||||
List<Integer> ns = getPositions(ps.size());
|
||||
List<Boolean> 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<String> ds = getPointDescriptions(ps.size());
|
||||
List<Integer> cs = getColors(ps.size());
|
||||
List<Integer> ns = getPositions(ps.size());
|
||||
List<Boolean> 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<LatLon> ps, List<String> ds, List<Integer> cs, List<Integer> ns) {
|
||||
public boolean savePoints(List<LatLon> ps, List<String> ds, List<Integer> cs,
|
||||
List<Integer> ns, List<Boolean> 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<Boolean> getMapMarkersSelections(int sz) {
|
||||
return mapMarkersStorage.getSelections(sz);
|
||||
}
|
||||
|
||||
public List<LatLon> 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<PointDescription> 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<LatLon> ps, List<String> ds, List<Integer> cs, List<Integer> ns) {
|
||||
return mapMarkersStorage.savePoints(ps, ds, cs, ns);
|
||||
public boolean saveMapMarkers(List<LatLon> ps, List<String> ds, List<Integer> cs, List<Integer> ns,
|
||||
List<Boolean> bs) {
|
||||
return mapMarkersStorage.savePoints(ps, ds, cs, ns, bs);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1959,22 +2025,18 @@ public class OsmandSettings {
|
|||
return mapMarkersHistoryStorage.getPointDescriptions(sz);
|
||||
}
|
||||
|
||||
public List<Integer> getMapMarkersHistoryColors(int sz) {
|
||||
return mapMarkersHistoryStorage.getColors(sz);
|
||||
}
|
||||
|
||||
public List<LatLon> 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<LatLon> ps, List<String> ds, List<Integer> cs) {
|
||||
return mapMarkersHistoryStorage.savePoints(ps, ds, cs, null);
|
||||
return mapMarkersHistoryStorage.savePoints(ps, ds);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -208,9 +208,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
//listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
|
||||
listView.setDrawSelectorOnTop(true);
|
||||
((DynamicListView) listView).setDynamicListViewCallbacks(this);
|
||||
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)));
|
||||
|
||||
// Create a ListView-specific touch listener. ListViews are given special treatment because
|
||||
// by default they handle touches for their list items... i.e. they're in charge of drawing
|
||||
|
@ -779,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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -331,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);
|
||||
|
@ -372,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);
|
||||
|
@ -381,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);
|
||||
|
@ -447,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) {
|
||||
|
@ -661,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) {
|
||||
|
|
|
@ -120,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);
|
||||
|
|
Loading…
Reference in a new issue