consolidate auto_zoom_map and route_view_distance Settings

This commit is contained in:
sonora 2013-10-23 22:50:04 +02:00
parent 3dd3ec8fa9
commit 789c49baf1
7 changed files with 39 additions and 38 deletions

View file

@ -9,10 +9,10 @@
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="route_distance_none">No auto zoom</string>
<string name="route_distance_close">Зачыніць</string>
<string name="route_distance_far">To mid-range</string>
<string name="route_distance_farthest">To long-range</string>
<string name="auto_zoom_none">No auto zoom</string>
<string name="auto_zoom_close">Зачыніць</string>
<string name="auto_zoom_far">To mid-range</string>
<string name="auto_zoom_farthest">To long-range</string>
<string name="map_magnifier">Map magnifier</string>
<string name="base_world_map">Асноўная мапа сьвету</string>
<string name="tip_map_styles">Стыль мапы</string>

View file

@ -11,12 +11,10 @@
-->
<string name="route_is_too_long">The possible route is too long to be calculated by OsmAnd offline router.
In average routing is possible between points located in 200km radius, please add a waypoint to see the route. </string>
<string name="route_distance_none">No auto zoom</string>
<string name="route_distance_close">To close-up</string>
<string name="route_distance_far">To mid-range</string>
<string name="route_distance_farthest">To long-range</string>
<string name="route_distance_settings_descr">Configure map view distance (TODO naming)</string>
<string name="route_distance_settings">Map view distance (TODO naming)</string>
<string name="auto_zoom_none">No auto zoom</string>
<string name="auto_zoom_close">To close-up</string>
<string name="auto_zoom_far">To mid-range</string>
<string name="auto_zoom_farthest">To long-range</string>
<string name="map_magnifier">Map magnifier</string>
<string name="base_world_map">World basemap</string>
<string name="tip_map_styles">Map Styles</string>

View file

@ -6,8 +6,7 @@
<ListPreference android:title="@string/voice_provider" android:key="voice_provider" android:summary="@string/voice_provider_descr"></ListPreference>
<ListPreference android:key="auto_follow_route" android:title="@string/choose_auto_follow_route"
android:summary="@string/choose_auto_follow_route_descr"></ListPreference>
<CheckBoxPreference android:title="@string/auto_zoom_map" android:summary="@string/auto_zoom_map_descr" android:key="auto_zoom_map"></CheckBoxPreference>
<ListPreference android:key="route_view_distance" android:title="@string/auto_zoom_map"
<ListPreference android:key="auto_zoom_map" android:title="@string/auto_zoom_map"
android:summary="@string/auto_zoom_map_descr"></ListPreference>
<CheckBoxPreference android:title="@string/snap_to_road" android:summary="@string/snap_to_road_descr" android:key="snap_to_road"></CheckBoxPreference>
<Preference android:title="@string/show_warnings_title" android:summary="@string/show_warnings_descr" android:key="show_routing_alarms"/>
@ -18,5 +17,4 @@
android:key="use_compass_navigation"></CheckBoxPreference>
<CheckBoxPreference android:summary="@string/precise_routing_mode_descr" android:title="@string/precise_routing_mode"
android:key="precise_routing_mode"></CheckBoxPreference>
</PreferenceScreen>

View file

