Fix route preferences (set profile for nav settings, refresh params, UI). Fix geocoding result crash.
This commit is contained in:
parent
9e5a603ee5
commit
1d69dd1b67
6 changed files with 55 additions and 27 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);
|
||||
}
|
||||
|
|
|
@ -784,14 +784,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();
|
||||
|
@ -836,6 +834,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) {
|
||||
|
|
|
@ -292,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);
|
||||
|
|
Loading…
Reference in a new issue