Search in sources :

Example 6 with SettingsCategoryItems

use of net.osmand.plus.settings.fragments.SettingsCategoryItems 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;
}
Also used : SettingsCategoryItems(net.osmand.plus.settings.fragments.SettingsCategoryItems) Typeface(android.graphics.Typeface) ExportSettingsCategory(net.osmand.plus.settings.backend.ExportSettingsCategory) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType)

Example 7 with SettingsCategoryItems

use of net.osmand.plus.settings.fragments.SettingsCategoryItems 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);
}
Also used : SettingsCategoryItems(net.osmand.plus.settings.fragments.SettingsCategoryItems) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType)

Example 8 with SettingsCategoryItems

use of net.osmand.plus.settings.fragments.SettingsCategoryItems 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;
}
Also used : SettingsCategoryItems(net.osmand.plus.settings.fragments.SettingsCategoryItems) ExportSettingsCategory(net.osmand.plus.settings.backend.ExportSettingsCategory) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType)

Example 9 with SettingsCategoryItems

use of net.osmand.plus.settings.fragments.SettingsCategoryItems in project Osmand by osmandapp.

the class BaseBackupTypesFragment method onCategorySelected.

@Override
public void onCategorySelected(ExportSettingsCategory category, boolean selected) {
    boolean hasItemsToDelete = false;
    SettingsCategoryItems categoryItems = dataList.get(category);
    List<ExportSettingsType> types = categoryItems.getTypes();
    for (ExportSettingsType type : types) {
        List<Object> items = getItemsForType(type);
        hasItemsToDelete |= !Algorithms.isEmpty(items);
        selectedItemsMap.put(type, selected ? items : null);
    }
    if (!selected && hasItemsToDelete) {
        showClearTypesBottomSheet(types);
    }
}
Also used : SettingsCategoryItems(net.osmand.plus.settings.fragments.SettingsCategoryItems) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType)

Aggregations

ExportSettingsType (net.osmand.plus.settings.backend.ExportSettingsType)9 SettingsCategoryItems (net.osmand.plus.settings.fragments.SettingsCategoryItems)9 ExportSettingsCategory (net.osmand.plus.settings.backend.ExportSettingsCategory)4 View (android.view.View)2 CompoundButton (android.widget.CompoundButton)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Typeface (android.graphics.Typeface)1 EnumMap (java.util.EnumMap)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1