diff --git a/OsmAnd/src/net/osmand/plus/ApplicationMode.java b/OsmAnd/src/net/osmand/plus/ApplicationMode.java index f35b2bc76f..7c8499d484 100644 --- a/OsmAnd/src/net/osmand/plus/ApplicationMode.java +++ b/OsmAnd/src/net/osmand/plus/ApplicationMode.java @@ -52,7 +52,6 @@ public class ApplicationMode { private static Map> widgetsAvailabilityMap = new LinkedHashMap<>(); private static List defaultValues = new ArrayList<>(); - private static List customValues = new ArrayList<>(); private static List values = new ArrayList<>(); private static List 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()); } diff --git a/OsmAnd/src/net/osmand/plus/profiles/EditProfilesFragment.java b/OsmAnd/src/net/osmand/plus/profiles/EditProfilesFragment.java index f8bc935ed1..325c135f74 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/EditProfilesFragment.java +++ b/OsmAnd/src/net/osmand/plus/profiles/EditProfilesFragment.java @@ -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);