refactoring p.2
This commit is contained in:
parent
e3c257b255
commit
1ec3189a86
8 changed files with 300 additions and 161 deletions
|
@ -29,7 +29,6 @@ import java.util.Map;
|
||||||
|
|
||||||
import static net.osmand.IndexConstants.BINARY_MAP_INDEX_EXT;
|
import static net.osmand.IndexConstants.BINARY_MAP_INDEX_EXT;
|
||||||
import static net.osmand.plus.activities.LocalIndexHelper.LocalIndexType.SRTM_DATA;
|
import static net.osmand.plus.activities.LocalIndexHelper.LocalIndexType.SRTM_DATA;
|
||||||
import static net.osmand.plus.download.SelectIndexesUiHelper.getSRTMExt;
|
|
||||||
|
|
||||||
public class DownloadActivityType {
|
public class DownloadActivityType {
|
||||||
private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd.MM.yyyy", Locale.US);
|
private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd.MM.yyyy", Locale.US);
|
||||||
|
@ -231,7 +230,7 @@ public class DownloadActivityType {
|
||||||
} else if (FONT_FILE == this) {
|
} else if (FONT_FILE == this) {
|
||||||
return IndexConstants.FONT_INDEX_EXT;
|
return IndexConstants.FONT_INDEX_EXT;
|
||||||
} else if (SRTM_COUNTRY_FILE == this) {
|
} else if (SRTM_COUNTRY_FILE == this) {
|
||||||
return getSRTMExt(indexItem);
|
return SrtmDownloadItem.getExtension(indexItem);
|
||||||
} else if (WIKIPEDIA_FILE == this) {
|
} else if (WIKIPEDIA_FILE == this) {
|
||||||
return IndexConstants.BINARY_WIKI_MAP_INDEX_EXT;
|
return IndexConstants.BINARY_WIKI_MAP_INDEX_EXT;
|
||||||
} else if (WIKIVOYAGE_FILE == this) {
|
} else if (WIKIVOYAGE_FILE == this) {
|
||||||
|
@ -427,7 +426,7 @@ public class DownloadActivityType {
|
||||||
}
|
}
|
||||||
String baseNameWithoutVersion = fileName.substring(0, l);
|
String baseNameWithoutVersion = fileName.substring(0, l);
|
||||||
if (this == SRTM_COUNTRY_FILE) {
|
if (this == SRTM_COUNTRY_FILE) {
|
||||||
return baseNameWithoutVersion + getSRTMExt(item);
|
return baseNameWithoutVersion + SrtmDownloadItem.getExtension(item);
|
||||||
}
|
}
|
||||||
if (this == WIKIPEDIA_FILE) {
|
if (this == WIKIPEDIA_FILE) {
|
||||||
return baseNameWithoutVersion + IndexConstants.BINARY_WIKI_MAP_INDEX_EXT;
|
return baseNameWithoutVersion + IndexConstants.BINARY_WIKI_MAP_INDEX_EXT;
|
||||||
|
@ -505,14 +504,4 @@ public class DownloadActivityType {
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSRTMItem(Object item) {
|
|
||||||
if (item instanceof IndexItem) {
|
|
||||||
return ((IndexItem) item).getType() == SRTM_COUNTRY_FILE;
|
|
||||||
} else if (item instanceof DownloadItem) {
|
|
||||||
return ((DownloadItem) item).getType() == SRTM_COUNTRY_FILE;
|
|
||||||
} else if (item instanceof LocalIndexInfo) {
|
|
||||||
return ((LocalIndexInfo) item).getType() == SRTM_DATA;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -471,14 +471,49 @@ public class DownloadResources extends DownloadResourceGroup {
|
||||||
addGroup(otherGroup);
|
addGroup(otherGroup);
|
||||||
|
|
||||||
createHillshadeSRTMGroups();
|
createHillshadeSRTMGroups();
|
||||||
collectMultipleIndexesItems();
|
replaceIndividualSrtmWithGroups(region);
|
||||||
|
collectMultipleIndexesItems(region);
|
||||||
trimEmptyGroups();
|
trimEmptyGroups();
|
||||||
updateLoadedFiles();
|
updateLoadedFiles();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collectMultipleIndexesItems() {
|
private void replaceIndividualSrtmWithGroups(@NonNull WorldRegion region) {
|
||||||
collectMultipleIndexesItems(region);
|
DownloadResourceGroup group = getRegionMapsGroup(region);
|
||||||
|
if (group != null) {
|
||||||
|
boolean useMetersByDefault = SrtmDownloadItem.shouldUseMetersByDefault(app);
|
||||||
|
boolean listModified = false;
|
||||||
|
DownloadActivityType srtmType = DownloadActivityType.SRTM_COUNTRY_FILE;
|
||||||
|
List<IndexItem> indexesList = group.getIndividualResources();
|
||||||
|
List<DownloadItem> individualDownloadItems = group.getIndividualDownloadItems();
|
||||||
|
if (doesListContainIndexWithType(indexesList, srtmType)) {
|
||||||
|
IndexItem meters = null;
|
||||||
|
IndexItem feet = null;
|
||||||
|
for (IndexItem item : indexesList) {
|
||||||
|
if (item.getType() == srtmType) {
|
||||||
|
if (SrtmDownloadItem.isMetersItem(item)) {
|
||||||
|
meters = item;
|
||||||
|
} else {
|
||||||
|
feet = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
individualDownloadItems.remove(meters);
|
||||||
|
individualDownloadItems.remove(feet);
|
||||||
|
group.addItem(new SrtmDownloadItem(meters, feet, useMetersByDefault));
|
||||||
|
listModified = true;
|
||||||
|
}
|
||||||
|
if (listModified) {
|
||||||
|
sortDownloadItems(individualDownloadItems);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<WorldRegion> subRegions = region.getSubregions();
|
||||||
|
if (!Algorithms.isEmpty(subRegions)) {
|
||||||
|
for (WorldRegion subRegion : subRegions) {
|
||||||
|
replaceIndividualSrtmWithGroups(subRegion);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collectMultipleIndexesItems(@NonNull WorldRegion region) {
|
private void collectMultipleIndexesItems(@NonNull WorldRegion region) {
|
||||||
|
|
|
@ -12,7 +12,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.osmand.plus.download.DownloadActivityType.SRTM_COUNTRY_FILE;
|
import static net.osmand.plus.download.DownloadActivityType.SRTM_COUNTRY_FILE;
|
||||||
import static net.osmand.plus.download.SelectIndexesUiHelper.isBaseSRTMItem;
|
|
||||||
|
|
||||||
public class MultipleIndexItem extends DownloadItem {
|
public class MultipleIndexItem extends DownloadItem {
|
||||||
|
|
||||||
|
@ -121,7 +120,8 @@ public class MultipleIndexItem extends DownloadItem {
|
||||||
if (this.type == SRTM_COUNTRY_FILE) {
|
if (this.type == SRTM_COUNTRY_FILE) {
|
||||||
for (IndexItem item : items) {
|
for (IndexItem item : items) {
|
||||||
if (item.hasActualDataToDownload()) {
|
if (item.hasActualDataToDownload()) {
|
||||||
if (baseSRTM && isBaseSRTMItem(item) || !baseSRTM && !isBaseSRTMItem(item)) {
|
boolean isBase = SrtmDownloadItem.isMetersItem(item);
|
||||||
|
if (baseSRTM && isBase || !baseSRTM && !isBase) {
|
||||||
totalSizeMb += item.getSizeToDownloadInMb();
|
totalSizeMb += item.getSizeToDownloadInMb();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,9 @@ import android.view.View;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import net.osmand.IndexConstants;
|
|
||||||
import net.osmand.map.OsmandRegions;
|
import net.osmand.map.OsmandRegions;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.LocalIndexInfo;
|
|
||||||
import net.osmand.plus.base.SelectMultipleItemsBottomSheet;
|
import net.osmand.plus.base.SelectMultipleItemsBottomSheet;
|
||||||
import net.osmand.plus.base.SelectMultipleItemsBottomSheet.SelectionUpdateListener;
|
import net.osmand.plus.base.SelectMultipleItemsBottomSheet.SelectionUpdateListener;
|
||||||
import net.osmand.plus.base.SelectModeBottomSheet;
|
import net.osmand.plus.base.SelectModeBottomSheet;
|
||||||
|
@ -19,7 +17,6 @@ import net.osmand.plus.base.SelectionBottomSheet;
|
||||||
import net.osmand.plus.base.SelectionBottomSheet.OnApplySelectionListener;
|
import net.osmand.plus.base.SelectionBottomSheet.OnApplySelectionListener;
|
||||||
import net.osmand.plus.base.SelectionBottomSheet.OnUiInitializedListener;
|
import net.osmand.plus.base.SelectionBottomSheet.OnUiInitializedListener;
|
||||||
import net.osmand.plus.base.SelectionBottomSheet.SelectableItem;
|
import net.osmand.plus.base.SelectionBottomSheet.SelectableItem;
|
||||||
import net.osmand.plus.helpers.enums.MetricsConstants;
|
|
||||||
import net.osmand.plus.widgets.MultiStateToggleButton.OnRadioItemClickListener;
|
import net.osmand.plus.widgets.MultiStateToggleButton.OnRadioItemClickListener;
|
||||||
import net.osmand.plus.widgets.MultiStateToggleButton.RadioItem;
|
import net.osmand.plus.widgets.MultiStateToggleButton.RadioItem;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -29,35 +26,56 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.osmand.IndexConstants.BINARY_SRTM_MAP_INDEX_EXT;
|
|
||||||
import static net.osmand.IndexConstants.BINARY_SRTM_MAP_INDEX_EXT_ZIP;
|
|
||||||
import static net.osmand.plus.download.DownloadActivityType.SRTM_COUNTRY_FILE;
|
import static net.osmand.plus.download.DownloadActivityType.SRTM_COUNTRY_FILE;
|
||||||
|
|
||||||
public class SelectIndexesUiHelper {
|
public class SelectIndexesUiHelper {
|
||||||
|
|
||||||
public static void showDialog(@NonNull DownloadItem item,
|
private OsmandApplication app;
|
||||||
|
private AppCompatActivity activity;
|
||||||
|
|
||||||
|
private DateFormat dateFormat;
|
||||||
|
private boolean showRemoteDate;
|
||||||
|
private DownloadItem downloadItem;
|
||||||
|
private SelectItemsToDownloadListener listener;
|
||||||
|
private SelectionBottomSheet dialog;
|
||||||
|
|
||||||
|
private SelectIndexesUiHelper(@NonNull DownloadItem item,
|
||||||
@NonNull AppCompatActivity activity,
|
@NonNull AppCompatActivity activity,
|
||||||
@NonNull final OsmandApplication app,
|
|
||||||
@NonNull DateFormat dateFormat,
|
@NonNull DateFormat dateFormat,
|
||||||
boolean showRemoteDate,
|
boolean showRemoteDate,
|
||||||
@NonNull final SelectItemsToDownloadListener listener) {
|
@NonNull SelectItemsToDownloadListener listener) {
|
||||||
if (item.getType() == SRTM_COUNTRY_FILE) {
|
this.activity = activity;
|
||||||
if (item instanceof MultipleIndexItem) {
|
this.app = (OsmandApplication) activity.getApplicationContext();
|
||||||
showMultipleSrtmDialog(item, activity, app, dateFormat, showRemoteDate, listener);
|
this.downloadItem = item;
|
||||||
} else {
|
this.dateFormat = dateFormat;
|
||||||
showSingleSrtmDialog(item, activity, app, dateFormat, showRemoteDate, listener);
|
this.showRemoteDate = showRemoteDate;
|
||||||
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
} else if (item instanceof MultipleIndexItem) {
|
|
||||||
showBaseDialog((MultipleIndexItem) item, activity, app, dateFormat, showRemoteDate, listener);
|
public static void showDialog(@NonNull DownloadItem item,
|
||||||
|
@NonNull AppCompatActivity activity,
|
||||||
|
@NonNull DateFormat dateFormat,
|
||||||
|
boolean showRemoteDate,
|
||||||
|
@NonNull SelectItemsToDownloadListener listener) {
|
||||||
|
SelectIndexesUiHelper helper =
|
||||||
|
new SelectIndexesUiHelper(item, activity, dateFormat, showRemoteDate, listener);
|
||||||
|
helper.showDialogInternal();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showDialogInternal() {
|
||||||
|
if (downloadItem.getType() == SRTM_COUNTRY_FILE) {
|
||||||
|
if (downloadItem instanceof MultipleIndexItem) {
|
||||||
|
showMultipleSrtmDialog();
|
||||||
|
} else {
|
||||||
|
showSingleSrtmDialog();
|
||||||
|
}
|
||||||
|
} else if (downloadItem instanceof MultipleIndexItem) {
|
||||||
|
showBaseDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showBaseDialog(@NonNull MultipleIndexItem multipleIndexItem,
|
private void showBaseDialog() {
|
||||||
@NonNull AppCompatActivity activity,
|
MultipleIndexItem multipleIndexItem = (MultipleIndexItem) downloadItem;
|
||||||
@NonNull final OsmandApplication app,
|
|
||||||
@NonNull DateFormat dateFormat,
|
|
||||||
boolean showRemoteDate,
|
|
||||||
@NonNull final SelectItemsToDownloadListener listener) {
|
|
||||||
List<IndexItem> indexesToDownload = getIndexesToDownload(multipleIndexItem);
|
List<IndexItem> indexesToDownload = getIndexesToDownload(multipleIndexItem);
|
||||||
List<SelectableItem> allItems = new ArrayList<>();
|
List<SelectableItem> allItems = new ArrayList<>();
|
||||||
List<SelectableItem> selectedItems = new ArrayList<>();
|
List<SelectableItem> selectedItems = new ArrayList<>();
|
||||||
|
@ -65,10 +83,12 @@ public class SelectIndexesUiHelper {
|
||||||
for (IndexItem indexItem : multipleIndexItem.getAllIndexes()) {
|
for (IndexItem indexItem : multipleIndexItem.getAllIndexes()) {
|
||||||
SelectableItem selectableItem = new SelectableItem();
|
SelectableItem selectableItem = new SelectableItem();
|
||||||
selectableItem.setTitle(indexItem.getVisibleName(app, osmandRegions, false));
|
selectableItem.setTitle(indexItem.getVisibleName(app, osmandRegions, false));
|
||||||
|
|
||||||
String size = indexItem.getSizeDescription(app);
|
String size = indexItem.getSizeDescription(app);
|
||||||
String date = indexItem.getDate(dateFormat, showRemoteDate);
|
String date = indexItem.getDate(dateFormat, showRemoteDate);
|
||||||
String description = app.getString(R.string.ltr_or_rtl_combine_via_bold_point, size, date);
|
String description = app.getString(R.string.ltr_or_rtl_combine_via_bold_point, size, date);
|
||||||
selectableItem.setDescription(description);
|
selectableItem.setDescription(description);
|
||||||
|
|
||||||
selectableItem.setIconId(indexItem.getType().getIconResource());
|
selectableItem.setIconId(indexItem.getType().getIconResource());
|
||||||
selectableItem.setObject(indexItem);
|
selectableItem.setObject(indexItem);
|
||||||
allItems.add(selectableItem);
|
allItems.add(selectableItem);
|
||||||
|
@ -91,90 +111,37 @@ public class SelectIndexesUiHelper {
|
||||||
dialog.setSelectionUpdateListener(new SelectionUpdateListener() {
|
dialog.setSelectionUpdateListener(new SelectionUpdateListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSelectionUpdate() {
|
public void onSelectionUpdate() {
|
||||||
updateSize(app, dialog, true);
|
updateSize(dialog, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dialog.setOnApplySelectionListener(getOnApplySelectionListener(listener));
|
dialog.setOnApplySelectionListener(getOnApplySelectionListener(listener));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showSingleSrtmDialog(@NonNull final DownloadItem downloadItem,
|
private void showSingleSrtmDialog() {
|
||||||
@NonNull AppCompatActivity activity,
|
boolean baseSRTM = SrtmDownloadItem.shouldUseMetersByDefault(app);
|
||||||
@NonNull final OsmandApplication app,
|
SrtmDownloadItem srtmItem = (SrtmDownloadItem) downloadItem;
|
||||||
@NonNull final DateFormat dateFormat,
|
|
||||||
final boolean showRemoteDate,
|
SelectableItem meterItem = createSrtmSelectableItem(srtmItem.getMeterItem());
|
||||||
@NonNull final SelectItemsToDownloadListener listener) {
|
SelectableItem feetItem = createSrtmSelectableItem(srtmItem.getFeetItem());
|
||||||
List<IndexItem> allIndexes = getIndexesToDownload(downloadItem);
|
|
||||||
boolean baseSRTM = isBaseSRTMMetricSystem(app);
|
|
||||||
|
|
||||||
List<RadioItem> radioItems = new ArrayList<>();
|
List<RadioItem> radioItems = new ArrayList<>();
|
||||||
final RadioItem meters = new RadioItem(Algorithms.capitalizeFirstLetter(app.getString(R.string.shared_string_meters)));
|
RadioItem meters = createRadioItem(meterItem, R.string.shared_string_meters);
|
||||||
RadioItem feet = new RadioItem(Algorithms.capitalizeFirstLetter(app.getString(R.string.shared_string_feets)));
|
RadioItem feet = createRadioItem(feetItem, R.string.shared_string_feets);
|
||||||
radioItems.add(meters);
|
radioItems.add(meters);
|
||||||
radioItems.add(feet);
|
radioItems.add(feet);
|
||||||
SelectableItem meterItem = null;
|
|
||||||
SelectableItem feetItem = null;
|
|
||||||
for (IndexItem indexItem : allIndexes) {
|
|
||||||
boolean baseItem = isBaseSRTMItem(indexItem);
|
|
||||||
SelectableItem selectableItem = new SelectableItem();
|
|
||||||
selectableItem.setTitle(indexItem.getVisibleName(app, app.getRegions(), false));
|
|
||||||
String size = indexItem.getSizeDescription(app);
|
|
||||||
size += " (" + getSRTMAbbrev(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);
|
|
||||||
selectableItem.setIconId(indexItem.getType().getIconResource());
|
|
||||||
selectableItem.setObject(indexItem);
|
|
||||||
if (baseItem) {
|
|
||||||
meterItem = selectableItem;
|
|
||||||
} else {
|
|
||||||
feetItem = selectableItem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final SelectableItem initMeter = meterItem;
|
dialog = SelectModeBottomSheet.showInstance(activity,
|
||||||
final SelectableItem initFeet = feetItem;
|
|
||||||
|
|
||||||
final SelectModeBottomSheet dialog = SelectModeBottomSheet.showInstance(activity,
|
|
||||||
baseSRTM ? meterItem : feetItem, radioItems, true);
|
baseSRTM ? meterItem : feetItem, radioItems, true);
|
||||||
|
|
||||||
meters.setOnClickListener(new OnRadioItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onRadioItemClick(RadioItem radioItem, View view) {
|
|
||||||
dialog.setPreviewItem(initMeter);
|
|
||||||
updateSize(app, dialog, false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
feet.setOnClickListener(new OnRadioItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onRadioItemClick(RadioItem radioItem, View view) {
|
|
||||||
dialog.setPreviewItem(initFeet);
|
|
||||||
|
|
||||||
double sizeToDownload = getDownloadSizeInMb(Collections.singletonList(initFeet));
|
|
||||||
String size = DownloadItem.getFormattedMb(app, sizeToDownload);
|
|
||||||
String btnTitle = app.getString(R.string.shared_string_download);
|
|
||||||
if (sizeToDownload > 0) {
|
|
||||||
btnTitle = app.getString(R.string.ltr_or_rtl_combine_via_dash, btnTitle, size);
|
|
||||||
}
|
|
||||||
dialog.setApplyButtonTitle(btnTitle);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
final RadioItem initRadio = baseSRTM ? meters : feet;
|
final RadioItem initRadio = baseSRTM ? meters : feet;
|
||||||
|
final SelectableItem initItem = baseSRTM ? meterItem : feetItem;
|
||||||
dialog.setUiInitializedListener(new OnUiInitializedListener() {
|
dialog.setUiInitializedListener(new OnUiInitializedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onUiInitialized() {
|
public void onUiInitialized() {
|
||||||
|
SelectModeBottomSheet dialog = (SelectModeBottomSheet) SelectIndexesUiHelper.this.dialog;
|
||||||
dialog.setTitle(app.getString(R.string.srtm_unit_format));
|
dialog.setTitle(app.getString(R.string.srtm_unit_format));
|
||||||
dialog.setDescription(app.getString(R.string.srtm_download_single_help_message));
|
dialog.setDescription(app.getString(R.string.srtm_download_single_help_message));
|
||||||
double sizeToDownload = getDownloadSizeInMb(Collections.singletonList(initFeet));
|
updateSize(dialog, false);
|
||||||
String size = DownloadItem.getFormattedMb(app, sizeToDownload);
|
|
||||||
String btnTitle = app.getString(R.string.shared_string_download);
|
|
||||||
if (sizeToDownload > 0) {
|
|
||||||
btnTitle = app.getString(R.string.ltr_or_rtl_combine_via_dash, btnTitle, size);
|
|
||||||
}
|
|
||||||
dialog.setApplyButtonTitle(btnTitle);
|
|
||||||
dialog.setSelectedMode(initRadio);
|
dialog.setSelectedMode(initRadio);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -182,17 +149,40 @@ public class SelectIndexesUiHelper {
|
||||||
dialog.setOnApplySelectionListener(getOnApplySelectionListener(listener));
|
dialog.setOnApplySelectionListener(getOnApplySelectionListener(listener));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showMultipleSrtmDialog(@NonNull final DownloadItem downloadItem,
|
private SelectableItem createSrtmSelectableItem(IndexItem indexItem) {
|
||||||
@NonNull AppCompatActivity activity,
|
boolean baseItem = SrtmDownloadItem.isMetersItem(indexItem);
|
||||||
@NonNull final OsmandApplication app,
|
SelectableItem selectableItem = new SelectableItem();
|
||||||
@NonNull final DateFormat dateFormat,
|
selectableItem.setTitle(indexItem.getVisibleName(app, app.getRegions(), false));
|
||||||
final boolean showRemoteDate,
|
String size = indexItem.getSizeDescription(app);
|
||||||
@NonNull final SelectItemsToDownloadListener listener) {
|
size += " (" + SrtmDownloadItem.getAbbreviation(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);
|
||||||
|
selectableItem.setIconId(indexItem.getType().getIconResource());
|
||||||
|
selectableItem.setObject(indexItem);
|
||||||
|
return selectableItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
private RadioItem createRadioItem(final SelectableItem selectableItem, int titleId) {
|
||||||
|
String title = Algorithms.capitalizeFirstLetter(app.getString(titleId));
|
||||||
|
RadioItem radioItem = new RadioItem(title);
|
||||||
|
radioItem.setOnClickListener(new OnRadioItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onRadioItemClick(RadioItem radioItem, View view) {
|
||||||
|
((SelectModeBottomSheet)dialog).setPreviewItem(selectableItem);
|
||||||
|
updateSize(dialog, false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return radioItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showMultipleSrtmDialog() {
|
||||||
List<SelectableItem> selectedItems = new ArrayList<>();
|
List<SelectableItem> selectedItems = new ArrayList<>();
|
||||||
final List<SelectableItem> meterItems = new ArrayList<>();
|
final List<SelectableItem> meterItems = new ArrayList<>();
|
||||||
final List<SelectableItem> feetItems = new ArrayList<>();
|
final List<SelectableItem> feetItems = new ArrayList<>();
|
||||||
List<IndexItem> indexesToDownload = getIndexesToDownload(downloadItem);
|
List<IndexItem> indexesToDownload = getIndexesToDownload(downloadItem);
|
||||||
boolean baseSRTM = isBaseSRTMMetricSystem(app);
|
boolean baseSRTM = SrtmDownloadItem.shouldUseMetersByDefault(app);
|
||||||
|
|
||||||
List<IndexItem> allIndexes = new ArrayList<>();
|
List<IndexItem> allIndexes = new ArrayList<>();
|
||||||
if (downloadItem instanceof MultipleIndexItem) {
|
if (downloadItem instanceof MultipleIndexItem) {
|
||||||
|
@ -206,11 +196,11 @@ public class SelectIndexesUiHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (IndexItem indexItem : allIndexes) {
|
for (IndexItem indexItem : allIndexes) {
|
||||||
boolean baseItem = isBaseSRTMItem(indexItem);
|
boolean baseItem = SrtmDownloadItem.isMetersItem(indexItem);
|
||||||
SelectableItem selectableItem = new SelectableItem();
|
SelectableItem selectableItem = new SelectableItem();
|
||||||
selectableItem.setTitle(indexItem.getVisibleName(app, app.getRegions(), false));
|
selectableItem.setTitle(indexItem.getVisibleName(app, app.getRegions(), false));
|
||||||
String size = indexItem.getSizeDescription(app);
|
String size = indexItem.getSizeDescription(app);
|
||||||
size += " (" + getSRTMAbbrev(app, baseItem) + ")";
|
size += " (" + SrtmDownloadItem.getAbbreviation(app, baseItem) + ")";
|
||||||
String date = indexItem.getDate(dateFormat, showRemoteDate);
|
String date = indexItem.getDate(dateFormat, showRemoteDate);
|
||||||
String description = app.getString(R.string.ltr_or_rtl_combine_via_bold_point, size, date);
|
String description = app.getString(R.string.ltr_or_rtl_combine_via_bold_point, size, date);
|
||||||
selectableItem.setDescription(description);
|
selectableItem.setDescription(description);
|
||||||
|
@ -232,7 +222,7 @@ public class SelectIndexesUiHelper {
|
||||||
List<RadioItem> radioItems = new ArrayList<>();
|
List<RadioItem> radioItems = new ArrayList<>();
|
||||||
RadioItem meters = new RadioItem(Algorithms.capitalizeFirstLetter(app.getString(R.string.shared_string_meters)));
|
RadioItem meters = new RadioItem(Algorithms.capitalizeFirstLetter(app.getString(R.string.shared_string_meters)));
|
||||||
RadioItem feet = new RadioItem(Algorithms.capitalizeFirstLetter(app.getString(R.string.shared_string_feets)));
|
RadioItem feet = new RadioItem(Algorithms.capitalizeFirstLetter(app.getString(R.string.shared_string_feets)));
|
||||||
final RadioItem selectedMode = isBaseSRTMItem(downloadItem) ? meters : feet;
|
final RadioItem selectedMode = SrtmDownloadItem.isMetersItem(downloadItem) ? meters : feet;
|
||||||
radioItems.add(meters);
|
radioItems.add(meters);
|
||||||
radioItems.add(feet);
|
radioItems.add(feet);
|
||||||
|
|
||||||
|
@ -267,13 +257,13 @@ public class SelectIndexesUiHelper {
|
||||||
dialog.setSelectionUpdateListener(new SelectionUpdateListener() {
|
dialog.setSelectionUpdateListener(new SelectionUpdateListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSelectionUpdate() {
|
public void onSelectionUpdate() {
|
||||||
updateSize(app, dialog, true);
|
updateSize(dialog, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dialog.setOnApplySelectionListener(getOnApplySelectionListener(listener));
|
dialog.setOnApplySelectionListener(getOnApplySelectionListener(listener));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static OnApplySelectionListener getOnApplySelectionListener(final SelectItemsToDownloadListener listener) {
|
private OnApplySelectionListener getOnApplySelectionListener(final SelectItemsToDownloadListener listener) {
|
||||||
return new OnApplySelectionListener() {
|
return new OnApplySelectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSelectionApplied(List<SelectableItem> selectedItems) {
|
public void onSelectionApplied(List<SelectableItem> selectedItems) {
|
||||||
|
@ -289,8 +279,7 @@ public class SelectIndexesUiHelper {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateSize(OsmandApplication app,
|
private void updateSize(SelectionBottomSheet dialog,
|
||||||
SelectionBottomSheet dialog,
|
|
||||||
boolean updateDescription) {
|
boolean updateDescription) {
|
||||||
double sizeToDownload = getDownloadSizeInMb(dialog.getSelection());
|
double sizeToDownload = getDownloadSizeInMb(dialog.getSelection());
|
||||||
String size = DownloadItem.getFormattedMb(app, sizeToDownload);
|
String size = DownloadItem.getFormattedMb(app, sizeToDownload);
|
||||||
|
@ -306,28 +295,6 @@ public class SelectIndexesUiHelper {
|
||||||
dialog.setApplyButtonTitle(btnTitle);
|
dialog.setApplyButtonTitle(btnTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getSRTMAbbrev(Context context, boolean base) {
|
|
||||||
return context.getString(base ? R.string.m : R.string.foot);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getSRTMExt(IndexItem indexItem) {
|
|
||||||
return isBaseSRTMItem(indexItem)
|
|
||||||
? IndexConstants.BINARY_SRTM_MAP_INDEX_EXT : IndexConstants.BINARY_SRTM_FEET_MAP_INDEX_EXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isBaseSRTMItem(Object item) {
|
|
||||||
if (item instanceof IndexItem) {
|
|
||||||
return ((IndexItem) item).getFileName().endsWith(BINARY_SRTM_MAP_INDEX_EXT_ZIP);
|
|
||||||
} else if (item instanceof LocalIndexInfo) {
|
|
||||||
return ((LocalIndexInfo) item).getFileName().endsWith(BINARY_SRTM_MAP_INDEX_EXT);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isBaseSRTMMetricSystem(OsmandApplication app) {
|
|
||||||
return app.getSettings().METRIC_SYSTEM.get() != MetricsConstants.MILES_AND_FEET;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<IndexItem> getIndexesToDownload(DownloadItem downloadItem) {
|
private static List<IndexItem> getIndexesToDownload(DownloadItem downloadItem) {
|
||||||
if (downloadItem instanceof MultipleIndexItem) {
|
if (downloadItem instanceof MultipleIndexItem) {
|
||||||
if (downloadItem.hasActualDataToDownload()) {
|
if (downloadItem.hasActualDataToDownload()) {
|
||||||
|
|
137
OsmAnd/src/net/osmand/plus/download/SrtmDownloadItem.java
Normal file
137
OsmAnd/src/net/osmand/plus/download/SrtmDownloadItem.java
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
package net.osmand.plus.download;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import net.osmand.IndexConstants;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.LocalIndexInfo;
|
||||||
|
import net.osmand.plus.helpers.enums.MetricsConstants;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static net.osmand.IndexConstants.BINARY_SRTM_MAP_INDEX_EXT;
|
||||||
|
import static net.osmand.IndexConstants.BINARY_SRTM_MAP_INDEX_EXT_ZIP;
|
||||||
|
import static net.osmand.plus.activities.LocalIndexHelper.LocalIndexType.SRTM_DATA;
|
||||||
|
import static net.osmand.plus.download.DownloadActivityType.SRTM_COUNTRY_FILE;
|
||||||
|
|
||||||
|
public class SrtmDownloadItem extends DownloadItem {
|
||||||
|
|
||||||
|
private IndexItem meterItem;
|
||||||
|
private IndexItem feetItem;
|
||||||
|
|
||||||
|
private boolean useMetersByDefault;
|
||||||
|
|
||||||
|
public SrtmDownloadItem(IndexItem meterItem,
|
||||||
|
IndexItem feetItem,
|
||||||
|
boolean useMetersByDefault) {
|
||||||
|
super(SRTM_COUNTRY_FILE);
|
||||||
|
this.meterItem = meterItem;
|
||||||
|
this.feetItem = feetItem;
|
||||||
|
this.useMetersByDefault = useMetersByDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUseMetersByDefault() {
|
||||||
|
return useMetersByDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUseMetersByDefault(boolean useMetersByDefault) {
|
||||||
|
this.useMetersByDefault = useMetersByDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IndexItem getIndexItem() {
|
||||||
|
return useMetersByDefault ? getMeterItem() : getFeetItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IndexItem getMeterItem() {
|
||||||
|
return meterItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IndexItem getFeetItem() {
|
||||||
|
return feetItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected double getSizeToDownloadInMb() {
|
||||||
|
return getIndexItem().getSizeToDownloadInMb();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getArchiveSizeMB() {
|
||||||
|
return getIndexItem().getArchiveSizeMB();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDownloaded() {
|
||||||
|
return getIndexItem().isDownloaded();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOutdated() {
|
||||||
|
return getIndexItem().isOutdated();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasActualDataToDownload() {
|
||||||
|
return getIndexItem().hasActualDataToDownload();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDownloading(@NonNull DownloadIndexesThread thread) {
|
||||||
|
return getMeterItem().isDownloading(thread) || getFeetItem().isDownloading(thread);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFileName() {
|
||||||
|
return getIndexItem().getFileName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public List<File> getDownloadedFiles(@NonNull OsmandApplication app) {
|
||||||
|
return getIndexItem().getDownloadedFiles(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDate(@NonNull DateFormat dateFormat, boolean remote) {
|
||||||
|
return getIndexItem().getDate(dateFormat, remote);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean shouldUseMetersByDefault(@NonNull OsmandApplication app) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 isMetersItem(Object item) {
|
||||||
|
if (item instanceof IndexItem) {
|
||||||
|
return ((IndexItem) item).getFileName().endsWith(BINARY_SRTM_MAP_INDEX_EXT_ZIP);
|
||||||
|
} else if (item instanceof LocalIndexInfo) {
|
||||||
|
return ((LocalIndexInfo) item).getFileName().endsWith(BINARY_SRTM_MAP_INDEX_EXT);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSRTMItem(Object item) {
|
||||||
|
if (item instanceof IndexItem) {
|
||||||
|
return ((IndexItem) item).getType() == SRTM_COUNTRY_FILE;
|
||||||
|
} else if (item instanceof DownloadItem) {
|
||||||
|
return ((DownloadItem) item).getType() == SRTM_COUNTRY_FILE;
|
||||||
|
} else if (item instanceof LocalIndexInfo) {
|
||||||
|
return ((LocalIndexInfo) item).getType() == SRTM_DATA;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -44,6 +44,7 @@ import net.osmand.plus.download.IndexItem;
|
||||||
import net.osmand.plus.download.SelectIndexesUiHelper;
|
import net.osmand.plus.download.SelectIndexesUiHelper;
|
||||||
import net.osmand.plus.download.SelectIndexesUiHelper.SelectItemsToDownloadListener;
|
import net.osmand.plus.download.SelectIndexesUiHelper.SelectItemsToDownloadListener;
|
||||||
import net.osmand.plus.download.MultipleIndexItem;
|
import net.osmand.plus.download.MultipleIndexItem;
|
||||||
|
import net.osmand.plus.download.SrtmDownloadItem;
|
||||||
import net.osmand.plus.download.ui.LocalIndexesFragment.LocalIndexOperationTask;
|
import net.osmand.plus.download.ui.LocalIndexesFragment.LocalIndexOperationTask;
|
||||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||||
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||||
|
@ -55,10 +56,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.osmand.plus.download.DownloadActivityType.SRTM_COUNTRY_FILE;
|
import static net.osmand.plus.download.DownloadActivityType.SRTM_COUNTRY_FILE;
|
||||||
import static net.osmand.plus.download.DownloadActivityType.isSRTMItem;
|
|
||||||
import static net.osmand.plus.download.SelectIndexesUiHelper.getSRTMAbbrev;
|
|
||||||
import static net.osmand.plus.download.SelectIndexesUiHelper.isBaseSRTMItem;
|
|
||||||
import static net.osmand.plus.download.SelectIndexesUiHelper.isBaseSRTMMetricSystem;
|
|
||||||
|
|
||||||
public class ItemViewHolder {
|
public class ItemViewHolder {
|
||||||
|
|
||||||
|
@ -196,8 +193,8 @@ public class ItemViewHolder {
|
||||||
}
|
}
|
||||||
descrTextView.setTextColor(textColorSecondary);
|
descrTextView.setTextColor(textColorSecondary);
|
||||||
if (!isDownloading) {
|
if (!isDownloading) {
|
||||||
boolean srtmItem = isSRTMItem(downloadItem);
|
boolean srtmItem = SrtmDownloadItem.isSRTMItem(downloadItem);
|
||||||
boolean baseMetricSystem = isBaseSRTMMetricSystem(context.getMyApplication());
|
boolean baseMetricSystem = SrtmDownloadItem.shouldUseMetersByDefault(context.getMyApplication());
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
descrTextView.setVisibility(View.VISIBLE);
|
descrTextView.setVisibility(View.VISIBLE);
|
||||||
if (downloadItem instanceof CustomIndexItem && (((CustomIndexItem) downloadItem).getSubName(context) != null)) {
|
if (downloadItem instanceof CustomIndexItem && (((CustomIndexItem) downloadItem).getSubName(context) != null)) {
|
||||||
|
@ -218,10 +215,10 @@ public class ItemViewHolder {
|
||||||
String regionsHeader = context.getString(R.string.regions);
|
String regionsHeader = context.getString(R.string.regions);
|
||||||
String allRegionsCount;
|
String allRegionsCount;
|
||||||
String leftToDownloadCount;
|
String leftToDownloadCount;
|
||||||
if (isSRTMItem(item)) {
|
if (SrtmDownloadItem.isSRTMItem(item)) {
|
||||||
List<IndexItem> items = new ArrayList<>();
|
List<IndexItem> items = new ArrayList<>();
|
||||||
for (IndexItem indexItem : item.getAllIndexes()) {
|
for (IndexItem indexItem : item.getAllIndexes()) {
|
||||||
boolean baseItem = isBaseSRTMItem(indexItem);
|
boolean baseItem = SrtmDownloadItem.isMetersItem(indexItem);
|
||||||
if (baseMetricSystem && baseItem || !baseMetricSystem && !baseItem) {
|
if (baseMetricSystem && baseItem || !baseMetricSystem && !baseItem) {
|
||||||
items.add(indexItem);
|
items.add(indexItem);
|
||||||
}
|
}
|
||||||
|
@ -229,7 +226,7 @@ public class ItemViewHolder {
|
||||||
allRegionsCount = String.valueOf(items.size());
|
allRegionsCount = String.valueOf(items.size());
|
||||||
items.clear();
|
items.clear();
|
||||||
for (IndexItem indexItem : item.getIndexesToDownload()) {
|
for (IndexItem indexItem : item.getIndexesToDownload()) {
|
||||||
boolean baseItem = isBaseSRTMItem(indexItem);
|
boolean baseItem = SrtmDownloadItem.isMetersItem(indexItem);
|
||||||
if (!indexItem.isDownloaded()
|
if (!indexItem.isDownloaded()
|
||||||
&& (baseMetricSystem && baseItem || !baseMetricSystem && !baseItem)) {
|
&& (baseMetricSystem && baseItem || !baseMetricSystem && !baseItem)) {
|
||||||
items.add(indexItem);
|
items.add(indexItem);
|
||||||
|
@ -259,7 +256,7 @@ public class ItemViewHolder {
|
||||||
}
|
}
|
||||||
String fullDescription = context.getString(R.string.ltr_or_rtl_combine_via_colon, header, count);
|
String fullDescription = context.getString(R.string.ltr_or_rtl_combine_via_colon, header, count);
|
||||||
if (srtmItem) {
|
if (srtmItem) {
|
||||||
fullDescription += " (" + getSRTMAbbrev(context, baseMetricSystem) + ")";
|
fullDescription += " (" + SrtmDownloadItem.getAbbreviation(context, baseMetricSystem) + ")";
|
||||||
}
|
}
|
||||||
if (item.hasActualDataToDownload()) {
|
if (item.hasActualDataToDownload()) {
|
||||||
fullDescription = context.getString(
|
fullDescription = context.getString(
|
||||||
|
@ -267,14 +264,23 @@ public class ItemViewHolder {
|
||||||
? item.getSizeDescription(context, baseMetricSystem) : item.getSizeDescription(context));
|
? item.getSizeDescription(context, baseMetricSystem) : item.getSizeDescription(context));
|
||||||
}
|
}
|
||||||
descrTextView.setText(fullDescription);
|
descrTextView.setText(fullDescription);
|
||||||
|
} else if (downloadItem instanceof SrtmDownloadItem) {
|
||||||
|
SrtmDownloadItem item = (SrtmDownloadItem) downloadItem;
|
||||||
|
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)) + ")";
|
||||||
|
String date = item.getDate(dateFormat, showRemoteDate);
|
||||||
|
String fullDescription = String.format(pattern, size, date);
|
||||||
|
if (showTypeInDesc) {
|
||||||
|
fullDescription = String.format(pattern, type, fullDescription);
|
||||||
|
}
|
||||||
|
descrTextView.setText(fullDescription);
|
||||||
} else {
|
} else {
|
||||||
IndexItem item = (IndexItem) downloadItem;
|
IndexItem item = (IndexItem) downloadItem;
|
||||||
String pattern = context.getString(R.string.ltr_or_rtl_combine_via_bold_point);
|
String pattern = context.getString(R.string.ltr_or_rtl_combine_via_bold_point);
|
||||||
String type = item.getType().getString(context);
|
String type = item.getType().getString(context);
|
||||||
String size = item.getSizeDescription(context);
|
String size = item.getSizeDescription(context);
|
||||||
if (srtmItem) {
|
|
||||||
size += " (" + getSRTMAbbrev(context, isBaseSRTMItem(item)) + ")";
|
|
||||||
}
|
|
||||||
String date = item.getDate(dateFormat, showRemoteDate);
|
String date = item.getDate(dateFormat, showRemoteDate);
|
||||||
String fullDescription = String.format(pattern, size, date);
|
String fullDescription = String.format(pattern, size, date);
|
||||||
if (showTypeInDesc) {
|
if (showTypeInDesc) {
|
||||||
|
@ -522,8 +528,7 @@ public class ItemViewHolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectIndexesToDownload(DownloadItem item) {
|
private void selectIndexesToDownload(DownloadItem item) {
|
||||||
OsmandApplication app = context.getMyApplication();
|
SelectIndexesUiHelper.showDialog(item, context, dateFormat, showRemoteDate,
|
||||||
SelectIndexesUiHelper.showDialog(item, context, app, dateFormat, showRemoteDate,
|
|
||||||
new SelectItemsToDownloadListener() {
|
new SelectItemsToDownloadListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemsToDownloadSelected(List<IndexItem> indexes) {
|
public void onItemsToDownloadSelected(List<IndexItem> indexes) {
|
||||||
|
|
|
@ -55,6 +55,7 @@ import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||||
import net.osmand.plus.download.DownloadActivity;
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
|
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
|
||||||
import net.osmand.plus.download.IndexItem;
|
import net.osmand.plus.download.IndexItem;
|
||||||
|
import net.osmand.plus.download.SrtmDownloadItem;
|
||||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||||
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||||
import net.osmand.plus.mapsource.EditMapSourceDialogFragment.OnMapSourceUpdateListener;
|
import net.osmand.plus.mapsource.EditMapSourceDialogFragment.OnMapSourceUpdateListener;
|
||||||
|
@ -74,9 +75,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static net.osmand.plus.download.DownloadActivityType.isSRTMItem;
|
|
||||||
import static net.osmand.plus.download.SelectIndexesUiHelper.getSRTMAbbrev;
|
|
||||||
import static net.osmand.plus.download.SelectIndexesUiHelper.isBaseSRTMItem;
|
|
||||||
|
|
||||||
public class LocalIndexesFragment extends OsmandExpandableListFragment implements DownloadEvents,
|
public class LocalIndexesFragment extends OsmandExpandableListFragment implements DownloadEvents,
|
||||||
OnMapSourceUpdateListener, RenameCallback {
|
OnMapSourceUpdateListener, RenameCallback {
|
||||||
|
@ -1034,8 +1032,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
builder.append(AndroidUtils.formatSize(ctx, child.getSize() * 1024l));
|
builder.append(AndroidUtils.formatSize(ctx, child.getSize() * 1024l));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSRTMItem(child)) {
|
if (SrtmDownloadItem.isSRTMItem(child)) {
|
||||||
builder.append(" (").append(getSRTMAbbrev(ctx, isBaseSRTMItem(child))).append(")");
|
builder.append(" (").append(SrtmDownloadItem.getAbbreviation(ctx, SrtmDownloadItem.isMetersItem(child))).append(")");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Algorithms.isEmpty(child.getDescription())) {
|
if (!Algorithms.isEmpty(child.getDescription())) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ import net.osmand.plus.UiUtilities;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MultiStateToggleButton {
|
public class MultiStateToggleButton {
|
||||||
|
@ -37,6 +38,13 @@ public class MultiStateToggleButton {
|
||||||
this.nightMode = nightMode;
|
this.nightMode = nightMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setItems(Collection<RadioItem> radioItems) {
|
||||||
|
if (radioItems == null || radioItems.size() < 2) return;
|
||||||
|
items.clear();
|
||||||
|
items.addAll(radioItems);
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
public void setItems(RadioItem firstBtn, RadioItem secondBtn, RadioItem... other) {
|
public void setItems(RadioItem firstBtn, RadioItem secondBtn, RadioItem... other) {
|
||||||
items.clear();
|
items.clear();
|
||||||
items.add(firstBtn);
|
items.add(firstBtn);
|
||||||
|
|
Loading…
Reference in a new issue