Fix creating new profile

This commit is contained in:
Vitaliy 2020-01-28 11:38:33 +02:00
parent c88625bfee
commit 091d23ad93

View file

@ -653,17 +653,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
} }
return false; return false;
} }
ApplicationMode mode = ApplicationMode.valueOfStringKey(changedProfile.stringKey, null); if (isNew) {
if (mode != null && !isNew) {
mode.setParentAppMode(app, changedProfile.parent);
mode.setUserProfileName(app, changedProfile.name.trim());
mode.setIconResName(app, ProfileIcons.getResStringByResId(changedProfile.iconRes));
mode.setRouteService(app, changedProfile.routeService);
mode.setRoutingProfile(app, changedProfile.routingProfile);
mode.setIconColor(app, changedProfile.color);
mode.setLocationIcon(app, changedProfile.locationIcon);
mode.setNavigationIcon(app, changedProfile.navigationIcon);
} else {
ApplicationMode.ApplicationModeBuilder builder = ApplicationMode ApplicationMode.ApplicationModeBuilder builder = ApplicationMode
.createCustomMode(changedProfile.parent, changedProfile.name.trim(), changedProfile.stringKey) .createCustomMode(changedProfile.parent, changedProfile.name.trim(), changedProfile.stringKey)
.icon(app, ProfileIcons.getResStringByResId(changedProfile.iconRes)) .icon(app, ProfileIcons.getResStringByResId(changedProfile.iconRes))
@ -673,15 +663,23 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
.locationIcon(changedProfile.locationIcon) .locationIcon(changedProfile.locationIcon)
.navigationIcon(changedProfile.navigationIcon); .navigationIcon(changedProfile.navigationIcon);
mode = ApplicationMode.saveProfile(builder, app); app.getSettings().copyPreferencesFromProfile(changedProfile.parent, builder.getApplicationMode());
} ApplicationMode mode = ApplicationMode.saveProfile(builder, app);
if (isNew) {
if (!ApplicationMode.values(app).contains(mode)) { if (!ApplicationMode.values(app).contains(mode)) {
ApplicationMode.changeProfileAvailability(mode, true, app); ApplicationMode.changeProfileAvailability(mode, true, app);
} }
app.getSettings().copyPreferencesFromProfile(changedProfile.parent, mode); } else {
ApplicationMode mode = ApplicationMode.valueOfStringKey(changedProfile.stringKey, null);
mode.setParentAppMode(app, changedProfile.parent);
mode.setUserProfileName(app, changedProfile.name.trim());
mode.setIconResName(app, ProfileIcons.getResStringByResId(changedProfile.iconRes));
mode.setRouteService(app, changedProfile.routeService);
mode.setRoutingProfile(app, changedProfile.routingProfile);
mode.setIconColor(app, changedProfile.color);
mode.setLocationIcon(app, changedProfile.locationIcon);
mode.setNavigationIcon(app, changedProfile.navigationIcon);
} }
return true; return true;
} }