refactoring p.3
This commit is contained in:
parent
1ec3189a86
commit
4a6ab0c6bb
20 changed files with 151 additions and 95 deletions
|
@ -31,7 +31,7 @@
|
|||
tools:text="Some title" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/description"
|
||||
android:id="@+id/title_description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/title"
|
||||
|
@ -61,7 +61,25 @@
|
|||
</RelativeLayout>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/additional_description"
|
||||
android:id="@+id/primary_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/dialog_content_margin"
|
||||
android:letterSpacing="@dimen/description_letter_spacing"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
android:visibility="gone"
|
||||
app:typeface="@string/font_roboto_regular"
|
||||
tools:text="@string/srtm_download_single_help_message"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/secondary_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/content_padding_small"
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.SQLiteTileSource;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.download.SrtmDownloadItem;
|
||||
import net.osmand.plus.download.ui.AbstractLoadLocalIndexTask;
|
||||
import net.osmand.plus.voice.JSMediaCommandPlayerImpl;
|
||||
import net.osmand.plus.voice.JSTTSCommandPlayerImpl;
|
||||
|
@ -333,8 +334,7 @@ public class LocalIndexHelper {
|
|||
if (mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
|
||||
String fileName = mapFile.getName();
|
||||
LocalIndexType lt = LocalIndexType.MAP_DATA;
|
||||
if (fileName.endsWith(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT)
|
||||
|| fileName.endsWith(IndexConstants.BINARY_SRTM_FEET_MAP_INDEX_EXT)) {
|
||||
if (SrtmDownloadItem.isSrtmFile(fileName)) {
|
||||
lt = LocalIndexType.SRTM_DATA;
|
||||
} else if (fileName.endsWith(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT)) {
|
||||
lt = LocalIndexType.WIKI_DATA;
|
||||
|
|
|
@ -28,10 +28,10 @@ public class SelectModeBottomSheet extends SelectionBottomSheet {
|
|||
protected void initHeaderUi() {
|
||||
radioGroup.setItems(modes);
|
||||
|
||||
AndroidUiHelper.setVisibility(View.VISIBLE, secondaryDescription, toggleContainer);
|
||||
AndroidUiHelper.setVisibility(View.VISIBLE, primaryDescription, toggleContainer);
|
||||
|
||||
AndroidUiHelper.setVisibility(View.GONE, checkBox, checkBoxTitle,
|
||||
primaryDescription, selectedSize, selectAllButton);
|
||||
titleDescription, secondaryDescription, selectedSize, selectAllButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,17 +69,17 @@ public class SelectModeBottomSheet extends SelectionBottomSheet {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDescription(@NonNull String description) {
|
||||
secondaryDescription.setText(description);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public List<SelectableItem> getSelection() {
|
||||
return Collections.singletonList(previewItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldShowDivider() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static SelectModeBottomSheet showInstance(@NonNull AppCompatActivity activity,
|
||||
@NonNull SelectableItem previewItem,
|
||||
@NonNull List<RadioItem> radioItems,
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<RadioItem> modes) {
|
||||
|
|
|
@ -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());
|
||||
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) {
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -487,20 +487,14 @@ public class DownloadResources extends DownloadResourceGroup {
|
|||
List<IndexItem> indexesList = group.getIndividualResources();
|
||||
List<DownloadItem> individualDownloadItems = group.getIndividualDownloadItems();
|
||||
if (doesListContainIndexWithType(indexesList, srtmType)) {
|
||||
IndexItem meters = null;
|
||||
IndexItem feet = null;
|
||||
List<IndexItem> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<SelectableItem> 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<IndexItem> items);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<IndexItem> indexes;
|
||||
private IndexItem meter;
|
||||
private IndexItem feet;
|
||||
|
||||
private boolean useMetersByDefault;
|
||||
private boolean shouldUseMeters;
|
||||
|
||||
public SrtmDownloadItem(IndexItem meterItem,
|
||||
IndexItem feetItem,
|
||||
boolean useMetersByDefault) {
|
||||
public SrtmDownloadItem(List<IndexItem> 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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<IndexItem> indexes) {
|
||||
IndexItem[] indexesArray = new IndexItem[indexes.size()];
|
||||
|
|
|
@ -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())) {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<String> existingFiles = new HashSet<String>();
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue