diff --git a/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java b/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java index ca626b0563..fde2f7f9b0 100644 --- a/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java +++ b/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java @@ -107,9 +107,9 @@ public class SQLiteTileSource implements ITileSource { this.inversiveZoom = inversiveZoom; } - public SQLiteTileSource(SQLiteTileSource tileSource, int suffixNum, OsmandApplication ctx) { + public SQLiteTileSource(SQLiteTileSource tileSource, String name, OsmandApplication ctx) { this.ctx = ctx; - this.name = tileSource.getName() + "_" + suffixNum; + this.name = name; this.urlTemplate = tileSource.getUrlTemplate(); this.maxZoom = tileSource.getMaximumZoomSupported(); this.minZoom = tileSource.getMinimumZoomSupported(); diff --git a/OsmAnd/src/net/osmand/plus/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/SettingsHelper.java index 8a1668d364..ab8c98c0c7 100644 --- a/OsmAnd/src/net/osmand/plus/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/SettingsHelper.java @@ -260,10 +260,10 @@ public class SettingsHelper { @NonNull public abstract List excludeDuplicateItems(); - public abstract boolean isDuplicate(T item); + public abstract boolean isDuplicate(@NonNull T item); @NonNull - public abstract T renameItem(T item); + public abstract T renameItem(@NonNull T item); } public abstract static class SettingsItemReader { @@ -854,13 +854,13 @@ public class SettingsHelper { } @Override - public boolean isDuplicate(QuickAction item) { + public boolean isDuplicate(@NonNull QuickAction item) { return !actionRegistry.isNameUnique(item, app); } @NonNull @Override - public QuickAction renameItem(QuickAction item) { + public QuickAction renameItem(@NonNull QuickAction item) { return actionRegistry.generateUniqueName(item, app); } @@ -898,7 +898,7 @@ public class SettingsHelper { newActions.addAll(duplicateItems); } newActions.addAll(items); - app.getQuickActionRegistry().updateQuickActions(newActions); + actionRegistry.updateQuickActions(newActions); } } @@ -1044,7 +1044,7 @@ public class SettingsHelper { } @Override - public boolean isDuplicate(PoiUIFilter item) { + public boolean isDuplicate(@NonNull PoiUIFilter item) { String savedName = item.getName(); for (PoiUIFilter filter : existingItems) { if (filter.getName().equals(savedName)) { @@ -1072,11 +1072,13 @@ public class SettingsHelper { @NonNull @Override - public PoiUIFilter renameItem(PoiUIFilter item) { + public PoiUIFilter renameItem(@NonNull PoiUIFilter item) { int number = 0; while (true) { number++; - PoiUIFilter renamedItem = new PoiUIFilter(item, number, app); + PoiUIFilter renamedItem = new PoiUIFilter(item, + item.getName() + "_" + number, + item.getFilterId() + "_" + number); if (!isDuplicate(renamedItem)) { return renamedItem; } @@ -1269,13 +1271,16 @@ public class SettingsHelper { @NonNull @Override - public ITileSource renameItem(ITileSource item) { + public ITileSource renameItem(@NonNull ITileSource item) { int number = 0; while (true) { number++; if (item instanceof SQLiteTileSource) { SQLiteTileSource oldItem = (SQLiteTileSource) item; - SQLiteTileSource renamedItem = new SQLiteTileSource(oldItem, number, app); + SQLiteTileSource renamedItem = new SQLiteTileSource( + oldItem, + oldItem.getName() + "_" + number, + app); if (!isDuplicate(renamedItem)) { return renamedItem; } @@ -1290,7 +1295,7 @@ public class SettingsHelper { } @Override - public boolean isDuplicate(ITileSource item) { + public boolean isDuplicate(@NonNull ITileSource item) { for (String name : existingItemsNames) { if (name.equals(item.getName())) { return true; diff --git a/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java b/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java index 30d643b57c..ac604910a5 100644 --- a/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java +++ b/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java @@ -125,14 +125,16 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable name = app.getPoiFilters().getFiltersName(filtersToMerge); } - public PoiUIFilter(PoiUIFilter filter, int suffixNum, OsmandApplication app) { - this.app = app; - name = filter.getName() + "_" + suffixNum; - filterId = filter.getFilterId() + "_" + suffixNum; + public PoiUIFilter(PoiUIFilter filter, String name, String filterId) { + this.app = filter.app; + this.name = name; + this.filterId = filterId; isStandardFilter = false; - poiTypes = app.getPoiTypes(); + poiTypes = filter.poiTypes; acceptedTypes = filter.getAcceptedTypes(); poiAdditionals = filter.getPoiAdditionals(); + filterByName = filter.filterByName; + savedFilterByName = filter.savedFilterByName; } public boolean isDeleted() {