use of net.osmand.plus.settings.backend.ExportSettingsType in project Osmand by osmandapp.
the class ExportSettingsAdapter method getCategoryDescr.
private String getCategoryDescr(ExportSettingsCategory category, boolean exportMode) {
long itemsSize = 0;
int selectedTypes = 0;
SettingsCategoryItems items = itemsMap.get(category);
for (ExportSettingsType type : items.getTypes()) {
if (!Algorithms.isEmpty(selectedItemsMap.get(type))) {
selectedTypes++;
itemsSize += calculateItemsSize(items.getItemsForType(type));
}
}
String description;
if (selectedTypes == 0 && exportMode) {
description = app.getString(R.string.shared_string_none);
} else if (selectedTypes == items.getTypes().size()) {
description = app.getString(R.string.shared_string_all);
} else {
description = app.getString(R.string.ltr_or_rtl_combine_via_slash, String.valueOf(selectedTypes), String.valueOf(items.getTypes().size()));
}
String formattedSize = AndroidUtils.formatSize(app, itemsSize);
return itemsSize == 0 ? description : app.getString(R.string.ltr_or_rtl_combine_via_comma, description, formattedSize);
}
use of net.osmand.plus.settings.backend.ExportSettingsType in project Osmand by osmandapp.
the class ClearTypesBottomSheet method onSaveInstanceState.
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
ArrayList<String> names = new ArrayList<>();
for (ExportSettingsType type : types) {
names.add(type.name());
}
outState.putStringArrayList(DISABLED_TYPES_KEY, names);
outState.putString(CLEAR_TYPE_KEY, clearType.name());
}
use of net.osmand.plus.settings.backend.ExportSettingsType in project Osmand by osmandapp.
the class BackupTypesAdapter method getGroupView.
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
view = themedInflater.inflate(R.layout.backup_type_item, parent, false);
}
ExportSettingsCategory category = itemsTypes.get(groupPosition);
SettingsCategoryItems items = itemsMap.get(category);
String name = app.getString(category.getTitleId());
Typeface typeface = FontCache.getRobotoMedium(app);
TextView titleTv = view.findViewById(R.id.title);
titleTv.setText(UiUtilities.createCustomFontSpannable(typeface, name, name));
TextView description = view.findViewById(R.id.description);
description.setText(getCategoryDescr(category));
int selectedTypes = 0;
for (ExportSettingsType type : items.getTypes()) {
if (selectedItemsMap.get(type) != null) {
selectedTypes++;
}
}
CompoundButton compoundButton = view.findViewById(R.id.switch_widget);
compoundButton.setChecked(selectedTypes == items.getTypes().size());
UiUtilities.setupCompoundButton(compoundButton, nightMode, CompoundButtonType.GLOBAL);
view.findViewById(R.id.switch_container).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
compoundButton.performClick();
if (listener != null) {
listener.onCategorySelected(category, compoundButton.isChecked());
}
notifyDataSetChanged();
}
});
setupSelectableBackground(view);
adjustIndicator(app, groupPosition, isExpanded, view, !nightMode);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.divider), isExpanded);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.card_top_divider), true);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.card_bottom_divider), !isExpanded);
return view;
}
use of net.osmand.plus.settings.backend.ExportSettingsType in project Osmand by osmandapp.
the class BackupTypesAdapter method getChild.
@Override
public Object getChild(int groupPosition, int childPosition) {
SettingsCategoryItems categoryItems = itemsMap.get(itemsTypes.get(groupPosition));
ExportSettingsType type = categoryItems.getTypes().get(groupPosition);
return categoryItems.getItemsForType(type).get(childPosition);
}
use of net.osmand.plus.settings.backend.ExportSettingsType in project Osmand by osmandapp.
the class BackupTypesAdapter method getChildView.
@Override
public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
view = themedInflater.inflate(R.layout.backup_type_item, parent, false);
}
ExportSettingsCategory category = itemsTypes.get(groupPosition);
SettingsCategoryItems categoryItems = itemsMap.get(category);
ExportSettingsType type = categoryItems.getTypes().get(childPosition);
List<?> items = categoryItems.getItemsForType(type);
List<?> selectedItems = selectedItemsMap.get(type);
boolean selected = selectedItems != null;
TextView title = view.findViewById(R.id.title);
title.setText(type.getTitleId());
TextView description = view.findViewById(R.id.description);
description.setText(getSelectedTypeDescr(app, selectedItemsMap, type, items));
CompoundButton compoundButton = view.findViewById(R.id.switch_widget);
compoundButton.setChecked(selected);
UiUtilities.setupCompoundButton(compoundButton, nightMode, CompoundButtonType.GLOBAL);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
compoundButton.performClick();
if (listener != null) {
listener.onTypeSelected(type, compoundButton.isChecked());
}
notifyDataSetChanged();
}
});
setupSelectableBackground(view);
setupChildIcon(view, type.getIconRes(), selected);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.divider), false);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.card_top_divider), false);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.card_bottom_divider), isLastChild);
return view;
}
Aggregations