Fix renew widgets after profiles import

This commit is contained in:
Dima-1 2020-11-27 15:26:39 +02:00
parent ca2b6f4d0e
commit ac497a9f14
3 changed files with 14 additions and 0 deletions

View file

@ -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<Void, Void, String> {
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());

View file

@ -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);
}

View file

@ -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();