diff --git a/OsmAnd/res/layout/settings_group_title.xml b/OsmAnd/res/layout/settings_group_title.xml index 4ac7fbfe05..6c2c220b4e 100644 --- a/OsmAnd/res/layout/settings_group_title.xml +++ b/OsmAnd/res/layout/settings_group_title.xml @@ -31,7 +31,7 @@ tools:text="Some title" /> + + getSelection() { return Collections.singletonList(previewItem); } + @Override + protected boolean shouldShowDivider() { + return false; + } + public static SelectModeBottomSheet showInstance(@NonNull AppCompatActivity activity, @NonNull SelectableItem previewItem, @NonNull List radioItems, diff --git a/OsmAnd/src/net/osmand/plus/base/SelectMultipleItemsBottomSheet.java b/OsmAnd/src/net/osmand/plus/base/SelectMultipleItemsBottomSheet.java index ab8ae1f3e9..d9a6204e2c 100644 --- a/OsmAnd/src/net/osmand/plus/base/SelectMultipleItemsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/base/SelectMultipleItemsBottomSheet.java @@ -122,11 +122,8 @@ public class SelectMultipleItemsBottomSheet extends SelectionBottomSheet { } private void updateApplyButtonEnable() { - if (Algorithms.isEmpty(selectedItems)) { - rightButton.setEnabled(false); - } else { - rightButton.setEnabled(true); - } + boolean noEmptySelection = !Algorithms.isEmpty(selectedItems); + rightButton.setEnabled(noEmptySelection); } private void updateItems(boolean checked) { diff --git a/OsmAnd/src/net/osmand/plus/base/SelectMultipleWithModeBottomSheet.java b/OsmAnd/src/net/osmand/plus/base/SelectMultipleWithModeBottomSheet.java index 2c0680d690..4318d9c3c7 100644 --- a/OsmAnd/src/net/osmand/plus/base/SelectMultipleWithModeBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/base/SelectMultipleWithModeBottomSheet.java @@ -24,7 +24,7 @@ public class SelectMultipleWithModeBottomSheet extends SelectMultipleItemsBottom radioGroup.setItems(modes); AndroidUiHelper.setVisibility(View.VISIBLE, secondaryDescription, toggleContainer, - checkBox, checkBoxTitle, primaryDescription, selectedSize, selectAllButton); + checkBox, checkBoxTitle, titleDescription, selectedSize, selectAllButton); } private void setModes(@NonNull List modes) { diff --git a/OsmAnd/src/net/osmand/plus/base/SelectionBottomSheet.java b/OsmAnd/src/net/osmand/plus/base/SelectionBottomSheet.java index 978f649083..6f788a9be2 100644 --- a/OsmAnd/src/net/osmand/plus/base/SelectionBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/base/SelectionBottomSheet.java @@ -27,6 +27,7 @@ public abstract class SelectionBottomSheet extends MenuBottomSheetDialogFragment protected UiUtilities uiUtilities; protected TextView title; + protected TextView titleDescription; protected TextView primaryDescription; protected TextView secondaryDescription; protected TextView selectedSize; @@ -35,7 +36,7 @@ public abstract class SelectionBottomSheet extends MenuBottomSheetDialogFragment protected View selectAllButton; protected TextView checkBoxTitle; protected ThreeStateCheckbox checkBox; - protected LinearLayout selectionListView; + protected LinearLayout listContainer; protected TextView applyButtonTitle; protected int activeColorRes; @@ -60,7 +61,9 @@ public abstract class SelectionBottomSheet extends MenuBottomSheetDialogFragment secondaryColorRes = nightMode ? R.color.icon_color_secondary_dark : R.color.icon_color_secondary_light; items.add(createHeaderUi()); - items.add(new SimpleDividerItem(app)); + if (shouldShowDivider()) { + items.add(new SimpleDividerItem(app)); + } createSelectionUi(); } @@ -77,8 +80,9 @@ public abstract class SelectionBottomSheet extends MenuBottomSheetDialogFragment View view = themedInflater.inflate(R.layout.settings_group_title, null); title = view.findViewById(R.id.title); - primaryDescription = view.findViewById(R.id.description); - secondaryDescription = view.findViewById(R.id.additional_description); + titleDescription = view.findViewById(R.id.title_description); + primaryDescription = view.findViewById(R.id.primary_description); + secondaryDescription = view.findViewById(R.id.secondary_description); selectedSize = view.findViewById(R.id.selected_size); toggleContainer = view.findViewById(R.id.custom_radio_buttons); radioGroup = new MultiStateToggleButton(app, toggleContainer, nightMode); @@ -94,6 +98,10 @@ public abstract class SelectionBottomSheet extends MenuBottomSheetDialogFragment protected abstract void initHeaderUi(); + protected boolean shouldShowDivider() { + return true; + } + @Override protected void setupRightButton() { super.setupRightButton(); @@ -104,12 +112,16 @@ public abstract class SelectionBottomSheet extends MenuBottomSheetDialogFragment this.title.setText(title); } - public void setDescription(@NonNull String description) { - this.primaryDescription.setText(description); + public void setTitleDescription(@NonNull String description) { + titleDescription.setText(description); + } + + public void setPrimaryDescription(@NonNull String description) { + primaryDescription.setText(description); } public void setSecondaryDescription(@NonNull String description) { - this.secondaryDescription.setText(description); + secondaryDescription.setText(description); } public void setApplyButtonTitle(@NonNull String title) { diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java index 8024709969..e00e59fc53 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java @@ -210,6 +210,10 @@ public class DownloadActivityType { return this == VOICE_FILE && indexItem.fileName.endsWith(IndexConstants.VOICE_INDEX_EXT_ZIP); } + public boolean mayProvideSeveralIndexes() { + return this == SRTM_COUNTRY_FILE; + } + public String getUnzipExtension(OsmandApplication ctx, IndexItem indexItem) { if (NORMAL_FILE == this) { if (indexItem.fileName.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT_ZIP)) { diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadResources.java b/OsmAnd/src/net/osmand/plus/download/DownloadResources.java index cc8647804b..6b13be8d29 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadResources.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadResources.java @@ -487,20 +487,14 @@ public class DownloadResources extends DownloadResourceGroup { List indexesList = group.getIndividualResources(); List individualDownloadItems = group.getIndividualDownloadItems(); if (doesListContainIndexWithType(indexesList, srtmType)) { - IndexItem meters = null; - IndexItem feet = null; + List srtmIndexes = new ArrayList<>(); for (IndexItem item : indexesList) { if (item.getType() == srtmType) { - if (SrtmDownloadItem.isMetersItem(item)) { - meters = item; - } else { - feet = item; - } + srtmIndexes.add(item); } } - individualDownloadItems.remove(meters); - individualDownloadItems.remove(feet); - group.addItem(new SrtmDownloadItem(meters, feet, useMetersByDefault)); + individualDownloadItems.removeAll(srtmIndexes); + group.addItem(new SrtmDownloadItem(srtmIndexes, useMetersByDefault)); listModified = true; } if (listModified) { @@ -563,6 +557,7 @@ public class DownloadResources extends DownloadResourceGroup { if (index.getType() == type) { found = true; collectedIndexes.add(index); + if (!type.mayProvideSeveralIndexes()) break; } } } diff --git a/OsmAnd/src/net/osmand/plus/download/SelectIndexesUiHelper.java b/OsmAnd/src/net/osmand/plus/download/SelectIndexesUiHelper.java index 357eb4f377..23e1462576 100644 --- a/OsmAnd/src/net/osmand/plus/download/SelectIndexesUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/download/SelectIndexesUiHelper.java @@ -1,6 +1,5 @@ package net.osmand.plus.download; -import android.content.Context; import android.view.View; import androidx.annotation.NonNull; @@ -23,7 +22,6 @@ import net.osmand.util.Algorithms; import java.text.DateFormat; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import static net.osmand.plus.download.DownloadActivityType.SRTM_COUNTRY_FILE; @@ -36,14 +34,14 @@ public class SelectIndexesUiHelper { private DateFormat dateFormat; private boolean showRemoteDate; private DownloadItem downloadItem; - private SelectItemsToDownloadListener listener; + private ItemsToDownloadSelectedListener listener; private SelectionBottomSheet dialog; private SelectIndexesUiHelper(@NonNull DownloadItem item, @NonNull AppCompatActivity activity, @NonNull DateFormat dateFormat, boolean showRemoteDate, - @NonNull SelectItemsToDownloadListener listener) { + @NonNull ItemsToDownloadSelectedListener listener) { this.activity = activity; this.app = (OsmandApplication) activity.getApplicationContext(); this.downloadItem = item; @@ -56,7 +54,7 @@ public class SelectIndexesUiHelper { @NonNull AppCompatActivity activity, @NonNull DateFormat dateFormat, boolean showRemoteDate, - @NonNull SelectItemsToDownloadListener listener) { + @NonNull ItemsToDownloadSelectedListener listener) { SelectIndexesUiHelper helper = new SelectIndexesUiHelper(item, activity, dateFormat, showRemoteDate, listener); helper.showDialogInternal(); @@ -140,7 +138,7 @@ public class SelectIndexesUiHelper { public void onUiInitialized() { SelectModeBottomSheet dialog = (SelectModeBottomSheet) SelectIndexesUiHelper.this.dialog; dialog.setTitle(app.getString(R.string.srtm_unit_format)); - dialog.setDescription(app.getString(R.string.srtm_download_single_help_message)); + dialog.setPrimaryDescription(app.getString(R.string.srtm_download_single_help_message)); updateSize(dialog, false); dialog.setSelectedMode(initRadio); } @@ -154,7 +152,7 @@ public class SelectIndexesUiHelper { SelectableItem selectableItem = new SelectableItem(); selectableItem.setTitle(indexItem.getVisibleName(app, app.getRegions(), false)); String size = indexItem.getSizeDescription(app); - size += " (" + SrtmDownloadItem.getAbbreviation(app, baseItem) + ")"; + size += " " + SrtmDownloadItem.getAbbreviationInScopes(app, baseItem); String date = indexItem.getDate(dateFormat, showRemoteDate); String description = app.getString(R.string.ltr_or_rtl_combine_via_bold_point, size, date); selectableItem.setDescription(description); @@ -200,7 +198,7 @@ public class SelectIndexesUiHelper { SelectableItem selectableItem = new SelectableItem(); selectableItem.setTitle(indexItem.getVisibleName(app, app.getRegions(), false)); String size = indexItem.getSizeDescription(app); - size += " (" + SrtmDownloadItem.getAbbreviation(app, baseItem) + ")"; + size += " " + SrtmDownloadItem.getAbbreviationInScopes(app, baseItem); String date = indexItem.getDate(dateFormat, showRemoteDate); String description = app.getString(R.string.ltr_or_rtl_combine_via_bold_point, size, date); selectableItem.setDescription(description); @@ -263,7 +261,7 @@ public class SelectIndexesUiHelper { dialog.setOnApplySelectionListener(getOnApplySelectionListener(listener)); } - private OnApplySelectionListener getOnApplySelectionListener(final SelectItemsToDownloadListener listener) { + private OnApplySelectionListener getOnApplySelectionListener(final ItemsToDownloadSelectedListener listener) { return new OnApplySelectionListener() { @Override public void onSelectionApplied(List selectedItems) { @@ -286,7 +284,7 @@ public class SelectIndexesUiHelper { if (updateDescription) { String total = app.getString(R.string.shared_string_total); String description = app.getString(R.string.ltr_or_rtl_combine_via_colon, total, size); - dialog.setDescription(description); + dialog.setTitleDescription(description); } String btnTitle = app.getString(R.string.shared_string_download); if (sizeToDownload > 0) { @@ -330,7 +328,7 @@ public class SelectIndexesUiHelper { return totalSizeMb; } - public interface SelectItemsToDownloadListener { + public interface ItemsToDownloadSelectedListener { void onItemsToDownloadSelected(List items); } diff --git a/OsmAnd/src/net/osmand/plus/download/SrtmDownloadItem.java b/OsmAnd/src/net/osmand/plus/download/SrtmDownloadItem.java index 2f528423d1..d060a196a0 100644 --- a/OsmAnd/src/net/osmand/plus/download/SrtmDownloadItem.java +++ b/OsmAnd/src/net/osmand/plus/download/SrtmDownloadItem.java @@ -3,6 +3,7 @@ package net.osmand.plus.download; import android.content.Context; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import net.osmand.IndexConstants; import net.osmand.plus.OsmandApplication; @@ -21,38 +22,53 @@ import static net.osmand.plus.download.DownloadActivityType.SRTM_COUNTRY_FILE; public class SrtmDownloadItem extends DownloadItem { - private IndexItem meterItem; - private IndexItem feetItem; + private List indexes; + private IndexItem meter; + private IndexItem feet; - private boolean useMetersByDefault; + private boolean shouldUseMeters; - public SrtmDownloadItem(IndexItem meterItem, - IndexItem feetItem, - boolean useMetersByDefault) { + public SrtmDownloadItem(List indexes, + boolean shouldUseMeters) { super(SRTM_COUNTRY_FILE); - this.meterItem = meterItem; - this.feetItem = feetItem; - this.useMetersByDefault = useMetersByDefault; + this.indexes = indexes; + this.shouldUseMeters = shouldUseMeters; } - public boolean isUseMetersByDefault() { - return useMetersByDefault; + public boolean isShouldUseMeters() { + return shouldUseMeters; } - public void setUseMetersByDefault(boolean useMetersByDefault) { - this.useMetersByDefault = useMetersByDefault; + public void setShouldUseMeters(boolean shouldUseMeters) { + this.shouldUseMeters = shouldUseMeters; } public IndexItem getIndexItem() { - return useMetersByDefault ? getMeterItem() : getFeetItem(); + return shouldUseMeters ? getMeterItem() : getFeetItem(); } + @Nullable public IndexItem getMeterItem() { - return meterItem; + if (meter == null && indexes != null) { + for (IndexItem index : indexes) { + if (isMetersItem(index)) { + meter = index; + } + } + } + return meter; } + @Nullable public IndexItem getFeetItem() { - return feetItem; + if (feet == null && indexes != null) { + for (IndexItem index : indexes) { + if (!isMetersItem(index)) { + feet = index; + } + } + } + return feet; } @Override @@ -67,12 +83,12 @@ public class SrtmDownloadItem extends DownloadItem { @Override public boolean isDownloaded() { - return getIndexItem().isDownloaded(); + return meter.isDownloaded() || feet.isDownloaded(); } @Override public boolean isOutdated() { - return getIndexItem().isOutdated(); + return meter.isOutdated() || feet.isOutdated(); } @Override @@ -104,14 +120,14 @@ public class SrtmDownloadItem extends DownloadItem { return app.getSettings().METRIC_SYSTEM.get() != MetricsConstants.MILES_AND_FEET; } - public static String getAbbreviation(Context context, boolean base) { - return context.getString(base ? R.string.m : R.string.foot); + @NonNull + public static String getAbbreviationInScopes(Context ctx, boolean base) { + return "(" + getAbbreviation(ctx, base) + ")"; } - public static String getExtension(IndexItem indexItem) { - return isMetersItem(indexItem) ? - IndexConstants.BINARY_SRTM_MAP_INDEX_EXT : - IndexConstants.BINARY_SRTM_FEET_MAP_INDEX_EXT; + @NonNull + public static String getAbbreviation(Context context, boolean base) { + return context.getString(base ? R.string.m : R.string.foot); } public static boolean isMetersItem(Object item) { @@ -123,6 +139,23 @@ public class SrtmDownloadItem extends DownloadItem { return false; } + public static boolean containsSrtmExtension(@NonNull String fileName) { + return fileName.contains(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT) + || fileName.contains(IndexConstants.BINARY_SRTM_FEET_MAP_INDEX_EXT); + } + + public static boolean isSrtmFile(@NonNull String fileName) { + return fileName.endsWith(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT) + || fileName.endsWith(IndexConstants.BINARY_SRTM_FEET_MAP_INDEX_EXT); + } + + @NonNull + public static String getExtension(IndexItem indexItem) { + return isMetersItem(indexItem) ? + IndexConstants.BINARY_SRTM_MAP_INDEX_EXT : + IndexConstants.BINARY_SRTM_FEET_MAP_INDEX_EXT; + } + public static boolean isSRTMItem(Object item) { if (item instanceof IndexItem) { return ((IndexItem) item).getType() == SRTM_COUNTRY_FILE; diff --git a/OsmAnd/src/net/osmand/plus/download/ui/ActiveDownloadsDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/ActiveDownloadsDialogFragment.java index 1b8667685c..31a0205f0e 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/ActiveDownloadsDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/ActiveDownloadsDialogFragment.java @@ -87,7 +87,7 @@ public class ActiveDownloadsDialogFragment extends DialogFragment implements Dow } ItemViewHolder viewHolder = (ItemViewHolder) convertView.getTag(); IndexItem item = getItem(position); - viewHolder.bindIndexItem(item); + viewHolder.bindDownloadItem(item); return convertView; } diff --git a/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupAdapter.java b/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupAdapter.java index d2e281bbfc..168888434d 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupAdapter.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupAdapter.java @@ -78,7 +78,7 @@ public class DownloadResourceGroupAdapter extends OsmandBaseExpandableListAdapte } else { viewHolder.setShowTypeInDesc(true); } - viewHolder.bindIndexItem(item); + viewHolder.bindDownloadItem(item); } else { DownloadResourceGroup group = (DownloadResourceGroup) child; DownloadGroupViewHolder viewHolder; diff --git a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java index 872234795d..99d1dc1024 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java @@ -42,7 +42,7 @@ import net.osmand.plus.download.DownloadResourceGroup; import net.osmand.plus.download.DownloadResources; import net.osmand.plus.download.IndexItem; import net.osmand.plus.download.SelectIndexesUiHelper; -import net.osmand.plus.download.SelectIndexesUiHelper.SelectItemsToDownloadListener; +import net.osmand.plus.download.SelectIndexesUiHelper.ItemsToDownloadSelectedListener; import net.osmand.plus.download.MultipleIndexItem; import net.osmand.plus.download.SrtmDownloadItem; import net.osmand.plus.download.ui.LocalIndexesFragment.LocalIndexOperationTask; @@ -150,11 +150,11 @@ public class ItemViewHolder { depthContoursPurchased = InAppPurchaseHelper.isDepthContoursPurchased(context.getMyApplication()); } - public void bindIndexItem(final DownloadItem downloadItem) { - bindIndexItem(downloadItem, null); + public void bindDownloadItem(final DownloadItem downloadItem) { + bindDownloadItem(downloadItem, null); } - public void bindIndexItem(final DownloadItem downloadItem, final String cityName) { + public void bindDownloadItem(final DownloadItem downloadItem, final String cityName) { initAppStatusVariables(); boolean isDownloading = downloadItem.isDownloading(context.getDownloadThread()); int progress = -1; @@ -256,7 +256,7 @@ public class ItemViewHolder { } String fullDescription = context.getString(R.string.ltr_or_rtl_combine_via_colon, header, count); if (srtmItem) { - fullDescription += " (" + SrtmDownloadItem.getAbbreviation(context, baseMetricSystem) + ")"; + fullDescription += " " + SrtmDownloadItem.getAbbreviationInScopes(context, baseMetricSystem); } if (item.hasActualDataToDownload()) { fullDescription = context.getString( @@ -269,7 +269,7 @@ public class ItemViewHolder { String pattern = context.getString(R.string.ltr_or_rtl_combine_via_bold_point); String type = item.getType().getString(context); String size = item.getSizeDescription(context) - + " (" + SrtmDownloadItem.getAbbreviation(context, SrtmDownloadItem.isMetersItem(item)) + ")"; + + " " + SrtmDownloadItem.getAbbreviationInScopes(context, SrtmDownloadItem.isMetersItem(item)); String date = item.getDate(dateFormat, showRemoteDate); String fullDescription = String.format(pattern, size, date); if (showTypeInDesc) { @@ -316,9 +316,9 @@ public class ItemViewHolder { } } - public void bindIndexItem(final CityItem cityItem) { + public void bindDownloadItem(final CityItem cityItem) { if (cityItem.getIndexItem() != null) { - bindIndexItem(cityItem.getIndexItem(), cityItem.getName()); + bindDownloadItem(cityItem.getIndexItem(), cityItem.getName()); } else { nameTextView.setText(cityItem.getName()); nameTextView.setTextColor(textColorPrimary); @@ -529,7 +529,7 @@ public class ItemViewHolder { private void selectIndexesToDownload(DownloadItem item) { SelectIndexesUiHelper.showDialog(item, context, dateFormat, showRemoteDate, - new SelectItemsToDownloadListener() { + new ItemsToDownloadSelectedListener() { @Override public void onItemsToDownloadSelected(List indexes) { IndexItem[] indexesArray = new IndexItem[indexes.size()]; diff --git a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java index 2c695cd1e6..b4e11d6bf7 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java @@ -965,8 +965,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement return ctx.getString(R.string.download_roads_only_item); } else if (child.isBackupedData() && child.getFileName().endsWith(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT)) { return ctx.getString(R.string.download_wikipedia_maps); - } else if (child.isBackupedData() && (child.getFileName().endsWith(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT) - || child.getFileName().endsWith(IndexConstants.BINARY_SRTM_FEET_MAP_INDEX_EXT))) { + } else if (child.isBackupedData() && (SrtmDownloadItem.isSrtmFile(child.getFileName()))) { return ctx.getString(R.string.download_srtm_maps); } return ""; @@ -1033,7 +1032,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement } if (SrtmDownloadItem.isSRTMItem(child)) { - builder.append(" (").append(SrtmDownloadItem.getAbbreviation(ctx, SrtmDownloadItem.isMetersItem(child))).append(")"); + builder.append(" ").append(SrtmDownloadItem.getAbbreviationInScopes(ctx, SrtmDownloadItem.isMetersItem(child))); } if (!Algorithms.isEmpty(child.getDescription())) { diff --git a/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java index ac9a87b32e..e6e3508ade 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java @@ -382,10 +382,10 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven if (obj instanceof IndexItem) { IndexItem item = (IndexItem) obj; viewHolder.setShowTypeInDesc(true); - viewHolder.bindIndexItem(item); + viewHolder.bindDownloadItem(item); } else { CityItem item = (CityItem) obj; - viewHolder.bindIndexItem(item); + viewHolder.bindDownloadItem(item); if (item.getIndexItem() == null) { new IndexItemResolverTask(viewHolder, item).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } @@ -461,7 +461,7 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven if (viewHolder != null) { if (indexItem != null) { cityItem.setIndexItem(indexItem); - viewHolder.bindIndexItem(indexItem, cityItem.getName()); + viewHolder.bindDownloadItem(indexItem, cityItem.getName()); } } } diff --git a/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java index ae0ab9b560..2cf1555428 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java @@ -410,7 +410,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download holder.setShowRemoteDate(true); holder.setShowTypeInDesc(true); holder.setShowParentRegionName(true); - holder.bindIndexItem(getItem(position)); + holder.bindDownloadItem(getItem(position)); } return view; } diff --git a/OsmAnd/src/net/osmand/plus/resources/IncrementalChangesManager.java b/OsmAnd/src/net/osmand/plus/resources/IncrementalChangesManager.java index efcb487fd4..565d300e47 100644 --- a/OsmAnd/src/net/osmand/plus/resources/IncrementalChangesManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/IncrementalChangesManager.java @@ -5,6 +5,7 @@ import net.osmand.PlatformUtil; import net.osmand.binary.BinaryMapIndexReader; import net.osmand.osm.io.NetworkUtils; import net.osmand.plus.R; +import net.osmand.plus.download.SrtmDownloadItem; import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; @@ -45,8 +46,7 @@ public class IncrementalChangesManager { Set existingFiles = new HashSet(); for (File f : files) { if (!f.getName().endsWith(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT) && - !f.getName().endsWith(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT) && - !f.getName().endsWith(IndexConstants.BINARY_SRTM_FEET_MAP_INDEX_EXT)) { + !SrtmDownloadItem.isSrtmFile(f.getName())) { existingFiles.add(Algorithms.getFileNameWithoutExtension(f)); } } diff --git a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java index 9271a3b1c2..7263eab1d8 100644 --- a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java @@ -41,6 +41,7 @@ import net.osmand.plus.R; import net.osmand.plus.Version; import net.osmand.plus.download.DownloadOsmandIndexesHelper; import net.osmand.plus.download.DownloadOsmandIndexesHelper.AssetEntry; +import net.osmand.plus.download.SrtmDownloadItem; import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.plus.render.MapRenderRepositories; import net.osmand.plus.render.NativeOsmandLibrary; @@ -701,8 +702,7 @@ public class ResourceManager { log.error(String.format("File %s could not be read", f.getName()), e); } boolean wikiMap = (f.getName().contains("_wiki") || f.getName().contains(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT)); - boolean srtmMap = f.getName().contains(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT) - || f.getName().contains(IndexConstants.BINARY_SRTM_FEET_MAP_INDEX_EXT); + boolean srtmMap = SrtmDownloadItem.containsSrtmExtension(f.getName()); if (mapReader == null || (!Version.isPaidVersion(context) && wikiMap && !f.getName().equals(DEFAULT_WIKIVOYAGE_TRAVEL_OBF))) { warnings.add(MessageFormat.format(context.getString(R.string.version_index_is_not_supported), f.getName())); //$NON-NLS-1$ } else { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java index e549c74406..53b6ec0500 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java @@ -7,6 +7,7 @@ import androidx.annotation.Nullable; import net.osmand.IndexConstants; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.download.SrtmDownloadItem; import net.osmand.util.Algorithms; import org.json.JSONException; @@ -92,8 +93,7 @@ public class FileSettingsItem extends StreamSettingsItem { case OTHER: break; case SRTM_MAP: - if (name.endsWith(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT) - || name.endsWith(IndexConstants.BINARY_SRTM_FEET_MAP_INDEX_EXT)) { + if (SrtmDownloadItem.isSrtmFile(name)) { return subtype; } break; diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java index b78a4bd0aa..5e4b4f0449 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java @@ -36,6 +36,7 @@ import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton.Bu import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.SimpleDividerItem; +import net.osmand.plus.download.SrtmDownloadItem; import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.GpxUiHelper; @@ -530,8 +531,7 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment { return getString(R.string.download_roads_only_item); } else if (file.getName().endsWith(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT)) { return getString(R.string.download_wikipedia_maps); - } else if (file.getName().endsWith(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT) - || file.getName().endsWith(IndexConstants.BINARY_SRTM_FEET_MAP_INDEX_EXT)) { + } else if (SrtmDownloadItem.isSrtmFile(file.getName())) { return getString(R.string.download_srtm_maps); } else if (file.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) { return getString(R.string.download_regular_maps);