Search in sources :

Example 31 with ExportSettingsType

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

Example 32 with ExportSettingsType

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());
}
Also used : ArrayList(java.util.ArrayList) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType)

Example 33 with ExportSettingsType

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;
}
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 34 with ExportSettingsType

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

Example 35 with ExportSettingsType

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;
}
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)

Aggregations

ExportSettingsType (net.osmand.plus.settings.backend.ExportSettingsType)36 ArrayList (java.util.ArrayList)18 List (java.util.List)10 SettingsCategoryItems (net.osmand.plus.settings.fragments.SettingsCategoryItems)9 ExportSettingsCategory (net.osmand.plus.settings.backend.ExportSettingsCategory)6 View (android.view.View)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 File (java.io.File)5 LinkedHashMap (java.util.LinkedHashMap)5 Nullable (androidx.annotation.Nullable)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 SettingsItem (net.osmand.plus.settings.backend.backup.items.SettingsItem)4 NonNull (androidx.annotation.NonNull)3 EnumMap (java.util.EnumMap)3 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)3 SuppressLint (android.annotation.SuppressLint)2 Typeface (android.graphics.Typeface)2 AsyncTask (android.os.AsyncTask)2