Added switch on/off map markers to dev settings

This commit is contained in:
Alexey Kulish 2016-02-14 12:01:55 +03:00
parent 73e1283722
commit a3ed18c8df
11 changed files with 75 additions and 32 deletions

View file

@ -10,7 +10,8 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clickable="true" android:clickable="true"
android:minHeight="@dimen/map_address_height"> android:minHeight="@dimen/map_address_height"
android:visibility="gone">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -150,7 +150,8 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clickable="true" android:clickable="true"
android:minHeight="@dimen/map_address_height"> android:minHeight="@dimen/map_address_height"
android:visibility="gone">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -9,6 +9,8 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="show_map_markers">Map Markers</string>
<string name="show_map_markers_description">Activate Map Markers feature</string>
<string name="clear_active_markers_q">Do you want to delete all active markers?</string> <string name="clear_active_markers_q">Do you want to delete all active markers?</string>
<string name="clear_markers_history_q">Do you want to clear markers history?</string> <string name="clear_markers_history_q">Do you want to clear markers history?</string>
<string name="active_markers">Active markers</string> <string name="active_markers">Active markers</string>

View file

@ -1101,6 +1101,8 @@ public class OsmandSettings {
public final OsmandPreference<Boolean> SHOULD_SHOW_FREE_VERSION_BANNER = new BooleanPreference("should_show_free_version_banner", false).makeGlobal().cache(); public final OsmandPreference<Boolean> SHOULD_SHOW_FREE_VERSION_BANNER = new BooleanPreference("should_show_free_version_banner", false).makeGlobal().cache();
public final OsmandPreference<Boolean> USE_MAP_MARKERS = new BooleanPreference("use_map_markers", false).makeGlobal().cache();
public ITileSource getMapTileSource(boolean warnWhenSelected) { public ITileSource getMapTileSource(boolean warnWhenSelected) {
String tileName = MAP_TILE_SOURCES.get(); String tileName = MAP_TILE_SOURCES.get();
if (tileName != null) { if (tileName != null) {

View file

@ -98,14 +98,14 @@ public class MapActivityActions implements DialogProvider {
openIntermediateEditPointsDialog(); openIntermediateEditPointsDialog();
} }
*/
public void addAsTarget(double latitude, double longitude, PointDescription pd) { public void addAsTarget(double latitude, double longitude, PointDescription pd) {
TargetPointsHelper targets = getMyApplication().getTargetPointsHelper(); TargetPointsHelper targets = getMyApplication().getTargetPointsHelper();
targets.navigateToPoint(new LatLon(latitude, longitude), true, targets.getIntermediatePoints().size() + 1, targets.navigateToPoint(new LatLon(latitude, longitude), true, targets.getIntermediatePoints().size() + 1,
pd); pd);
openIntermediatePointsDialog(); openIntermediatePointsDialog();
} }
*/
public void addMapMarker(double latitude, double longitude, PointDescription pd) { public void addMapMarker(double latitude, double longitude, PointDescription pd) {
MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper(); MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
@ -286,7 +286,7 @@ public class MapActivityActions implements DialogProvider {
if (getMyApplication().getTargetPointsHelper().getPointToNavigate() != null && if (getMyApplication().getTargetPointsHelper().getPointToNavigate() != null &&
(mapActivity.getRoutingHelper().isFollowingMode() || mapActivity.getRoutingHelper().isRoutePlanningMode())) { (mapActivity.getRoutingHelper().isFollowingMode() || mapActivity.getRoutingHelper().isRoutePlanningMode())) {
adapter.item(R.string.context_menu_item_last_intermediate_point).iconColor( adapter.item(R.string.context_menu_item_last_intermediate_point).iconColor(
R.drawable.ic_action_flage_dark).reg(); R.drawable.ic_action_intermediate).reg();
} }
OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj); OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj);
@ -571,15 +571,27 @@ public class MapActivityActions implements DialogProvider {
return true; return true;
} }
}).reg(); }).reg();
optionsMenuHelper.item(R.string.map_markers).iconColor(R.drawable.ic_action_flag_dark) if (settings.USE_MAP_MARKERS.get()) {
.listen(new OnContextMenuClick() { optionsMenuHelper.item(R.string.map_markers).iconColor(R.drawable.ic_action_flag_dark)
@Override .listen(new OnContextMenuClick() {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) { @Override
MapActivity.clearPrevActivityIntent(); public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.MAP_MARKERS); MapActivity.clearPrevActivityIntent();
return false; mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.MAP_MARKERS);
} return false;
}).reg(); }
}).reg();
} else {
optionsMenuHelper.item(R.string.waypoints).iconColor(R.drawable.ic_action_intermediate)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS);
return false;
}
}).reg();
}
optionsMenuHelper.item(R.string.get_directions).iconColor(R.drawable.ic_action_gdirections_dark) optionsMenuHelper.item(R.string.get_directions).iconColor(R.drawable.ic_action_gdirections_dark)
.listen(new OnContextMenuClick() { .listen(new OnContextMenuClick() {
@Override @Override

View file

@ -146,8 +146,10 @@ public class MapActivityLayers {
navigationLayer = new PointNavigationLayer(activity); navigationLayer = new PointNavigationLayer(activity);
mapView.addLayer(navigationLayer, 7); mapView.addLayer(navigationLayer, 7);
// 7.3 map markers layer // 7.3 map markers layer
mapMarkersLayer = new MapMarkersLayer(activity); if (app.getSettings().USE_MAP_MARKERS.get()) {
mapView.addLayer(mapMarkersLayer, 7.3f); mapMarkersLayer = new MapMarkersLayer(activity);
mapView.addLayer(mapMarkersLayer, 7.3f);
}
// 7.5 Impassible roads // 7.5 Impassible roads
impassableRoadsLayer = new ImpassableRoadsLayer(activity); impassableRoadsLayer = new ImpassableRoadsLayer(activity);
mapView.addLayer(impassableRoadsLayer, 7.5f); mapView.addLayer(impassableRoadsLayer, 7.5f);
@ -463,8 +465,11 @@ public class MapActivityLayers {
public MapControlsLayer getMapControlsLayer() { public MapControlsLayer getMapControlsLayer() {
return mapControlsLayer; return mapControlsLayer;
} }
public MapMarkersLayer getMapMarkersLayer() {
return mapMarkersLayer;
}
public MapTileLayer getMapTileLayer() { public MapTileLayer getMapTileLayer() {
return mapTileLayer; return mapTileLayer;
} }

View file

@ -63,7 +63,7 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
firstRunPreference.setSummary(R.string.simulate_initial_startup_descr); firstRunPreference.setSummary(R.string.simulate_initial_startup_descr);
firstRunPreference.setSelectable(true); firstRunPreference.setSelectable(true);
firstRunPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { firstRunPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
getMyApplication().getAppInitializer().resetFirstTimeRun(); getMyApplication().getAppInitializer().resetFirstTimeRun();
getMyApplication().getSettings().FIRST_MAP_IS_DOWNLOADED.set(false); getMyApplication().getSettings().FIRST_MAP_IS_DOWNLOADED.set(false);
@ -77,6 +77,10 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
R.string.show_free_version_banner, R.string.show_free_version_banner,
R.string.show_free_version_banner_description)); R.string.show_free_version_banner_description));
cat.addPreference(createCheckBoxPreference(settings.USE_MAP_MARKERS,
R.string.show_map_markers,
R.string.show_map_markers_description));
Preference pref = new Preference(this); Preference pref = new Preference(this);
final Preference simulate = pref; final Preference simulate = pref;
final OsmAndLocationSimulation sim = getMyApplication().getLocationProvider().getLocationSimulation(); final OsmAndLocationSimulation sim = getMyApplication().getLocationProvider().getLocationSimulation();

View file

@ -21,6 +21,7 @@ import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener; import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -48,6 +49,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
MapMarkerChangedListener { MapMarkerChangedListener {
private MapActivity mapActivity; private MapActivity mapActivity;
private OsmandSettings settings;
private MapMultiSelectionMenu mapMultiSelectionMenu; private MapMultiSelectionMenu mapMultiSelectionMenu;
private FavoritePointEditor favoritePointEditor; private FavoritePointEditor favoritePointEditor;
@ -81,6 +83,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
public void setMapActivity(MapActivity mapActivity) { public void setMapActivity(MapActivity mapActivity) {
this.mapActivity = mapActivity; this.mapActivity = mapActivity;
settings = mapActivity.getMyApplication().getSettings();
if (!appModeListenerAdded) { if (!appModeListenerAdded) {
mapActivity.getMyApplication().getSettings().APPLICATION_MODE.addListener(this); mapActivity.getMyApplication().getSettings().APPLICATION_MODE.addListener(this);
appModeListenerAdded = true; appModeListenerAdded = true;
@ -500,12 +503,17 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
public void buttonWaypointPressed() { public void buttonWaypointPressed() {
if (pointDescription.isDestination()) { if (pointDescription.isDestination()) {
mapActivity.getMapActions().editWaypoints(); mapActivity.getMapActions().editWaypoints();
} else if (pointDescription.isMapMarker()) { } else if (settings.USE_MAP_MARKERS.get()) {
hide(); if (pointDescription.isMapMarker()) {
MapActivity.clearPrevActivityIntent(); hide();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.MAP_MARKERS); MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.MAP_MARKERS);
} else {
mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(),
getPointDescriptionForTarget());
}
} else { } else {
mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(), mapActivity.getMapActions().addAsTarget(latLon.getLatitude(), latLon.getLongitude(),
getPointDescriptionForTarget()); getPointDescriptionForTarget());
} }
close(); close();

View file

@ -387,8 +387,13 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
}); });
final ImageButton buttonWaypoint = (ImageButton) view.findViewById(R.id.context_menu_route_button); final ImageButton buttonWaypoint = (ImageButton) view.findViewById(R.id.context_menu_route_button);
buttonWaypoint.setImageDrawable(iconsCache.getIcon(R.drawable.map_action_flag_dark, if (getMyApplication().getSettings().USE_MAP_MARKERS.get()) {
!nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark)); buttonWaypoint.setImageDrawable(iconsCache.getIcon(R.drawable.map_action_flag_dark,
!nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
} else {
buttonWaypoint.setImageDrawable(iconsCache.getIcon(R.drawable.map_action_waypoint,
!nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
}
AndroidUtils.setDashButtonBackground(getMapActivity(), buttonWaypoint, nightMode); AndroidUtils.setDashButtonBackground(getMapActivity(), buttonWaypoint, nightMode);
buttonWaypoint.setOnClickListener(new View.OnClickListener() { buttonWaypoint.setOnClickListener(new View.OnClickListener() {
@Override @Override

View file

@ -8,6 +8,7 @@ import android.graphics.Paint;
import android.graphics.Paint.Align; import android.graphics.Paint.Align;
import android.graphics.Paint.Style; import android.graphics.Paint.Style;
import android.graphics.PointF; import android.graphics.PointF;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.data.QuadPoint; import net.osmand.data.QuadPoint;
@ -16,7 +17,6 @@ import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider; import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
import java.util.Iterator; import java.util.Iterator;
@ -79,8 +79,7 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu
@Override @Override
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings nightMode) { public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings nightMode) {
RoutingHelper routingHelper = view.getApplication().getRoutingHelper(); if (tb.getZoom() < 3) {
if (tb.getZoom() < 3 || (!routingHelper.isRoutePlanningMode() && !routingHelper.isFollowingMode())) {
return; return;
} }
@ -128,7 +127,7 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu
pointToNavigate = it.next(); pointToNavigate = it.next();
} }
if (pointToNavigate != null && !isLocationVisible(tb, pointToNavigate)) { if (pointToNavigate != null && !isLocationVisible(tb, pointToNavigate)) {
boolean show = !routingHelper.isRouteCalculated(); boolean show = !view.getApplication().getRoutingHelper().isRouteCalculated();
if(view.getSettings().SHOW_DESTINATION_ARROW.isSet()) { if(view.getSettings().SHOW_DESTINATION_ARROW.isSet()) {
show = view.getSettings().SHOW_DESTINATION_ARROW.get(); show = view.getSettings().SHOW_DESTINATION_ARROW.get();
} }

View file

@ -205,8 +205,12 @@ public class MapMarkersWidget {
arrowImg.invalidate(); arrowImg.invalidate();
int dist = (int) mes[0]; int dist = (int) mes[0];
distText.setText(OsmAndFormatter.getFormattedDistance(dist, map.getMyApplication())); if (loc != null) {
updateVisibility(okButton, dist < MIN_DIST_OK_VISIBLE); distText.setText(OsmAndFormatter.getFormattedDistance(dist, map.getMyApplication()));
} else {
distText.setText("" + map.getString(R.string.m));
}
updateVisibility(okButton, loc != null && dist < MIN_DIST_OK_VISIBLE);
String descr; String descr;
PointDescription pd = marker.getPointDescription(map); PointDescription pd = marker.getPointDescription(map);