Merge pull request #10451 from osmandapp/Fix_10346
Fix #10346 (4) don't save application mode like last used when naviga…
This commit is contained in:
commit
85999f4787
14 changed files with 32 additions and 21 deletions
|
@ -2366,7 +2366,7 @@ public class OsmandAidlApi {
|
|||
if (!ApplicationMode.values(app).contains(appMode)) {
|
||||
ApplicationMode.changeProfileAvailability(appMode, true, app);
|
||||
}
|
||||
app.getSettings().APPLICATION_MODE.set(appMode);
|
||||
app.getSettings().setApplicationMode(appMode);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
|
|
@ -419,10 +419,10 @@ public class AppInitializer implements IProgress {
|
|||
if (osmandSettings.FOLLOW_THE_ROUTE.get()) {
|
||||
ApplicationMode savedMode = osmandSettings.readApplicationMode();
|
||||
if (!osmandSettings.APPLICATION_MODE.get().getStringKey().equals(savedMode.getStringKey())) {
|
||||
osmandSettings.APPLICATION_MODE.set(savedMode);
|
||||
osmandSettings.setApplicationMode(savedMode);
|
||||
}
|
||||
} else {
|
||||
osmandSettings.APPLICATION_MODE.set(osmandSettings.DEFAULT_APPLICATION_MODE.get());
|
||||
osmandSettings.setApplicationMode(osmandSettings.DEFAULT_APPLICATION_MODE.get());
|
||||
}
|
||||
startTime = System.currentTimeMillis();
|
||||
getLazyRoutingConfig();
|
||||
|
|
|
@ -258,7 +258,7 @@ public class ContextMenuAdapter {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
if (selected.size() > 0) {
|
||||
app.getSettings().APPLICATION_MODE.set(selected.iterator().next());
|
||||
app.getSettings().setApplicationMode(selected.iterator().next());
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
if (changeAppModeListener != null) {
|
||||
|
|
|
@ -547,7 +547,7 @@ public class OsmandApplication extends MultiDexApplication {
|
|||
routingHelper.clearCurrentRoute(null, new ArrayList<LatLon>());
|
||||
routingHelper.setRoutePlanningMode(false);
|
||||
osmandSettings.LAST_ROUTING_APPLICATION_MODE = osmandSettings.APPLICATION_MODE.get();
|
||||
osmandSettings.APPLICATION_MODE.set(osmandSettings.DEFAULT_APPLICATION_MODE.get());
|
||||
osmandSettings.setApplicationMode(osmandSettings.DEFAULT_APPLICATION_MODE.get());
|
||||
targetPointsHelper.removeAllWayPoints(false, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -555,7 +555,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
TargetPointsHelper targets = app.getTargetPointsHelper();
|
||||
|
||||
ApplicationMode mode = appMode != null ? appMode : getRouteMode(from);
|
||||
//app.getSettings().APPLICATION_MODE.set(mode);
|
||||
//app.getSettings().setApplicationMode(mode, false);
|
||||
app.getRoutingHelper().setAppMode(mode);
|
||||
app.initVoiceCommandPlayer(mapActivity, mode, true, null, false, false, showMenu);
|
||||
// save application mode controls
|
||||
|
@ -588,7 +588,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
TargetPointsHelper targets = app.getTargetPointsHelper();
|
||||
|
||||
ApplicationMode mode = getRouteMode(null);
|
||||
//app.getSettings().APPLICATION_MODE.set(mode);
|
||||
//app.getSettings().setApplicationMode(mode, false);
|
||||
app.getRoutingHelper().setAppMode(mode);
|
||||
//Test for #2810: No need to init player here?
|
||||
//app.initVoiceCommandPlayer(mapActivity, true, null, false, false);
|
||||
|
@ -756,7 +756,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
.setListener(new ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) {
|
||||
app.getSettings().APPLICATION_MODE.set(appMode);
|
||||
app.getSettings().setApplicationMode(appMode);
|
||||
updateDrawerMenu();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -737,7 +737,7 @@ public class ExternalApiHelper {
|
|||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
if (gpx == null) {
|
||||
app.getSettings().APPLICATION_MODE.set(mode);
|
||||
app.getSettings().setApplicationMode(mode);
|
||||
final TargetPointsHelper targets = mapActivity.getMyApplication().getTargetPointsHelper();
|
||||
targets.removeAllWayPoints(false, true);
|
||||
targets.navigateToPoint(to, true, -1, toDesc);
|
||||
|
@ -747,7 +747,7 @@ public class ExternalApiHelper {
|
|||
mapActivity.getMapRouteInfoMenu().show();
|
||||
} else {
|
||||
if (app.getSettings().APPLICATION_MODE.get() != routingHelper.getAppMode()) {
|
||||
app.getSettings().APPLICATION_MODE.set(routingHelper.getAppMode());
|
||||
app.getSettings().setApplicationMode(routingHelper.getAppMode(), false);
|
||||
}
|
||||
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
|
||||
app.getSettings().FOLLOW_THE_ROUTE.set(true);
|
||||
|
|
|
@ -953,7 +953,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
if (navigateInPedestrianMode()) {
|
||||
mapActivity.getMyApplication().getSettings().APPLICATION_MODE.set(ApplicationMode.PEDESTRIAN);
|
||||
mapActivity.getMyApplication().getSettings().setApplicationMode(ApplicationMode.PEDESTRIAN, false);
|
||||
}
|
||||
mapActivity.getMapLayers().getMapControlsLayer().navigateButton();
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ public class DestinationReachedMenuFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
OsmandSettings settings = mapActivity.getMyApplication().getSettings();
|
||||
settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get());
|
||||
settings.setApplicationMode(settings.DEFAULT_APPLICATION_MODE.get());
|
||||
mapActivity.getMapActions().stopNavigationWithoutConfirm();
|
||||
dismissMenu();
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public class SelectAppModesBottomSheetDialogFragment extends AppModesBottomSheet
|
|||
OsmandSettings settings = getMyApplication().getSettings();
|
||||
if (appMode != this.appMode) {
|
||||
if (appModeChangeable) {
|
||||
settings.APPLICATION_MODE.set(appMode);
|
||||
settings.setApplicationMode(appMode);
|
||||
}
|
||||
Fragment targetFragment = getTargetFragment();
|
||||
if (targetFragment instanceof AppModeChangedListener) {
|
||||
|
|
|
@ -123,7 +123,7 @@ public class SwitchProfileAction extends SwitchableAction<String> {
|
|||
ApplicationMode appMode = getModeForKey(params);
|
||||
if (appMode != null) {
|
||||
OsmandApplication app = activity.getMyApplication();
|
||||
app.getSettings().APPLICATION_MODE.set(appMode);
|
||||
app.getSettings().setApplicationMode(appMode);
|
||||
app.getQuickActionRegistry().setQuickActionFabState(true);
|
||||
|
||||
String message = String.format(activity.getString(
|
||||
|
|
|
@ -621,7 +621,7 @@ public class RoutingHelper {
|
|||
@Override
|
||||
public void run() {
|
||||
settings.LAST_ROUTING_APPLICATION_MODE = settings.APPLICATION_MODE.get();
|
||||
//settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get());
|
||||
//settings.setApplicationMode(settings.DEFAULT_APPLICATION_MODE.get());
|
||||
}
|
||||
});
|
||||
finishCurrentRoute();
|
||||
|
|
|
@ -238,7 +238,7 @@ public class OsmandSettings {
|
|||
String appModeKey = (String) value;
|
||||
ApplicationMode appMode = ApplicationMode.valueOfStringKey(appModeKey, null);
|
||||
if (appMode != null) {
|
||||
APPLICATION_MODE.set(appMode);
|
||||
setApplicationMode(appMode);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -380,6 +380,18 @@ public class OsmandSettings {
|
|||
|
||||
public ApplicationMode LAST_ROUTING_APPLICATION_MODE = null;
|
||||
|
||||
public boolean setApplicationMode(ApplicationMode appMode) {
|
||||
return setApplicationMode(appMode, true);
|
||||
}
|
||||
|
||||
public boolean setApplicationMode(ApplicationMode appMode, boolean markAsLastUsed) {
|
||||
boolean valueSaved = APPLICATION_MODE.set(appMode);
|
||||
if (markAsLastUsed && valueSaved) {
|
||||
LAST_USED_APPLICATION_MODE.set(appMode.getStringKey());
|
||||
}
|
||||
return valueSaved;
|
||||
}
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<ApplicationMode> APPLICATION_MODE = new PreferenceWithListener<ApplicationMode>() {
|
||||
|
||||
|
@ -425,7 +437,6 @@ public class OsmandSettings {
|
|||
if (valueSaved) {
|
||||
currentMode = val;
|
||||
profilePreferences = getProfilePreferences(currentMode);
|
||||
LAST_USED_APPLICATION_MODE.set(currentMode.getStringKey());
|
||||
|
||||
fireEvent(oldMode);
|
||||
}
|
||||
|
@ -757,7 +768,7 @@ public class OsmandSettings {
|
|||
protected boolean setValue(Object prefs, ApplicationMode val) {
|
||||
boolean valueSaved = settingsAPI.edit(prefs).putString(getId(), val.getStringKey()).commit();
|
||||
if (valueSaved) {
|
||||
APPLICATION_MODE.set(val);
|
||||
setApplicationMode(val);
|
||||
}
|
||||
|
||||
return valueSaved;
|
||||
|
|
|
@ -417,7 +417,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
|
|||
if (!ApplicationMode.values(app).contains(selectedMode)) {
|
||||
ApplicationMode.changeProfileAvailability(selectedMode, true, app);
|
||||
}
|
||||
settings.APPLICATION_MODE.set(selectedMode);
|
||||
settings.setApplicationMode(selectedMode);
|
||||
fragmentManager.beginTransaction()
|
||||
.remove(this)
|
||||
.addToBackStack(TAG)
|
||||
|
|
|
@ -800,7 +800,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
if (routingHelper.isFollowingMode()) {
|
||||
switchToRouteFollowingLayout();
|
||||
if (app.getSettings().APPLICATION_MODE.get() != routingHelper.getAppMode()) {
|
||||
app.getSettings().APPLICATION_MODE.set(routingHelper.getAppMode());
|
||||
app.getSettings().setApplicationMode(routingHelper.getAppMode(), false);
|
||||
}
|
||||
} else {
|
||||
if (!app.getTargetPointsHelper().checkPointToNavigateShort()) {
|
||||
|
@ -808,7 +808,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
} else {
|
||||
touchEvent = 0;
|
||||
app.logEvent("start_navigation");
|
||||
app.getSettings().APPLICATION_MODE.set(routingHelper.getAppMode());
|
||||
app.getSettings().setApplicationMode(routingHelper.getAppMode(), false);
|
||||
mapActivity.getMapViewTrackingUtilities().backToLocationImpl(17, true);
|
||||
app.getSettings().FOLLOW_THE_ROUTE.set(true);
|
||||
routingHelper.setFollowingMode(true);
|
||||
|
|
Loading…
Reference in a new issue