Added switch on/off map markers to dev settings
This commit is contained in:
parent
73e1283722
commit
a3ed18c8df
11 changed files with 75 additions and 32 deletions
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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,15 +571,27 @@ public class MapActivityActions implements DialogProvider {
|
|||
return true;
|
||||
}
|
||||
}).reg();
|
||||
optionsMenuHelper.item(R.string.map_markers).iconColor(R.drawable.ic_action_flag_dark)
|
||||
.listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.MAP_MARKERS);
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
if (settings.USE_MAP_MARKERS.get()) {
|
||||
optionsMenuHelper.item(R.string.map_markers).iconColor(R.drawable.ic_action_flag_dark)
|
||||
.listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.MAP_MARKERS);
|
||||
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
|
||||
|
|
|
@ -146,8 +146,10 @@ public class MapActivityLayers {
|
|||
navigationLayer = new PointNavigationLayer(activity);
|
||||
mapView.addLayer(navigationLayer, 7);
|
||||
// 7.3 map markers layer
|
||||
mapMarkersLayer = new MapMarkersLayer(activity);
|
||||
mapView.addLayer(mapMarkersLayer, 7.3f);
|
||||
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);
|
||||
|
@ -463,8 +465,11 @@ public class MapActivityLayers {
|
|||
public MapControlsLayer getMapControlsLayer() {
|
||||
return mapControlsLayer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public MapMarkersLayer getMapMarkersLayer() {
|
||||
return mapMarkersLayer;
|
||||
}
|
||||
|
||||
public MapTileLayer getMapTileLayer() {
|
||||
return mapTileLayer;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
|
|||
firstRunPreference.setSummary(R.string.simulate_initial_startup_descr);
|
||||
firstRunPreference.setSelectable(true);
|
||||
firstRunPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
getMyApplication().getAppInitializer().resetFirstTimeRun();
|
||||
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_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();
|
||||
|
|
|
@ -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,12 +503,17 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
public void buttonWaypointPressed() {
|
||||
if (pointDescription.isDestination()) {
|
||||
mapActivity.getMapActions().editWaypoints();
|
||||
} else if (pointDescription.isMapMarker()) {
|
||||
hide();
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.MAP_MARKERS);
|
||||
} else if (settings.USE_MAP_MARKERS.get()) {
|
||||
if (pointDescription.isMapMarker()) {
|
||||
hide();
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.MAP_MARKERS);
|
||||
} else {
|
||||
mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(),
|
||||
getPointDescriptionForTarget());
|
||||
}
|
||||
} else {
|
||||
mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(),
|
||||
mapActivity.getMapActions().addAsTarget(latLon.getLatitude(), latLon.getLongitude(),
|
||||
getPointDescriptionForTarget());
|
||||
}
|
||||
close();
|
||||
|
|
|
@ -387,8 +387,13 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
});
|
||||
|
||||
final ImageButton buttonWaypoint = (ImageButton) view.findViewById(R.id.context_menu_route_button);
|
||||
buttonWaypoint.setImageDrawable(iconsCache.getIcon(R.drawable.map_action_flag_dark,
|
||||
!nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
|
||||
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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -205,8 +205,12 @@ public class MapMarkersWidget {
|
|||
arrowImg.invalidate();
|
||||
|
||||
int dist = (int) mes[0];
|
||||
distText.setText(OsmAndFormatter.getFormattedDistance(dist, map.getMyApplication()));
|
||||
updateVisibility(okButton, dist < MIN_DIST_OK_VISIBLE);
|
||||
if (loc != null) {
|
||||
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;
|
||||
PointDescription pd = marker.getPointDescription(map);
|
||||
|
|
Loading…
Reference in a new issue