From 9368b7383a5647e285748c63a9db65bdd8d04b5f Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Mon, 12 Apr 2021 20:14:27 +0300 Subject: [PATCH] Refactoring SRTMf download ui, part 1 --- .../plus/base/SelectModeBottomSheet.java | 96 ++++ .../base/SelectMultipleItemsBottomSheet.java | 445 ++++-------------- .../SelectMultipleWithModeBottomSheet.java | 51 ++ .../plus/base/SelectionBottomSheet.java | 201 ++++++++ .../plus/download/DownloadActivityType.java | 2 +- .../plus/download/MultipleIndexItem.java | 2 +- ...Helper.java => SelectIndexesUiHelper.java} | 222 ++++++--- .../plus/download/ui/ItemViewHolder.java | 12 +- .../download/ui/LocalIndexesFragment.java | 4 +- 9 files changed, 600 insertions(+), 435 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/base/SelectModeBottomSheet.java create mode 100644 OsmAnd/src/net/osmand/plus/base/SelectMultipleWithModeBottomSheet.java create mode 100644 OsmAnd/src/net/osmand/plus/base/SelectionBottomSheet.java rename OsmAnd/src/net/osmand/plus/download/{MultipleIndexesUiHelper.java => SelectIndexesUiHelper.java} (52%) diff --git a/OsmAnd/src/net/osmand/plus/base/SelectModeBottomSheet.java b/OsmAnd/src/net/osmand/plus/base/SelectModeBottomSheet.java new file mode 100644 index 0000000000..f1ecf92743 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/base/SelectModeBottomSheet.java @@ -0,0 +1,96 @@ +package net.osmand.plus.base; + +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.FragmentManager; + +import net.osmand.AndroidUtils; +import net.osmand.plus.R; +import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; +import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.widgets.MultiStateToggleButton.RadioItem; + +import java.util.Collections; +import java.util.List; + +public class SelectModeBottomSheet extends SelectionBottomSheet { + + public static final String TAG = SelectModeBottomSheet.class.getSimpleName(); + + private BottomSheetItemWithDescription previewUi; + + private List modes; + private SelectableItem previewItem; + + @Override + protected void initHeaderUi() { + radioGroup.setItems(modes); + + AndroidUiHelper.setVisibility(View.VISIBLE, secondaryDescription, toggleContainer); + + AndroidUiHelper.setVisibility(View.GONE, checkBox, checkBoxTitle, + primaryDescription, selectedSize, selectAllButton); + } + + @Override + protected void createSelectionUi() { + previewUi = (BottomSheetItemWithDescription) new BottomSheetItemWithDescription.Builder() + .setDescription(previewItem.getDescription()) + .setDescriptionColorId(AndroidUtils.getSecondaryTextColorId(nightMode)) + .setTitle(previewItem.getTitle()) + .setIcon(uiUtilities.getIcon(previewItem.getIconId(), activeColorRes)) + .setTag(previewItem) + .setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp) + .create(); + items.add(previewUi); + } + + private void updatePreviewUi() { + previewUi.setTitle(previewItem.getTitle()); + previewUi.setIcon(uiUtilities.getIcon(previewItem.getIconId(), activeColorRes)); + previewUi.setDescription(previewItem.getDescription()); + previewUi.setTag(previewItem); + } + + private void setModes(@NonNull List modes) { + this.modes = modes; + } + + public void setSelectedMode(@NonNull RadioItem mode) { + radioGroup.setSelectedItem(mode); + } + + public void setPreviewItem(@NonNull SelectableItem preview) { + this.previewItem = preview; + if (previewUi != null) { + updatePreviewUi(); + } + } + + @Override + public void setDescription(@NonNull String description) { + secondaryDescription.setText(description); + } + + @NonNull + @Override + public List getSelection() { + return Collections.singletonList(previewItem); + } + + public static SelectModeBottomSheet showInstance(@NonNull AppCompatActivity activity, + @NonNull SelectableItem previewItem, + @NonNull List radioItems, + boolean usedOnMap) { + SelectModeBottomSheet fragment = new SelectModeBottomSheet(); + fragment.setUsedOnMap(usedOnMap); + fragment.setModes(radioItems); + fragment.setPreviewItem(previewItem); + FragmentManager fm = activity.getSupportFragmentManager(); + fragment.show(fm, TAG); + return fragment; + } + +} diff --git a/OsmAnd/src/net/osmand/plus/base/SelectMultipleItemsBottomSheet.java b/OsmAnd/src/net/osmand/plus/base/SelectMultipleItemsBottomSheet.java index 7629f80169..ab8ae1f3e9 100644 --- a/OsmAnd/src/net/osmand/plus/base/SelectMultipleItemsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/base/SelectMultipleItemsBottomSheet.java @@ -1,12 +1,7 @@ package net.osmand.plus.base; import android.content.res.ColorStateList; -import android.os.Bundle; -import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; -import android.widget.LinearLayout; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -16,22 +11,11 @@ import androidx.core.widget.CompoundButtonCompat; import androidx.fragment.app.FragmentManager; import net.osmand.AndroidUtils; -import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; -import net.osmand.plus.UiUtilities; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton.Builder; -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.MultipleIndexesUiHelper.SelectedItemsListener; -import net.osmand.plus.helpers.AndroidUiHelper; -import net.osmand.plus.widgets.MultiStateToggleButton; -import net.osmand.plus.widgets.MultiStateToggleButton.OnRadioItemClickListener; -import net.osmand.plus.widgets.MultiStateToggleButton.RadioItem; import net.osmand.util.Algorithms; -import net.osmand.view.ThreeStateCheckbox; import java.util.ArrayList; import java.util.List; @@ -40,180 +24,68 @@ import static net.osmand.view.ThreeStateCheckbox.State.CHECKED; import static net.osmand.view.ThreeStateCheckbox.State.MISC; import static net.osmand.view.ThreeStateCheckbox.State.UNCHECKED; -public class SelectMultipleItemsBottomSheet extends MenuBottomSheetDialogFragment { +public class SelectMultipleItemsBottomSheet extends SelectionBottomSheet { public static final String TAG = SelectMultipleItemsBottomSheet.class.getSimpleName(); - private OsmandApplication app; - private UiUtilities uiUtilities; - - private TextView title; - private TextView description; - private TextView applyButtonTitle; - private TextView checkBoxTitle; - private TextView selectedSize; - private ThreeStateCheckbox checkBox; - - private int sizeAboveList = 0; - private int activeColorRes; - private int secondaryColorRes; - private String addDescriptionText; - private String leftRadioButtonText; - private String rightRadioButtonText; - private boolean customOptionsVisible; - private boolean leftButtonSelected; - private final List allItems = new ArrayList<>(); private final List selectedItems = new ArrayList<>(); private SelectionUpdateListener selectionUpdateListener; - private OnApplySelectionListener onApplySelectionListener; - private OnRadioButtonSelectListener onRadioButtonSelectListener; - private SelectedItemsListener selectedItemsListener; - - @Nullable - @Override - public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { - View mainView = super.onCreateView(inflater, parent, savedInstanceState); - onSelectedItemsChanged(); - return mainView; - } @Override - public void createMenuItems(Bundle savedInstanceState) { - app = requiredMyApplication(); - uiUtilities = app.getUIUtilities(); - activeColorRes = nightMode ? R.color.icon_color_active_dark : R.color.icon_color_active_light; - secondaryColorRes = nightMode ? R.color.icon_color_secondary_dark : R.color.icon_color_secondary_light; - - items.add(createTitleItem()); - items.add(new SimpleDividerItem(app)); - sizeAboveList = items.size(); - createListItems(); - } - - @Override - public void onPause() { - super.onPause(); - if (requireActivity().isChangingConfigurations()) { - dismiss(); - } - } - - private BaseBottomSheetItem createTitleItem() { - LayoutInflater themedInflater = UiUtilities.getInflater(requireContext(), nightMode); - View view = themedInflater.inflate(R.layout.settings_group_title, null); - - checkBox = view.findViewById(R.id.check_box); - checkBoxTitle = view.findViewById(R.id.check_box_title); - description = view.findViewById(R.id.description); - selectedSize = view.findViewById(R.id.selected_size); - title = view.findViewById(R.id.title); - View selectAllButton = view.findViewById(R.id.select_all_button); - TextView addDescription = view.findViewById(R.id.additional_description); - LinearLayout customRadioButtons = view.findViewById(R.id.custom_radio_buttons); - - if (!isMultipleItem()) { - AndroidUiHelper.setVisibility(View.GONE, description, selectedSize, selectAllButton); - } else { - selectAllButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - checkBox.performClick(); - boolean checked = checkBox.getState() == CHECKED; - if (checked) { - selectedItems.addAll(allItems); - } else { - selectedItems.clear(); - } - onSelectedItemsChanged(); - updateItems(checked); + protected void initHeaderUi() { + selectAllButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + checkBox.performClick(); + boolean checked = checkBox.getState() == CHECKED; + if (checked) { + selectedItems.addAll(allItems); + } else { + selectedItems.clear(); } - }); - } - - if (!Algorithms.isEmpty(addDescriptionText)) { - addDescription.setText(addDescriptionText); - AndroidUiHelper.setVisibility(View.VISIBLE, addDescription); - } - - if (customOptionsVisible) { - AndroidUiHelper.setVisibility(View.VISIBLE, customRadioButtons); - RadioItem leftRadioButton = new RadioItem(leftRadioButtonText); - RadioItem rightRadioButton = new RadioItem(rightRadioButtonText); - MultiStateToggleButton toggleButtons = - new MultiStateToggleButton(app, customRadioButtons, nightMode); - toggleButtons.setItems(leftRadioButton, rightRadioButton); - toggleButtons.updateView(true); - leftRadioButton.setOnClickListener(new OnRadioItemClickListener() { - @Override - public boolean onRadioItemClick(RadioItem radioItem, View view) { - onRadioButtonSelectListener.onSelect(leftButtonSelected = true); - updateSelectedSizeView(); - updateSelectAllButton(); - updateApplyButtonEnable(); - return true; - } - }); - rightRadioButton.setOnClickListener(new OnRadioItemClickListener() { - @Override - public boolean onRadioItemClick(RadioItem radioItem, View view) { - onRadioButtonSelectListener.onSelect(leftButtonSelected = false); - updateSelectedSizeView(); - updateSelectAllButton(); - updateApplyButtonEnable(); - return true; - } - }); - toggleButtons.setSelectedItem(leftButtonSelected ? leftRadioButton : rightRadioButton); - } - - return new SimpleBottomSheetItem.Builder().setCustomView(view).create(); - } - - private void createListItems() { - if (isMultipleItem()) { - for (int i = 0; i < allItems.size(); i++) { - final SelectableItem item = allItems.get(i); - boolean checked = selectedItems.contains(item); - final int finalI = i; - items.add(new Builder() - .setChecked(checked) - .setButtonTintList(AndroidUtils.createCheckedColorStateList(app, secondaryColorRes, activeColorRes)) - .setDescription(item.description) - .setIcon(uiUtilities.getIcon(item.iconId, activeColorRes)) - .setTitle(item.title) - .setLayoutId(R.layout.bottom_sheet_item_with_descr_and_checkbox_56dp) - .setTag(item) - .setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - BottomSheetItemWithCompoundButton item = (BottomSheetItemWithCompoundButton) items.get(finalI + sizeAboveList); - boolean checked = item.isChecked(); - item.setChecked(!checked); - SelectableItem tag = (SelectableItem) item.getTag(); - if (!checked) { - selectedItems.add(tag); - } else { - selectedItems.remove(tag); - } - onSelectedItemsChanged(); - } - }) - .create()); + onSelectedItemsChanged(); + updateItems(checked); } - } else if (allItems.size() == 1) { - final SelectableItem item = allItems.get(0); - items.add(new Builder() - .setDescription(item.description) - .setDescriptionColorId(AndroidUtils.getSecondaryTextColorId(nightMode)) - .setIcon(uiUtilities.getIcon(item.iconId, activeColorRes)) - .setTitle(item.title) - .setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp) - .setTag(item) - .create()); + }); + } + + @Override + protected void createSelectionUi() { + for (final SelectableItem item : allItems) { + boolean checked = selectedItems.contains(item); + final BottomSheetItemWithCompoundButton[] uiItem = new BottomSheetItemWithCompoundButton[1]; + final Builder builder = (BottomSheetItemWithCompoundButton.Builder) new Builder(); + builder.setChecked(checked) + .setButtonTintList(AndroidUtils.createCheckedColorStateList(app, secondaryColorRes, activeColorRes)) + .setLayoutId(R.layout.bottom_sheet_item_with_descr_and_checkbox_56dp) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + boolean checked = !uiItem[0].isChecked(); + uiItem[0].setChecked(checked); + SelectableItem tag = (SelectableItem) uiItem[0].getTag(); + if (checked) { + selectedItems.add(tag); + } else { + selectedItems.remove(tag); + } + onSelectedItemsChanged(); + } + }) + .setTag(item); + setupListItem(builder, item); + uiItem[0] = builder.create(); + items.add(uiItem[0]); } } + @Override + protected void notifyUiInitialized() { + onSelectedItemsChanged(); + super.notifyUiInitialized(); + } + private void onSelectedItemsChanged() { updateSelectAllButton(); updateSelectedSizeView(); @@ -223,32 +95,38 @@ public class SelectMultipleItemsBottomSheet extends MenuBottomSheetDialogFragmen } } + private void setupListItem(Builder builder, SelectableItem item) { + builder.setTitle(item.getTitle()); + builder.setDescription(item.getDescription()); + builder.setIcon(uiUtilities.getIcon(item.getIconId(), activeColorRes)); + } + private void updateSelectAllButton() { - if (isMultipleItem()) { - String checkBoxTitle; - if (Algorithms.isEmpty(selectedItems)) { - checkBox.setState(UNCHECKED); - checkBoxTitle = getString(R.string.shared_string_select_all); - } else { - checkBox.setState(selectedItems.containsAll(allItems) ? CHECKED : MISC); - checkBoxTitle = getString(R.string.shared_string_deselect_all); - } - int checkBoxColor = checkBox.getState() == UNCHECKED ? secondaryColorRes : activeColorRes; - CompoundButtonCompat.setButtonTintList(checkBox, ColorStateList.valueOf(ContextCompat.getColor(app, checkBoxColor))); - this.checkBoxTitle.setText(checkBoxTitle); + String checkBoxTitle; + if (Algorithms.isEmpty(selectedItems)) { + checkBox.setState(UNCHECKED); + checkBoxTitle = getString(R.string.shared_string_select_all); + } else { + checkBox.setState(selectedItems.containsAll(allItems) ? CHECKED : MISC); + checkBoxTitle = getString(R.string.shared_string_deselect_all); } + int checkBoxColor = checkBox.getState() == UNCHECKED ? secondaryColorRes : activeColorRes; + CompoundButtonCompat.setButtonTintList(checkBox, ColorStateList.valueOf(ContextCompat.getColor(app, checkBoxColor))); + this.checkBoxTitle.setText(checkBoxTitle); } private void updateSelectedSizeView() { - if (isMultipleItem()) { - String selected = String.valueOf(selectedItems.size()); - String all = String.valueOf(allItems.size()); - selectedSize.setText(getString(R.string.ltr_or_rtl_combine_via_slash, selected, all)); - } + String selected = String.valueOf(selectedItems.size()); + String all = String.valueOf(allItems.size()); + selectedSize.setText(getString(R.string.ltr_or_rtl_combine_via_slash, selected, all)); } private void updateApplyButtonEnable() { - rightButton.setEnabled(!Algorithms.isEmpty(selectedItems)); + if (Algorithms.isEmpty(selectedItems)) { + rightButton.setEnabled(false); + } else { + rightButton.setEnabled(true); + } } private void updateItems(boolean checked) { @@ -259,127 +137,30 @@ public class SelectMultipleItemsBottomSheet extends MenuBottomSheetDialogFragmen } } - public void setItems(List allItems) { - this.allItems.clear(); + protected void setItems(List allItems) { if (!Algorithms.isEmpty(allItems)) { + this.allItems.clear(); this.allItems.addAll(allItems); } } - private void setSelectedItems(List selected) { - this.selectedItems.clear(); + protected void setSelectedItems(List selected) { if (!Algorithms.isEmpty(selected)) { - /*List prevDownloadItems = new ArrayList<>(this.selectedItems); - for (SelectableItem prevDownloadItem : selected) { - Object object = prevDownloadItem.getObject(); - if (object instanceof IndexItem && ((IndexItem) object).isDownloaded()) { - prevDownloadItems.add(prevDownloadItem); - } - } - selected.removeAll(prevDownloadItems);*/ - this.selectedItems.addAll(selected); + selectedItems.clear(); + selectedItems.addAll(selected); } } - public void recreateList(List allItems) { - setItems(allItems); - if (selectedItemsListener != null) { - setSelectedItems(selectedItemsListener.createSelectedItems(this.allItems, leftButtonSelected)); - } - if (items.size() > sizeAboveList) { - for (int i = 0; i < this.allItems.size(); i++) { - SelectableItem item = this.allItems.get(i); - BottomSheetItemWithDescription button = (BottomSheetItemWithDescription) items.get(i + sizeAboveList); - button.setDescription(item.description); - button.setTitle(item.title); - button.setTag(item); - if (isMultipleItem()) { - ((BottomSheetItemWithCompoundButton) button).setChecked(selectedItems.contains(item)); - } - } - } - } - - public boolean isMultipleItem() { - return allItems.size() > 1; - } - - public List getSelectedItems() { + @NonNull + @Override + public List getSelection() { return selectedItems; } - public void setConfirmButtonTitle(@NonNull String confirmButtonTitle) { - applyButtonTitle.setText(confirmButtonTitle); - } - - public void setTitle(@NonNull String title) { - this.title.setText(title); - } - - public void setDescription(@NonNull String description) { - this.description.setText(description); - } - - public void setAddDescriptionText(String addDescriptionText) { - this.addDescriptionText = addDescriptionText; - } - - public void setLeftRadioButtonText(String leftRadioButtonText) { - this.leftRadioButtonText = leftRadioButtonText; - } - - public void setRightRadioButtonText(String rightRadioButtonText) { - this.rightRadioButtonText = rightRadioButtonText; - } - - public void setCustomOptionsVisible(boolean customOptionsVisible) { - this.customOptionsVisible = customOptionsVisible; - } - - public void setLeftButtonSelected(boolean leftButtonSelected) { - this.leftButtonSelected = leftButtonSelected; - } - public void setSelectionUpdateListener(SelectionUpdateListener selectionUpdateListener) { this.selectionUpdateListener = selectionUpdateListener; } - public void setOnApplySelectionListener(OnApplySelectionListener onApplySelectionListener) { - this.onApplySelectionListener = onApplySelectionListener; - } - - public void setOnRadioButtonSelectListener(OnRadioButtonSelectListener onRadioButtonSelectListener) { - this.onRadioButtonSelectListener = onRadioButtonSelectListener; - } - - public void setSelectedItemsListener(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 items, @Nullable List selected, @@ -393,70 +174,8 @@ public class SelectMultipleItemsBottomSheet extends MenuBottomSheetDialogFragmen return fragment; } - public static SelectMultipleItemsBottomSheet showInstance(@NonNull AppCompatActivity activity, - @NonNull List items, - @Nullable List 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 { void onSelectionUpdate(); } - public interface OnApplySelectionListener { - void onSelectionApplied(List selectedItems); - } - - public interface OnRadioButtonSelectListener { - void onSelect(boolean leftButton); - } - - public static class SelectableItem { - private String title; - private String description; - private int iconId; - private Object object; - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public void setIconId(int iconId) { - this.iconId = iconId; - } - - public void setObject(Object object) { - this.object = object; - } - - public Object getObject() { - return object; - } - } - -} +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/base/SelectMultipleWithModeBottomSheet.java b/OsmAnd/src/net/osmand/plus/base/SelectMultipleWithModeBottomSheet.java new file mode 100644 index 0000000000..5aee912d0d --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/base/SelectMultipleWithModeBottomSheet.java @@ -0,0 +1,51 @@ +package net.osmand.plus.base; + +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.FragmentManager; + +import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.widgets.MultiStateToggleButton.RadioItem; + +import java.util.List; + +public class SelectMultipleWithModeBottomSheet extends SelectMultipleItemsBottomSheet { + + private List modes; + + @Override + protected void initHeaderUi() { + super.initHeaderUi(); + radioGroup.setItems(modes); + + AndroidUiHelper.setVisibility(View.VISIBLE, secondaryDescription, toggleContainer, + checkBox, checkBoxTitle, primaryDescription, selectedSize, selectAllButton); + } + + private void setModes(@NonNull List modes) { + this.modes = modes; + } + + public void setSelectedMode(@NonNull RadioItem mode) { + radioGroup.setSelectedItem(mode); + } + + public static SelectMultipleWithModeBottomSheet showInstance(@NonNull AppCompatActivity activity, + @NonNull List items, + @Nullable List selected, + @NonNull List modes, + boolean usedOnMap) { + SelectMultipleWithModeBottomSheet fragment = new SelectMultipleWithModeBottomSheet(); + fragment.setUsedOnMap(usedOnMap); + fragment.setItems(items); + fragment.setSelectedItems(selected); + fragment.setModes(modes); + FragmentManager fm = activity.getSupportFragmentManager(); + fragment.show(fm, TAG); + return fragment; + } + +} diff --git a/OsmAnd/src/net/osmand/plus/base/SelectionBottomSheet.java b/OsmAnd/src/net/osmand/plus/base/SelectionBottomSheet.java new file mode 100644 index 0000000000..978f649083 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/base/SelectionBottomSheet.java @@ -0,0 +1,201 @@ +package net.osmand.plus.base; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.SimpleDividerItem; +import net.osmand.plus.widgets.MultiStateToggleButton; +import net.osmand.view.ThreeStateCheckbox; + +import java.util.List; + +public abstract class SelectionBottomSheet extends MenuBottomSheetDialogFragment { + + protected OsmandApplication app; + protected UiUtilities uiUtilities; + + protected TextView title; + protected TextView primaryDescription; + protected TextView secondaryDescription; + protected TextView selectedSize; + protected LinearLayout toggleContainer; + protected MultiStateToggleButton radioGroup; + protected View selectAllButton; + protected TextView checkBoxTitle; + protected ThreeStateCheckbox checkBox; + protected LinearLayout selectionListView; + protected TextView applyButtonTitle; + + protected int activeColorRes; + protected int secondaryColorRes; + + private OnUiInitializedListener uiInitializedListener; + private OnApplySelectionListener applySelectionListener; + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { + View mainView = super.onCreateView(inflater, parent, savedInstanceState); + notifyUiInitialized(); + return mainView; + } + + @Override + public void createMenuItems(Bundle savedInstanceState) { + app = requiredMyApplication(); + uiUtilities = app.getUIUtilities(); + activeColorRes = nightMode ? R.color.icon_color_active_dark : R.color.icon_color_active_light; + secondaryColorRes = nightMode ? R.color.icon_color_secondary_dark : R.color.icon_color_secondary_light; + + items.add(createHeaderUi()); + items.add(new SimpleDividerItem(app)); + createSelectionUi(); + } + + @Override + public void onPause() { + super.onPause(); + if (requireActivity().isChangingConfigurations()) { + dismiss(); + } + } + + private BaseBottomSheetItem createHeaderUi() { + LayoutInflater themedInflater = UiUtilities.getInflater(requireContext(), nightMode); + 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); + selectedSize = view.findViewById(R.id.selected_size); + toggleContainer = view.findViewById(R.id.custom_radio_buttons); + radioGroup = new MultiStateToggleButton(app, toggleContainer, nightMode); + selectAllButton = view.findViewById(R.id.select_all_button); + checkBoxTitle = view.findViewById(R.id.check_box_title); + checkBox = view.findViewById(R.id.check_box); + + initHeaderUi(); + return new SimpleBottomSheetItem.Builder().setCustomView(view).create(); + } + + protected abstract void createSelectionUi(); + + protected abstract void initHeaderUi(); + + @Override + protected void setupRightButton() { + super.setupRightButton(); + applyButtonTitle = rightButton.findViewById(R.id.button_text); + } + + public void setTitle(@NonNull String title) { + this.title.setText(title); + } + + public void setDescription(@NonNull String description) { + this.primaryDescription.setText(description); + } + + public void setSecondaryDescription(@NonNull String description) { + this.secondaryDescription.setText(description); + } + + public void setApplyButtonTitle(@NonNull String title) { + applyButtonTitle.setText(title); + } + + @Override + protected void onRightBottomButtonClick() { + if (applySelectionListener != null) { + applySelectionListener.onSelectionApplied(getSelection()); + } + dismiss(); + } + + @NonNull + public abstract List getSelection(); + + @Override + protected int getRightBottomButtonTextId() { + return R.string.shared_string_apply; + } + + public void setUiInitializedListener(OnUiInitializedListener uiInitializedListener) { + this.uiInitializedListener = uiInitializedListener; + } + + public void setOnApplySelectionListener(OnApplySelectionListener onApplySelectionListener) { + this.applySelectionListener = onApplySelectionListener; + } + + protected void notifyUiInitialized() { + if (uiInitializedListener != null) { + uiInitializedListener.onUiInitialized(); + } + } + + @Override + protected boolean useVerticalButtons() { + return true; + } + + public interface OnUiInitializedListener { + void onUiInitialized(); + } + + public interface OnApplySelectionListener { + void onSelectionApplied(List selectedItems); + } + + public static class SelectableItem { + private String title; + private String description; + private int iconId; + private Object object; + + public String getTitle() { + return title; + } + + public String getDescription() { + return description; + } + + public int getIconId() { + return iconId; + } + + public Object getObject() { + return object; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setIconId(int iconId) { + this.iconId = iconId; + } + + public void setObject(Object object) { + this.object = object; + } + } + +} diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java index 5c84250d07..715d2f02f5 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java @@ -29,7 +29,7 @@ import java.util.Map; import static net.osmand.IndexConstants.BINARY_MAP_INDEX_EXT; import static net.osmand.plus.activities.LocalIndexHelper.LocalIndexType.SRTM_DATA; -import static net.osmand.plus.download.MultipleIndexesUiHelper.getSRTMExt; +import static net.osmand.plus.download.SelectIndexesUiHelper.getSRTMExt; public class DownloadActivityType { private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd.MM.yyyy", Locale.US); diff --git a/OsmAnd/src/net/osmand/plus/download/MultipleIndexItem.java b/OsmAnd/src/net/osmand/plus/download/MultipleIndexItem.java index a6a0a46686..caf47d71f5 100644 --- a/OsmAnd/src/net/osmand/plus/download/MultipleIndexItem.java +++ b/OsmAnd/src/net/osmand/plus/download/MultipleIndexItem.java @@ -12,7 +12,7 @@ import java.util.ArrayList; import java.util.List; import static net.osmand.plus.download.DownloadActivityType.SRTM_COUNTRY_FILE; -import static net.osmand.plus.download.MultipleIndexesUiHelper.isBaseSRTMItem; +import static net.osmand.plus.download.SelectIndexesUiHelper.isBaseSRTMItem; public class MultipleIndexItem extends DownloadItem { diff --git a/OsmAnd/src/net/osmand/plus/download/MultipleIndexesUiHelper.java b/OsmAnd/src/net/osmand/plus/download/SelectIndexesUiHelper.java similarity index 52% rename from OsmAnd/src/net/osmand/plus/download/MultipleIndexesUiHelper.java rename to OsmAnd/src/net/osmand/plus/download/SelectIndexesUiHelper.java index 509609bd94..ff0401215d 100644 --- a/OsmAnd/src/net/osmand/plus/download/MultipleIndexesUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/download/SelectIndexesUiHelper.java @@ -1,6 +1,7 @@ package net.osmand.plus.download; import android.content.Context; +import android.view.View; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; @@ -11,22 +12,28 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.base.SelectMultipleItemsBottomSheet; -import net.osmand.plus.base.SelectMultipleItemsBottomSheet.OnApplySelectionListener; -import net.osmand.plus.base.SelectMultipleItemsBottomSheet.OnRadioButtonSelectListener; -import net.osmand.plus.base.SelectMultipleItemsBottomSheet.SelectableItem; import net.osmand.plus.base.SelectMultipleItemsBottomSheet.SelectionUpdateListener; +import net.osmand.plus.base.SelectModeBottomSheet; +import net.osmand.plus.base.SelectMultipleWithModeBottomSheet; +import net.osmand.plus.base.SelectionBottomSheet; +import net.osmand.plus.base.SelectionBottomSheet.OnApplySelectionListener; +import net.osmand.plus.base.SelectionBottomSheet.OnUiInitializedListener; +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.RadioItem; 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.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; -public class MultipleIndexesUiHelper { +public class SelectIndexesUiHelper { public static void showDialog(@NonNull DownloadItem item, @NonNull AppCompatActivity activity, @@ -35,7 +42,11 @@ public class MultipleIndexesUiHelper { boolean showRemoteDate, @NonNull final SelectItemsToDownloadListener listener) { if (item.getType() == SRTM_COUNTRY_FILE) { - showSRTMDialog(item, activity, app, dateFormat, showRemoteDate, listener); + if (item instanceof MultipleIndexItem) { + showMultipleSrtmDialog(item, activity, app, dateFormat, showRemoteDate, listener); + } else { + showSingleSrtmDialog(item, activity, app, dateFormat, showRemoteDate, listener); + } } else if (item instanceof MultipleIndexItem) { showBaseDialog((MultipleIndexItem) item, activity, app, dateFormat, showRemoteDate, listener); } @@ -70,24 +81,116 @@ public class MultipleIndexesUiHelper { final SelectMultipleItemsBottomSheet dialog = SelectMultipleItemsBottomSheet.showInstance(activity, allItems, selectedItems, true); + dialog.setUiInitializedListener(new OnUiInitializedListener() { + @Override + public void onUiInitialized() { + dialog.setTitle(app.getString(R.string.welmode_download_maps)); + } + }); + dialog.setSelectionUpdateListener(new SelectionUpdateListener() { @Override public void onSelectionUpdate() { - updateSize(app, dialog); + updateSize(app, dialog, true); } }); dialog.setOnApplySelectionListener(getOnApplySelectionListener(listener)); } - public static void showSRTMDialog(@NonNull final DownloadItem downloadItem, - @NonNull AppCompatActivity activity, - @NonNull final OsmandApplication app, - @NonNull final DateFormat dateFormat, - final boolean showRemoteDate, - @NonNull final SelectItemsToDownloadListener listener) { + public static void showSingleSrtmDialog(@NonNull final DownloadItem downloadItem, + @NonNull AppCompatActivity activity, + @NonNull final OsmandApplication app, + @NonNull final DateFormat dateFormat, + final boolean showRemoteDate, + @NonNull final SelectItemsToDownloadListener listener) { + List allIndexes = getIndexesToDownload(downloadItem); + boolean baseSRTM = isBaseSRTMMetricSystem(app); + + List radioItems = new ArrayList<>(); + final 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))); + radioItems.add(meters); + 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; + final SelectableItem initFeet = feetItem; + + final SelectModeBottomSheet dialog = SelectModeBottomSheet.showInstance(activity, + 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; + dialog.setUiInitializedListener(new OnUiInitializedListener() { + @Override + public void onUiInitialized() { + dialog.setTitle(app.getString(R.string.srtm_unit_format)); + dialog.setDescription(app.getString(R.string.srtm_download_single_help_message)); + 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); + dialog.setSelectedMode(initRadio); + } + }); + + dialog.setOnApplySelectionListener(getOnApplySelectionListener(listener)); + } + + public static void showMultipleSrtmDialog(@NonNull final DownloadItem downloadItem, + @NonNull AppCompatActivity activity, + @NonNull final OsmandApplication app, + @NonNull final DateFormat dateFormat, + final boolean showRemoteDate, + @NonNull final SelectItemsToDownloadListener listener) { List selectedItems = new ArrayList<>(); - final List leftItems = new ArrayList<>(); - final List rightItems = new ArrayList<>(); + final List meterItems = new ArrayList<>(); + final List feetItems = new ArrayList<>(); List indexesToDownload = getIndexesToDownload(downloadItem); boolean baseSRTM = isBaseSRTMMetricSystem(app); @@ -115,9 +218,9 @@ public class MultipleIndexesUiHelper { selectableItem.setObject(indexItem); if (baseItem) { - leftItems.add(selectableItem); + meterItems.add(selectableItem); } else { - rightItems.add(selectableItem); + feetItems.add(selectableItem); } if (indexesToDownload.contains(indexItem) @@ -126,45 +229,48 @@ public class MultipleIndexesUiHelper { } } - String addDescription = app.getString(isListDialog(app, leftItems, rightItems) - ? R.string.srtm_download_list_help_message : R.string.srtm_download_single_help_message); - final SelectMultipleItemsBottomSheet dialog = SelectMultipleItemsBottomSheet.showInstance( - activity, baseSRTM ? leftItems : rightItems, selectedItems, true, - addDescription, true, baseSRTM, - Algorithms.capitalizeFirstLetter(app.getString(R.string.shared_string_meters)), - Algorithms.capitalizeFirstLetter(app.getString(R.string.shared_string_feets))); + List radioItems = new ArrayList<>(); + 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))); + final RadioItem selectedMode = isBaseSRTMItem(downloadItem) ? meters : feet; + radioItems.add(meters); + radioItems.add(feet); + + final SelectMultipleWithModeBottomSheet dialog = SelectMultipleWithModeBottomSheet.showInstance( + activity, baseSRTM ? meterItems : feetItems, selectedItems, radioItems, true); + + meters.setOnClickListener(new OnRadioItemClickListener() { + @Override + public boolean onRadioItemClick(RadioItem radioItem, View view) { +// dialog.recreateList(meterItems); + return true; + } + }); + + feet.setOnClickListener(new OnRadioItemClickListener() { + @Override + public boolean onRadioItemClick(RadioItem radioItem, View view) { +// dialog.recreateList(feetItems); + return true; + } + }); + + dialog.setUiInitializedListener(new OnUiInitializedListener() { + @Override + public void onUiInitialized() { + dialog.setTitle(app.getString(R.string.welmode_download_maps)); + dialog.setSelectedMode(selectedMode); + dialog.setSecondaryDescription(app.getString(R.string.srtm_download_list_help_message)); + } + }); dialog.setSelectionUpdateListener(new SelectionUpdateListener() { @Override public void onSelectionUpdate() { - updateSize(app, dialog); + updateSize(app, dialog, true); } }); dialog.setOnApplySelectionListener(getOnApplySelectionListener(listener)); - dialog.setOnRadioButtonSelectListener(new OnRadioButtonSelectListener() { - @Override - public void onSelect(boolean leftButton) { - dialog.recreateList(leftButton ? leftItems : rightItems); - updateSize(app, dialog); - } - }); - dialog.setSelectedItemsListener(new SelectedItemsListener() { - @Override - public List createSelectedItems(List currentAllItems, boolean baseSRTM) { - List indexesToDownload = getIndexesToDownload(downloadItem); - List selectedItems = new ArrayList<>(); - - for (SelectableItem currentItem : currentAllItems) { - IndexItem indexItem = (IndexItem) currentItem.getObject(); - boolean baseItem = isBaseSRTMItem(indexItem); - if (indexesToDownload.contains(indexItem) - && (baseSRTM && baseItem || !baseSRTM && !baseItem)) { - selectedItems.add(currentItem); - } - } - return selectedItems; - } - }); } private static OnApplySelectionListener getOnApplySelectionListener(final SelectItemsToDownloadListener listener) { @@ -183,12 +289,12 @@ public class MultipleIndexesUiHelper { }; } - private static void updateSize(OsmandApplication app, SelectMultipleItemsBottomSheet dialog) { - boolean isListDialog = dialog.isMultipleItem(); - dialog.setTitle(app.getString(isListDialog ? R.string.welmode_download_maps : R.string.srtm_unit_format)); - double sizeToDownload = getDownloadSizeInMb(dialog.getSelectedItems()); + private static void updateSize(OsmandApplication app, + SelectionBottomSheet dialog, + boolean updateDescription) { + double sizeToDownload = getDownloadSizeInMb(dialog.getSelection()); String size = DownloadItem.getFormattedMb(app, sizeToDownload); - if (isListDialog) { + 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); @@ -197,12 +303,7 @@ public class MultipleIndexesUiHelper { if (sizeToDownload > 0) { btnTitle = app.getString(R.string.ltr_or_rtl_combine_via_dash, btnTitle, size); } - dialog.setConfirmButtonTitle(btnTitle); - } - - private static boolean isListDialog(OsmandApplication app, - List leftItems, List rightItems) { - return (isBaseSRTMMetricSystem(app) ? leftItems : rightItems).size() > 1; + dialog.setApplyButtonTitle(btnTitle); } public static String getSRTMAbbrev(Context context, boolean base) { @@ -266,7 +367,4 @@ public class MultipleIndexesUiHelper { void onItemsToDownloadSelected(List items); } - public interface SelectedItemsListener { - List createSelectedItems(List currentAllItems, boolean base); - } } diff --git a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java index 07aab7de88..498b122547 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java @@ -41,8 +41,8 @@ import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.DownloadResourceGroup; import net.osmand.plus.download.DownloadResources; import net.osmand.plus.download.IndexItem; -import net.osmand.plus.download.MultipleIndexesUiHelper; -import net.osmand.plus.download.MultipleIndexesUiHelper.SelectItemsToDownloadListener; +import net.osmand.plus.download.SelectIndexesUiHelper; +import net.osmand.plus.download.SelectIndexesUiHelper.SelectItemsToDownloadListener; import net.osmand.plus.download.MultipleIndexItem; import net.osmand.plus.download.ui.LocalIndexesFragment.LocalIndexOperationTask; import net.osmand.plus.helpers.FileNameTranslationHelper; @@ -56,9 +56,9 @@ import java.util.List; import static net.osmand.plus.download.DownloadActivityType.SRTM_COUNTRY_FILE; import static net.osmand.plus.download.DownloadActivityType.isSRTMItem; -import static net.osmand.plus.download.MultipleIndexesUiHelper.getSRTMAbbrev; -import static net.osmand.plus.download.MultipleIndexesUiHelper.isBaseSRTMItem; -import static net.osmand.plus.download.MultipleIndexesUiHelper.isBaseSRTMMetricSystem; +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 { @@ -523,7 +523,7 @@ public class ItemViewHolder { private void selectIndexesToDownload(DownloadItem item) { OsmandApplication app = context.getMyApplication(); - MultipleIndexesUiHelper.showDialog(item, context, app, dateFormat, showRemoteDate, + SelectIndexesUiHelper.showDialog(item, context, app, dateFormat, showRemoteDate, new SelectItemsToDownloadListener() { @Override public void onItemsToDownloadSelected(List indexes) { diff --git a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java index 91b1aabc76..d56420c29c 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java @@ -75,8 +75,8 @@ import java.util.Map; import java.util.Set; import static net.osmand.plus.download.DownloadActivityType.isSRTMItem; -import static net.osmand.plus.download.MultipleIndexesUiHelper.getSRTMAbbrev; -import static net.osmand.plus.download.MultipleIndexesUiHelper.isBaseSRTMItem; +import static net.osmand.plus.download.SelectIndexesUiHelper.getSRTMAbbrev; +import static net.osmand.plus.download.SelectIndexesUiHelper.isBaseSRTMItem; public class LocalIndexesFragment extends OsmandExpandableListFragment implements DownloadEvents, OnMapSourceUpdateListener, RenameCallback {