Fix route preferences (set profile for nav settings, refresh params, UI). Fix geocoding result crash.

This commit is contained in:
Alexey Kulish 2016-03-18 19:49:44 +03:00
parent 9e5a603ee5
commit 1d69dd1b67
6 changed files with 55 additions and 27 deletions

View file

@ -2004,19 +2004,27 @@ public class OsmandSettings {
List<LatLon> ps = getPoints(); List<LatLon> ps = getPoints();
List<String> ds = getPointDescriptions(ps.size()); List<String> ds = getPointDescriptions(ps.size());
int i = ps.indexOf(new LatLon(latitude, longitude)); int i = ps.indexOf(new LatLon(latitude, longitude));
ds.set(i, PointDescription.serializeToString(historyDescription)); if (i != -1) {
if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) { ds.set(i, PointDescription.serializeToString(historyDescription));
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, 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) { public boolean deletePoint(int index) {
List<LatLon> ps = getPoints(); List<LatLon> ps = getPoints();
List<String> ds = getPointDescriptions(ps.size()); List<String> ds = getPointDescriptions(ps.size());
ps.remove(index); if (index < ps.size()) {
ds.remove(index); ps.remove(index);
return savePoints(ps, ds); ds.remove(index);
return savePoints(ps, ds);
} else {
return false;
}
} }
public boolean savePoints(List<LatLon> ps, List<String> ds) { public boolean savePoints(List<LatLon> ps, List<String> ds) {

View file

@ -138,10 +138,12 @@ public class TargetPointsHelper {
AddressLookupRequest lookupRequest = new AddressLookupRequest(targetPoint.point, new GeocodingLookupService.OnAddressLookupResult() { AddressLookupRequest lookupRequest = new AddressLookupRequest(targetPoint.point, new GeocodingLookupService.OnAddressLookupResult() {
@Override @Override
public void geocodingDone(String address) { public void geocodingDone(String address) {
targetPoint.pointDescription.setName(address); if (intermediatePoints.contains(targetPoint)) {
settings.updateIntermediatePoint(targetPoint.point.getLatitude(), targetPoint.point.getLongitude(), targetPoint.pointDescription.setName(address);
targetPoint.pointDescription); settings.updateIntermediatePoint(targetPoint.point.getLatitude(), targetPoint.point.getLongitude(),
updateRouteAndRefresh(false); targetPoint.pointDescription);
updateRouteAndRefresh(false);
}
} }
}, null); }, null);
ctx.getGeocodingLookupService().lookupAddress(lookupRequest); ctx.getGeocodingLookupService().lookupAddress(lookupRequest);
@ -156,10 +158,12 @@ public class TargetPointsHelper {
@Override @Override
public void geocodingDone(String address) { public void geocodingDone(String address) {
startPointRequest = null; startPointRequest = null;
pointToStart.pointDescription.setName(address); if (pointToStart != null) {
settings.setPointToStart(pointToStart.point.getLatitude(), pointToStart.point.getLongitude(), pointToStart.pointDescription.setName(address);
pointToStart.pointDescription); settings.setPointToStart(pointToStart.point.getLatitude(), pointToStart.point.getLongitude(),
updateRouteAndRefresh(false); pointToStart.pointDescription);
updateRouteAndRefresh(false);
}
} }
}, null); }, null);
ctx.getGeocodingLookupService().lookupAddress(startPointRequest); ctx.getGeocodingLookupService().lookupAddress(startPointRequest);
@ -174,10 +178,12 @@ public class TargetPointsHelper {
@Override @Override
public void geocodingDone(String address) { public void geocodingDone(String address) {
targetPointRequest = null; targetPointRequest = null;
pointToNavigate.pointDescription.setName(address); if (pointToNavigate != null) {
settings.setPointToNavigate(pointToNavigate.point.getLatitude(), pointToNavigate.point.getLongitude(), pointToNavigate.pointDescription.setName(address);
pointToNavigate.pointDescription); settings.setPointToNavigate(pointToNavigate.point.getLatitude(), pointToNavigate.point.getLongitude(),
updateRouteAndRefresh(false); pointToNavigate.pointDescription);
updateRouteAndRefresh(false);
}
} }
}, null); }, null);
ctx.getGeocodingLookupService().lookupAddress(targetPointRequest); ctx.getGeocodingLookupService().lookupAddress(targetPointRequest);