@ -678,9 +678,15 @@ public class OsmandSettings {
RouteService.values()).makeProfile();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<RouteViewDistance> ROUTE_VIEW_DISTANCE =
new EnumIntPreference<RouteViewDistance>("route_view_distance", RouteViewDistance.FARTHEST,
RouteViewDistance.values()).makeProfile().cache();
public final OsmandPreference<AutoViewMap> AUTO_ZOOM_MAP =
new EnumIntPreference<AutoViewMap>("auto_zoom_map", AutoZoomMap.NONE,
AutoZoomMap.values());
{
AUTO_ZOOM_MAP.makeProfile().cache();
AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.CAR, AutoZoomMap.FARTHEST);
AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.BICYCLE, AutoZoomMap.NONE);
AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.PEDESTRIAN, AutoZoomMap.NONE);
}
public final CommonPreference<Boolean> SNAP_TO_ROAD = new BooleanPreference("snap_to_road", false).makeProfile().cache();
{
@ -770,12 +776,6 @@ public class OsmandSettings {
SHOW_VIEW_ANGLE.setModeDefaultValue(ApplicationMode.BICYCLE, true);
SHOW_VIEW_ANGLE.setModeDefaultValue(ApplicationMode.PEDESTRIAN, true);
}
// this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<Boolean> AUTO_ZOOM_MAP = new BooleanPreference("auto_zoom_map", false).makeProfile();
{
AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.CAR, true);
}
// this value string is synchronized with settings_pref.xml preference name
// seconds to auto_follow
@ -1532,14 +1532,15 @@ public class OsmandSettings {
}
public enum RouteViewDistance {
FARTHEST(R.string.route_distance_farthest, 1f),
FAR(R.string.route_distance_far, 1.4f),
CLOSE(R.string.route_distance_close, 2f)
public enum AutoZoomMap {
NONE(R.string.auto_zoom_none, 0f),
FARTHEST(R.string.auto_zoom_farthest, 1f),
FAR(R.string.auto_zoom_far, 1.4f),
CLOSE(R.string.auto_zoom_close, 2f)
;
public final float coefficient;
public final int name;
RouteViewDistance(int name, float coefficient) {
AutoZoomMap(int name, float coefficient) {
this.name = name;
this.coefficient = coefficient;

View file

@ -22,6 +22,7 @@ import net.osmand.plus.BusyIndicator;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.AutoZoomMap;
import net.osmand.plus.PoiFilter;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
@ -364,7 +365,10 @@ public class MapActivity extends AccessibleActivity {
public void changeZoom(int stp){
// delta = Math.round(delta * OsmandMapTileView.ZOOM_DELTA) * OsmandMapTileView.ZOOM_DELTA_1;
boolean changeLocation = settings.AUTO_ZOOM_MAP.get();
boolean changeLocation = true;
if (settings.AUTO_ZOOM_MAP.get() == settings.AutoZoomMap.NONE) {
changeLocation = false;
}
final int newZoom = mapView.getZoom() + stp;
mapView.getAnimatedDraggingThread().startZooming(newZoom, changeLocation);
if (app.getInternalAPI().accessibilityEnabled())

View file

@ -8,7 +8,7 @@ import java.util.Set;
import net.osmand.IndexConstants;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.OsmandSettings.RouteViewDistance;
import net.osmand.plus.OsmandSettings.AutoZoomMap;
import net.osmand.plus.R;
import net.osmand.plus.routing.RouteProvider.RouteService;
import android.app.AlertDialog;
@ -28,7 +28,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
private Preference showAlarms;
private Preference speakAlarms;
private ListPreference routerServicePreference;
private ListPreference routeViewDistancePreference;
private ListPreference autoZoomMapPreference;
public static final String MORE_VALUE = "MORE_VALUE";
public SettingsNavigationActivity() {
@ -63,7 +63,6 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
PreferenceScreen screen = getPreferenceScreen();
settings = getMyApplication().getSettings();
registerBooleanPreference(settings.AUTO_ZOOM_MAP, screen);
registerBooleanPreference(settings.FAST_ROUTE_MODE, screen);
registerBooleanPreference(settings.PRECISE_ROUTING_MODE, screen);
registerBooleanPreference(settings.SNAP_TO_ROAD, screen);
@ -85,14 +84,14 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
routerServicePreference = (ListPreference) screen.findPreference(settings.ROUTER_SERVICE.getId());
entries = new String[RouteViewDistance.values().length];
entries = new String[AutoZoomMap.values().length];
for(int i=0; i<entries.length; i++){
entries[i] = getString(RouteViewDistance.values()[i].name);
entries[i] = getString(AutoZoomMap.values()[i].name);
}
registerListPreference(settings.ROUTE_VIEW_DISTANCE, screen, entries, RouteViewDistance.values());
registerListPreference(settings.AUTO_ZOOM_MAP, screen, entries, AutoZoomMap.values());
routeViewDistancePreference = (ListPreference) screen.findPreference(settings.ROUTE_VIEW_DISTANCE.getId());
routeViewDistancePreference.setOnPreferenceChangeListener(this);
autoZoomMapPreference = (ListPreference) screen.findPreference(settings.AUTO_ZOOM_MAP.getId());
autoZoomMapPreference.setOnPreferenceChangeListener(this);
avoidRouting = (Preference) screen.findPreference("avoid_in_routing");

View file

@ -9,6 +9,7 @@ import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.AutoZoomMap;
import net.osmand.plus.R;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.AnimateDraggingMapThread;
@ -79,7 +80,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
public void updateLocation(Location location) {
if (mapView != null) {
if (isMapLinkedToLocation() && location != null) {
if (settings.AUTO_ZOOM_MAP.get()) {
if (settings.AUTO_ZOOM_MAP.get() != settings.AutoZoomMap.NONE) {
autozoom(location);
}
int currentMapRotation = settings.ROTATE_MAP.get();
@ -160,7 +161,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
if (speed < 83f / 3.6) {
time = 60f;
}
time /= settings.ROUTE_VIEW_DISTANCE.get().coefficient;
time /= settings.AUTO_ZOOM_MAP.get().coefficient;
double distToSee = speed * time;
float zoomDelta = (float) (Math.log(visibleDist / distToSee) / Math.log(2.0f));
// check if 17, 18 is correct?