Fixed map markers UI

This commit is contained in:
Alexey Kulish 2016-02-17 19:31:32 +03:00
parent d55526661b
commit 214f144555
6 changed files with 439 additions and 307 deletions

View file

@ -28,7 +28,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:background="@color/markers_top_bar_background" android:background="@color/markers_top_bar_background"
android:minHeight="@dimen/map_address_height"> android:minHeight="50dp">
<LinearLayout <LinearLayout
android:id="@+id/map_marker_row" android:id="@+id/map_marker_row"
@ -42,8 +42,8 @@
<ImageView <ImageView
android:id="@+id/map_marker_arrow" android:id="@+id/map_marker_arrow"
android:layout_width="60dp" android:layout_width="60dp"
android:layout_height="30dp" android:layout_height="24dp"
android:src="@drawable/map_arrow_to_destination"/> android:src="@drawable/ic_arrow_marker_diretion"/>
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
@ -67,7 +67,6 @@
android:id="@+id/map_marker_address" android:id="@+id/map_marker_address"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:text="Dmitrievskaya st., 45" android:text="Dmitrievskaya st., 45"
@ -102,7 +101,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:background="@color/markers_top_bar_2nd_background" android:background="@color/markers_top_bar_2nd_background"
android:minHeight="@dimen/map_address_height" android:minHeight="50dp"
android:visibility="visible"> android:visibility="visible">
@ -118,8 +117,8 @@
<ImageView <ImageView
android:id="@+id/map_marker_arrow_2nd" android:id="@+id/map_marker_arrow_2nd"
android:layout_width="60dp" android:layout_width="60dp"
android:layout_height="30dp" android:layout_height="24dp"
android:src="@drawable/map_arrow_to_destination"/> android:src="@drawable/ic_arrow_marker_diretion"/>
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
@ -144,7 +143,6 @@
android:id="@+id/map_marker_address_2nd" android:id="@+id/map_marker_address_2nd"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:text="Dmitrievskaya st., 45" android:text="Dmitrievskaya st., 45"

View file

@ -161,7 +161,7 @@
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="@dimen/map_address_height" android:minHeight="60dp"
android:background="@color/markers_top_bar_background"> android:background="@color/markers_top_bar_background">
<LinearLayout <LinearLayout
@ -171,20 +171,20 @@
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:gravity="center_vertical" android:gravity="center_vertical"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
android:id="@+id/map_marker_arrow" android:id="@+id/map_marker_arrow"
android:layout_width="60dp" android:layout_width="66dp"
android:layout_height="40dp" android:layout_height="36dp"
android:src="@drawable/map_arrow_to_destination"/> android:src="@drawable/ic_arrow_marker_diretion"/>
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
@ -200,7 +200,6 @@
android:id="@+id/map_marker_address" android:id="@+id/map_marker_address"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:textColor="@color/marker_top_2nd_line_color" android:textColor="@color/marker_top_2nd_line_color"
android:textStyle="bold" android:textStyle="bold"
android:maxLines="1" android:maxLines="1"
@ -233,7 +232,7 @@
android:id="@+id/map_markers_top_bar_2nd" android:id="@+id/map_markers_top_bar_2nd"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="@dimen/map_address_height" android:minHeight="50dp"
android:background="@color/markers_top_bar_2nd_background" android:background="@color/markers_top_bar_2nd_background"
android:visibility="visible"> android:visibility="visible">
@ -254,9 +253,9 @@
<ImageView <ImageView
android:id="@+id/map_marker_arrow_2nd" android:id="@+id/map_marker_arrow_2nd"
android:layout_width="60dp" android:layout_width="66dp"
android:layout_height="30dp" android:layout_height="24dp"
android:src="@drawable/map_arrow_to_destination"/> android:src="@drawable/ic_arrow_marker_diretion"/>
<RelativeLayout <RelativeLayout
android:layout_width="0dp" android:layout_width="0dp"

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="markers_top_bar_background">#145256</color> <color name="markers_top_bar_background">#0f5257</color>
<color name="markers_top_bar_2nd_background">#0e3b3e</color> <color name="markers_top_bar_2nd_background">#0c4347</color>
<color name="marker_top_2nd_line_color">#588689</color> <color name="marker_top_2nd_line_color">#859899</color>
<color name="marker_blue">#2196f3</color> <color name="marker_blue">#2196f3</color>
<color name="marker_green">#73b825</color> <color name="marker_green">#73b825</color>

View file

