Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-03-24 09:39:04 +01:00
commit 745710dda1
5 changed files with 98 additions and 42 deletions

View file

@ -12,7 +12,7 @@
<PreferenceCategory android:key="guidance_preferences" android:title="@string/guidance_preferences_descr">
<ListPreference android:key="auto_follow_route" android:title="@string/choose_auto_follow_route"
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" />
<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"/>

View file

@ -955,18 +955,20 @@ public class OsmandSettings {
RouteService.values()).makeProfile();
// this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<AutoZoomMap> AUTO_ZOOM_MAP_PREV =
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();
public final CommonPreference<Boolean> AUTO_ZOOM_MAP = new BooleanPreference("auto_zoom_map_on_off", false).makeProfile().cache();
{
AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.CAR, AutoZoomMap.FAR);
AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.BICYCLE, AutoZoomMap.NONE);
AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.PEDESTRIAN, AutoZoomMap.NONE);
AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.CAR, true);
AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.BICYCLE, false);
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) {
@ -3016,7 +3018,6 @@ public class OsmandSettings {
}
public enum AutoZoomMap {
NONE(R.string.auto_zoom_none, 0f, 18),
FARTHEST(R.string.auto_zoom_farthest, 1f, 15.5f),
FAR(R.string.auto_zoom_far, 1.4f, 17f),
CLOSE(R.string.auto_zoom_close, 2f, 19f);

View file

@ -47,10 +47,10 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
private Preference avoidRouting;
private Preference preferRouting;
private Preference reliefFactorRouting;
private Preference autoZoom;
private Preference showAlarms;
private Preference speakAlarms;
private ListPreference routerServicePreference;
private ListPreference autoZoomMapPreference;
private ListPreference speedLimitExceed;
private ComponentName mDeviceAdmin;
@ -133,13 +133,10 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
}
registerListPreference(settings.AUTO_FOLLOW_ROUTE, screen, entries, intValues);
entries = new String[AutoZoomMap.values().length];
for(int i=0; i<entries.length; i++){
entries[i] = getString(AutoZoomMap.values()[i].name);
}
registerListPreference(settings.AUTO_ZOOM_MAP, screen, entries, AutoZoomMap.values());
autoZoom = screen.findPreference("auto_zoom_map_on_off");
autoZoom.setOnPreferenceClickListener(this);
//keep informing option:
//keep informing option:
Integer[] keepInformingValues = new Integer[]{0, 1, 2, 3, 5, 7, 10, 15, 20, 25, 30};
String[] keepInformingNames = new String[keepInformingValues.length];
keepInformingNames[0] = getString(R.string.keep_informing_never);
@ -169,10 +166,6 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
// 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.setOnPreferenceClickListener(this);
@ -405,6 +398,77 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
}
showBooleanSettings(vals, bls, preference.getTitle());
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) {
final ApplicationMode am = settings.getApplicationMode();
final ContextMenuAdapter adapter = new ContextMenuAdapter();

View file

@ -19,8 +19,6 @@ 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.OsmandSettings.DrivingRegion;
import net.osmand.plus.R;
import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
@ -173,7 +171,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
if (mapView != null) {
RotatedTileBox tb = mapView.getCurrentRotatedTileBox();
if (isMapLinkedToLocation() && location != null) {
if (settings.AUTO_ZOOM_MAP.get() != AutoZoomMap.NONE) {
if (settings.AUTO_ZOOM_MAP.get()) {
autozoom(location);
}
int currentMapRotation = settings.ROTATE_MAP.get();
@ -268,7 +266,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
if (speed < 83f / 3.6) {
time = 60f;
}
time /= settings.AUTO_ZOOM_MAP.get().coefficient;
time /= settings.AUTO_ZOOM_MAP_SCALE.get().coefficient;
double distToSee = speed * time;
float zoomDelta = (float) (Math.log(visibleDist / distToSee) / Math.log(2.0f));
// check if 17, 18 is correct?
@ -289,7 +287,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
// decrease a bit
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();
if (now - lastTimeAutoZooming > 4500 && (now - lastTimeAutoZooming > threshold || !isUserZoomed)) {
isUserZoomed = false;

View file

@ -8,7 +8,6 @@ import android.widget.Toast;
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.activities.MapActivity;
import net.osmand.plus.quickaction.QuickAction;
@ -29,13 +28,8 @@ public class NavAutoZoomMapAction extends QuickAction {
public void execute(MapActivity activity) {
OsmandSettings settings = activity.getMyApplication().getSettings();
if (settings.AUTO_ZOOM_MAP.get() == AutoZoomMap.NONE) {
settings.AUTO_ZOOM_MAP.set(settings.AUTO_ZOOM_MAP_PREV.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
settings.AUTO_ZOOM_MAP.set(!settings.AUTO_ZOOM_MAP.get());
Toast.makeText(activity, activity.getString(!settings.AUTO_ZOOM_MAP.get()
? 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
public String getActionText(OsmandApplication application) {
return application.getSettings().AUTO_ZOOM_MAP.get() != AutoZoomMap.NONE
? application.getString(R.string.quick_action_auto_zoom_off)
: application.getString(R.string.quick_action_auto_zoom_on);
return application.getSettings().AUTO_ZOOM_MAP.get()
? application.getString(R.string.quick_action_auto_zoom_off) : application.getString(R.string.quick_action_auto_zoom_on);
}
@Override
public boolean isActionWithSlash(OsmandApplication application) {
return application.getSettings().AUTO_ZOOM_MAP.get() != AutoZoomMap.NONE;
return application.getSettings().AUTO_ZOOM_MAP.get();
}
}