Fix copy prefs for new app mode
This commit is contained in:
parent
acddd4f4ff
commit
a94853da95
4 changed files with 15 additions and 13 deletions
|
@ -520,9 +520,9 @@ public class ApplicationMode {
|
|||
String parent = settings.PARENT_APP_MODE.getValue(profilePreferences, null);
|
||||
int order = settings.APP_MODE_ORDER.getValue(profilePreferences, values.size());
|
||||
|
||||
ApplicationModeBuilder builder = createCustomMode(valueOfStringKey(parent, CAR), appModeKey);
|
||||
ApplicationModeBuilder builder = createCustomMode(valueOfStringKey(parent, CAR), appModeKey, app);
|
||||
builder.setOrder(order);
|
||||
builder.customReg(app);
|
||||
builder.customReg();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -573,7 +573,7 @@ public class ApplicationMode {
|
|||
mode.setNavigationIcon(builder.navigationIcon);
|
||||
mode.setOrder(builder.order);
|
||||
} else {
|
||||
mode = builder.customReg(app);
|
||||
mode = builder.customReg();
|
||||
initRegVisibility();
|
||||
}
|
||||
reorderAppModes();
|
||||
|
@ -586,8 +586,8 @@ public class ApplicationMode {
|
|||
return gson.fromJson(json, ApplicationModeBean.class);
|
||||
}
|
||||
|
||||
public static ApplicationModeBuilder fromModeBean(ApplicationModeBean modeBean) {
|
||||
ApplicationModeBuilder builder = createCustomMode(valueOfStringKey(modeBean.parent, null), modeBean.stringKey);
|
||||
public static ApplicationModeBuilder fromModeBean(OsmandApplication app, ApplicationModeBean modeBean) {
|
||||
ApplicationModeBuilder builder = createCustomMode(valueOfStringKey(modeBean.parent, null), modeBean.stringKey, app);
|
||||
builder.setUserProfileName(modeBean.userProfileName);
|
||||
builder.setIconResName(modeBean.iconName);
|
||||
builder.setIconColor(modeBean.iconColor);
|
||||
|
@ -667,8 +667,10 @@ public class ApplicationMode {
|
|||
return builder;
|
||||
}
|
||||
|
||||
public static ApplicationModeBuilder createCustomMode(ApplicationMode parent, String stringKey) {
|
||||
return create(parent, -1, stringKey);
|
||||
public static ApplicationModeBuilder createCustomMode(ApplicationMode parent, String stringKey, OsmandApplication app) {
|
||||
ApplicationModeBuilder builder = create(parent, -1, stringKey);
|
||||
builder.getApplicationMode().app = app;
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static class ApplicationModeBuilder {
|
||||
|
@ -694,11 +696,9 @@ public class ApplicationMode {
|
|||
return applicationMode;
|
||||
}
|
||||
|
||||
private ApplicationMode customReg(OsmandApplication app) {
|
||||
private ApplicationMode customReg() {
|
||||
values.add(applicationMode);
|
||||
|
||||
applicationMode.app = app;
|
||||
|
||||
ApplicationMode parent = applicationMode.parentAppMode;
|
||||
applicationMode.minDistanceForTurn = parent.minDistanceForTurn;
|
||||
applicationMode.arrivalDistance = parent.arrivalDistance;
|
||||
|
|
|
@ -35,6 +35,7 @@ import net.osmand.map.TileSourceManager;
|
|||
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||
import net.osmand.osm.io.NetworkUtils;
|
||||
import net.osmand.plus.ApplicationMode.ApplicationModeBean;
|
||||
import net.osmand.plus.ApplicationMode.ApplicationModeBuilder;
|
||||
import net.osmand.plus.access.AccessibilityMode;
|
||||
import net.osmand.plus.access.RelativeDirectionStyle;
|
||||
import net.osmand.plus.api.SettingsAPI;
|
||||
|
@ -292,7 +293,8 @@ public class OsmandSettings {
|
|||
List<ApplicationModeBean> customProfiles = gson.fromJson(json, t);
|
||||
if (!Algorithms.isEmpty(customProfiles)) {
|
||||
for (ApplicationModeBean modeBean : customProfiles) {
|
||||
ApplicationMode.saveProfile(ApplicationMode.fromModeBean(modeBean), ctx);
|
||||
ApplicationModeBuilder builder = ApplicationMode.fromModeBean(ctx, modeBean);
|
||||
ApplicationMode.saveProfile(builder, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -446,7 +446,7 @@ public class SettingsHelper {
|
|||
void readFromJson(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException {
|
||||
String appModeJson = json.getString("appMode");
|
||||
modeBean = ApplicationMode.fromJson(appModeJson);
|
||||
builder = ApplicationMode.fromModeBean(modeBean);
|
||||
builder = ApplicationMode.fromModeBean(app, modeBean);
|
||||
ApplicationMode appMode = builder.getApplicationMode();
|
||||
if (!appMode.isCustomProfile()) {
|
||||
appMode = ApplicationMode.valueOfStringKey(appMode.getStringKey(), appMode);
|
||||
|
|
|
@ -655,7 +655,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
|
|||
}
|
||||
if (isNew) {
|
||||
ApplicationMode.ApplicationModeBuilder builder = ApplicationMode
|
||||
.createCustomMode(changedProfile.parent, changedProfile.stringKey)
|
||||
.createCustomMode(changedProfile.parent, changedProfile.stringKey, app)
|
||||
.setIconResName(ProfileIcons.getResStringByResId(changedProfile.iconRes))
|
||||
.setUserProfileName(changedProfile.name.trim())
|
||||
.setRoutingProfile(changedProfile.routingProfile)
|
||||
|
|
Loading…
Reference in a new issue