From ab3ed3f93cc440a70bc3176dfb75b4f6bf153267 Mon Sep 17 00:00:00 2001 From: chumv Date: Tue, 7 Jan 2025 20:59:27 +0200 Subject: [PATCH 1/2] Remove unnecessary changes --- .../backend/backup/items/QuickActionsSettingsItem.java | 2 ++ .../views/mapwidgets/configure/buttons/ButtonStateBean.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/items/QuickActionsSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/items/QuickActionsSettingsItem.java index f7c57255649..0a7c46d3613 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/items/QuickActionsSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/items/QuickActionsSettingsItem.java @@ -144,6 +144,7 @@ private void readButtonState(@NonNull JSONObject json) { buttonState = new QuickActionButtonState(app, id); stateBean = new ButtonStateBean(id); stateBean.name = object.optString("name"); + stateBean.enabled = object.optBoolean("enabled"); String iconName = object.optString("icon"); if (!Algorithms.isEmpty(iconName)) { @@ -178,6 +179,7 @@ void writeToJson(@NonNull JSONObject json) throws JSONException { JSONObject jsonObject = new JSONObject(); jsonObject.put("id", buttonState.getId()); jsonObject.put("name", buttonState.hasCustomName() ? buttonState.getName() : ""); + jsonObject.put("enabled", buttonState.isEnabled()); if (buttonState.getIconPref().isSet()) { jsonObject.put("icon", buttonState.getIconPref().get()); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/configure/buttons/ButtonStateBean.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/configure/buttons/ButtonStateBean.java index 3813d1725cd..c46629a9d89 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/configure/buttons/ButtonStateBean.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/configure/buttons/ButtonStateBean.java @@ -12,6 +12,7 @@ public class ButtonStateBean { public int size = -1; public int cornerRadius = -1; public float opacity = -1; + public boolean enabled; public ButtonStateBean(@NonNull String id) { this.id = id; @@ -19,6 +20,7 @@ public ButtonStateBean(@NonNull String id) { public void setupButtonState(@NonNull QuickActionButtonState buttonState) { buttonState.setName(name); + buttonState.setEnabled(enabled); if (!Algorithms.isEmpty(icon)) { buttonState.getIconPref().set(icon); @@ -37,6 +39,7 @@ public void setupButtonState(@NonNull QuickActionButtonState buttonState) { @NonNull public static ButtonStateBean toStateBean(@NonNull QuickActionButtonState state) { ButtonStateBean bean = new ButtonStateBean(state.getId()); + bean.enabled = state.isEnabled(); if (state.hasCustomName()) { bean.name = state.getName(); } From 0c441a15570a8ad04c155e72c77cf7f4c0eaa6ba Mon Sep 17 00:00:00 2001 From: chumv Date: Tue, 7 Jan 2025 20:59:51 +0200 Subject: [PATCH 2/2] Fix #21408 --- .../backup/items/QuickActionsSettingsItem.java | 2 +- .../mapwidgets/configure/buttons/ButtonStateBean.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/items/QuickActionsSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/items/QuickActionsSettingsItem.java index 0a7c46d3613..e784e4d4083 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/items/QuickActionsSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/items/QuickActionsSettingsItem.java @@ -108,7 +108,7 @@ public void apply() { renameButton(); } } - stateBean.setupButtonState(buttonState); + stateBean.setupButtonState(app, buttonState); mapButtonsHelper.addQuickActionButtonState(buttonState); } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/configure/buttons/ButtonStateBean.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/configure/buttons/ButtonStateBean.java index c46629a9d89..71fc45f1503 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/configure/buttons/ButtonStateBean.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/configure/buttons/ButtonStateBean.java @@ -2,6 +2,9 @@ import androidx.annotation.NonNull; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.util.Algorithms; public class ButtonStateBean { @@ -18,7 +21,12 @@ public ButtonStateBean(@NonNull String id) { this.id = id; } - public void setupButtonState(@NonNull QuickActionButtonState buttonState) { + public void setupButtonState(@NonNull OsmandApplication app, + @NonNull QuickActionButtonState buttonState) { + OsmandSettings settings = app.getSettings(); + ApplicationMode appMode = settings.getApplicationMode(); + long time = settings.getLastModePreferencesEditTime(appMode); + buttonState.setName(name); buttonState.setEnabled(enabled); @@ -34,6 +42,7 @@ public void setupButtonState(@NonNull QuickActionButtonState buttonState) { if (opacity >= 0) { buttonState.getOpacityPref().set(opacity); } + settings.setLastModePreferencesEditTime(appMode, time); } @NonNull