add srtm map download option, refactoring p1
This commit is contained in:
parent
ac3aeacca1
commit
b14f62822b
10 changed files with 121 additions and 121 deletions
|
@ -331,15 +331,16 @@ public class LocalIndexHelper {
|
||||||
if (mapPath.canRead()) {
|
if (mapPath.canRead()) {
|
||||||
for (File mapFile : listFilesSorted(mapPath)) {
|
for (File mapFile : listFilesSorted(mapPath)) {
|
||||||
if (mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
|
if (mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
|
||||||
|
String fileName = mapFile.getName();
|
||||||
LocalIndexType lt = LocalIndexType.MAP_DATA;
|
LocalIndexType lt = LocalIndexType.MAP_DATA;
|
||||||
if (mapFile.getName().endsWith(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT)
|
if (fileName.endsWith(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT)
|
||||||
|| mapFile.getName().endsWith(IndexConstants.BINARY_SRTM_FEET_MAP_INDEX_EXT)) {
|
|| fileName.endsWith(IndexConstants.BINARY_SRTM_FEET_MAP_INDEX_EXT)) {
|
||||||
lt = LocalIndexType.SRTM_DATA;
|
lt = LocalIndexType.SRTM_DATA;
|
||||||
} else if (mapFile.getName().endsWith(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT)) {
|
} else if (fileName.endsWith(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT)) {
|
||||||
lt = LocalIndexType.WIKI_DATA;
|
lt = LocalIndexType.WIKI_DATA;
|
||||||
}
|
}
|
||||||
LocalIndexInfo info = new LocalIndexInfo(lt, mapFile, backup, app);
|
LocalIndexInfo info = new LocalIndexInfo(lt, mapFile, backup, app);
|
||||||
if (loadedMaps.containsKey(mapFile.getName()) && !backup) {
|
if (loadedMaps.containsKey(fileName) && !backup) {
|
||||||
info.setLoaded(true);
|
info.setLoaded(true);
|
||||||
}
|
}
|
||||||
updateDescription(info);
|
updateDescription(info);
|
||||||
|
|
|
@ -70,42 +70,6 @@ public class SelectMultipleItemsBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
private OnRadioButtonSelectListener onRadioButtonSelectListener;
|
private OnRadioButtonSelectListener onRadioButtonSelectListener;
|
||||||
private SelectedItemsListener selectedItemsListener;
|
private SelectedItemsListener selectedItemsListener;
|
||||||
|
|
||||||
public static SelectMultipleItemsBottomSheet showInstance(@NonNull AppCompatActivity activity,
|
|
||||||
@NonNull List<SelectableItem> items,
|
|
||||||
@Nullable List<SelectableItem> selected,
|
|
||||||
boolean usedOnMap) {
|
|
||||||
SelectMultipleItemsBottomSheet fragment = new SelectMultipleItemsBottomSheet();
|
|
||||||
fragment.setUsedOnMap(usedOnMap);
|
|
||||||
fragment.setItems(items);
|
|
||||||
fragment.setSelectedItems(selected);
|
|
||||||
FragmentManager fm = activity.getSupportFragmentManager();
|
|
||||||
fragment.show(fm, TAG);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SelectMultipleItemsBottomSheet showInstance(@NonNull AppCompatActivity activity,
|
|
||||||
@NonNull List<SelectableItem> items,
|
|
||||||
@Nullable List<SelectableItem> selected,
|
|
||||||
boolean usedOnMap,
|
|
||||||
String addDescription,
|
|
||||||
boolean customOptionsVisible,
|
|
||||||
boolean leftButtonSelected,
|
|
||||||
String leftRadioButtonText,
|
|
||||||
String rightRadioButtonText) {
|
|
||||||
SelectMultipleItemsBottomSheet fragment = new SelectMultipleItemsBottomSheet();
|
|
||||||
fragment.setUsedOnMap(usedOnMap);
|
|
||||||
fragment.setItems(items);
|
|
||||||
fragment.setSelectedItems(selected);
|
|
||||||
fragment.setAddDescriptionText(addDescription);
|
|
||||||
fragment.setCustomOptionsVisible(customOptionsVisible);
|
|
||||||
fragment.setLeftButtonSelected(leftButtonSelected);
|
|
||||||
fragment.setLeftRadioButtonText(leftRadioButtonText);
|
|
||||||
fragment.setRightRadioButtonText(rightRadioButtonText);
|
|
||||||
FragmentManager fm = activity.getSupportFragmentManager();
|
|
||||||
fragment.show(fm, TAG);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
|
||||||
|
@ -392,6 +356,66 @@ public class SelectMultipleItemsBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
this.selectedItemsListener = selectedItemsListener;
|
this.selectedItemsListener = selectedItemsListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setupRightButton() {
|
||||||
|
super.setupRightButton();
|
||||||
|
applyButtonTitle = rightButton.findViewById(R.id.button_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRightBottomButtonClick() {
|
||||||
|
if (onApplySelectionListener != null) {
|
||||||
|
onApplySelectionListener.onSelectionApplied(selectedItems);
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getRightBottomButtonTextId() {
|
||||||
|
return R.string.shared_string_apply;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean useVerticalButtons() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SelectMultipleItemsBottomSheet showInstance(@NonNull AppCompatActivity activity,
|
||||||
|
@NonNull List<SelectableItem> items,
|
||||||
|
@Nullable List<SelectableItem> selected,
|
||||||
|
boolean usedOnMap) {
|
||||||
|
SelectMultipleItemsBottomSheet fragment = new SelectMultipleItemsBottomSheet();
|
||||||
|
fragment.setUsedOnMap(usedOnMap);
|
||||||
|
fragment.setItems(items);
|
||||||
|
fragment.setSelectedItems(selected);
|
||||||
|
FragmentManager fm = activity.getSupportFragmentManager();
|
||||||
|
fragment.show(fm, TAG);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SelectMultipleItemsBottomSheet showInstance(@NonNull AppCompatActivity activity,
|
||||||
|
@NonNull List<SelectableItem> items,
|
||||||
|
@Nullable List<SelectableItem> selected,
|
||||||
|
boolean usedOnMap,
|
||||||
|
String addDescription,
|
||||||
|
boolean customOptionsVisible,
|
||||||
|
boolean leftButtonSelected,
|
||||||
|
String leftRadioButtonText,
|
||||||
|
String rightRadioButtonText) {
|
||||||
|
SelectMultipleItemsBottomSheet fragment = new SelectMultipleItemsBottomSheet();
|
||||||
|
fragment.setUsedOnMap(usedOnMap);
|
||||||
|
fragment.setItems(items);
|
||||||
|
fragment.setSelectedItems(selected);
|
||||||
|
fragment.setAddDescriptionText(addDescription);
|
||||||
|
fragment.setCustomOptionsVisible(customOptionsVisible);
|
||||||
|
fragment.setLeftButtonSelected(leftButtonSelected);
|
||||||
|
fragment.setLeftRadioButtonText(leftRadioButtonText);
|
||||||
|
fragment.setRightRadioButtonText(rightRadioButtonText);
|
||||||
|
FragmentManager fm = activity.getSupportFragmentManager();
|
||||||
|
fragment.show(fm, TAG);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
public interface SelectionUpdateListener {
|
public interface SelectionUpdateListener {
|
||||||
void onSelectionUpdate();
|
void onSelectionUpdate();
|
||||||
}
|
}
|
||||||
|
@ -435,27 +459,4 @@ public class SelectMultipleItemsBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setupRightButton() {
|
|
||||||
super.setupRightButton();
|
|
||||||
applyButtonTitle = rightButton.findViewById(R.id.button_text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onRightBottomButtonClick() {
|
|
||||||
if (onApplySelectionListener != null) {
|
|
||||||
onApplySelectionListener.onSelectionApplied(selectedItems);
|
|
||||||
}
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getRightBottomButtonTextId() {
|
|
||||||
return R.string.shared_string_apply;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean useVerticalButtons() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,9 +207,6 @@ public class DownloadOsmandIndexesHelper {
|
||||||
if (next == XmlPullParser.START_TAG) {
|
if (next == XmlPullParser.START_TAG) {
|
||||||
DownloadActivityType tp = DownloadActivityType.getIndexType(parser.getAttributeValue(null, "type"));
|
DownloadActivityType tp = DownloadActivityType.getIndexType(parser.getAttributeValue(null, "type"));
|
||||||
if (tp != null) {
|
if (tp != null) {
|
||||||
if (tp == DownloadActivityType.SRTM_COUNTRY_FILE) {
|
|
||||||
log.debug("strUrl = " + strUrl);
|
|
||||||
}
|
|
||||||
IndexItem it = tp.parseIndexItem(ctx, parser);
|
IndexItem it = tp.parseIndexItem(ctx, parser);
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
result.add(it);
|
result.add(it);
|
||||||
|
|
|
@ -139,4 +139,5 @@ public class MultipleIndexItem extends DownloadItem {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,8 +216,8 @@ public class ItemViewHolder {
|
||||||
MultipleIndexItem item = (MultipleIndexItem) downloadItem;
|
MultipleIndexItem item = (MultipleIndexItem) downloadItem;
|
||||||
String allRegionsHeader = context.getString(R.string.shared_strings_all_regions);
|
String allRegionsHeader = context.getString(R.string.shared_strings_all_regions);
|
||||||
String regionsHeader = context.getString(R.string.regions);
|
String regionsHeader = context.getString(R.string.regions);
|
||||||
String allRegionsCountStr;
|
String allRegionsCount;
|
||||||
String leftToDownloadCountStr;
|
String leftToDownloadCount;
|
||||||
if (isSRTMItem(item)) {
|
if (isSRTMItem(item)) {
|
||||||
List<IndexItem> items = new ArrayList<>();
|
List<IndexItem> items = new ArrayList<>();
|
||||||
for (IndexItem indexItem : item.getAllIndexes()) {
|
for (IndexItem indexItem : item.getAllIndexes()) {
|
||||||
|
@ -226,7 +226,7 @@ public class ItemViewHolder {
|
||||||
items.add(indexItem);
|
items.add(indexItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
allRegionsCountStr = 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 = isBaseSRTMItem(indexItem);
|
||||||
|
@ -235,27 +235,27 @@ public class ItemViewHolder {
|
||||||
items.add(indexItem);
|
items.add(indexItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
leftToDownloadCountStr = String.valueOf(items.size());
|
leftToDownloadCount = String.valueOf(items.size());
|
||||||
} else {
|
} else {
|
||||||
allRegionsCountStr = String.valueOf(item.getAllIndexes().size());
|
allRegionsCount = String.valueOf(item.getAllIndexes().size());
|
||||||
leftToDownloadCountStr = String.valueOf(item.getIndexesToDownload().size());
|
leftToDownloadCount = String.valueOf(item.getIndexesToDownload().size());
|
||||||
}
|
}
|
||||||
String header;
|
String header;
|
||||||
String count;
|
String count;
|
||||||
if (item.hasActualDataToDownload()) {
|
if (item.hasActualDataToDownload()) {
|
||||||
if (!item.isDownloaded()) {
|
if (!item.isDownloaded()) {
|
||||||
header = allRegionsHeader;
|
header = allRegionsHeader;
|
||||||
count = leftToDownloadCountStr;
|
count = leftToDownloadCount;
|
||||||
} else {
|
} else {
|
||||||
header = regionsHeader;
|
header = regionsHeader;
|
||||||
count = String.format(
|
count = String.format(
|
||||||
context.getString(R.string.ltr_or_rtl_combine_via_slash),
|
context.getString(R.string.ltr_or_rtl_combine_via_slash),
|
||||||
leftToDownloadCountStr,
|
leftToDownloadCount,
|
||||||
allRegionsCountStr);
|
allRegionsCount);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
header = allRegionsHeader;
|
header = allRegionsHeader;
|
||||||
count = allRegionsCountStr;
|
count = allRegionsCount;
|
||||||
}
|
}
|
||||||
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) {
|
||||||
|
|
Loading…
Reference in a new issue