@ -8,12 +8,15 @@ import net.osmand.data.PointDescription;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
public class MapMarkersHelper { public class MapMarkersHelper {
public static final int MAP_MARKERS_COLORS_COUNT = 7; public static final int MAP_MARKERS_COLORS_COUNT = 7;
private List<MapMarker> mapMarkers = new ArrayList<>(); private List<MapMarker> mapMarkers = new ArrayList<>();
private List<MapMarker> mapMarkersPositions = new ArrayList<>();
private List<MapMarker> mapMarkersHistory = new ArrayList<>(); private List<MapMarker> mapMarkersHistory = new ArrayList<>();
private OsmandSettings settings; private OsmandSettings settings;
private List<MapMarkerChangedListener> listeners = new ArrayList<>(); private List<MapMarkerChangedListener> listeners = new ArrayList<>();
@ -29,14 +32,16 @@ public class MapMarkersHelper {
public LatLon point; public LatLon point;
private PointDescription pointDescription; private PointDescription pointDescription;
public int colorIndex; public int colorIndex;
public int pos;
public int index; public int index;
public boolean history; public boolean history;
public int dist; public int dist;
public MapMarker(LatLon point, PointDescription name, int colorIndex, int index) { public MapMarker(LatLon point, PointDescription name, int colorIndex, int pos, int index) {
this.point = point; this.point = point;
this.pointDescription = name; this.pointDescription = name;
this.colorIndex = colorIndex; this.colorIndex = colorIndex;
this.pos = pos;
this.index = index; this.index = index;
} }
@ -89,24 +94,58 @@ public class MapMarkersHelper {
List<LatLon> ips = settings.getMapMarkersPoints(); List<LatLon> ips = settings.getMapMarkersPoints();
List<String> desc = settings.getMapMarkersPointDescriptions(ips.size()); List<String> desc = settings.getMapMarkersPointDescriptions(ips.size());
List<Integer> colors = settings.getMapMarkersColors(ips.size()); List<Integer> colors = settings.getMapMarkersColors(ips.size());
List<Integer> positions = settings.getMapMarkersPositions(ips.size());
int colorIndex = 0;
int pos = 0;
for (int i = 0; i < ips.size(); i++) { for (int i = 0; i < ips.size(); i++) {
if (colors.size() > i) {
colorIndex = colors.get(i);
}
if (positions.size() > i) {
pos = positions.get(i);
} else {
pos++;
}
MapMarker mapMarker = new MapMarker(ips.get(i), MapMarker mapMarker = new MapMarker(ips.get(i),
PointDescription.deserializeFromString(desc.get(i), ips.get(i)), colors.get(i), i); PointDescription.deserializeFromString(desc.get(i), ips.get(i)), colorIndex,
pos, i);
mapMarkers.add(mapMarker); mapMarkers.add(mapMarker);
lookupAddress(mapMarker, false); lookupAddress(mapMarker, false);
} }
updatePositionArray();
ips = settings.getMapMarkersHistoryPoints(); ips = settings.getMapMarkersHistoryPoints();
desc = settings.getMapMarkersHistoryPointDescriptions(ips.size()); desc = settings.getMapMarkersHistoryPointDescriptions(ips.size());
colors = settings.getMapMarkersHistoryColors(ips.size()); colors = settings.getMapMarkersHistoryColors(ips.size());
for (int i = 0; i < ips.size(); i++) { for (int i = 0; i < ips.size(); i++) {
MapMarker mapMarker = new MapMarker(ips.get(i), MapMarker mapMarker = new MapMarker(ips.get(i),
PointDescription.deserializeFromString(desc.get(i), ips.get(i)), colors.get(i), i); PointDescription.deserializeFromString(desc.get(i), ips.get(i)), colors.get(i), 0, i);
mapMarker.history = true; mapMarker.history = true;
mapMarkersHistory.add(mapMarker); mapMarkersHistory.add(mapMarker);
lookupAddress(mapMarker, true); lookupAddress(mapMarker, true);
} }
} }
private void updatePositionArray() {
mapMarkersPositions.clear();
mapMarkersPositions.addAll(mapMarkers);
Collections.sort(mapMarkersPositions, new Comparator<MapMarker>() {
@Override
public int compare(MapMarker lhs, MapMarker rhs) {
return lhs.pos < rhs.pos ? -1 : (lhs.pos == rhs.pos ? 0 : 1);
}
});
}
public void normalizePositions() {
for (int i = 0; i < mapMarkersPositions.size(); i++) {
MapMarker marker = mapMarkersPositions.get(i);
marker.pos = i;
}
saveMapMarkers(mapMarkers, null);
}
private void lookupAddress(final MapMarker mapMarker, final boolean history) { private void lookupAddress(final MapMarker mapMarker, final boolean history) {
if (mapMarker != null && mapMarker.pointDescription.isSearchingAddress(ctx)) { if (mapMarker != null && mapMarker.pointDescription.isSearchingAddress(ctx)) {
cancelPointAddressRequests(mapMarker.point); cancelPointAddressRequests(mapMarker.point);
@ -123,7 +162,7 @@ public class MapMarkersHelper {
mapMarker.pointDescription, mapMarker.colorIndex); mapMarker.pointDescription, mapMarker.colorIndex);
} else { } else {
settings.updateMapMarker(mapMarker.point.getLatitude(), mapMarker.point.getLongitude(), settings.updateMapMarker(mapMarker.point.getLatitude(), mapMarker.point.getLongitude(),
mapMarker.pointDescription, mapMarker.colorIndex); mapMarker.pointDescription, mapMarker.colorIndex, mapMarker.pos);
} }
updateMarker(mapMarker); updateMarker(mapMarker);
} }
@ -140,6 +179,7 @@ public class MapMarkersHelper {
for (MapMarker marker : mapMarkers) { for (MapMarker marker : mapMarkers) {
marker.index = ind++; marker.index = ind++;
} }
updatePositionArray();
refresh(); refresh();
} }
@ -147,6 +187,10 @@ public class MapMarkersHelper {
return mapMarkers; return mapMarkers;
} }
public List<MapMarker> getMapMarkersPositions() {
return mapMarkersPositions;
}
public List<MapMarker> getMapMarkersHistory() { public List<MapMarker> getMapMarkersHistory() {
return mapMarkersHistory; return mapMarkersHistory;
} }
@ -176,25 +220,19 @@ public class MapMarkersHelper {
markers.add(marker); markers.add(marker);
} }
mapMarkers = markers; mapMarkers = markers;
saveMapMarkers(mapMarkers, mapMarkersHistory); saveMapMarkers(mapMarkers, null);
readFromSettings();
refresh();
} }
public void removeActiveMarkers() { public void removeActiveMarkers() {
cancelAddressRequests(); cancelAddressRequests();
settings.clearActiveMapMarkers(); settings.clearActiveMapMarkers();
mapMarkers.clear();
readFromSettings(); readFromSettings();
refresh(); refresh();
} }
public void removeMarkersHistory() { public void removeMarkersHistory() {
cancelAddressRequests(); cancelAddressRequests();
settings.clearMapMarkersHistory(); settings.clearMapMarkersHistory();
mapMarkersHistory.clear();
readFromSettings(); readFromSettings();
refresh(); refresh();
} }
@ -214,6 +252,7 @@ public class MapMarkersHelper {
double[] longitudes = new double[points.size()]; double[] longitudes = new double[points.size()];
List<PointDescription> pointDescriptions = new ArrayList<>(); List<PointDescription> pointDescriptions = new ArrayList<>();
int[] colorIndexes = new int[points.size()]; int[] colorIndexes = new int[points.size()];
int[] positions = new int[points.size()];
int[] indexes = new int[points.size()]; int[] indexes = new int[points.size()];
for (int i = 0; i < points.size(); i++) { for (int i = 0; i < points.size(); i++) {
LatLon point = points.get(i); LatLon point = points.get(i);
@ -241,11 +280,12 @@ public class MapMarkersHelper {
longitudes[i] = point.getLongitude(); longitudes[i] = point.getLongitude();
pointDescriptions.add(pointDescription); pointDescriptions.add(pointDescription);
colorIndexes[i] = colorIndex; colorIndexes[i] = colorIndex;
positions[i] = -1 - i;
indexes[i] = 0; indexes[i] = 0;
} }
settings.insertMapMarkers(latitudes, longitudes, pointDescriptions, colorIndexes, indexes); settings.insertMapMarkers(latitudes, longitudes, pointDescriptions, colorIndexes, positions, indexes);
readFromSettings(); readFromSettings();
refresh(); normalizePositions();
} }
} }
@ -278,12 +318,14 @@ public class MapMarkersHelper {
List<LatLon> ls = new ArrayList<>(markers.size()); List<LatLon> ls = new ArrayList<>(markers.size());
List<String> names = new ArrayList<>(markers.size()); List<String> names = new ArrayList<>(markers.size());
List<Integer> colors = new ArrayList<>(markers.size()); List<Integer> colors = new ArrayList<>(markers.size());
List<Integer> positions = new ArrayList<>(markers.size());
for (MapMarker marker : markers) { for (MapMarker marker : markers) {
ls.add(marker.point); ls.add(marker.point);
names.add(PointDescription.serializeToString(marker.pointDescription)); names.add(PointDescription.serializeToString(marker.pointDescription));
colors.add(marker.colorIndex); colors.add(marker.colorIndex);
positions.add(marker.pos);
} }
settings.saveMapMarkers(ls, names, colors); settings.saveMapMarkers(ls, names, colors, positions);
} }
if (markersHistory != null) { if (markersHistory != null) {

View file

@ -176,7 +176,9 @@ public class OsmandSettings {
@Override @Override
public String getId() { public String getId() {
return "application_mode"; return "application_mode";
}; }
;
@Override @Override
public ApplicationMode get() { public ApplicationMode get() {
@ -191,12 +193,16 @@ public class OsmandSettings {
@Override @Override
public void resetToDefault() { public void resetToDefault() {
set(ApplicationMode.DEFAULT); set(ApplicationMode.DEFAULT);
}; }
;
@Override @Override
public boolean isSet() { public boolean isSet() {
return true; return true;
}; }
;
@Override @Override
public boolean set(ApplicationMode val) { public boolean set(ApplicationMode val) {
@ -235,6 +241,7 @@ public class OsmandSettings {
public boolean isInternetConnectionAvailable() { public boolean isInternetConnectionAvailable() {
return isInternetConnectionAvailable(false); return isInternetConnectionAvailable(false);
} }
public boolean isInternetConnectionAvailable(boolean update) { public boolean isInternetConnectionAvailable(boolean update) {
long delta = System.currentTimeMillis() - lastTimeInternetConnectionChecked; long delta = System.currentTimeMillis() - lastTimeInternetConnectionChecked;
if (delta < 0 || delta > 15000 || update) { if (delta < 0 || delta > 15000 || update) {
@ -637,6 +644,7 @@ public class OsmandSettings {
registeredPreferences.put(id, p); registeredPreferences.put(id, p);
return p; return p;
} }
public final CommonPreference<Boolean> USE_FAST_RECALCULATION = new BooleanPreference("use_fast_recalculation", true).makeGlobal().cache(); public final CommonPreference<Boolean> USE_FAST_RECALCULATION = new BooleanPreference("use_fast_recalculation", true).makeGlobal().cache();
public final CommonPreference<Boolean> SHOW_CARD_TO_CHOOSE_DRAWER = new BooleanPreference("show_card_to_choose_drawer", false).makeGlobal(); public final CommonPreference<Boolean> SHOW_CARD_TO_CHOOSE_DRAWER = new BooleanPreference("show_card_to_choose_drawer", false).makeGlobal();
@ -678,7 +686,9 @@ public class OsmandSettings {
METRIC_SYSTEM.set(val.defMetrics); METRIC_SYSTEM.set(val.defMetrics);
} }
return super.setValue(prefs, val); return super.setValue(prefs, val);
}; }
;
protected DrivingRegion getDefaultValue() { protected DrivingRegion getDefaultValue() {
Locale df = Locale.getDefault(); Locale df = Locale.getDefault();
@ -696,7 +706,9 @@ public class OsmandSettings {
// return DrivingRegion.UK_AND_OTHERS; // return DrivingRegion.UK_AND_OTHERS;
} }
return DrivingRegion.EUROPE_ASIA; return DrivingRegion.EUROPE_ASIA;
}; }
;
}.makeGlobal().cache(); }.makeGlobal().cache();
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
@ -705,7 +717,9 @@ public class OsmandSettings {
"default_metric_system", MetricsConstants.KILOMETERS_AND_METERS, MetricsConstants.values()) { "default_metric_system", MetricsConstants.KILOMETERS_AND_METERS, MetricsConstants.values()) {
protected MetricsConstants getDefaultValue() { protected MetricsConstants getDefaultValue() {
return DRIVING_REGION.get().defMetrics; return DRIVING_REGION.get().defMetrics;
}; }
;
}.makeGlobal().cache(); }.makeGlobal().cache();
@ -732,7 +746,9 @@ public class OsmandSettings {
} else { } else {
return SpeedConstants.MILES_PER_HOUR; return SpeedConstants.MILES_PER_HOUR;
} }
}; }
;
}.makeProfile().cache(); }.makeProfile().cache();
@ -784,17 +800,18 @@ public class OsmandSettings {
public final CommonPreference<Float> TEXT_SCALE = new FloatPreference("text_scale", 1f).makeProfile().cache(); public final CommonPreference<Float> TEXT_SCALE = new FloatPreference("text_scale", 1f).makeProfile().cache();
{ {
TEXT_SCALE.setModeDefaultValue(ApplicationMode.CAR, 1.25f); TEXT_SCALE.setModeDefaultValue(ApplicationMode.CAR, 1.25f);
} }
public final CommonPreference<Float> MAP_DENSITY = new FloatPreference("map_density_n", 1f).makeProfile().cache(); public final CommonPreference<Float> MAP_DENSITY = new FloatPreference("map_density_n", 1f).makeProfile().cache();
{ {
MAP_DENSITY.setModeDefaultValue(ApplicationMode.CAR, 1.5f); MAP_DENSITY.setModeDefaultValue(ApplicationMode.CAR, 1.5f);
} }
public final OsmandPreference<Boolean> SHOW_POI_LABEL = new BooleanPreference("show_poi_label", false).makeGlobal(); public final OsmandPreference<Boolean> SHOW_POI_LABEL = new BooleanPreference("show_poi_label", false).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
@ -834,6 +851,7 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<DayNightMode> DAYNIGHT_MODE = public final CommonPreference<DayNightMode> DAYNIGHT_MODE =
new EnumIntPreference<DayNightMode>("daynight_mode", DayNightMode.DAY, DayNightMode.values()); new EnumIntPreference<DayNightMode>("daynight_mode", DayNightMode.DAY, DayNightMode.values());
{ {
DAYNIGHT_MODE.makeProfile().cache(); DAYNIGHT_MODE.makeProfile().cache();
DAYNIGHT_MODE.setModeDefaultValue(ApplicationMode.CAR, DayNightMode.AUTO); DAYNIGHT_MODE.setModeDefaultValue(ApplicationMode.CAR, DayNightMode.AUTO);
@ -850,6 +868,7 @@ public class OsmandSettings {
public final CommonPreference<AutoZoomMap> AUTO_ZOOM_MAP = public final CommonPreference<AutoZoomMap> AUTO_ZOOM_MAP =
new EnumIntPreference<AutoZoomMap>("auto_zoom_map_new", AutoZoomMap.NONE, new EnumIntPreference<AutoZoomMap>("auto_zoom_map_new", AutoZoomMap.NONE,
AutoZoomMap.values()).makeProfile().cache(); AutoZoomMap.values()).makeProfile().cache();
{ {
AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.CAR, AutoZoomMap.FAR); AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.CAR, AutoZoomMap.FAR);
AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.BICYCLE, AutoZoomMap.NONE); AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.BICYCLE, AutoZoomMap.NONE);
@ -863,10 +882,13 @@ public class OsmandSettings {
return 10; return 10;
} }
return -1; return -1;
}; }
;
}.makeGlobal().cache(); }.makeGlobal().cache();
public final CommonPreference<Boolean> SNAP_TO_ROAD = new BooleanPreference("snap_to_road", false).makeProfile().cache(); public final CommonPreference<Boolean> SNAP_TO_ROAD = new BooleanPreference("snap_to_road", false).makeProfile().cache();
{ {
SNAP_TO_ROAD.setModeDefaultValue(ApplicationMode.CAR, true); SNAP_TO_ROAD.setModeDefaultValue(ApplicationMode.CAR, true);
SNAP_TO_ROAD.setModeDefaultValue(ApplicationMode.BICYCLE, true); SNAP_TO_ROAD.setModeDefaultValue(ApplicationMode.BICYCLE, true);
@ -885,6 +907,7 @@ public class OsmandSettings {
public final CommonPreference<Boolean> SAVE_GLOBAL_TRACK_REMEMBER = new BooleanPreference("save_global_track_remember", false).makeGlobal().cache(); public final CommonPreference<Boolean> SAVE_GLOBAL_TRACK_REMEMBER = new BooleanPreference("save_global_track_remember", false).makeGlobal().cache();
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<Boolean> SAVE_TRACK_TO_GPX = new BooleanPreference("save_track_to_gpx", false).makeProfile().cache(); public final CommonPreference<Boolean> SAVE_TRACK_TO_GPX = new BooleanPreference("save_track_to_gpx", false).makeProfile().cache();
{ {
SAVE_TRACK_TO_GPX.setModeDefaultValue(ApplicationMode.CAR, false); SAVE_TRACK_TO_GPX.setModeDefaultValue(ApplicationMode.CAR, false);
SAVE_TRACK_TO_GPX.setModeDefaultValue(ApplicationMode.BICYCLE, false); SAVE_TRACK_TO_GPX.setModeDefaultValue(ApplicationMode.BICYCLE, false);
@ -899,19 +922,25 @@ public class OsmandSettings {
public final CommonPreference<Boolean> DISABLE_COMPLEX_ROUTING = new BooleanPreference("disable_complex_routing", false).makeGlobal(); public final CommonPreference<Boolean> DISABLE_COMPLEX_ROUTING = new BooleanPreference("disable_complex_routing", false).makeGlobal();
public final CommonPreference<Boolean> SHOW_TRAFFIC_WARNINGS = new BooleanPreference("show_traffic_warnings", false).makeProfile().cache(); public final CommonPreference<Boolean> SHOW_TRAFFIC_WARNINGS = new BooleanPreference("show_traffic_warnings", false).makeProfile().cache();
{ {
SHOW_TRAFFIC_WARNINGS.setModeDefaultValue(ApplicationMode.CAR, true); SHOW_TRAFFIC_WARNINGS.setModeDefaultValue(ApplicationMode.CAR, true);
} }
public final CommonPreference<Boolean> SHOW_PEDESTRIAN = new BooleanPreference("show_pedestrian", false).makeProfile().cache(); public final CommonPreference<Boolean> SHOW_PEDESTRIAN = new BooleanPreference("show_pedestrian", false).makeProfile().cache();
{ {
SHOW_PEDESTRIAN.setModeDefaultValue(ApplicationMode.CAR, true); SHOW_PEDESTRIAN.setModeDefaultValue(ApplicationMode.CAR, true);
} }
public final OsmandPreference<Boolean> SHOW_CAMERAS = new BooleanPreference("show_cameras", false).makeProfile().cache(); public final OsmandPreference<Boolean> SHOW_CAMERAS = new BooleanPreference("show_cameras", false).makeProfile().cache();
public final CommonPreference<Boolean> SHOW_LANES = new BooleanPreference("show_lanes", false).makeProfile().cache(); public final CommonPreference<Boolean> SHOW_LANES = new BooleanPreference("show_lanes", false).makeProfile().cache();
{ {
SHOW_LANES.setModeDefaultValue(ApplicationMode.CAR, true); SHOW_LANES.setModeDefaultValue(ApplicationMode.CAR, true);
SHOW_LANES.setModeDefaultValue(ApplicationMode.BICYCLE, true); SHOW_LANES.setModeDefaultValue(ApplicationMode.BICYCLE, true);
} }
public final OsmandPreference<Boolean> SHOW_WPT = new BooleanPreference("show_gpx_wpt", true).makeGlobal().cache(); public final OsmandPreference<Boolean> SHOW_WPT = new BooleanPreference("show_gpx_wpt", true).makeGlobal().cache();
public final OsmandPreference<Boolean> SHOW_NEARBY_FAVORITES = new BooleanPreference("show_nearby_favorites", false).makeGlobal().cache(); public final OsmandPreference<Boolean> SHOW_NEARBY_FAVORITES = new BooleanPreference("show_nearby_favorites", false).makeGlobal().cache();
public final OsmandPreference<Boolean> SHOW_NEARBY_POI = new BooleanPreference("show_nearby_poi", false).makeGlobal().cache(); public final OsmandPreference<Boolean> SHOW_NEARBY_POI = new BooleanPreference("show_nearby_poi", false).makeGlobal().cache();
@ -940,6 +969,7 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<Integer> SAVE_TRACK_INTERVAL = new IntPreference("save_track_interval", 5000).makeProfile(); public final CommonPreference<Integer> SAVE_TRACK_INTERVAL = new IntPreference("save_track_interval", 5000).makeProfile();
{ {
SAVE_TRACK_INTERVAL.setModeDefaultValue(ApplicationMode.CAR, 3000); SAVE_TRACK_INTERVAL.setModeDefaultValue(ApplicationMode.CAR, 3000);
SAVE_TRACK_INTERVAL.setModeDefaultValue(ApplicationMode.BICYCLE, 7000); SAVE_TRACK_INTERVAL.setModeDefaultValue(ApplicationMode.BICYCLE, 7000);
@ -991,6 +1021,7 @@ public class OsmandSettings {
public final OsmandPreference<Boolean> SHOW_FAVORITES = new BooleanPreference("show_favorites", true).makeGlobal().cache(); public final OsmandPreference<Boolean> SHOW_FAVORITES = new BooleanPreference("show_favorites", true).makeGlobal().cache();
public final CommonPreference<Boolean> SHOW_ZOOM_BUTTONS_NAVIGATION = new BooleanPreference("show_zoom_buttons_navigation", false).makeProfile().cache(); public final CommonPreference<Boolean> SHOW_ZOOM_BUTTONS_NAVIGATION = new BooleanPreference("show_zoom_buttons_navigation", false).makeProfile().cache();
{ {
SHOW_ZOOM_BUTTONS_NAVIGATION.setModeDefaultValue(ApplicationMode.PEDESTRIAN, true); SHOW_ZOOM_BUTTONS_NAVIGATION.setModeDefaultValue(ApplicationMode.PEDESTRIAN, true);
} }
@ -1013,6 +1044,7 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
// seconds to auto_follow // seconds to auto_follow
public final CommonPreference<Integer> AUTO_FOLLOW_ROUTE = new IntPreference("auto_follow_route", 0).makeProfile(); public final CommonPreference<Integer> AUTO_FOLLOW_ROUTE = new IntPreference("auto_follow_route", 0).makeProfile();
{ {
AUTO_FOLLOW_ROUTE.setModeDefaultValue(ApplicationMode.CAR, 15); AUTO_FOLLOW_ROUTE.setModeDefaultValue(ApplicationMode.CAR, 15);
AUTO_FOLLOW_ROUTE.setModeDefaultValue(ApplicationMode.BICYCLE, 15); AUTO_FOLLOW_ROUTE.setModeDefaultValue(ApplicationMode.BICYCLE, 15);
@ -1022,6 +1054,7 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
// seconds to auto_follow // seconds to auto_follow
public final CommonPreference<Integer> KEEP_INFORMING = new IntPreference("keep_informing", 0).makeProfile(); public final CommonPreference<Integer> KEEP_INFORMING = new IntPreference("keep_informing", 0).makeProfile();
{ {
// 0 means never // 0 means never
KEEP_INFORMING.setModeDefaultValue(ApplicationMode.CAR, 0); KEEP_INFORMING.setModeDefaultValue(ApplicationMode.CAR, 0);
@ -1031,6 +1064,7 @@ public class OsmandSettings {
// screen power save // screen power save
public final CommonPreference<Integer> WAKE_ON_VOICE_INT = new IntPreference("wake_on_voice_int", 0).makeProfile(); public final CommonPreference<Integer> WAKE_ON_VOICE_INT = new IntPreference("wake_on_voice_int", 0).makeProfile();
{ {
// 0 means never // 0 means never
WAKE_ON_VOICE_INT.setModeDefaultValue(ApplicationMode.CAR, 0); WAKE_ON_VOICE_INT.setModeDefaultValue(ApplicationMode.CAR, 0);
@ -1048,6 +1082,7 @@ public class OsmandSettings {
public static final int ROTATE_MAP_COMPASS = 2; public static final int ROTATE_MAP_COMPASS = 2;
public final CommonPreference<Integer> ROTATE_MAP = public final CommonPreference<Integer> ROTATE_MAP =
new IntPreference("rotate_map", ROTATE_MAP_NONE).makeProfile().cache(); new IntPreference("rotate_map", ROTATE_MAP_NONE).makeProfile().cache();
{ {
ROTATE_MAP.setModeDefaultValue(ApplicationMode.CAR, ROTATE_MAP_BEARING); ROTATE_MAP.setModeDefaultValue(ApplicationMode.CAR, ROTATE_MAP_BEARING);
ROTATE_MAP.setModeDefaultValue(ApplicationMode.BICYCLE, ROTATE_MAP_BEARING); ROTATE_MAP.setModeDefaultValue(ApplicationMode.BICYCLE, ROTATE_MAP_BEARING);
@ -1074,6 +1109,7 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<Boolean> SHOW_DESTINATION_ARROW = new BooleanPreference("show_destination_arrow", false).makeProfile(); public final CommonPreference<Boolean> SHOW_DESTINATION_ARROW = new BooleanPreference("show_destination_arrow", false).makeProfile();
{ {
SHOW_DESTINATION_ARROW.setModeDefaultValue(ApplicationMode.PEDESTRIAN, true); SHOW_DESTINATION_ARROW.setModeDefaultValue(ApplicationMode.PEDESTRIAN, true);
} }
@ -1133,7 +1169,6 @@ public class OsmandSettings {
} }
public ITileSource getTileSourceByName(String tileName, boolean warnWhenSelected) { public ITileSource getTileSourceByName(String tileName, boolean warnWhenSelected) {
if (tileName == null || tileName.length() == 0) { if (tileName == null || tileName.length() == 0) {
return null; return null;
@ -1415,6 +1450,7 @@ public class OsmandSettings {
} }
private Object objectToShow; private Object objectToShow;
public Object getAndClearObjectToShow() { public Object getAndClearObjectToShow() {
Object objectToShow = this.objectToShow; Object objectToShow = this.objectToShow;
this.objectToShow = null; this.objectToShow = null;
@ -1483,6 +1519,7 @@ public class OsmandSettings {
public final static String MAP_MARKERS_POINT = "map_markers_point"; //$NON-NLS-1$ public final static String MAP_MARKERS_POINT = "map_markers_point"; //$NON-NLS-1$
public final static String MAP_MARKERS_COLOR = "map_markers_color"; //$NON-NLS-1$ 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_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_HISTORY_POINT = "map_markers_history_point"; //$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_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 String MAP_MARKERS_HISTORY_DESCRIPTION = "map_markers_history_description"; //$NON-NLS-1$
@ -1537,14 +1574,17 @@ public class OsmandSettings {
return settingsAPI.edit(globalPreferences) return settingsAPI.edit(globalPreferences)
.remove(MAP_MARKERS_POINT) .remove(MAP_MARKERS_POINT)
.remove(MAP_MARKERS_DESCRIPTION) .remove(MAP_MARKERS_DESCRIPTION)
.remove(MAP_MARKERS_COLOR).commit(); .remove(MAP_MARKERS_COLOR)
.remove(MAP_MARKERS_POSITION)
.commit();
} }
public boolean clearMapMarkersHistory() { public boolean clearMapMarkersHistory() {
return settingsAPI.edit(globalPreferences) return settingsAPI.edit(globalPreferences)
.remove(MAP_MARKERS_HISTORY_POINT) .remove(MAP_MARKERS_HISTORY_POINT)
.remove(MAP_MARKERS_HISTORY_DESCRIPTION) .remove(MAP_MARKERS_HISTORY_DESCRIPTION)
.remove(MAP_MARKERS_HISTORY_COLOR).commit(); .remove(MAP_MARKERS_HISTORY_COLOR)
.commit();
} }
public final CommonPreference<Boolean> USE_INTERMEDIATE_POINTS_NAVIGATION = public final CommonPreference<Boolean> USE_INTERMEDIATE_POINTS_NAVIGATION =
@ -1568,24 +1608,26 @@ public class OsmandSettings {
} }
@Override @Override
public boolean savePoints(List<LatLon> ps, List<String> ds, List<Integer> cs) { public boolean savePoints(List<LatLon> ps, List<String> ds, List<Integer> cs, List<Integer> ns) {
if (ps.size() > MAP_MARKERS_HISTORY_LIMIT) { if (ps.size() > MAP_MARKERS_HISTORY_LIMIT) {
ps.remove(ps.size() - 1); ps.remove(ps.size() - 1);
ds.remove(ds.size() - 1); ds.remove(ds.size() - 1);
cs.remove(cs.size() - 1); cs.remove(cs.size() - 1);
} }
return super.savePoints(ps, ds, cs); return super.savePoints(ps, ds, cs, ns);
} }
} }
private class MapMarkersStorage extends MapPointsStorage { private class MapMarkersStorage extends MapPointsStorage {
protected String colorsKey; protected String colorsKey;
protected String posKey;
public MapMarkersStorage() { public MapMarkersStorage() {
pointsKey = MAP_MARKERS_POINT; pointsKey = MAP_MARKERS_POINT;
descriptionsKey = MAP_MARKERS_DESCRIPTION; descriptionsKey = MAP_MARKERS_DESCRIPTION;
colorsKey = MAP_MARKERS_COLOR; colorsKey = MAP_MARKERS_COLOR;
posKey = MAP_MARKERS_POSITION;
} }
public List<Integer> getColors(int sz) { public List<Integer> getColors(int sz) {
@ -1601,53 +1643,74 @@ public class OsmandSettings {
return list; return list;
} }
public List<Integer> getPositions(int sz) {
List<Integer> list = new ArrayList<>();
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));
}
}
return list;
}
public boolean insertPoint(double latitude, double longitude, public boolean insertPoint(double latitude, double longitude,
PointDescription historyDescription, int colorIndex, int index) { PointDescription historyDescription, int colorIndex, int pos, int index) {
List<LatLon> ps = getPoints(); List<LatLon> ps = getPoints();
List<String> ds = getPointDescriptions(ps.size()); List<String> ds = getPointDescriptions(ps.size());
List<Integer> cs = getColors(ps.size()); List<Integer> cs = getColors(ps.size());
List<Integer> ns = getPositions(ps.size());
ps.add(index, new LatLon(latitude, longitude)); ps.add(index, new LatLon(latitude, longitude));
ds.add(index, PointDescription.serializeToString(historyDescription)); ds.add(index, PointDescription.serializeToString(historyDescription));
cs.add(index, colorIndex); cs.add(index, colorIndex);
ns.add(index, pos);
if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) { if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription); SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription);
} }
return savePoints(ps, ds, cs); return savePoints(ps, ds, cs, ns);
} }
public boolean insertPoints(double[] latitudes, double[] longitudes, public boolean insertPoints(double[] latitudes, double[] longitudes,
List<PointDescription> historyDescriptions, int[] colorIndexes, int[] indexes) { List<PointDescription> historyDescriptions, int[] colorIndexes,
int[] positions, int[] indexes) {
List<LatLon> ps = getPoints(); List<LatLon> ps = getPoints();
List<String> ds = getPointDescriptions(ps.size()); List<String> ds = getPointDescriptions(ps.size());
List<Integer> cs = getColors(ps.size()); List<Integer> cs = getColors(ps.size());
List<Integer> ns = getPositions(ps.size());
for (int i = 0; i < latitudes.length; i++) { for (int i = 0; i < latitudes.length; i++) {
double latitude = latitudes[i]; double latitude = latitudes[i];
double longitude = longitudes[i]; double longitude = longitudes[i];
PointDescription historyDescription = historyDescriptions.get(i); PointDescription historyDescription = historyDescriptions.get(i);
int colorIndex = colorIndexes[i]; int colorIndex = colorIndexes[i];
int pos = positions[i];
int index = indexes[i]; int index = indexes[i];
ps.add(index, new LatLon(latitude, longitude)); ps.add(index, new LatLon(latitude, longitude));
ds.add(index, PointDescription.serializeToString(historyDescription)); ds.add(index, PointDescription.serializeToString(historyDescription));
cs.add(index, colorIndex); cs.add(index, colorIndex);
ns.add(index, pos);
if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) { if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription); SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription);
} }
} }
return savePoints(ps, ds, cs); return savePoints(ps, ds, cs, ns);
} }
public boolean updatePoint(double latitude, double longitude, public boolean updatePoint(double latitude, double longitude,
PointDescription historyDescription, int colorIndex) { PointDescription historyDescription, int colorIndex, int pos) {
List<LatLon> ps = getPoints(); List<LatLon> ps = getPoints();
List<String> ds = getPointDescriptions(ps.size()); List<String> ds = getPointDescriptions(ps.size());
List<Integer> cs = getColors(ps.size()); List<Integer> cs = getColors(ps.size());
int i = ps.indexOf(new LatLon(latitude, longitude)); List<Integer> ns = getPositions(ps.size());
ds.set(i, PointDescription.serializeToString(historyDescription)); int index = ps.indexOf(new LatLon(latitude, longitude));
cs.set(i, colorIndex); ds.set(index, PointDescription.serializeToString(historyDescription));
cs.set(index, colorIndex);
ns.set(index, pos);
if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) { if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription); SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription);
} }
return savePoints(ps, ds, cs); return savePoints(ps, ds, cs, ns);
} }
@Override @Override
@ -1655,13 +1718,15 @@ public class OsmandSettings {
List<LatLon> ps = getPoints(); List<LatLon> ps = getPoints();
List<String> ds = getPointDescriptions(ps.size()); List<String> ds = getPointDescriptions(ps.size());
List<Integer> cs = getColors(ps.size()); List<Integer> cs = getColors(ps.size());
List<Integer> ns = getPositions(ps.size());
ps.remove(index); ps.remove(index);
ds.remove(index); ds.remove(index);
cs.remove(index); cs.remove(index);
return savePoints(ps, ds, cs); ns.remove(index);
return savePoints(ps, ds, cs, ns);
} }
public boolean savePoints(List<LatLon> ps, List<String> ds, List<Integer> cs) { public boolean savePoints(List<LatLon> ps, List<String> ds, List<Integer> cs, List<Integer> ns) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < ps.size(); i++) { for (int i = 0; i < ps.size(); i++) {
if (i > 0) { if (i > 0) {
@ -1687,10 +1752,20 @@ public class OsmandSettings {
} }
cb.append(Integer.toString(cs.get(i))); cb.append(Integer.toString(cs.get(i)));
} }
StringBuilder nb = new StringBuilder();
if (ns != null) {
for (int i = 0; i < ns.size(); i++) {
if (i > 0) {
nb.append(",");
}
nb.append(Integer.toString(ns.get(i)));
}
}
return settingsAPI.edit(globalPreferences) return settingsAPI.edit(globalPreferences)
.putString(pointsKey, sb.toString()) .putString(pointsKey, sb.toString())
.putString(descriptionsKey, tb.toString()) .putString(descriptionsKey, tb.toString())
.putString(colorsKey, cb.toString()) .putString(colorsKey, cb.toString())
.putString(posKey, nb.toString())
.commit(); .commit();
} }
@ -1840,31 +1915,37 @@ public class OsmandSettings {
return mapMarkersStorage.getColors(sz); return mapMarkersStorage.getColors(sz);
} }
public List<Integer> getMapMarkersPositions(int sz) {
return mapMarkersStorage.getPositions(sz);
}
public List<LatLon> getMapMarkersPoints() { public List<LatLon> getMapMarkersPoints() {
return mapMarkersStorage.getPoints(); return mapMarkersStorage.getPoints();
} }
public boolean insertMapMarker(double latitude, double longitude, public boolean insertMapMarker(double latitude, double longitude,
PointDescription historyDescription, int colorIndex, int index) { PointDescription historyDescription, int colorIndex, int pos, int index) {
return mapMarkersStorage.insertPoint(latitude, longitude, historyDescription, colorIndex, index); return mapMarkersStorage.insertPoint(latitude, longitude, historyDescription, colorIndex, index, pos);
} }
public boolean insertMapMarkers(double[] latitudes, double[] longitudes, public boolean insertMapMarkers(double[] latitudes, double[] longitudes,
List<PointDescription> historyDescriptions, int[] colorIndexes, int[] indexes) { List<PointDescription> historyDescriptions, int[] colorIndexes,
return mapMarkersStorage.insertPoints(latitudes, longitudes, historyDescriptions, colorIndexes, indexes); int[] positions, int[] indexes) {
return mapMarkersStorage.insertPoints(latitudes, longitudes, historyDescriptions, colorIndexes,
positions, indexes);
} }
public boolean updateMapMarker(double latitude, double longitude, public boolean updateMapMarker(double latitude, double longitude,
PointDescription historyDescription, int colorIndex) { PointDescription historyDescription, int colorIndex, int pos) {
return mapMarkersStorage.updatePoint(latitude, longitude, historyDescription, colorIndex); return mapMarkersStorage.updatePoint(latitude, longitude, historyDescription, colorIndex, pos);
} }
public boolean deleteMapMarker(int index) { public boolean deleteMapMarker(int index) {
return mapMarkersStorage.deletePoint(index); return mapMarkersStorage.deletePoint(index);
} }
public boolean saveMapMarkers(List<LatLon> ps, List<String> ds, List<Integer> cs) { public boolean saveMapMarkers(List<LatLon> ps, List<String> ds, List<Integer> cs, List<Integer> ns) {
return mapMarkersStorage.savePoints(ps, ds, cs); return mapMarkersStorage.savePoints(ps, ds, cs, ns);
} }
@ -1882,12 +1963,12 @@ public class OsmandSettings {
public boolean insertMapMarkerHistory(double latitude, double longitude, public boolean insertMapMarkerHistory(double latitude, double longitude,
PointDescription historyDescription, int colorIndex, int index) { PointDescription historyDescription, int colorIndex, int index) {
return mapMarkersHistoryStorage.insertPoint(latitude, longitude, historyDescription, colorIndex, index); return mapMarkersHistoryStorage.insertPoint(latitude, longitude, historyDescription, colorIndex, index, 0);
} }
public boolean updateMapMarkerHistory(double latitude, double longitude, public boolean updateMapMarkerHistory(double latitude, double longitude,
PointDescription historyDescription, int colorIndex) { PointDescription historyDescription, int colorIndex) {
return mapMarkersHistoryStorage.updatePoint(latitude, longitude, historyDescription, colorIndex); return mapMarkersHistoryStorage.updatePoint(latitude, longitude, historyDescription, colorIndex, 0);
} }
public boolean deleteMapMarkerHistory(int index) { public boolean deleteMapMarkerHistory(int index) {
@ -1895,7 +1976,7 @@ public class OsmandSettings {
} }
public boolean saveMapMarkersHistory(List<LatLon> ps, List<String> ds, List<Integer> cs) { public boolean saveMapMarkersHistory(List<LatLon> ps, List<String> ds, List<Integer> cs) {
return mapMarkersHistoryStorage.savePoints(ps, ds, cs); return mapMarkersHistoryStorage.savePoints(ps, ds, cs, null);
} }
@ -2072,7 +2153,9 @@ public class OsmandSettings {
} }
} }
return "en-tts"; return "en-tts";
}; }
;
}.makeGlobal(); }.makeGlobal();
@ -2081,6 +2164,7 @@ public class OsmandSettings {
{ {
makeProfile(); makeProfile();
} }
@Override @Override
protected boolean setValue(Object prefs, String val) { protected boolean setValue(Object prefs, String val) {
if (val == null) { if (val == null) {
@ -2092,17 +2176,21 @@ public class OsmandSettings {
return true; return true;
} }
return false; return false;
}; }
;
}; };
Map<String, CommonPreference<String>> customRendersProps = new LinkedHashMap<String, OsmandSettings.CommonPreference<String>>(); Map<String, CommonPreference<String>> customRendersProps = new LinkedHashMap<String, OsmandSettings.CommonPreference<String>>();
public CommonPreference<String> getCustomRenderProperty(String attrName) { public CommonPreference<String> getCustomRenderProperty(String attrName) {
if (!customRendersProps.containsKey(attrName)) { if (!customRendersProps.containsKey(attrName)) {
customRendersProps.put(attrName, new StringPreference("nrenderer_" + attrName, "").makeProfile()); customRendersProps.put(attrName, new StringPreference("nrenderer_" + attrName, "").makeProfile());
} }
return customRendersProps.get(attrName); return customRendersProps.get(attrName);
} }
{ {
CommonPreference<String> pref = getCustomRenderProperty("appMode"); CommonPreference<String> pref = getCustomRenderProperty("appMode");
pref.setModeDefaultValue(ApplicationMode.CAR, "car"); pref.setModeDefaultValue(ApplicationMode.CAR, "car");
@ -2111,6 +2199,7 @@ public class OsmandSettings {
} }
Map<String, CommonPreference<Boolean>> customBooleanRendersProps = new LinkedHashMap<String, OsmandSettings.CommonPreference<Boolean>>(); Map<String, CommonPreference<Boolean>> customBooleanRendersProps = new LinkedHashMap<String, OsmandSettings.CommonPreference<Boolean>>();
public CommonPreference<Boolean> getCustomRenderBooleanProperty(String attrName) { public CommonPreference<Boolean> getCustomRenderBooleanProperty(String attrName) {
if (!customBooleanRendersProps.containsKey(attrName)) { if (!customBooleanRendersProps.containsKey(attrName)) {
customBooleanRendersProps.put(attrName, new BooleanPreference("nrenderer_" + attrName, false).makeProfile()); customBooleanRendersProps.put(attrName, new BooleanPreference("nrenderer_" + attrName, false).makeProfile());
@ -2119,18 +2208,21 @@ public class OsmandSettings {
} }
Map<String, CommonPreference<String>> customRoutingProps = new LinkedHashMap<String, OsmandSettings.CommonPreference<String>>(); Map<String, CommonPreference<String>> customRoutingProps = new LinkedHashMap<String, OsmandSettings.CommonPreference<String>>();
public CommonPreference<String> getCustomRoutingProperty(String attrName, String defValue) { public CommonPreference<String> getCustomRoutingProperty(String attrName, String defValue) {
if (!customRoutingProps.containsKey(attrName)) { if (!customRoutingProps.containsKey(attrName)) {
customRoutingProps.put(attrName, new StringPreference("prouting_" + attrName, defValue).makeProfile()); customRoutingProps.put(attrName, new StringPreference("prouting_" + attrName, defValue).makeProfile());
} }
return customRoutingProps.get(attrName); return customRoutingProps.get(attrName);
} }
{ {
// CommonPreference<String> pref = getCustomRoutingProperty("appMode"); // CommonPreference<String> pref = getCustomRoutingProperty("appMode");
// pref.setModeDefaultValue(ApplicationMode.CAR, "car"); // pref.setModeDefaultValue(ApplicationMode.CAR, "car");
} }
Map<String, CommonPreference<Boolean>> customBooleanRoutingProps = new LinkedHashMap<String, OsmandSettings.CommonPreference<Boolean>>(); Map<String, CommonPreference<Boolean>> customBooleanRoutingProps = new LinkedHashMap<String, OsmandSettings.CommonPreference<Boolean>>();
public CommonPreference<Boolean> getCustomRoutingBooleanProperty(String attrName) { public CommonPreference<Boolean> getCustomRoutingBooleanProperty(String attrName) {
if (!customBooleanRoutingProps.containsKey(attrName)) { if (!customBooleanRoutingProps.containsKey(attrName)) {
customBooleanRoutingProps.put(attrName, new BooleanPreference("prouting_" + attrName, false).makeProfile()); customBooleanRoutingProps.put(attrName, new BooleanPreference("prouting_" + attrName, false).makeProfile());
@ -2186,6 +2278,7 @@ public class OsmandSettings {
// UI boxes // UI boxes
public final CommonPreference<Boolean> TRANSPARENT_MAP_THEME = public final CommonPreference<Boolean> TRANSPARENT_MAP_THEME =
new BooleanPreference("transparent_map_theme", true).makeProfile(); new BooleanPreference("transparent_map_theme", true).makeProfile();
{ {
TRANSPARENT_MAP_THEME.setModeDefaultValue(ApplicationMode.CAR, false); TRANSPARENT_MAP_THEME.setModeDefaultValue(ApplicationMode.CAR, false);
TRANSPARENT_MAP_THEME.setModeDefaultValue(ApplicationMode.BICYCLE, false); TRANSPARENT_MAP_THEME.setModeDefaultValue(ApplicationMode.BICYCLE, false);
@ -2194,6 +2287,7 @@ public class OsmandSettings {
public final CommonPreference<Boolean> SHOW_STREET_NAME = public final CommonPreference<Boolean> SHOW_STREET_NAME =
new BooleanPreference("show_street_name", false).makeProfile(); new BooleanPreference("show_street_name", false).makeProfile();
{ {
SHOW_STREET_NAME.setModeDefaultValue(ApplicationMode.CAR, true); SHOW_STREET_NAME.setModeDefaultValue(ApplicationMode.CAR, true);
SHOW_STREET_NAME.setModeDefaultValue(ApplicationMode.BICYCLE, false); SHOW_STREET_NAME.setModeDefaultValue(ApplicationMode.BICYCLE, false);
@ -2351,11 +2445,11 @@ public class OsmandSettings {
NONE(R.string.auto_zoom_none, 0f, 18), NONE(R.string.auto_zoom_none, 0f, 18),
FARTHEST(R.string.auto_zoom_farthest, 1f, 15.5f), FARTHEST(R.string.auto_zoom_farthest, 1f, 15.5f),
FAR(R.string.auto_zoom_far, 1.4f, 17f), FAR(R.string.auto_zoom_far, 1.4f, 17f),
CLOSE(R.string.auto_zoom_close, 2f, 19f) CLOSE(R.string.auto_zoom_close, 2f, 19f);
;
public final float coefficient; public final float coefficient;
public final int name; public final int name;
public final float maxZoom; public final float maxZoom;
AutoZoomMap(int name, float coefficient, float maxZoom) { AutoZoomMap(int name, float coefficient, float maxZoom) {
this.name = name; this.name = name;
this.coefficient = coefficient; this.coefficient = coefficient;
@ -2374,8 +2468,7 @@ public class OsmandSettings {
US(R.string.driving_region_us, MetricsConstants.MILES_AND_FOOTS, false, true), US(R.string.driving_region_us, MetricsConstants.MILES_AND_FOOTS, false, true),
CANADA(R.string.driving_region_canada, MetricsConstants.KILOMETERS_AND_METERS, false, true), CANADA(R.string.driving_region_canada, MetricsConstants.KILOMETERS_AND_METERS, false, true),
UK_AND_OTHERS(R.string.driving_region_uk, MetricsConstants.MILES_AND_FOOTS, true, false), UK_AND_OTHERS(R.string.driving_region_uk, MetricsConstants.MILES_AND_FOOTS, true, false),
JAPAN(R.string.driving_region_japan, MetricsConstants.KILOMETERS_AND_METERS, true, false) JAPAN(R.string.driving_region_japan, MetricsConstants.KILOMETERS_AND_METERS, true, false);
;
public final boolean leftHandDriving; public final boolean leftHandDriving;
public final boolean americanSigns; public final boolean americanSigns;

View file

@ -90,7 +90,7 @@ public class MapMarkersWidgetsFactory {
}); });
IconsCache iconsCache = map.getMyApplication().getIconsCache(); IconsCache iconsCache = map.getMyApplication().getIconsCache();
if (isLandscapeLayout() && helper.getActiveMapMarkers().size() > 1) { if (isLandscapeLayout() && helper.getMapMarkersPositions().size() > 1) {
moreButton.setVisibility(View.GONE); moreButton.setVisibility(View.GONE);
} else { } else {
moreButton.setImageDrawable(iconsCache.getIcon(R.drawable.ic_overflow_menu_white, R.color.marker_top_2nd_line_color)); moreButton.setImageDrawable(iconsCache.getIcon(R.drawable.ic_overflow_menu_white, R.color.marker_top_2nd_line_color));
@ -129,16 +129,16 @@ public class MapMarkersWidgetsFactory {
} }
private void removeMarker(int index) { private void removeMarker(int index) {
if (helper.getActiveMapMarkers().size() > index) { if (helper.getMapMarkersPositions().size() > index) {
MapMarker marker = helper.getActiveMapMarkers().get(index); MapMarker marker = helper.getMapMarkersPositions().get(index);
helper.removeMapMarker(marker.index); helper.removeMapMarker(marker.index);
helper.addMapMarkerHistory(marker); helper.addMapMarkerHistory(marker);
} }
} }
private void showMarkerOnMap(int index) { private void showMarkerOnMap(int index) {
if (helper.getActiveMapMarkers().size() > index) { if (helper.getMapMarkersPositions().size() > index) {
MapMarker marker = helper.getActiveMapMarkers().get(index); MapMarker marker = helper.getMapMarkersPositions().get(index);
MapMarkerDialogHelper.showMarkerOnMap(map, marker); MapMarkerDialogHelper.showMarkerOnMap(map, marker);
} }
} }
@ -173,7 +173,7 @@ public class MapMarkersWidgetsFactory {
return; return;
} }
List<MapMarker> markers = helper.getActiveMapMarkers(); List<MapMarker> markers = helper.getMapMarkersPositions();
if (zoom < 3 || markers.size() == 0 if (zoom < 3 || markers.size() == 0
|| !map.getMyApplication().getSettings().SHOW_MAP_MARKERS_TOOLBAR.get() || !map.getMyApplication().getSettings().SHOW_MAP_MARKERS_TOOLBAR.get()
|| map.getMyApplication().getRoutingHelper().isFollowingMode() || map.getMyApplication().getRoutingHelper().isFollowingMode()
@ -223,9 +223,9 @@ public class MapMarkersWidgetsFactory {
} else { } else {
dd = (DirectionDrawable) arrowImg.getDrawable(); dd = (DirectionDrawable) arrowImg.getDrawable();
} }
dd.setImage(R.drawable.map_arrow_to_destination, MapMarkerDialogHelper.getMapMarkerColorId(marker.colorIndex)); dd.setImage(R.drawable.ic_arrow_marker_diretion, MapMarkerDialogHelper.getMapMarkerColorId(marker.colorIndex));
if (heading != null && loc != null) { if (heading != null && loc != null) {
dd.setAngle(mes[1] - heading + 90 + screenOrientation); dd.setAngle(mes[1] - heading + 180 + screenOrientation);
} }
if (newImage) { if (newImage) {
arrowImg.setImageDrawable(dd); arrowImg.setImageDrawable(dd);