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 296b9cb308
commit e09508f651
6 changed files with 55 additions and 27 deletions

View file

@ -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));
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;
}
}
public boolean deletePoint(int index) {
List<LatLon> ps = getPoints();
List<String> ds = getPointDescriptions(ps.size());
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) {

View file

@ -138,11 +138,13 @@ public class TargetPointsHelper {
AddressLookupRequest lookupRequest = new AddressLookupRequest(targetPoint.point, new GeocodingLookupService.OnAddressLookupResult() {
@Override
public void geocodingDone(String address) {
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,11 +158,13 @@ public class TargetPointsHelper {
@Override
public void geocodingDone(String address) {
startPointRequest = null;
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,11 +178,13 @@ public class TargetPointsHelper {
@Override
public void geocodingDone(String address) {
targetPointRequest = null;
if (pointToNavigate != null) {
pointToNavigate.pointDescription.setName(address);
settings.setPointToNavigate(pointToNavigate.point.getLatitude(), pointToNavigate.point.getLongitude(),
pointToNavigate.pointDescription);
updateRouteAndRefresh(false);
}
}
}, null);
ctx.getGeocodingLookupService().lookupAddress(targetPointRequest);
}

View file

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

View file

@ -44,7 +44,7 @@ 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;
@ -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);
}

View file

@ -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) {

View file

@ -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);