Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
745710dda1
5 changed files with 98 additions and 42 deletions
|
@ -12,7 +12,7 @@
|
||||||
<PreferenceCategory android:key="guidance_preferences" android:title="@string/guidance_preferences_descr">
|
<PreferenceCategory android:key="guidance_preferences" android:title="@string/guidance_preferences_descr">
|
||||||
<ListPreference android:key="auto_follow_route" android:title="@string/choose_auto_follow_route"
|
<ListPreference android:key="auto_follow_route" android:title="@string/choose_auto_follow_route"
|
||||||
android:summary="@string/choose_auto_follow_route_descr" />
|
android:summary="@string/choose_auto_follow_route_descr" />
|
||||||
<ListPreference android:key="auto_zoom_map_new" android:title="@string/auto_zoom_map"
|
<Preference android:key="auto_zoom_map_on_off" android:title="@string/auto_zoom_map"
|
||||||
android:summary="@string/auto_zoom_map_descr" />
|
android:summary="@string/auto_zoom_map_descr" />
|
||||||
<CheckBoxPreference android:title="@string/snap_to_road" android:summary="@string/snap_to_road_descr" android:key="snap_to_road" />
|
<CheckBoxPreference android:title="@string/snap_to_road" android:summary="@string/snap_to_road_descr" android:key="snap_to_road" />
|
||||||
<Preference android:title="@string/show_warnings_title" android:summary="@string/show_warnings_descr" android:key="show_routing_alarms"/>
|
<Preference android:title="@string/show_warnings_title" android:summary="@string/show_warnings_descr" android:key="show_routing_alarms"/>
|
||||||
|
|
|
@ -955,18 +955,20 @@ public class OsmandSettings {
|
||||||
RouteService.values()).makeProfile();
|
RouteService.values()).makeProfile();
|
||||||
|
|
||||||
// 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<AutoZoomMap> AUTO_ZOOM_MAP_PREV =
|
public final CommonPreference<Boolean> AUTO_ZOOM_MAP = new BooleanPreference("auto_zoom_map_on_off", false).makeProfile().cache();
|
||||||
new EnumIntPreference<AutoZoomMap>("auto_zoom_map_new_prev", AutoZoomMap.NONE,
|
|
||||||
AutoZoomMap.values()).makeProfile().cache();
|
|
||||||
|
|
||||||
public final CommonPreference<AutoZoomMap> AUTO_ZOOM_MAP =
|
|
||||||
new EnumIntPreference<AutoZoomMap>("auto_zoom_map_new", AutoZoomMap.NONE,
|
|
||||||
AutoZoomMap.values()).makeProfile().cache();
|
|
||||||
|
|
||||||
{
|
{
|
||||||
AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.CAR, AutoZoomMap.FAR);
|
AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.CAR, true);
|
||||||
AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.BICYCLE, AutoZoomMap.NONE);
|
AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.BICYCLE, false);
|
||||||
AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.PEDESTRIAN, AutoZoomMap.NONE);
|
AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.PEDESTRIAN, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final CommonPreference<AutoZoomMap> AUTO_ZOOM_MAP_SCALE =
|
||||||
|
new EnumIntPreference<AutoZoomMap>("auto_zoom_map_scale", AutoZoomMap.FAR,
|
||||||
|
AutoZoomMap.values()).makeProfile().cache();
|
||||||
|
{
|
||||||
|
AUTO_ZOOM_MAP_SCALE.setModeDefaultValue(ApplicationMode.CAR, AutoZoomMap.FAR);
|
||||||
|
AUTO_ZOOM_MAP_SCALE.setModeDefaultValue(ApplicationMode.BICYCLE, AutoZoomMap.CLOSE);
|
||||||
|
AUTO_ZOOM_MAP_SCALE.setModeDefaultValue(ApplicationMode.PEDESTRIAN, AutoZoomMap.CLOSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final CommonPreference<Integer> DELAY_TO_START_NAVIGATION = new IntPreference("delay_to_start_navigation", -1) {
|
public final CommonPreference<Integer> DELAY_TO_START_NAVIGATION = new IntPreference("delay_to_start_navigation", -1) {
|
||||||
|
@ -3016,7 +3018,6 @@ public class OsmandSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum AutoZoomMap {
|
public enum AutoZoomMap {
|
||||||
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);
|
||||||
|
|
|
@ -47,10 +47,10 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
private Preference avoidRouting;
|
private Preference avoidRouting;
|
||||||
private Preference preferRouting;
|
private Preference preferRouting;
|
||||||
private Preference reliefFactorRouting;
|
private Preference reliefFactorRouting;
|
||||||
|
private Preference autoZoom;
|
||||||
private Preference showAlarms;
|
private Preference showAlarms;
|
||||||
private Preference speakAlarms;
|
private Preference speakAlarms;
|
||||||
private ListPreference routerServicePreference;
|
private ListPreference routerServicePreference;
|
||||||
private ListPreference autoZoomMapPreference;
|
|
||||||
private ListPreference speedLimitExceed;
|
private ListPreference speedLimitExceed;
|
||||||
|
|
||||||
private ComponentName mDeviceAdmin;
|
private ComponentName mDeviceAdmin;
|
||||||
|
@ -133,13 +133,10 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
}
|
}
|
||||||
registerListPreference(settings.AUTO_FOLLOW_ROUTE, screen, entries, intValues);
|
registerListPreference(settings.AUTO_FOLLOW_ROUTE, screen, entries, intValues);
|
||||||
|
|
||||||
entries = new String[AutoZoomMap.values().length];
|
autoZoom = screen.findPreference("auto_zoom_map_on_off");
|
||||||
for(int i=0; i<entries.length; i++){
|
autoZoom.setOnPreferenceClickListener(this);
|
||||||
entries[i] = getString(AutoZoomMap.values()[i].name);
|
|
||||||
}
|
//keep informing option:
|
||||||
registerListPreference(settings.AUTO_ZOOM_MAP, screen, entries, AutoZoomMap.values());
|
|
||||||
|
|
||||||
//keep informing option:
|
|
||||||
Integer[] keepInformingValues = new Integer[]{0, 1, 2, 3, 5, 7, 10, 15, 20, 25, 30};
|
Integer[] keepInformingValues = new Integer[]{0, 1, 2, 3, 5, 7, 10, 15, 20, 25, 30};
|
||||||
String[] keepInformingNames = new String[keepInformingValues.length];
|
String[] keepInformingNames = new String[keepInformingValues.length];
|
||||||
keepInformingNames[0] = getString(R.string.keep_informing_never);
|
keepInformingNames[0] = getString(R.string.keep_informing_never);
|
||||||
|
@ -168,10 +165,6 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
registerListPreference(settings.WAKE_ON_VOICE_INT, screen, screenPowerSaveNames, screenPowerSaveValues);
|
registerListPreference(settings.WAKE_ON_VOICE_INT, screen, screenPowerSaveNames, screenPowerSaveValues);
|
||||||
|
|
||||||
// registerBooleanPreference(settings.SHOW_ZOOM_BUTTONS_NAVIGATION, screen);
|
// registerBooleanPreference(settings.SHOW_ZOOM_BUTTONS_NAVIGATION, screen);
|
||||||
|
|
||||||
autoZoomMapPreference = (ListPreference) screen.findPreference(settings.AUTO_ZOOM_MAP.getId());
|
|
||||||
autoZoomMapPreference.setOnPreferenceChangeListener(this);
|
|
||||||
|
|
||||||
|
|
||||||
showAlarms = (Preference) screen.findPreference("show_routing_alarms");
|
showAlarms = (Preference) screen.findPreference("show_routing_alarms");
|
||||||
showAlarms.setOnPreferenceClickListener(this);
|
showAlarms.setOnPreferenceClickListener(this);
|
||||||
|
@ -405,6 +398,77 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
}
|
}
|
||||||
showBooleanSettings(vals, bls, preference.getTitle());
|
showBooleanSettings(vals, bls, preference.getTitle());
|
||||||
return true;
|
return true;
|
||||||
|
} else if (preference == autoZoom) {
|
||||||
|
final ApplicationMode am = settings.getApplicationMode();
|
||||||
|
final ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||||
|
int i = 0;
|
||||||
|
int selectedIndex = -1;
|
||||||
|
adapter.addItem(ContextMenuItem.createBuilder(getString(R.string.auto_zoom_none))
|
||||||
|
.setSelected(false).createItem());
|
||||||
|
if (!settings.AUTO_ZOOM_MAP.get()) {
|
||||||
|
selectedIndex = 0;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
for (AutoZoomMap autoZoomMap : AutoZoomMap.values()) {
|
||||||
|
adapter.addItem(ContextMenuItem.createBuilder(getString(autoZoomMap.name))
|
||||||
|
.setSelected(false).createItem());
|
||||||
|
if (selectedIndex == -1 && settings.AUTO_ZOOM_MAP_SCALE.get() == autoZoomMap) {
|
||||||
|
selectedIndex = i;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (selectedIndex == -1) {
|
||||||
|
selectedIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
final int layout = R.layout.list_menu_item_native_singlechoice;
|
||||||
|
|
||||||
|
final ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(this, layout, R.id.text1,
|
||||||
|
adapter.getItemNames()) {
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||||
|
// User super class to create the View
|
||||||
|
View v = convertView;
|
||||||
|
if (v == null) {
|
||||||
|
v = SettingsNavigationActivity.this.getLayoutInflater().inflate(layout, null);
|
||||||
|
}
|
||||||
|
final ContextMenuItem item = adapter.getItem(position);
|
||||||
|
TextView tv = (TextView) v.findViewById(R.id.text1);
|
||||||
|
tv.setText(item.getTitle());
|
||||||
|
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f);
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
final int[] selectedPosition = {selectedIndex};
|
||||||
|
builder.setSingleChoiceItems(listAdapter, selectedIndex, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int position) {
|
||||||
|
selectedPosition[0] = position;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setTitle(R.string.auto_zoom_map)
|
||||||
|
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
|
||||||
|
int position = selectedPosition[0];
|
||||||
|
if (position == 0) {
|
||||||
|
settings.AUTO_ZOOM_MAP.set(false);
|
||||||
|
} else {
|
||||||
|
settings.AUTO_ZOOM_MAP.set(true);
|
||||||
|
settings.AUTO_ZOOM_MAP_SCALE.set(AutoZoomMap.values()[position -1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
|
|
||||||
|
builder.create().show();
|
||||||
|
return true;
|
||||||
} else if (preference == reliefFactorRouting) {
|
} else if (preference == reliefFactorRouting) {
|
||||||
final ApplicationMode am = settings.getApplicationMode();
|
final ApplicationMode am = settings.getApplicationMode();
|
||||||
final ContextMenuAdapter adapter = new ContextMenuAdapter();
|
final ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||||
|
|
|
@ -19,8 +19,6 @@ import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
|
||||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.AutoZoomMap;
|
|
||||||
import net.osmand.plus.OsmandSettings.DrivingRegion;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||||
|
@ -173,7 +171,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
if (mapView != null) {
|
if (mapView != null) {
|
||||||
RotatedTileBox tb = mapView.getCurrentRotatedTileBox();
|
RotatedTileBox tb = mapView.getCurrentRotatedTileBox();
|
||||||
if (isMapLinkedToLocation() && location != null) {
|
if (isMapLinkedToLocation() && location != null) {
|
||||||
if (settings.AUTO_ZOOM_MAP.get() != AutoZoomMap.NONE) {
|
if (settings.AUTO_ZOOM_MAP.get()) {
|
||||||
autozoom(location);
|
autozoom(location);
|
||||||
}
|
}
|
||||||
int currentMapRotation = settings.ROTATE_MAP.get();
|
int currentMapRotation = settings.ROTATE_MAP.get();
|
||||||
|
@ -268,7 +266,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
if (speed < 83f / 3.6) {
|
if (speed < 83f / 3.6) {
|
||||||
time = 60f;
|
time = 60f;
|
||||||
}
|
}
|
||||||
time /= settings.AUTO_ZOOM_MAP.get().coefficient;
|
time /= settings.AUTO_ZOOM_MAP_SCALE.get().coefficient;
|
||||||
double distToSee = speed * time;
|
double distToSee = speed * time;
|
||||||
float zoomDelta = (float) (Math.log(visibleDist / distToSee) / Math.log(2.0f));
|
float zoomDelta = (float) (Math.log(visibleDist / distToSee) / Math.log(2.0f));
|
||||||
// check if 17, 18 is correct?
|
// check if 17, 18 is correct?
|
||||||
|
@ -289,7 +287,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
// decrease a bit
|
// decrease a bit
|
||||||
zdelta += 1;
|
zdelta += 1;
|
||||||
}
|
}
|
||||||
double targetZoom = Math.min(tb.getZoom() + tb.getZoomFloatPart() + zdelta, settings.AUTO_ZOOM_MAP.get().maxZoom);
|
double targetZoom = Math.min(tb.getZoom() + tb.getZoomFloatPart() + zdelta, settings.AUTO_ZOOM_MAP_SCALE.get().maxZoom);
|
||||||
int threshold = settings.AUTO_FOLLOW_ROUTE.get();
|
int threshold = settings.AUTO_FOLLOW_ROUTE.get();
|
||||||
if (now - lastTimeAutoZooming > 4500 && (now - lastTimeAutoZooming > threshold || !isUserZoomed)) {
|
if (now - lastTimeAutoZooming > 4500 && (now - lastTimeAutoZooming > threshold || !isUserZoomed)) {
|
||||||
isUserZoomed = false;
|
isUserZoomed = false;
|
||||||
|
|
|
@ -8,7 +8,6 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.AutoZoomMap;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.quickaction.QuickAction;
|
import net.osmand.plus.quickaction.QuickAction;
|
||||||
|
@ -29,13 +28,8 @@ public class NavAutoZoomMapAction extends QuickAction {
|
||||||
public void execute(MapActivity activity) {
|
public void execute(MapActivity activity) {
|
||||||
|
|
||||||
OsmandSettings settings = activity.getMyApplication().getSettings();
|
OsmandSettings settings = activity.getMyApplication().getSettings();
|
||||||
if (settings.AUTO_ZOOM_MAP.get() == AutoZoomMap.NONE) {
|
settings.AUTO_ZOOM_MAP.set(!settings.AUTO_ZOOM_MAP.get());
|
||||||
settings.AUTO_ZOOM_MAP.set(settings.AUTO_ZOOM_MAP_PREV.get());
|
Toast.makeText(activity, activity.getString(!settings.AUTO_ZOOM_MAP.get()
|
||||||
} else {
|
|
||||||
settings.AUTO_ZOOM_MAP_PREV.set(settings.AUTO_ZOOM_MAP.get());
|
|
||||||
settings.AUTO_ZOOM_MAP.set(AutoZoomMap.NONE);
|
|
||||||
}
|
|
||||||
Toast.makeText(activity, activity.getString(settings.AUTO_ZOOM_MAP.get() == AutoZoomMap.NONE
|
|
||||||
? R.string.quick_action_auto_zoom_off : R.string.quick_action_auto_zoom_on), Toast.LENGTH_SHORT).show();
|
? R.string.quick_action_auto_zoom_off : R.string.quick_action_auto_zoom_on), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,14 +48,13 @@ public class NavAutoZoomMapAction extends QuickAction {
|
||||||
@Override
|
@Override
|
||||||
public String getActionText(OsmandApplication application) {
|
public String getActionText(OsmandApplication application) {
|
||||||
|
|
||||||
return application.getSettings().AUTO_ZOOM_MAP.get() != AutoZoomMap.NONE
|
return application.getSettings().AUTO_ZOOM_MAP.get()
|
||||||
? application.getString(R.string.quick_action_auto_zoom_off)
|
? application.getString(R.string.quick_action_auto_zoom_off) : application.getString(R.string.quick_action_auto_zoom_on);
|
||||||
: application.getString(R.string.quick_action_auto_zoom_on);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isActionWithSlash(OsmandApplication application) {
|
public boolean isActionWithSlash(OsmandApplication application) {
|
||||||
|
|
||||||
return application.getSettings().AUTO_ZOOM_MAP.get() != AutoZoomMap.NONE;
|
return application.getSettings().AUTO_ZOOM_MAP.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue