Merge pull request #8133 from osmandapp/Manage_profile_settings
Fix profiles reorder
This commit is contained in:
commit
f7b9b3decb
2 changed files with 20 additions and 9 deletions
|
@ -52,7 +52,6 @@ public class ApplicationMode {
|
|||
private static Map<String, Set<ApplicationMode>> widgetsAvailabilityMap = new LinkedHashMap<>();
|
||||
|
||||
private static List<ApplicationMode> defaultValues = new ArrayList<>();
|
||||
private static List<ApplicationMode> customValues = new ArrayList<>();
|
||||
private static List<ApplicationMode> values = new ArrayList<>();
|
||||
private static List<ApplicationMode> cachedFilteredValues = new ArrayList<>();
|
||||
|
||||
|
@ -194,6 +193,9 @@ public class ApplicationMode {
|
|||
private ApplicationMode reg() {
|
||||
values.add(applicationMode);
|
||||
defaultValues.add(applicationMode);
|
||||
if (applicationMode.getOrder() == 0 && !values.isEmpty()) {
|
||||
applicationMode.setOrder(values.size());
|
||||
}
|
||||
return applicationMode;
|
||||
}
|
||||
|
||||
|
@ -213,7 +215,9 @@ public class ApplicationMode {
|
|||
m.locationIconDayLost = m.parentAppMode.locationIconDayLost;
|
||||
m.locationIconNightLost = m.parentAppMode.locationIconNightLost;
|
||||
values.add(applicationMode);
|
||||
customValues.add(applicationMode);
|
||||
if (applicationMode.getOrder() == 0 && !values.isEmpty()) {
|
||||
applicationMode.setOrder(values.size());
|
||||
}
|
||||
return applicationMode;
|
||||
}
|
||||
|
||||
|
@ -677,9 +681,11 @@ public class ApplicationMode {
|
|||
|
||||
ApplicationModeBuilder b = createCustomMode(valueOfStringKey(mb.parent, null),
|
||||
mb.userProfileName, mb.stringKey);
|
||||
b.setRouteService(mb.routeService).setRoutingProfile(mb.routingProfile);
|
||||
b.setRouteService(mb.routeService);
|
||||
b.setRoutingProfile(mb.routingProfile);
|
||||
b.icon(app, mb.iconName);
|
||||
b.setColor(mb.iconColor);
|
||||
b.setOrder(mb.order);
|
||||
return b;
|
||||
}
|
||||
|
||||
|
@ -692,6 +698,7 @@ public class ApplicationMode {
|
|||
mb.stringKey = stringKey;
|
||||
mb.routeService = routeService;
|
||||
mb.routingProfile = routingProfile;
|
||||
mb.order = order;
|
||||
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
||||
return gson.toJson(mb);
|
||||
}
|
||||
|
@ -807,7 +814,6 @@ public class ApplicationMode {
|
|||
it.remove();
|
||||
}
|
||||
}
|
||||
customValues.remove(md);
|
||||
cachedFilteredValues.remove(md);
|
||||
saveAppModesToSettings(app.getSettings(), md.isCustomProfile());
|
||||
}
|
||||
|
|
|
@ -391,11 +391,16 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
|
|||
Object itemFrom = getItem(from);
|
||||
Object itemTo = getItem(to);
|
||||
if (itemFrom instanceof EditProfileDataObject && itemTo instanceof EditProfileDataObject) {
|
||||
EditProfileDataObject profileDataObjectFrom = (EditProfileDataObject) itemFrom;
|
||||
EditProfileDataObject profileDataObjectTo = (EditProfileDataObject) itemTo;
|
||||
int tmp = profileDataObjectFrom.getOrder();
|
||||
appModesOrders.put(profileDataObjectFrom.getStringKey(), profileDataObjectTo.getOrder());
|
||||
appModesOrders.put(profileDataObjectTo.getStringKey(), tmp);
|
||||
EditProfileDataObject profileFrom = (EditProfileDataObject) itemFrom;
|
||||
EditProfileDataObject profileTo = (EditProfileDataObject) itemTo;
|
||||
|
||||
int orderFrom = profileFrom.getOrder();
|
||||
int orderTo = profileTo.getOrder();
|
||||
|
||||
profileFrom.setOrder(orderTo);
|
||||
profileTo.setOrder(orderFrom);
|
||||
appModesOrders.put(profileFrom.getStringKey(), orderTo);
|
||||
appModesOrders.put(profileTo.getStringKey(), orderFrom);
|
||||
|
||||
Collections.swap(items, from, to);
|
||||
notifyItemMoved(from, to);
|
||||
|
|
Loading…
Reference in a new issue