View file

@ -486,6 +486,8 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
new RateUsBottomSheetDialog().show(getSupportFragmentManager(), "dialog"); new RateUsBottomSheetDialog().show(getSupportFragmentManager(), "dialog");
} }
} }
} else {
dashboardOnMap.updateDashboard();
} }
} }
dashboardOnMap.updateLocation(true, true, false); dashboardOnMap.updateLocation(true, true, false);

View file

@ -44,10 +44,10 @@ import java.util.Set;
public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
implements OnPreferenceChangeListener, OnPreferenceClickListener { implements OnPreferenceChangeListener, OnPreferenceClickListener {
public static final String INTENT_APP_MODE = "INTENT_APP_MODE";
protected OsmandSettings settings; protected OsmandSettings settings;
protected final boolean profileSettings ; protected final boolean profileSettings;
protected List<ApplicationMode> modes = new ArrayList<ApplicationMode>(); protected List<ApplicationMode> modes = new ArrayList<ApplicationMode>();
private ApplicationMode previousAppMode; private ApplicationMode previousAppMode;
@ -388,7 +388,14 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
super.onResume(); super.onResume();
if (profileSettings) { if (profileSettings) {
previousAppMode = settings.getApplicationMode(); 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) { if (!found) {
getSpinner().setSelection(0); getSpinner().setSelection(0);
} }

View file

@ -784,14 +784,12 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
} else { } else {
scrollView.setVisibility(View.GONE); scrollView.setVisibility(View.GONE);
listViewLayout.setVisibility(View.VISIBLE); listViewLayout.setVisibility(View.VISIBLE);
listView.scrollTo(0, 0);
listView.clearParams();
if (listView instanceof ObservableListView) {
onScrollChanged(listView.getScrollY(), false, false);
}
if (refresh) { if (refresh) {
refreshContent(false); refreshContent(false);
} else { } else {
listView.scrollTo(0, 0);
listView.clearParams();
onScrollChanged(listView.getScrollY(), false, false);
updateListAdapter(); updateListAdapter();
} }
updateListBackgroundHeight(); updateListBackgroundHeight();
@ -836,6 +834,12 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
} }
} }
public void updateDashboard() {
if (visibleType == DashboardType.ROUTE_PREFERENCES) {
refreshContent(false);
}
}
private void applyDayNightMode() { private void applyDayNightMode() {
if (nightMode) { if (nightMode) {
if (listBackgroundView != null) { if (listBackgroundView != null) {

View file

@ -292,6 +292,7 @@ public class RoutePreferencesMenu {
if (obj instanceof OtherSettingsRoutingParameter) { if (obj instanceof OtherSettingsRoutingParameter) {
final Intent settings = new Intent(mapActivity, SettingsNavigationActivity.class); final Intent settings = new Intent(mapActivity, SettingsNavigationActivity.class);
settings.putExtra(SettingsNavigationActivity.INTENT_SKIP_DIALOG, true); settings.putExtra(SettingsNavigationActivity.INTENT_SKIP_DIALOG, true);
settings.putExtra(SettingsBaseActivity.INTENT_APP_MODE, routingHelper.getAppMode().getStringKey());
mapActivity.startActivity(settings); mapActivity.startActivity(settings);
} else if (obj instanceof MuteSoundRoutingParameter) { } else if (obj instanceof MuteSoundRoutingParameter) {
final CompoundButton btn = (CompoundButton) view.findViewById(R.id.check_item); final CompoundButton btn = (CompoundButton) view.findViewById(R.id.check_item);