Merge pull request #10397 from osmandapp/Import/Export

Import/export
This commit is contained in:
Vitaliy 2020-12-14 10:26:40 +02:00 committed by GitHub
commit 1b64fd3ab6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 10 deletions

View file

@ -6,11 +6,12 @@
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingStart="@dimen/content_padding">
android:paddingStart="@dimen/content_padding"
android:paddingTop="@dimen/context_menu_padding_margin_medium"
android:paddingBottom="@dimen/context_menu_padding_margin_medium">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/icon"

View file

@ -13,8 +13,10 @@ import net.osmand.FileUtils;
import net.osmand.IndexConstants;
import net.osmand.plus.AppInitializer;
import net.osmand.plus.CustomOsmandPlugin;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
import net.osmand.plus.base.BaseLoadAsyncTask;
import net.osmand.plus.settings.backend.ExportSettingsType;
import net.osmand.plus.settings.backend.backup.PluginSettingsItem;
@ -138,6 +140,10 @@ class SettingsImportTask extends BaseLoadAsyncTask<Void, Void, String> {
app.getPoiFilters().loadSelectedPoiFilters();
AppInitializer.loadRoutingFiles(app, null);
FragmentActivity activity = activityRef.get();
AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
if (plugin != null) {
plugin.indexingFiles(null, true, true);
}
if (activity instanceof MapActivity) {
((MapActivity) activity).getMapLayers().getMapWidgetRegistry().updateVisibleWidgets();
((MapActivity) activity).updateApplicationModeSettings();
@ -151,6 +157,7 @@ class SettingsImportTask extends BaseLoadAsyncTask<Void, Void, String> {
};
}
private void handlePluginImport(final PluginSettingsItem pluginItem, final File file) {
FragmentActivity activity = activityRef.get();
final ProgressDialog progress;
@ -172,6 +179,10 @@ class SettingsImportTask extends BaseLoadAsyncTask<Void, Void, String> {
if (progress != null && AndroidUtils.isActivityNotDestroyed(activity)) {
progress.dismiss();
}
AudioVideoNotesPlugin pluginAudioVideo = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
if (pluginAudioVideo != null) {
pluginAudioVideo.indexingFiles(null, true, true);
}
CustomOsmandPlugin plugin = pluginItem.getPlugin();
plugin.loadResources();

View file

@ -12,10 +12,10 @@ public enum ExportSettingsType {
POI_TYPES(R.string.poi_dialog_poi_type, R.drawable.ic_action_info_dark),
AVOID_ROADS(R.string.avoid_road, R.drawable.ic_action_alert),
FAVORITES(R.string.shared_string_favorites, R.drawable.ic_action_favorite),
TRACKS(R.string.shared_string_tracks, R.drawable.ic_action_route_distance),
TRACKS(R.string.shared_string_tracks, R.drawable.ic_action_polygom_dark),
OSM_NOTES(R.string.osm_notes, R.drawable.ic_action_openstreetmap_logo),
OSM_EDITS(R.string.osm_edits, R.drawable.ic_action_openstreetmap_logo),
MULTIMEDIA_NOTES(R.string.audionotes_plugin_name, R.drawable.ic_grouped_by_type),
MULTIMEDIA_NOTES(R.string.notes, R.drawable.ic_grouped_by_type),
ACTIVE_MARKERS(R.string.map_markers, R.drawable.ic_action_flag),
HISTORY_MARKERS(R.string.markers_history, R.drawable.ic_action_flag),
SEARCH_HISTORY(R.string.shared_string_search_history, R.drawable.ic_action_history),

View file

@ -126,7 +126,7 @@ public abstract class BaseSettingsListFragment extends BaseOsmAndFragment implem
}
});
adapter = new ExportSettingsAdapter(app, this, nightMode);
adapter = new ExportSettingsAdapter(app, exportMode, this, nightMode);
adapter.updateSettingsItems(dataList, selectedItemsMap);
expandableList.setAdapter(adapter);
updateAvailableSpace();

View file

@ -43,6 +43,7 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
private final OsmandApplication app;
private final UiUtilities uiUtilities;
private final boolean exportMode;
private List<ExportSettingsCategory> itemsTypes;
private Map<ExportSettingsType, List<?>> selectedItemsMap;
@ -59,8 +60,9 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
private final int childViewHeight;
private final int listBottomPadding;
ExportSettingsAdapter(OsmandApplication app, OnItemSelectedListener listener, boolean nightMode) {
ExportSettingsAdapter(OsmandApplication app, boolean exportMode, OnItemSelectedListener listener, boolean nightMode) {
this.app = app;
this.exportMode = exportMode;
this.listener = listener;
this.nightMode = nightMode;
uiUtilities = app.getUIUtilities();
@ -279,7 +281,7 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
}
}
String description;
if (selectedTypes == 0) {
if (selectedTypes == 0 && exportMode) {
description = app.getString(R.string.shared_string_none);
} else if (selectedTypes == items.getTypes().size()) {
description = app.getString(R.string.shared_string_all);

View file

@ -24,10 +24,12 @@ import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.plus.AppInitializer;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.SQLiteTileSource;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
import net.osmand.plus.download.ReloadIndexesTask;
import net.osmand.plus.download.ReloadIndexesTask.ReloadIndexesListener;
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
@ -189,6 +191,10 @@ public class ImportSettingsFragment extends BaseSettingsListFragment {
app.getRendererRegistry().updateExternalRenderers();
AppInitializer.loadRoutingFiles(app, null);
reloadIndexes(items);
AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
if (plugin != null) {
plugin.indexingFiles(null, true, true);
}
FragmentManager fm = getFragmentManager();
if (fm != null && file != null) {
ImportCompleteFragment.showInstance(fm, items, file.getName());

View file

@ -87,7 +87,7 @@ public class ImportedSettingsItemsAdapter extends
holder.title.setText(R.string.configure_screen_quick_action);
break;
case POI_TYPES:
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_search_dark, activeColorRes));
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_info_dark, activeColorRes));
holder.title.setText(R.string.search_activity);
break;
case MAP_SOURCES:
@ -108,7 +108,7 @@ public class ImportedSettingsItemsAdapter extends
break;
case MULTIMEDIA_NOTES:
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_photo_dark, activeColorRes));
holder.title.setText(R.string.audionotes_plugin_name);
holder.title.setText(R.string.notes);
break;
case TRACKS:
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_route_distance, activeColorRes));
@ -119,7 +119,7 @@ public class ImportedSettingsItemsAdapter extends
holder.title.setText(R.string.osm_notes);
break;
case OSM_EDITS:
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_info_dark, activeColorRes));
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_openstreetmap_logo, activeColorRes));
holder.title.setText(R.string.osm_edits);
break;
case FAVORITES: