From ac497a9f143bb67b70d524fcd5d7ad6cd8aef3bd Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 27 Nov 2020 15:26:39 +0200 Subject: [PATCH] Fix renew widgets after profiles import --- .../src/net/osmand/plus/importfiles/SettingsImportTask.java | 6 ++++++ .../plus/settings/backend/backup/ProfileSettingsItem.java | 3 +++ .../plus/settings/fragments/ProfileAppearanceFragment.java | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/importfiles/SettingsImportTask.java b/OsmAnd/src/net/osmand/plus/importfiles/SettingsImportTask.java index 833ad34c3d..99c321adfd 100644 --- a/OsmAnd/src/net/osmand/plus/importfiles/SettingsImportTask.java +++ b/OsmAnd/src/net/osmand/plus/importfiles/SettingsImportTask.java @@ -14,6 +14,7 @@ import net.osmand.IndexConstants; import net.osmand.plus.AppInitializer; import net.osmand.plus.CustomOsmandPlugin; import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.BaseLoadAsyncTask; import net.osmand.plus.settings.backend.ExportSettingsType; import net.osmand.plus.settings.backend.backup.SettingsHelper; @@ -133,6 +134,11 @@ class SettingsImportTask extends BaseLoadAsyncTask { if (activity != null && succeed) { FragmentManager fm = activity.getSupportFragmentManager(); app.getRendererRegistry().updateExternalRenderers(); + app.getPoiFilters().loadSelectedPoiFilters(); + if (activity instanceof MapActivity) { + ((MapActivity) activity).getMapLayers().getMapWidgetRegistry().updateVisibleWidgets(); + ((MapActivity) activity).updateApplicationModeSettings(); + } AppInitializer.loadRoutingFiles(app, null); if (file != null) { ImportCompleteFragment.showInstance(fm, items, file.getName()); diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/ProfileSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/ProfileSettingsItem.java index 4ddb04daab..10e47d4e09 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/ProfileSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/ProfileSettingsItem.java @@ -170,6 +170,9 @@ public class ProfileSettingsItem extends OsmandSettingsItem { builder = ApplicationMode.fromModeBean(app, modeBean); appMode = ApplicationMode.saveProfile(builder, app); } else { + if (modeBean == null) { + modeBean = appMode.toModeBean(); + } builder = ApplicationMode.fromModeBean(app, modeBean); appMode = ApplicationMode.saveProfile(builder, app); } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java index 8e4dfc14c0..0374a4a42f 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java @@ -40,6 +40,7 @@ import androidx.recyclerview.widget.RecyclerView; import net.osmand.AndroidUtils; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; +import net.osmand.plus.activities.MapActivity; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.R; import net.osmand.plus.settings.backend.backup.ProfileSettingsItem; @@ -873,6 +874,10 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment { private void customProfileSaved() { FragmentActivity activity = getActivity(); if (activity != null) { + if (activity instanceof MapActivity) { + ((MapActivity) activity).getMapLayers().getMapWidgetRegistry().updateVisibleWidgets(); + ((MapActivity) activity).updateApplicationModeSettings(); + } FragmentManager fragmentManager = activity.getSupportFragmentManager(); if (!fragmentManager.isStateSaved()) { fragmentManager.popBackStack();