Merge branch 'r2.3' of https://github.com/osmandapp/Osmand into r2.3
This commit is contained in:
commit
a3d95d0213
9 changed files with 152 additions and 45 deletions
|
@ -2004,19 +2004,27 @@ public class OsmandSettings {
|
|||
List<LatLon> ps = getPoints();
|
||||
List<String> ds = getPointDescriptions(ps.size());
|
||||
int i = ps.indexOf(new LatLon(latitude, longitude));
|
||||
ds.set(i, PointDescription.serializeToString(historyDescription));
|
||||
if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
|
||||
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription);
|
||||
if (i != -1) {
|
||||
ds.set(i, PointDescription.serializeToString(historyDescription));
|
||||
if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
|
||||
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription);
|
||||
}
|
||||
return savePoints(ps, ds);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return savePoints(ps, ds);
|
||||
}
|
||||
|
||||
public boolean deletePoint(int index) {
|
||||
List<LatLon> ps = getPoints();
|
||||
List<String> ds = getPointDescriptions(ps.size());
|
||||
ps.remove(index);
|
||||
ds.remove(index);
|
||||
return savePoints(ps, ds);
|
||||
if (index < ps.size()) {
|
||||
ps.remove(index);
|
||||
ds.remove(index);
|
||||
return savePoints(ps, ds);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean savePoints(List<LatLon> ps, List<String> ds) {
|
||||
|
|
|
@ -138,10 +138,12 @@ public class TargetPointsHelper {
|
|||
AddressLookupRequest lookupRequest = new AddressLookupRequest(targetPoint.point, new GeocodingLookupService.OnAddressLookupResult() {
|
||||
@Override
|
||||
public void geocodingDone(String address) {
|
||||
targetPoint.pointDescription.setName(address);
|
||||
settings.updateIntermediatePoint(targetPoint.point.getLatitude(), targetPoint.point.getLongitude(),
|
||||
targetPoint.pointDescription);
|
||||
updateRouteAndRefresh(false);
|
||||
if (intermediatePoints.contains(targetPoint)) {
|
||||
targetPoint.pointDescription.setName(address);
|
||||
settings.updateIntermediatePoint(targetPoint.point.getLatitude(), targetPoint.point.getLongitude(),
|
||||
targetPoint.pointDescription);
|
||||
updateRouteAndRefresh(false);
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
ctx.getGeocodingLookupService().lookupAddress(lookupRequest);
|
||||
|
@ -156,10 +158,12 @@ public class TargetPointsHelper {
|
|||
@Override
|
||||
public void geocodingDone(String address) {
|
||||
startPointRequest = null;
|
||||
pointToStart.pointDescription.setName(address);
|
||||
settings.setPointToStart(pointToStart.point.getLatitude(), pointToStart.point.getLongitude(),
|
||||
pointToStart.pointDescription);
|
||||
updateRouteAndRefresh(false);
|
||||
if (pointToStart != null) {
|
||||
pointToStart.pointDescription.setName(address);
|
||||
settings.setPointToStart(pointToStart.point.getLatitude(), pointToStart.point.getLongitude(),
|
||||
pointToStart.pointDescription);
|
||||
updateRouteAndRefresh(false);
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
ctx.getGeocodingLookupService().lookupAddress(startPointRequest);
|
||||
|
@ -174,10 +178,12 @@ public class TargetPointsHelper {
|
|||
@Override
|
||||
public void geocodingDone(String address) {
|
||||
targetPointRequest = null;
|
||||
pointToNavigate.pointDescription.setName(address);
|
||||
settings.setPointToNavigate(pointToNavigate.point.getLatitude(), pointToNavigate.point.getLongitude(),
|
||||
pointToNavigate.pointDescription);
|
||||
updateRouteAndRefresh(false);
|
||||
if (pointToNavigate != null) {
|
||||
pointToNavigate.pointDescription.setName(address);
|
||||
settings.setPointToNavigate(pointToNavigate.point.getLatitude(), pointToNavigate.point.getLongitude(),
|
||||
pointToNavigate.pointDescription);
|
||||
updateRouteAndRefresh(false);
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
ctx.getGeocodingLookupService().lookupAddress(targetPointRequest);
|
||||
|
|
|
@ -486,6 +486,8 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
|
|||
new RateUsBottomSheetDialog().show(getSupportFragmentManager(), "dialog");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dashboardOnMap.updateDashboard();
|
||||
}
|
||||
}
|
||||
dashboardOnMap.updateLocation(true, true, false);
|
||||
|
|
|
@ -44,10 +44,10 @@ import java.util.Set;
|
|||
public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
||||
implements OnPreferenceChangeListener, OnPreferenceClickListener {
|
||||
|
||||
public static final String INTENT_APP_MODE = "INTENT_APP_MODE";
|
||||
|
||||
|
||||
protected OsmandSettings settings;
|
||||
protected final boolean profileSettings ;
|
||||
protected final boolean profileSettings;
|
||||
protected List<ApplicationMode> modes = new ArrayList<ApplicationMode>();
|
||||
private ApplicationMode previousAppMode;
|
||||
|
||||
|
@ -388,7 +388,14 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
|||
super.onResume();
|
||||
if (profileSettings) {
|
||||
previousAppMode = settings.getApplicationMode();
|
||||
boolean found = setSelectedAppMode(previousAppMode);
|
||||
boolean found;
|
||||
if (getIntent() != null && getIntent().hasExtra(INTENT_APP_MODE)) {
|
||||
String modeStr = getIntent().getStringExtra(INTENT_APP_MODE);
|
||||
ApplicationMode mode = ApplicationMode.valueOfStringKey(modeStr, previousAppMode);
|
||||
found = setSelectedAppMode(mode);
|
||||
} else {
|
||||
found = setSelectedAppMode(previousAppMode);
|
||||
}
|
||||
if (!found) {
|
||||
getSpinner().setSelection(0);
|
||||
}
|
||||
|
|
|
@ -804,14 +804,12 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
} else {
|
||||
scrollView.setVisibility(View.GONE);
|
||||
listViewLayout.setVisibility(View.VISIBLE);
|
||||
listView.scrollTo(0, 0);
|
||||
listView.clearParams();
|
||||
if (listView instanceof ObservableListView) {
|
||||
onScrollChanged(listView.getScrollY(), false, false);
|
||||
}
|
||||
if (refresh) {
|
||||
refreshContent(false);
|
||||
} else {
|
||||
listView.scrollTo(0, 0);
|
||||
listView.clearParams();
|
||||
onScrollChanged(listView.getScrollY(), false, false);
|
||||
updateListAdapter();
|
||||
}
|
||||
updateListBackgroundHeight();
|
||||
|
@ -856,6 +854,12 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
}
|
||||
}
|
||||
|
||||
public void updateDashboard() {
|
||||
if (visibleType == DashboardType.ROUTE_PREFERENCES) {
|
||||
refreshContent(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void applyDayNightMode() {
|
||||
if (nightMode) {
|
||||
if (listBackgroundView != null) {
|
||||
|
|
|
@ -3,7 +3,6 @@ package net.osmand.plus.download.ui;
|
|||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.StatFs;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -57,8 +56,8 @@ public class DataStoragePlaceDialogFragment extends BottomSheetDialogFragment {
|
|||
hasExternalStoragePermission = DownloadActivity.hasPermissionToWriteExternalStorage(getActivity());
|
||||
|
||||
internalStorage = getInternalStorageDirectory(getActivity());
|
||||
sharedStorage = getSharedStorageDirectory(getActivity());
|
||||
if (hasExternalStoragePermission) {
|
||||
sharedStorage = getSharedStorageDirectory(getActivity());
|
||||
externalStorage = getMyApplication().getSettings().getSecondaryStorage();
|
||||
}
|
||||
|
||||
|
@ -98,7 +97,7 @@ public class DataStoragePlaceDialogFragment extends BottomSheetDialogFragment {
|
|||
sharedMemoryDescription.setText(getFreeSpace(sharedStorage));
|
||||
|
||||
View memoryStickRow = view.findViewById(R.id.memoryStickRow);
|
||||
if (hasExternalStoragePermission) {
|
||||
if (hasExternalStoragePermission && externalStorage != null) {
|
||||
memoryStickRow.setOnClickListener(externalMemoryOnClickListener);
|
||||
ImageView memoryStickImageView = (ImageView) view.findViewById(R.id.memoryStickImageView);
|
||||
memoryStickImageView.setImageDrawable(getContentIcon(R.drawable.ic_sdcard));
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package net.osmand.plus.helpers;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.IndexConstants;
|
||||
|
@ -25,11 +24,15 @@ import net.osmand.plus.activities.MapActivity;
|
|||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
|
||||
import net.osmand.plus.routing.RouteDirectionInfo;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.router.TurnType;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
public class ExternalApiHelper {
|
||||
|
||||
|
@ -54,7 +57,9 @@ public class ExternalApiHelper {
|
|||
public static final String API_CMD_STOP_GPX_REC = "stop_gpx_rec";
|
||||
|
||||
public static final String API_CMD_SUBSCRIBE_VOICE_NOTIFICATIONS = "subscribe_voice_notifications";
|
||||
|
||||
public static final int VERSION_CODE = 1;
|
||||
|
||||
|
||||
public static final String PARAM_NAME = "name";
|
||||
public static final String PARAM_DESC = "desc";
|
||||
public static final String PARAM_CATEGORY = "category";
|
||||
|
@ -75,9 +80,16 @@ public class ExternalApiHelper {
|
|||
public static final String PARAM_DEST_LON = "dest_lon";
|
||||
public static final String PARAM_PROFILE = "profile";
|
||||
|
||||
public static final String PARAM_VERSION = "version";
|
||||
public static final String PARAM_ETA = "eta";
|
||||
public static final String PARAM_TIME_LEFT = "time_left";
|
||||
public static final String PARAM_DISTANCE_LEFT = "time_distance_left";
|
||||
public static final String PARAM_NT_DISTANCE = "turn_distance";
|
||||
public static final String PARAM_NT_IMMINENT = "turn_imminent";
|
||||
public static final String PARAM_NT_DIRECTION_NAME = "turn_name";
|
||||
public static final String PARAM_NT_DIRECTION_TURN = "turn_type";
|
||||
public static final String PARAM_NT_DIRECTION_LANES = "turn_lanes";
|
||||
|
||||
|
||||
public static final ApplicationMode[] VALID_PROFILES = new ApplicationMode[]{
|
||||
ApplicationMode.CAR,
|
||||
|
@ -95,6 +107,7 @@ public class ExternalApiHelper {
|
|||
public static final int RESULT_CODE_ERROR_GPX_NOT_FOUND = 20;
|
||||
public static final int RESULT_CODE_ERROR_INVALID_PROFILE = 30;
|
||||
|
||||
|
||||
private MapActivity mapActivity;
|
||||
private int resultCode;
|
||||
private boolean finish;
|
||||
|
@ -260,13 +273,27 @@ public class ExternalApiHelper {
|
|||
}
|
||||
|
||||
final RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
if (routingHelper.isFollowingMode()) {
|
||||
if (routingHelper.isRouteCalculated()) {
|
||||
int time = routingHelper.getLeftTime();
|
||||
result.putExtra(PARAM_TIME_LEFT, time);
|
||||
long eta = time + System.currentTimeMillis() / 1000;
|
||||
result.putExtra(PARAM_ETA, eta);
|
||||
result.putExtra(PARAM_DISTANCE_LEFT, routingHelper.getLeftDistance());
|
||||
|
||||
NextDirectionInfo ni = routingHelper.getNextRouteDirectionInfo(new NextDirectionInfo(), true);
|
||||
if(ni.distanceTo > 0) {
|
||||
updateTurnInfo("next_", result, ni);
|
||||
ni = routingHelper.getNextRouteDirectionInfoAfter(ni, new NextDirectionInfo(), true);
|
||||
if(ni.distanceTo > 0) {
|
||||
updateTurnInfo("after_next", result, ni);
|
||||
}
|
||||
}
|
||||
routingHelper.getNextRouteDirectionInfo(new NextDirectionInfo(), false);
|
||||
if(ni.distanceTo > 0) {
|
||||
updateTurnInfo("no_speak_next_", result, ni);
|
||||
}
|
||||
}
|
||||
result.putExtra(PARAM_VERSION, VERSION_CODE);
|
||||
|
||||
finish = true;
|
||||
resultCode = RESULT_CODE_OK;
|
||||
|
@ -359,6 +386,20 @@ public class ExternalApiHelper {
|
|||
return result;
|
||||
}
|
||||
|
||||
private void updateTurnInfo(String prefix, Intent result, NextDirectionInfo ni) {
|
||||
result.putExtra(prefix + PARAM_NT_DISTANCE, ni.distanceTo);
|
||||
result.putExtra(prefix + PARAM_NT_IMMINENT, ni.imminent);
|
||||
if(ni.directionInfo != null && ni.directionInfo.getTurnType() != null) {
|
||||
TurnType tt = ni.directionInfo.getTurnType();
|
||||
RouteDirectionInfo a = ni.directionInfo;
|
||||
result.putExtra(prefix + PARAM_NT_DIRECTION_NAME, RoutingHelper.formatStreetName(a.getStreetName(), a.getRef(), a.getDestinationName()));
|
||||
result.putExtra(prefix + PARAM_NT_DIRECTION_TURN, tt.toXmlString());
|
||||
if(tt.getLanes() != null) {
|
||||
result.putExtra(prefix + PARAM_NT_DIRECTION_LANES, Arrays.toString(tt.getLanes()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showOnMap(double lat, double lon, Object object, PointDescription pointDescription) {
|
||||
MapContextMenu mapContextMenu = mapActivity.getContextMenu();
|
||||
mapContextMenu.setMapCenter(new LatLon(lat, lon));
|
||||
|
|
|
@ -70,6 +70,11 @@ public class RoutePreferencesMenu {
|
|||
public static class LocalRoutingParameter {
|
||||
|
||||
public GeneralRouter.RoutingParameter routingParameter;
|
||||
private ApplicationMode am;
|
||||
|
||||
public LocalRoutingParameter(ApplicationMode am) {
|
||||
this.am = am;
|
||||
}
|
||||
|
||||
public String getText(MapActivity mapActivity) {
|
||||
return SettingsBaseActivity.getRoutingStringPropertyName(mapActivity, routingParameter.getId(),
|
||||
|
@ -79,33 +84,66 @@ public class RoutePreferencesMenu {
|
|||
public boolean isSelected(OsmandSettings settings) {
|
||||
final OsmandSettings.CommonPreference<Boolean> property = settings.getCustomRoutingBooleanProperty(routingParameter
|
||||
.getId());
|
||||
return property.get();
|
||||
if(am != null) {
|
||||
return property.getModeValue(am);
|
||||
} else {
|
||||
return property.get();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelected(OsmandSettings settings, boolean isChecked) {
|
||||
final OsmandSettings.CommonPreference<Boolean> property = settings.getCustomRoutingBooleanProperty(routingParameter
|
||||
.getId());
|
||||
property.set(isChecked);
|
||||
if(am != null) {
|
||||
property.setModeValue(am, isChecked);
|
||||
} else {
|
||||
property.set(isChecked);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class MuteSoundRoutingParameter extends LocalRoutingParameter {
|
||||
|
||||
public MuteSoundRoutingParameter() {
|
||||
super(null);
|
||||
}
|
||||
}
|
||||
|
||||
private static class InterruptMusicRoutingParameter extends LocalRoutingParameter {
|
||||
|
||||
public InterruptMusicRoutingParameter() {
|
||||
super(null);
|
||||
}
|
||||
}
|
||||
|
||||
private static class VoiceGuidanceRoutingParameter extends LocalRoutingParameter {
|
||||
|
||||
public VoiceGuidanceRoutingParameter() {
|
||||
super(null);
|
||||
}
|
||||
}
|
||||
|
||||
private static class AvoidRoadsRoutingParameter extends LocalRoutingParameter {
|
||||
|
||||
public AvoidRoadsRoutingParameter() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class GpxLocalRoutingParameter extends LocalRoutingParameter {
|
||||
|
||||
public GpxLocalRoutingParameter() {
|
||||
super(null);
|
||||
}
|
||||
}
|
||||
|
||||
private static class OtherSettingsRoutingParameter extends LocalRoutingParameter {
|
||||
|
||||
public OtherSettingsRoutingParameter() {
|
||||
super(null);
|
||||
}
|
||||
}
|
||||
|
||||
private static class OtherLocalRoutingParameter extends LocalRoutingParameter {
|
||||
|
@ -114,6 +152,7 @@ public class RoutePreferencesMenu {
|
|||
public int id;
|
||||
|
||||
public OtherLocalRoutingParameter(int id, String text, boolean selected) {
|
||||
super(null);
|
||||
this.text = text;
|
||||
this.selected = selected;
|
||||
this.id = id;
|
||||
|
@ -253,6 +292,7 @@ public class RoutePreferencesMenu {
|
|||
if (obj instanceof OtherSettingsRoutingParameter) {
|
||||
final Intent settings = new Intent(mapActivity, SettingsNavigationActivity.class);
|
||||
settings.putExtra(SettingsNavigationActivity.INTENT_SKIP_DIALOG, true);
|
||||
settings.putExtra(SettingsBaseActivity.INTENT_APP_MODE, routingHelper.getAppMode().getStringKey());
|
||||
mapActivity.startActivity(settings);
|
||||
} else if (obj instanceof MuteSoundRoutingParameter) {
|
||||
final CompoundButton btn = (CompoundButton) view.findViewById(R.id.check_item);
|
||||
|
@ -425,7 +465,7 @@ public class RoutePreferencesMenu {
|
|||
ch.setOnCheckedChangeListener(null);
|
||||
if (rp.routingParameter != null && rp.routingParameter.getId().equals("short_way")) {
|
||||
// if short route settings - it should be inverse of fast_route_mode
|
||||
ch.setChecked(!settings.FAST_ROUTE_MODE.get());
|
||||
ch.setChecked(!settings.FAST_ROUTE_MODE.getModeValue(routingHelper.getAppMode()));
|
||||
} else {
|
||||
ch.setChecked(rp.isSelected(settings));
|
||||
}
|
||||
|
@ -435,7 +475,7 @@ public class RoutePreferencesMenu {
|
|||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
// if short way that it should set valut to fast mode opposite of current
|
||||
if (rp.routingParameter != null && rp.routingParameter.getId().equals("short_way")) {
|
||||
settings.FAST_ROUTE_MODE.set(!isChecked);
|
||||
settings.FAST_ROUTE_MODE.setModeValue(routingHelper.getAppMode(), !isChecked);
|
||||
}
|
||||
rp.setSelected(settings, isChecked);
|
||||
|
||||
|
@ -550,7 +590,7 @@ public class RoutePreferencesMenu {
|
|||
}
|
||||
for (GeneralRouter.RoutingParameter r : rm.getParameters().values()) {
|
||||
if (r.getType() == GeneralRouter.RoutingParameterType.BOOLEAN) {
|
||||
LocalRoutingParameter rp = new LocalRoutingParameter();
|
||||
LocalRoutingParameter rp = new LocalRoutingParameter(am);
|
||||
rp.routingParameter = r;
|
||||
list.add(rp);
|
||||
}
|
||||
|
|
|
@ -1043,7 +1043,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
@Override
|
||||
public void run() {
|
||||
String top = OsMoGroupsActivity.this.operation;
|
||||
if (top.equals(operation) || (operation != null && operation.equals(top))) {
|
||||
if (operation != null && operation.equals(top)) {
|
||||
hideProgressBar();
|
||||
}
|
||||
if (joinGroup && (operation != null && operation.startsWith("GROUP_CONNECT"))) {
|
||||
|
|
Loading…
Reference in a new issue