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