From ca2b6f4d0e61eca55a29b7b7c43c64345766cb30 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 26 Nov 2020 19:22:33 +0200 Subject: [PATCH 1/3] Fix profiles import --- .../osmand/plus/importfiles/ImportHelper.java | 32 +++++++--- .../plus/importfiles/SettingsImportTask.java | 59 +++++++++++++++++-- .../plus/importfiles/ZipImportTask.java | 3 +- .../backend/OsmAndAppCustomization.java | 24 ++++---- .../fragments/ExportItemsBottomSheet.java | 2 +- 5 files changed, 91 insertions(+), 29 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java b/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java index 09d2064284..c7cad00b0c 100644 --- a/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java @@ -34,6 +34,7 @@ import net.osmand.plus.dialogs.ImportGpxBottomSheetDialogFragment; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; import net.osmand.plus.measurementtool.MeasurementToolFragment; +import net.osmand.plus.settings.backend.ExportSettingsType; import net.osmand.plus.settings.backend.backup.SettingsHelper; import net.osmand.plus.settings.backend.backup.SettingsItem; import net.osmand.plus.views.OsmandMapTileView; @@ -67,6 +68,8 @@ import static net.osmand.IndexConstants.WPT_CHART_FILE_EXT; import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE; import static net.osmand.plus.myplaces.FavoritesActivity.GPX_TAB; import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID; +import static net.osmand.plus.settings.backend.backup.SettingsHelper.REPLACE_KEY; +import static net.osmand.plus.settings.backend.backup.SettingsHelper.SETTINGS_TYPE_LIST_KEY; /** * @author Koen Rabaey @@ -203,10 +206,11 @@ public class ImportHelper { } } + @Nullable public static String getNameFromContentUri(OsmandApplication app, Uri contentUri) { try { String name; - Cursor returnCursor = app.getContentResolver().query(contentUri, new String[] {OpenableColumns.DISPLAY_NAME}, null, null, null); + Cursor returnCursor = app.getContentResolver().query(contentUri, new String[]{OpenableColumns.DISPLAY_NAME}, null, null, null); if (returnCursor != null && returnCursor.moveToFirst()) { int columnIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME); if (columnIndex != -1) { @@ -257,18 +261,32 @@ public class ImportHelper { } private void handleOsmAndSettingsImport(Uri intentUri, String fileName, Bundle extras, CallbackWithObject> callback) { - if (extras != null && extras.containsKey(SettingsHelper.SETTINGS_VERSION_KEY) && extras.containsKey(SettingsHelper.SETTINGS_LATEST_CHANGES_KEY)) { + if (extras != null + && extras.containsKey(SettingsHelper.SETTINGS_VERSION_KEY) + && extras.containsKey(SettingsHelper.SETTINGS_LATEST_CHANGES_KEY)) { int version = extras.getInt(SettingsHelper.SETTINGS_VERSION_KEY, -1); String latestChanges = extras.getString(SettingsHelper.SETTINGS_LATEST_CHANGES_KEY); - handleOsmAndSettingsImport(intentUri, fileName, latestChanges, version, callback); + boolean replace = extras.getBoolean(REPLACE_KEY); + ArrayList settingsTypeKeys = extras.getStringArrayList(SETTINGS_TYPE_LIST_KEY); + List settingsTypes = null; + if (settingsTypeKeys != null) { + settingsTypes = new ArrayList<>(); + for (String key : settingsTypeKeys) { + settingsTypes.add(ExportSettingsType.valueOf(key)); + } + } + handleOsmAndSettingsImport(intentUri, fileName, settingsTypes, replace, latestChanges, version, callback); } else { - handleOsmAndSettingsImport(intentUri, fileName, null, -1, callback); + handleOsmAndSettingsImport(intentUri, fileName, null, false, null, -1, + callback); } } - protected void handleOsmAndSettingsImport(Uri uri, String name, String latestChanges, int version, - CallbackWithObject> callback) { - executeImportTask(new SettingsImportTask(activity, uri, name, latestChanges, version, callback)); + protected void handleOsmAndSettingsImport(Uri uri, String name, final List settingsTypes, + final boolean replace, String latestChanges, int version, + CallbackWithObject> callback) { + executeImportTask(new SettingsImportTask(activity, uri, name, settingsTypes, replace, latestChanges, version, + callback)); } protected void handleXmlFileImport(Uri intentUri, String fileName, CallbackWithObject routingCallback) { diff --git a/OsmAnd/src/net/osmand/plus/importfiles/SettingsImportTask.java b/OsmAnd/src/net/osmand/plus/importfiles/SettingsImportTask.java index 991d8a83c4..833ad34c3d 100644 --- a/OsmAnd/src/net/osmand/plus/importfiles/SettingsImportTask.java +++ b/OsmAnd/src/net/osmand/plus/importfiles/SettingsImportTask.java @@ -11,38 +11,49 @@ import net.osmand.AndroidUtils; import net.osmand.CallbackWithObject; import net.osmand.FileUtils; import net.osmand.IndexConstants; +import net.osmand.plus.AppInitializer; import net.osmand.plus.CustomOsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.base.BaseLoadAsyncTask; +import net.osmand.plus.settings.backend.ExportSettingsType; +import net.osmand.plus.settings.backend.backup.SettingsHelper; import net.osmand.plus.settings.backend.backup.SettingsHelper.CheckDuplicatesListener; import net.osmand.plus.settings.backend.backup.PluginSettingsItem; import net.osmand.plus.settings.backend.backup.ProfileSettingsItem; import net.osmand.plus.settings.backend.backup.SettingsHelper.SettingsCollectListener; import net.osmand.plus.settings.backend.backup.SettingsHelper.SettingsImportListener; import net.osmand.plus.settings.backend.backup.SettingsItem; +import net.osmand.plus.settings.fragments.ImportCompleteFragment; import net.osmand.plus.settings.fragments.ImportSettingsFragment; import net.osmand.util.Algorithms; import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.Map; import static net.osmand.plus.AppInitializer.loadRoutingFiles; +import static net.osmand.plus.settings.backend.backup.SettingsHelper.getSettingsToOperate; class SettingsImportTask extends BaseLoadAsyncTask { private Uri uri; private String name; + private List settingsTypes; + private boolean replace; private String latestChanges; private int version; private CallbackWithObject> callback; public SettingsImportTask(@NonNull FragmentActivity activity, @NonNull Uri uri, - @NonNull String name, String latestChanges, int version, - CallbackWithObject> callback) { + @NonNull String name, List settingsTypes, + boolean replace, String latestChanges, int version, + CallbackWithObject> callback) { super(activity); this.uri = uri; this.name = name; + this.settingsTypes = settingsTypes; + this.replace = replace; this.latestChanges = latestChanges; this.version = version; this.callback = callback; @@ -60,7 +71,8 @@ class SettingsImportTask extends BaseLoadAsyncTask { File tempDir = FileUtils.getTempDir(app); final File file = new File(tempDir, name); if (error == null && file.exists()) { - app.getSettingsHelper().collectSettings(file, latestChanges, version, new SettingsCollectListener() { + final SettingsHelper settingsHelper = app.getSettingsHelper(); + settingsHelper.collectSettings(file, latestChanges, version, new SettingsCollectListener() { @Override public void onSettingsCollectFinished(boolean succeed, boolean empty, @NonNull List items) { hideProgress(); @@ -77,11 +89,15 @@ class SettingsImportTask extends BaseLoadAsyncTask { for (PluginSettingsItem pluginItem : pluginSettingsItems) { handlePluginImport(pluginItem, file); } - if (!pluginIndependentItems.isEmpty()) { - FragmentActivity activity = activityRef.get(); - if (activity != null) { + FragmentActivity activity = activityRef.get(); + if (!pluginIndependentItems.isEmpty() && activity != null) { + if (settingsTypes == null) { FragmentManager fragmentManager = activity.getSupportFragmentManager(); ImportSettingsFragment.showInstance(fragmentManager, pluginIndependentItems, file); + } else { + Map> allSettingsList = getSettingsToOperate(pluginIndependentItems, false); + List settingsList = settingsHelper.getFilteredSettingsItems(allSettingsList, settingsTypes); + settingsHelper.checkDuplicates(file, settingsList, settingsList, getDuplicatesListener(file, replace)); } } } else if (empty) { @@ -95,6 +111,37 @@ class SettingsImportTask extends BaseLoadAsyncTask { } } + private CheckDuplicatesListener getDuplicatesListener(final File file, final boolean replace) { + return new CheckDuplicatesListener() { + @Override + public void onDuplicatesChecked(@NonNull List duplicates, List items) { + if (replace) { + for (SettingsItem item : items) { + item.setShouldReplace(true); + } + } + app.getSettingsHelper().importSettings(file, items, "", 1, getImportListener(file)); + } + }; + } + + private SettingsImportListener getImportListener(final File file) { + return new SettingsImportListener() { + @Override + public void onSettingsImportFinished(boolean succeed, @NonNull List items) { + FragmentActivity activity = activityRef.get(); + if (activity != null && succeed) { + FragmentManager fm = activity.getSupportFragmentManager(); + app.getRendererRegistry().updateExternalRenderers(); + AppInitializer.loadRoutingFiles(app, null); + if (file != null) { + ImportCompleteFragment.showInstance(fm, items, file.getName()); + } + } + } + }; + } + private void handlePluginImport(final PluginSettingsItem pluginItem, final File file) { FragmentActivity activity = activityRef.get(); final ProgressDialog progress; diff --git a/OsmAnd/src/net/osmand/plus/importfiles/ZipImportTask.java b/OsmAnd/src/net/osmand/plus/importfiles/ZipImportTask.java index e9bac73258..afdb7a32f2 100644 --- a/OsmAnd/src/net/osmand/plus/importfiles/ZipImportTask.java +++ b/OsmAnd/src/net/osmand/plus/importfiles/ZipImportTask.java @@ -85,7 +85,8 @@ public class ZipImportTask extends BaseLoadAsyncTask { importHelper.handleKmzImport(uri, name + GPX_FILE_EXT, save, useImportDir); } else if (importType == ImportType.SETTINGS) { String name = createUniqueFileName(app, "settings", TEMP_DIR, OSMAND_SETTINGS_FILE_EXT); - importHelper.handleOsmAndSettingsImport(uri, name + OSMAND_SETTINGS_FILE_EXT, null, -1, null); + importHelper.handleOsmAndSettingsImport(uri, name + OSMAND_SETTINGS_FILE_EXT, + null, false, null, -1, null); } } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndAppCustomization.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndAppCustomization.java index 8a43f650ee..742d9b26e1 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndAppCustomization.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndAppCustomization.java @@ -287,20 +287,17 @@ public class OsmAndAppCustomization { if (!connectedAppDir.exists()) { connectedAppDir.mkdirs(); } - OutputStream fout = new FileOutputStream(new File(connectedAppDir, iconName)); + OutputStream fout = null; + if (!Algorithms.isEmpty(iconName)) { + fout = new FileOutputStream(new File(connectedAppDir, iconName)); + } try { - Algorithms.streamCopy(is, fout); + if (fout != null) { + Algorithms.streamCopy(is, fout); + } } finally { - try { - is.close(); - } catch (IOException e) { - LOG.error(e); - } - try { - fout.close(); - } catch (IOException e) { - LOG.error(e); - } + Algorithms.closeStream(is); + Algorithms.closeStream(fout); } JSONObject json = new JSONObject(); json.put("", connectedAppDirPath + "/" + iconName); @@ -406,8 +403,7 @@ public class OsmAndAppCustomization { return set.contains(appMode); } - public boolean setNavDrawerLogoWithParams(String imageUri, @Nullable String packageName, - @Nullable String intent) { + public boolean setNavDrawerLogoWithParams(String imageUri, @Nullable String packageName, @Nullable String intent) { return setNavDrawerLogo(imageUri, packageName, intent); } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java index 8c62e04ccf..93dff80cce 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java @@ -217,7 +217,7 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment { String profileName = modeBean.userProfileName; if (Algorithms.isEmpty(profileName)) { ApplicationMode appMode = ApplicationMode.valueOfStringKey(modeBean.stringKey, null); - profileName = getString(appMode.getNameKeyResource()); + profileName = appMode.toHumanString(); } builder.setTitle(profileName); From ac497a9f143bb67b70d524fcd5d7ad6cd8aef3bd Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 27 Nov 2020 15:26:39 +0200 Subject: [PATCH 2/3] 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(); From d0acb1d1d47fc84e9a74b998ed8d3a3d6b719cf8 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Sat, 28 Nov 2020 21:14:45 +0200 Subject: [PATCH 3/3] Fix export empty file, refactoring --- .../plus/importfiles/SettingsImportTask.java | 24 ++++++++++--------- .../backend/backup/ProfileSettingsItem.java | 3 --- .../backend/backup/SettingsHelper.java | 22 ++++++----------- .../fragments/ExportSettingsAdapter.java | 9 ++++++- .../fragments/ExportSettingsFragment.java | 7 ++---- 5 files changed, 30 insertions(+), 35 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/importfiles/SettingsImportTask.java b/OsmAnd/src/net/osmand/plus/importfiles/SettingsImportTask.java index 99c321adfd..75c8d55015 100644 --- a/OsmAnd/src/net/osmand/plus/importfiles/SettingsImportTask.java +++ b/OsmAnd/src/net/osmand/plus/importfiles/SettingsImportTask.java @@ -90,14 +90,16 @@ class SettingsImportTask extends BaseLoadAsyncTask { for (PluginSettingsItem pluginItem : pluginSettingsItems) { handlePluginImport(pluginItem, file); } - FragmentActivity activity = activityRef.get(); - if (!pluginIndependentItems.isEmpty() && activity != null) { + if (!pluginIndependentItems.isEmpty()) { if (settingsTypes == null) { - FragmentManager fragmentManager = activity.getSupportFragmentManager(); - ImportSettingsFragment.showInstance(fragmentManager, pluginIndependentItems, file); + FragmentActivity activity = activityRef.get(); + if (activity != null) { + FragmentManager fragmentManager = activity.getSupportFragmentManager(); + ImportSettingsFragment.showInstance(fragmentManager, pluginIndependentItems, file); + } } else { - Map> allSettingsList = getSettingsToOperate(pluginIndependentItems, false); - List settingsList = settingsHelper.getFilteredSettingsItems(allSettingsList, settingsTypes); + Map> allSettingsMap = getSettingsToOperate(pluginIndependentItems, false); + List settingsList = settingsHelper.getFilteredSettingsItems(allSettingsMap, settingsTypes); settingsHelper.checkDuplicates(file, settingsList, settingsList, getDuplicatesListener(file, replace)); } } @@ -130,17 +132,17 @@ class SettingsImportTask extends BaseLoadAsyncTask { return new SettingsImportListener() { @Override public void onSettingsImportFinished(boolean succeed, @NonNull List items) { - FragmentActivity activity = activityRef.get(); - if (activity != null && succeed) { - FragmentManager fm = activity.getSupportFragmentManager(); + if (succeed) { app.getRendererRegistry().updateExternalRenderers(); app.getPoiFilters().loadSelectedPoiFilters(); + AppInitializer.loadRoutingFiles(app, null); + FragmentActivity activity = activityRef.get(); if (activity instanceof MapActivity) { ((MapActivity) activity).getMapLayers().getMapWidgetRegistry().updateVisibleWidgets(); ((MapActivity) activity).updateApplicationModeSettings(); } - AppInitializer.loadRoutingFiles(app, null); - if (file != null) { + if (file != null && activity != null) { + FragmentManager fm = activity.getSupportFragmentManager(); 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 10e47d4e09..4ddb04daab 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/ProfileSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/ProfileSettingsItem.java @@ -170,9 +170,6 @@ 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/backend/backup/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java index 4553cf805f..c092ae054f 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java @@ -481,24 +481,19 @@ public class SettingsHelper { return getFilteredSettingsItems(typesMap, settingsTypes); } - public List getFilteredSettingsItems(Map> additionalData, - List settingsTypes) { + public List getFilteredSettingsItems(Map> allSettingsMap, + List settingsTypes) { List settingsItems = new ArrayList<>(); for (ExportSettingsType settingsType : settingsTypes) { - List settingsDataObjects = additionalData.get(settingsType); + List settingsDataObjects = allSettingsMap.get(settingsType); if (settingsDataObjects != null) { - for (Object object : settingsDataObjects) { - if (object instanceof ApplicationModeBean) { - settingsItems.add(new ProfileSettingsItem(app, null, (ApplicationModeBean) object)); - } - } - settingsItems.addAll(prepareAdditionalSettingsItems(new ArrayList<>(settingsDataObjects))); + settingsItems.addAll(prepareSettingsItems(new ArrayList<>(settingsDataObjects))); } } return settingsItems; } - public Map getAdditionalData(boolean globalExport) { + public Map getSettingsByCategory(boolean globalExport) { Map dataList = new LinkedHashMap<>(); Map> settingsItems = getSettingsItems(globalExport); @@ -692,7 +687,7 @@ public class SettingsHelper { return files; } - public List prepareAdditionalSettingsItems(List data) { + public List prepareSettingsItems(List data) { List settingsItems = new ArrayList<>(); List quickActions = new ArrayList<>(); List poiUIFilters = new ArrayList<>(); @@ -754,10 +749,7 @@ public class SettingsHelper { } if (!appModeBeans.isEmpty()) { for (ApplicationModeBean modeBean : appModeBeans) { - ApplicationMode mode = ApplicationMode.valueOfStringKey(modeBean.stringKey, null); - if (mode != null) { - settingsItems.add(new ProfileSettingsItem(app, mode)); - } + settingsItems.add(new ProfileSettingsItem(app, null, modeBean)); } } if (!osmNotesPointList.isEmpty()) { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsAdapter.java index d479b78a7c..2c45919f2c 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsAdapter.java @@ -248,7 +248,14 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter { } public boolean hasSelectedData() { - return !selectedItemsMap.isEmpty(); + boolean hasSelectedData = false; + for (ExportSettingsType key : selectedItemsMap.keySet()) { + if (!selectedItemsMap.get(key).isEmpty()) { + hasSelectedData = true; + break; + } + } + return hasSelectedData; } public List getData() { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsFragment.java index f831fd8fdd..1245290834 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsFragment.java @@ -44,12 +44,9 @@ public class ExportSettingsFragment extends BaseSettingsListFragment { public static final String TAG = ImportSettingsFragment.class.getSimpleName(); public static final Log LOG = PlatformUtil.getLog(ImportSettingsFragment.class.getSimpleName()); - private static final String EXPORT_SETTINGS_TAG = "import_settings_tag"; private static final String GLOBAL_EXPORT_KEY = "global_export_key"; private static final String EXPORT_START_TIME_KEY = "export_start_time_key"; private static final String EXPORTING_STARTED_KEY = "exporting_started_key"; - private static final String INCLUDE_ADDITIONAL_DATA_KEY = "include_additional_data_key"; - private static final String INCLUDE_GLOBAL_SETTINGS_KEY = "include_global_settings_key"; private static final String PROGRESS_MAX_KEY = "progress_max_key"; private static final String PROGRESS_VALUE_KEY = "progress_value_key"; @@ -76,7 +73,7 @@ public class ExportSettingsFragment extends BaseSettingsListFragment { progressMax = savedInstanceState.getInt(PROGRESS_MAX_KEY); progressValue = savedInstanceState.getInt(PROGRESS_VALUE_KEY); } - dataList = app.getSettingsHelper().getAdditionalData(globalExport); + dataList = app.getSettingsHelper().getSettingsByCategory(globalExport); requireActivity().getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) { @Override @@ -139,7 +136,7 @@ public class ExportSettingsFragment extends BaseSettingsListFragment { showExportProgressDialog(); File tempDir = FileUtils.getTempDir(app); String fileName = getFileName(); - List items = app.getSettingsHelper().prepareAdditionalSettingsItems(adapter.getData()); + List items = app.getSettingsHelper().prepareSettingsItems(adapter.getData()); progress.setMax(getMaxProgress(items)); app.getSettingsHelper().exportSettings(tempDir, fileName, getSettingsExportListener(), items, true); }