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_height="wrap_content"
android:clickable="true"
android:minHeight="@dimen/map_address_height">
android:minHeight="@dimen/map_address_height"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"

View file

@ -150,7 +150,8 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:minHeight="@dimen/map_address_height">
android:minHeight="@dimen/map_address_height"
android:visibility="gone">
<LinearLayout
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).
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_markers_history_q">Do you want to clear markers history?</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> USE_MAP_MARKERS = new BooleanPreference("use_map_markers", false).makeGlobal().cache();
public ITileSource getMapTileSource(boolean warnWhenSelected) {
String tileName = MAP_TILE_SOURCES.get();
if (tileName != null) {

View file

@ -98,14 +98,14 @@ public class MapActivityActions implements DialogProvider {
openIntermediateEditPointsDialog();
}
*/
public void addAsTarget(double latitude, double longitude, PointDescription pd) {
TargetPointsHelper targets = getMyApplication().getTargetPointsHelper();
targets.navigateToPoint(new LatLon(latitude, longitude), true, targets.getIntermediatePoints().size() + 1,
pd);
openIntermediatePointsDialog();
}
*/
public void addMapMarker(double latitude, double longitude, PointDescription pd) {
MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
@ -286,7 +286,7 @@ public class MapActivityActions implements DialogProvider {
if (getMyApplication().getTargetPointsHelper().getPointToNavigate() != null &&
(mapActivity.getRoutingHelper().isFollowingMode() || mapActivity.getRoutingHelper().isRoutePlanningMode())) {
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);
@ -571,6 +571,7 @@ public class MapActivityActions implements DialogProvider {
return true;
}
}).reg();
if (settings.USE_MAP_MARKERS.get()) {
optionsMenuHelper.item(R.string.map_markers).iconColor(R.drawable.ic_action_flag_dark)
.listen(new OnContextMenuClick() {
@Override
@ -580,6 +581,17 @@ public class MapActivityActions implements DialogProvider {
return false;
}
}).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)
.listen(new OnContextMenuClick() {
@Override

View file

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

View file

@ -77,6 +77,10 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
R.string.show_free_version_banner,
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);
final Preference simulate = pref;
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.MapMarkersHelper.MapMarker;
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.activities.MapActivity;
@ -48,6 +49,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
MapMarkerChangedListener {
private MapActivity mapActivity;
private OsmandSettings settings;
private MapMultiSelectionMenu mapMultiSelectionMenu;
private FavoritePointEditor favoritePointEditor;
@ -81,6 +83,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
public void setMapActivity(MapActivity mapActivity) {
this.mapActivity = mapActivity;
settings = mapActivity.getMyApplication().getSettings();
if (!appModeListenerAdded) {
mapActivity.getMyApplication().getSettings().APPLICATION_MODE.addListener(this);
appModeListenerAdded = true;
@ -500,7 +503,8 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
public void buttonWaypointPressed() {
if (pointDescription.isDestination()) {
mapActivity.getMapActions().editWaypoints();
} else if (pointDescription.isMapMarker()) {
} else if (settings.USE_MAP_MARKERS.get()) {
if (pointDescription.isMapMarker()) {
hide();
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.MAP_MARKERS);
@ -508,6 +512,10 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(),
getPointDescriptionForTarget());
}
} else {
mapActivity.getMapActions().addAsTarget(latLon.getLatitude(), latLon.getLongitude(),
getPointDescriptionForTarget());
}
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);
if (getMyApplication().getSettings().USE_MAP_MARKERS.get()) {
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);
buttonWaypoint.setOnClickListener(new View.OnClickListener() {
@Override

View file

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

View file

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