Fix import duplicates

This commit is contained in:
Dima-1 2020-11-03 17:29:56 +02:00
parent f3900ffd4a
commit 7d9dbb09ff
13 changed files with 149 additions and 113 deletions

View file

@ -214,7 +214,7 @@ public class LocalIndexHelper {
return result;
}
public void loadVoiceData(File voiceDir, List<LocalIndexInfo> result, boolean backup, AbstractLoadLocalIndexTask loadTask) {
private void loadVoiceData(File voiceDir, List<LocalIndexInfo> result, boolean backup, AbstractLoadLocalIndexTask loadTask) {
if (voiceDir.canRead()) {
//First list TTS files, they are preferred
for (File voiceF : listFilesSorted(voiceDir)) {

View file

@ -64,7 +64,7 @@ public class DataSettingsItem extends StreamSettingsItem {
SettingsItemReader<? extends SettingsItem> getReader() {
return new StreamSettingsItemReader(this) {
@Override
public void readFromStream(@NonNull InputStream inputStream, File destination) throws IOException, IllegalArgumentException {
public void readFromStream(@NonNull InputStream inputStream, String entryName) throws IOException, IllegalArgumentException {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int nRead;
byte[] data = new byte[SettingsHelper.BUFFER];

View file

@ -16,7 +16,6 @@ import net.osmand.plus.R;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -146,7 +145,7 @@ public class FavoritesSettingsItem extends CollectionSettingsItem<FavoriteGroup>
return new SettingsItemReader<FavoritesSettingsItem>(this) {
@Override
public void readFromStream(@NonNull InputStream inputStream, File destination) throws IllegalArgumentException {
public void readFromStream(@NonNull InputStream inputStream, String entryName) throws IllegalArgumentException {
GPXFile gpxFile = GPXUtilities.loadGPXFile(inputStream);
if (gpxFile.error != null) {
warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType())));

View file

@ -1,5 +1,6 @@
package net.osmand.plus.settings.backend.backup;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -23,36 +24,34 @@ import java.util.zip.ZipOutputStream;
public class FileSettingsItem extends StreamSettingsItem {
public enum FileSubtype {
UNKNOWN("", null),
OTHER("other", ""),
ROUTING_CONFIG("routing_config", IndexConstants.ROUTING_PROFILES_DIR),
RENDERING_STYLE("rendering_style", IndexConstants.RENDERERS_DIR),
WIKI_MAP("wiki_map", IndexConstants.WIKI_INDEX_DIR),
SRTM_MAP("srtm_map", IndexConstants.SRTM_INDEX_DIR),
OBF_MAP("obf_map", IndexConstants.MAPS_PATH),
TILES_MAP("tiles_map", IndexConstants.TILES_INDEX_DIR),
GPX("gpx", IndexConstants.GPX_INDEX_DIR),
TTS_VOICE("tts_voice", IndexConstants.VOICE_INDEX_DIR),
VOICE("voice", IndexConstants.VOICE_INDEX_DIR),
TRAVEL("travel", IndexConstants.WIKIVOYAGE_INDEX_DIR),
MULTIMEDIA_NOTES("multimedia_notes", IndexConstants.AV_INDEX_DIR);
UNKNOWN("", null, -1),
OTHER("other", "", -1),
ROUTING_CONFIG("routing_config", IndexConstants.ROUTING_PROFILES_DIR, R.drawable.ic_action_route_distance),
RENDERING_STYLE("rendering_style", IndexConstants.RENDERERS_DIR, R.drawable.ic_action_map_style),
WIKI_MAP("wiki_map", IndexConstants.WIKI_INDEX_DIR, R.drawable.ic_plugin_wikipedia),
SRTM_MAP("srtm_map", IndexConstants.SRTM_INDEX_DIR, R.drawable.ic_plugin_srtm),
OBF_MAP("obf_map", IndexConstants.MAPS_PATH, R.drawable.ic_map),
TILES_MAP("tiles_map", IndexConstants.TILES_INDEX_DIR, R.drawable.ic_map),
GPX("gpx", IndexConstants.GPX_INDEX_DIR, R.drawable.ic_action_route_distance),
TTS_VOICE("tts_voice", IndexConstants.VOICE_INDEX_DIR, R.drawable.ic_action_volume_up),
VOICE("voice", IndexConstants.VOICE_INDEX_DIR, R.drawable.ic_action_volume_up),
TRAVEL("travel", IndexConstants.WIKIVOYAGE_INDEX_DIR, R.drawable.ic_plugin_wikipedia),
MULTIMEDIA_NOTES("multimedia_notes", IndexConstants.AV_INDEX_DIR, R.drawable.ic_action_photo_dark);
private String subtypeName;
private String subtypeFolder;
private final String subtypeName;
private final String subtypeFolder;
private final int iconId;
FileSubtype(String subtypeName, String subtypeFolder) {
FileSubtype(@NonNull String subtypeName, String subtypeFolder, @DrawableRes int iconId) {
this.subtypeName = subtypeName;
this.subtypeFolder = subtypeFolder;
this.iconId = iconId;
}
public boolean isMap() {
return this == OBF_MAP || this == WIKI_MAP || this == SRTM_MAP || this == TILES_MAP;
}
public boolean isDirectory() {
return this == TTS_VOICE || this == VOICE;
}
public String getSubtypeName() {
return subtypeName;
}
@ -61,6 +60,10 @@ public class FileSettingsItem extends StreamSettingsItem {
return subtypeFolder;
}
public int getIconId() {
return iconId;
}
public static FileSubtype getSubtypeByName(@NonNull String name) {
for (FileSubtype subtype : FileSubtype.values()) {
if (name.equals(subtype.subtypeName)) {
@ -227,15 +230,30 @@ public class FileSettingsItem extends StreamSettingsItem {
return file.exists();
}
private File renameFile(File file) {
private File renameFile(File oldFile) {
int number = 0;
String path = file.getAbsolutePath();
String oldPath = oldFile.getAbsolutePath();
String suffix;
String prefix;
if (file.isDirectory()) {
prefix = file.getAbsolutePath();
suffix = oldPath.replace(file.getAbsolutePath(), "");
} else if (oldPath.endsWith(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT)) {
prefix = oldPath.substring(0, oldPath.lastIndexOf(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT));
suffix = IndexConstants.BINARY_WIKI_MAP_INDEX_EXT;
} else if (oldPath.endsWith(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT)) {
prefix = oldPath.substring(0, oldPath.lastIndexOf(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT));
suffix = IndexConstants.BINARY_SRTM_MAP_INDEX_EXT;
} else {
prefix = oldPath.substring(0, oldPath.lastIndexOf("."));
suffix = "." + Algorithms.getFileExtension(oldFile);
}
while (true) {
number++;
String copyName = path.replaceAll(file.getName(), file.getName().replaceFirst("[.]", "_" + number + "."));
File copyFile = new File(copyName);
if (!copyFile.exists()) {
return copyFile;
String newName = prefix + "_" + number + suffix;
File newFile = new File(newName);
if (!newFile.exists()) {
return newFile;
}
}
}
@ -245,8 +263,12 @@ public class FileSettingsItem extends StreamSettingsItem {
SettingsItemReader<? extends SettingsItem> getReader() {
return new StreamSettingsItemReader(this) {
@Override
public void readFromStream(@NonNull InputStream inputStream, File dest) throws IOException, IllegalArgumentException {
public void readFromStream(@NonNull InputStream inputStream, String entryName) throws IOException, IllegalArgumentException {
OutputStream output;
File dest = FileSettingsItem.this.getFile();
if (dest.isDirectory()) {
dest = new File(dest, entryName.substring(fileName.length()));
}
if (dest.exists() && !shouldReplace) {
dest = renameFile(dest);
}
@ -271,46 +293,42 @@ public class FileSettingsItem extends StreamSettingsItem {
@Nullable
@Override
public SettingsItemWriter<? extends SettingsItem> getWriter() {
try {
if (!file.isDirectory()) {
if (!file.isDirectory()) {
try {
setInputStream(new FileInputStream(file));
} catch (FileNotFoundException e) {
warnings.add(app.getString(R.string.settings_item_read_error, file.getName()));
SettingsHelper.LOG.error("Failed to set input stream from file: " + file.getName(), e);
}
} catch (FileNotFoundException e) {
warnings.add(app.getString(R.string.settings_item_read_error, file.getName()));
SettingsHelper.LOG.error("Failed to set input stream from file: " + file.getName(), e);
}
return new StreamSettingsItemWriter(this) {
return super.getWriter();
} else {
return new StreamSettingsItemWriter(this) {
@Override
public void writeEntry(String fileName, @NonNull ZipOutputStream zos) throws IOException {
if (getSubtype().isDirectory()) {
File file = getFile();
@Override
public void writeEntry(String fileName, @NonNull ZipOutputStream zos) throws IOException {
zipDirsWithFiles(file, zos);
} else {
super.writeEntry(fileName, zos);
}
}
public void zipDirsWithFiles(File f, ZipOutputStream zos)
throws IOException {
if (f == null) {
return;
}
if (f.isDirectory()) {
File[] fs = f.listFiles();
if (fs != null) {
for (File c : fs) {
zipDirsWithFiles(c, zos);
}
public void zipDirsWithFiles(File file, ZipOutputStream zos) throws IOException {
if (file == null) {
return;
}
if (file.isDirectory()) {
File[] fs = file.listFiles();
if (fs != null) {
for (File c : fs) {
zipDirsWithFiles(c, zos);
}
}
} else {
String zipEntryName = Algorithms.isEmpty(getSubtype().getSubtypeFolder())
? file.getName()
: file.getPath().substring(file.getPath().indexOf(getSubtype().getSubtypeFolder()) - 1);
setInputStream(new FileInputStream(file));
super.writeEntry(zipEntryName, zos);
}
} else {
String zipEntryName = Algorithms.isEmpty(getSubtype().getSubtypeFolder())
? f.getName()
: f.getPath().substring(f.getPath().indexOf(getSubtype().getSubtypeFolder()) - 1);
setInputStream(new FileInputStream(f));
super.writeEntry(zipEntryName, zos);
}
}
};
};
}
}
}

View file

@ -10,7 +10,6 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@ -30,7 +29,7 @@ public abstract class OsmandSettingsItemReader<T extends OsmandSettingsItem> ext
@NonNull JSONObject json) throws JSONException;
@Override
public void readFromStream(@NonNull InputStream inputStream, File destination) throws IOException, IllegalArgumentException {
public void readFromStream(@NonNull InputStream inputStream, String entryName) throws IOException, IllegalArgumentException {
StringBuilder buf = new StringBuilder();
try {
BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));

View file

@ -72,7 +72,6 @@ class SettingsExporter {
}
}
private JSONObject createItemsJson() throws JSONException {
JSONObject json = new JSONObject();
json.put("version", SettingsHelper.VERSION);

View file

@ -542,9 +542,8 @@ public class SettingsHelper {
if (!favoriteGroups.isEmpty()) {
dataList.put(ExportSettingsType.FAVORITES, favoriteGroups);
}
List<LocalIndexInfo> localIndexInfoList = getVoiceIndexInfo();
List<File> files;
files = getFilesByType(localIndexInfoList, LocalIndexType.MAP_DATA, LocalIndexType.TILES_DATA,
List<LocalIndexInfo> localIndexInfoList = getLocalIndexData();
List<File> files = getFilesByType(localIndexInfoList, LocalIndexType.MAP_DATA, LocalIndexType.TILES_DATA,
LocalIndexType.SRTM_DATA, LocalIndexType.WIKI_DATA);
if (!files.isEmpty()) {
sortData(files);
@ -561,7 +560,7 @@ public class SettingsHelper {
return dataList;
}
private List<LocalIndexInfo> getVoiceIndexInfo() {
private List<LocalIndexInfo> getLocalIndexData() {
return new LocalIndexHelper(app).getLocalIndexData(new AbstractLoadLocalIndexTask() {
@Override
public void loadFile(LocalIndexInfo... loaded) {

View file

@ -124,7 +124,7 @@ class SettingsImporter {
try {
SettingsItemReader<? extends SettingsItem> reader = item.getReader();
if (reader != null) {
reader.readFromStream(ois, app.getAppPath(fileName));
reader.readFromStream(ois, fileName);
}
} catch (IllegalArgumentException e) {
item.warnings.add(app.getString(R.string.settings_item_read_error, item.getName()));

View file

@ -169,7 +169,7 @@ public abstract class SettingsItem {
SettingsItemReader<? extends SettingsItem> getJsonReader() {
return new SettingsItemReader<SettingsItem>(this) {
@Override
public void readFromStream(@NonNull InputStream inputStream, File destination) throws IOException, IllegalArgumentException {
public void readFromStream(@NonNull InputStream inputStream, String entryName) throws IOException, IllegalArgumentException {
StringBuilder buf = new StringBuilder();
try {
BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));

View file

@ -2,7 +2,6 @@ package net.osmand.plus.settings.backend.backup;
import androidx.annotation.NonNull;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@ -14,5 +13,5 @@ public abstract class SettingsItemReader<T extends SettingsItem> {
this.item = item;
}
public abstract void readFromStream(@NonNull InputStream inputStream, File destination) throws IOException, IllegalArgumentException;
public abstract void readFromStream(@NonNull InputStream inputStream, String entryName) throws IOException, IllegalArgumentException;
}

View file

@ -15,6 +15,7 @@ import net.osmand.PlatformUtil;
import net.osmand.map.ITileSource;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
@ -34,6 +35,8 @@ import org.apache.commons.logging.Log;
import java.io.File;
import java.util.List;
import static net.osmand.plus.settings.backend.backup.FileSettingsItem.*;
public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final Log LOG = PlatformUtil.getLog(DuplicatesSettingsAdapter.class.getName());
@ -75,12 +78,11 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView
if (holder instanceof HeaderViewHolder) {
HeaderViewHolder headerHolder = (HeaderViewHolder) holder;
headerHolder.title.setText((String) currentItem);
headerHolder.subTitle.setText(String.format(
app.getString(R.string.listed_exist),
(String) currentItem));
headerHolder.subTitle.setText(String.format(app.getString(R.string.listed_exist), currentItem));
headerHolder.divider.setVisibility(View.VISIBLE);
} else if (holder instanceof ItemViewHolder) {
ItemViewHolder itemHolder = (ItemViewHolder) holder;
itemHolder.subTitle.setVisibility(View.GONE);
if (currentItem instanceof ApplicationModeBean) {
ApplicationModeBean modeBean = (ApplicationModeBean) currentItem;
String profileName = modeBean.userProfileName;
@ -116,25 +118,23 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView
QuickAction action = (QuickAction) currentItem;
itemHolder.title.setText(action.getName(app));
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(action.getIconRes(), activeColorRes));
itemHolder.subTitle.setVisibility(View.GONE);
} else if (currentItem instanceof PoiUIFilter) {
PoiUIFilter filter = (PoiUIFilter) currentItem;
itemHolder.title.setText(filter.getName());
int iconRes = RenderingIcons.getBigIconResourceId(filter.getIconId());
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(iconRes != 0 ? iconRes : R.drawable.ic_action_user, activeColorRes));
itemHolder.subTitle.setVisibility(View.GONE);
} else if (currentItem instanceof ITileSource) {
itemHolder.title.setText(((ITileSource) currentItem).getName());
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_map, activeColorRes));
itemHolder.subTitle.setVisibility(View.GONE);
} else if (currentItem instanceof File) {
File file = (File) currentItem;
FileSubtype fileSubtype = FileSubtype.getSubtypeByPath(app, file.getPath());
itemHolder.title.setText(file.getName());
if (file.getAbsolutePath().contains(IndexConstants.RENDERERS_DIR)) {
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_map_style, activeColorRes));
} else if (file.getAbsolutePath().contains(IndexConstants.ROUTING_PROFILES_DIR)) {
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_route_distance, activeColorRes));
} else if (file.getAbsolutePath().contains(IndexConstants.GPX_INDEX_DIR)) {
} else if (file.getAbsolutePath().contains(IndexConstants.GPX_INDEX_DIR)) {
itemHolder.title.setText(GpxUiHelper.getGpxTitle(file.getName()));
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_route_distance, activeColorRes));
} else if (file.getAbsolutePath().contains(IndexConstants.AV_INDEX_DIR)) {
@ -143,16 +143,18 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView
iconId = R.drawable.ic_action_photo_dark;
}
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(iconId, activeColorRes));
} else if (fileSubtype.isMap()
|| fileSubtype == FileSubtype.TTS_VOICE
|| fileSubtype == FileSubtype.VOICE) {
itemHolder.title.setText(FileNameTranslationHelper.getFileNameWithRegion(app, file.getName()));
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(fileSubtype.getIconId(), activeColorRes));
}
itemHolder.subTitle.setVisibility(View.GONE);
} else if (currentItem instanceof AvoidRoadInfo) {
itemHolder.title.setText(((AvoidRoadInfo) currentItem).name);
itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_alert, activeColorRes));
itemHolder.subTitle.setVisibility(View.GONE);
} else if (currentItem instanceof FavoriteGroup) {
itemHolder.title.setText(((FavoriteGroup) currentItem).getDisplayName(app));
itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_favorite, activeColorRes));
itemHolder.subTitle.setVisibility(View.GONE);
}
itemHolder.divider.setVisibility(shouldShowDivider(position) ? View.VISIBLE : View.GONE);
}
@ -172,7 +174,7 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView
}
}
private class HeaderViewHolder extends RecyclerView.ViewHolder {
private static class HeaderViewHolder extends RecyclerView.ViewHolder {
TextView title;
TextView subTitle;
View divider;
@ -185,7 +187,7 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView
}
}
private class ItemViewHolder extends RecyclerView.ViewHolder {
private static class ItemViewHolder extends RecyclerView.ViewHolder {
TextView title;
TextView subTitle;
ImageView icon;

View file

@ -285,21 +285,9 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
file = (File) currentItem;
size = file.length();
}
title.setText(FileNameTranslationHelper.getFileName(app,
app.getResourceManager().getOsmandRegions(),
file.getName()));
title.setText(FileNameTranslationHelper.getFileNameWithRegion(app, file.getName()));
FileSubtype subtype = FileSubtype.getSubtypeByPath(app, file.getPath());
switch (subtype) {
case SRTM_MAP:
iconId = R.drawable.ic_plugin_srtm;
break;
case WIKI_MAP:
iconId = R.drawable.ic_plugin_wikipedia;
break;
default:
iconId = R.drawable.ic_map;
}
setupIcon(icon, iconId, itemSelected);
setupIcon(icon, subtype.getIconId(), itemSelected);
subText.setText(AndroidUtils.formatSize(app, size));
subText.setVisibility(View.VISIBLE);
break;
@ -311,9 +299,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
case TTS_VOICE:
case VOICE:
file = (File) currentItem;
title.setText(FileNameTranslationHelper.getFileName(app,
app.getResourceManager().getOsmandRegions(),
file.getName()));
title.setText(FileNameTranslationHelper.getFileNameWithRegion(app, file.getName()));
setupIcon(icon, R.drawable.ic_action_volume_up, itemSelected);
break;
default:

View file

@ -32,6 +32,8 @@ import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
import net.osmand.plus.osmedit.OpenstreetmapPoint;
import net.osmand.plus.osmedit.OsmNotesPoint;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.settings.backend.ApplicationMode;
@ -46,10 +48,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
import static net.osmand.IndexConstants.AV_INDEX_DIR;
import static net.osmand.IndexConstants.GPX_INDEX_DIR;
import static net.osmand.IndexConstants.RENDERERS_DIR;
import static net.osmand.IndexConstants.ROUTING_PROFILES_DIR;
import static net.osmand.plus.settings.backend.backup.FileSettingsItem.*;
import static net.osmand.plus.settings.fragments.ImportSettingsFragment.IMPORT_SETTINGS_TAG;
@ -196,6 +195,11 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment {
List<File> trackFilesList = new ArrayList<>();
List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
List<FavoriteGroup> favoriteGroups = new ArrayList<>();
List<OsmNotesPoint> osmNotesPointList = new ArrayList<>();
List<OpenstreetmapPoint> osmEditsPointList = new ArrayList<>();
List<File> ttsVoiceFilesList = new ArrayList<>();
List<File> voiceFilesList = new ArrayList<>();
List<File> mapFilesList = new ArrayList<>();
for (Object object : duplicatesList) {
if (object instanceof ApplicationMode.ApplicationModeBean) {
@ -208,19 +212,30 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment {
tileSources.add((ITileSource) object);
} else if (object instanceof File) {
File file = (File) object;
if (file.getAbsolutePath().contains(RENDERERS_DIR)) {
FileSubtype fileSubtype = FileSubtype.getSubtypeByPath(app, file.getPath());
if (fileSubtype == FileSubtype.RENDERING_STYLE) {
renderFilesList.add(file);
} else if (file.getAbsolutePath().contains(ROUTING_PROFILES_DIR)) {
} else if (fileSubtype == FileSubtype.ROUTING_CONFIG) {
routingFilesList.add(file);
} else if (file.getAbsolutePath().contains(AV_INDEX_DIR)) {
} else if (fileSubtype == FileSubtype.MULTIMEDIA_NOTES) {
multimediaFilesList.add(file);
} else if (file.getAbsolutePath().contains(GPX_INDEX_DIR)) {
} else if (fileSubtype == FileSubtype.GPX) {
trackFilesList.add(file);
} else if (fileSubtype.isMap()) {
mapFilesList.add(file);
} else if (fileSubtype == FileSubtype.TTS_VOICE) {
ttsVoiceFilesList.add(file);
} else if (fileSubtype == FileSubtype.VOICE) {
voiceFilesList.add(file);
}
} else if (object instanceof AvoidRoadInfo) {
avoidRoads.add((AvoidRoadInfo) object);
} else if (object instanceof FavoriteGroup) {
favoriteGroups.add((FavoriteGroup) object);
} else if (object instanceof OsmNotesPoint) {
osmNotesPointList.add((OsmNotesPoint) object);
} else if (object instanceof OpenstreetmapPoint) {
osmEditsPointList.add((OpenstreetmapPoint) object);
}
}
if (!profiles.isEmpty()) {
@ -263,6 +278,26 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment {
duplicates.add(getString(R.string.shared_string_favorites));
duplicates.addAll(favoriteGroups);
}
if (!osmNotesPointList.isEmpty()) {
duplicates.add(getString(R.string.osm_notes));
duplicates.addAll(osmNotesPointList);
}
if (!osmEditsPointList.isEmpty()) {
duplicates.add(getString(R.string.osm_edits));
duplicates.addAll(osmEditsPointList);
}
if (!mapFilesList.isEmpty()) {
duplicates.add(getString(R.string.shared_string_maps));
duplicates.addAll(mapFilesList);
}
if (!ttsVoiceFilesList.isEmpty()) {
duplicates.add(getString(R.string.local_indexes_cat_tts));
duplicates.addAll(ttsVoiceFilesList);
}
if (!voiceFilesList.isEmpty()) {
duplicates.add(getString(R.string.local_indexes_cat_voice));
duplicates.addAll(voiceFilesList);
}
return duplicates;
}