Search in sources :

Example 6 with ViewAttribute

use of com.willowtreeapps.hyperion.attr.ViewAttribute in project Hyperion-Android by willowtreeapps.

the class EditTextAttributeCollector method collect.

@NonNull
@Override
public List<ViewAttribute> collect(final EditText view, AttributeTranslator attributeTranslator) {
    List<ViewAttribute> attributes = new ArrayList<>();
    attributes.add(new MutableBooleanViewAttribute("FreezesText", view.getFreezesText()) {

        @Override
        protected void mutate(Boolean value) {
            view.setFreezesText(value);
        }
    });
    return attributes;
}
Also used : ArrayList(java.util.ArrayList) MutableBooleanViewAttribute(com.willowtreeapps.hyperion.attr.MutableBooleanViewAttribute) ViewAttribute(com.willowtreeapps.hyperion.attr.ViewAttribute) MutableBooleanViewAttribute(com.willowtreeapps.hyperion.attr.MutableBooleanViewAttribute) NonNull(android.support.annotation.NonNull)

Example 7 with ViewAttribute

use of com.willowtreeapps.hyperion.attr.ViewAttribute in project Hyperion-Android by willowtreeapps.

the class BottomNavigationViewAttributeCollector method collect.

@NonNull
@Override
public List<ViewAttribute> collect(BottomNavigationView view, AttributeTranslator attributeTranslator) {
    final Context context = view.getContext();
    final Resources res = context.getResources();
    List<ViewAttribute> attributes = new ArrayList<>();
    attributes.add(new ViewAttribute<>("MaxItemCount", view.getMaxItemCount()));
    attributes.add(Collectors.createColorAttribute(view, "ItemTint", view.getItemIconTintList()));
    attributes.add(Collectors.createColorAttribute(view, "ItemTextColor", view.getItemTextColor()));
    attributes.add(new ViewAttribute<>("SelectedItemId", new ResourceValue(res, view.getSelectedItemId())));
    attributes.add(new ViewAttribute<>("ItemBackgroundRes", new ResourceValue(res, view.getItemBackgroundResource())));
    attributes.addAll(Collectors.createMenuAttributes(context, view.getMenu()));
    return attributes;
}
Also used : Context(android.content.Context) ArrayList(java.util.ArrayList) ResourceValue(com.willowtreeapps.hyperion.attr.collectors.ResourceValue) Resources(android.content.res.Resources) ViewAttribute(com.willowtreeapps.hyperion.attr.ViewAttribute) NonNull(android.support.annotation.NonNull)

Example 8 with ViewAttribute

use of com.willowtreeapps.hyperion.attr.ViewAttribute in project Hyperion-Android by willowtreeapps.

the class TextViewAttributeCollector method collect.

@NonNull
@Override
public List<ViewAttribute> collect(final TextView view, AttributeTranslator attributeTranslator) {
    List<ViewAttribute> attributes = new ArrayList<>();
    attributes.add(new MutableStringViewAttribute("Text", view.getText().toString()) {

        @Override
        protected void mutate(CharSequence value) {
            view.setText(value);
        }
    });
    attributes.add(new MutableStringViewAttribute("Hint", view.getHint()) {

        @Override
        protected void mutate(CharSequence value) {
            view.setHint(value);
        }
    });
    attributes.add(new ViewAttribute<>("TextColor", new ColorValue(view.getCurrentTextColor()), new ColorDrawable(view.getCurrentTextColor())));
    attributes.add(new ViewAttribute<>("HintColor", new ColorValue(view.getCurrentHintTextColor()), new ColorDrawable(view.getCurrentHintTextColor())));
    attributes.add(new ViewAttribute<>("Typeface", view.getTypeface()));
    attributes.add(new ViewAttribute<>("TextSize", attributeTranslator.translatePxToSp((int) view.getTextSize())));
    attributes.add(new ViewAttribute<>("AutoSizeMaxTextSize", TextViewCompat.getAutoSizeMaxTextSize(view)));
    attributes.add(new ViewAttribute<>("AutoSizeMinTextSize", TextViewCompat.getAutoSizeMinTextSize(view)));
    attributes.add(new ViewAttribute<>("AutoSizeStepGranularity", TextViewCompat.getAutoSizeStepGranularity(view)));
    attributes.add(new ViewAttribute<>("Gravity", new GravityValue(view.getGravity())));
    attributes.add(new ViewAttribute<>("ImeAction", view.getImeActionId()));
    attributes.add(new ViewAttribute<>("ImeActionLabel", view.getImeActionLabel()));
    attributes.add(new ViewAttribute<>("ImeOptions", new ImeOptionsValue(view.getImeOptions())));
    attributes.add(new ViewAttribute<>("CompoundPaddingLeft", attributeTranslator.translatePx(view.getCompoundPaddingLeft())));
    attributes.add(new ViewAttribute<>("CompoundPaddingTop", attributeTranslator.translatePx(view.getCompoundPaddingTop())));
    attributes.add(new ViewAttribute<>("CompoundPaddingRight", attributeTranslator.translatePx(view.getCompoundPaddingRight())));
    attributes.add(new ViewAttribute<>("CompoundPaddingBottom", attributeTranslator.translatePx(view.getCompoundPaddingBottom())));
    attributes.add(new ViewAttribute<>("CompoundDrawable", attributeTranslator.translatePx(view.getCompoundDrawablePadding())));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        attributes.add(Collectors.createColorAttribute(view, "CompoundDrawableTint", view.getCompoundDrawableTintList()));
        attributes.add(new ViewAttribute<>("CompoundDrawableTintMode", new PorterDuffModeValue(view.getCompoundDrawableTintMode())));
    }
    return attributes;
}
Also used : MutableStringViewAttribute(com.willowtreeapps.hyperion.attr.MutableStringViewAttribute) ColorDrawable(android.graphics.drawable.ColorDrawable) ArrayList(java.util.ArrayList) MutableStringViewAttribute(com.willowtreeapps.hyperion.attr.MutableStringViewAttribute) ViewAttribute(com.willowtreeapps.hyperion.attr.ViewAttribute) NonNull(android.support.annotation.NonNull)

Example 9 with ViewAttribute

use of com.willowtreeapps.hyperion.attr.ViewAttribute in project Hyperion-Android by willowtreeapps.

the class FrameLayoutAttributeCollector method collect.

@NonNull
@Override
public List<ViewAttribute> collect(final FrameLayout view, AttributeTranslator attributeTranslator) {
    List<ViewAttribute> attributes = new ArrayList<>();
    attributes.add(new MutableBooleanViewAttribute("MeasureAllChildren", view.getMeasureAllChildren()) {

        @Override
        protected void mutate(Boolean value) throws Exception {
            view.setMeasureAllChildren(value);
        }
    });
    return attributes;
}
Also used : ArrayList(java.util.ArrayList) MutableBooleanViewAttribute(com.willowtreeapps.hyperion.attr.MutableBooleanViewAttribute) ViewAttribute(com.willowtreeapps.hyperion.attr.ViewAttribute) MutableBooleanViewAttribute(com.willowtreeapps.hyperion.attr.MutableBooleanViewAttribute) NonNull(android.support.annotation.NonNull)

Example 10 with ViewAttribute

use of com.willowtreeapps.hyperion.attr.ViewAttribute in project Hyperion-Android by willowtreeapps.

the class LinearLayoutAttributeCollector method collect.

@NonNull
@Override
public List<ViewAttribute> collect(final LinearLayout view, AttributeTranslator attributeTranslator) {
    List<ViewAttribute> attributes = new ArrayList<>();
    attributes.add(new ViewAttribute<>("Orientation", new OrientationValue(view.getOrientation())));
    attributes.add(new ViewAttribute<>("WeightSum", view.getWeightSum()));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        attributes.add(new ViewAttribute<>("Gravity", new GravityValue(view.getGravity())));
    }
    attributes.add(new ViewAttribute<>("ShowDividers", new DividerModeValue(view.getShowDividers())));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        attributes.add(new ViewAttribute<Void>("Divider", view.getDividerDrawable()));
    }
    attributes.add(new ViewAttribute<>("DividerPadding", attributeTranslator.translatePx(view.getDividerPadding())));
    attributes.add(new MutableBooleanViewAttribute("MeasureWithLargestChild", view.isMeasureWithLargestChildEnabled()) {

        @Override
        protected void mutate(Boolean value) throws Exception {
            view.setMeasureWithLargestChildEnabled(value);
        }
    });
    attributes.add(new MutableBooleanViewAttribute("BaselineAligned", view.isBaselineAligned()) {

        @Override
        protected void mutate(Boolean value) throws Exception {
            view.setBaselineAligned(value);
        }
    });
    attributes.add(new MutableStringViewAttribute("BaselineAlignedChildIndex", String.valueOf(view.getBaselineAlignedChildIndex())) {

        @Override
        protected void mutate(CharSequence value) throws Exception {
            int index = Integer.parseInt(value.toString());
            view.setBaselineAlignedChildIndex(index);
        }
    });
    return attributes;
}
Also used : ArrayList(java.util.ArrayList) MutableStringViewAttribute(com.willowtreeapps.hyperion.attr.MutableStringViewAttribute) ViewAttribute(com.willowtreeapps.hyperion.attr.ViewAttribute) MutableBooleanViewAttribute(com.willowtreeapps.hyperion.attr.MutableBooleanViewAttribute) MutableStringViewAttribute(com.willowtreeapps.hyperion.attr.MutableStringViewAttribute) MutableBooleanViewAttribute(com.willowtreeapps.hyperion.attr.MutableBooleanViewAttribute) NonNull(android.support.annotation.NonNull)

Aggregations

ViewAttribute (com.willowtreeapps.hyperion.attr.ViewAttribute)12 ArrayList (java.util.ArrayList)11 NonNull (android.support.annotation.NonNull)10 MutableBooleanViewAttribute (com.willowtreeapps.hyperion.attr.MutableBooleanViewAttribute)7 MutableStringViewAttribute (com.willowtreeapps.hyperion.attr.MutableStringViewAttribute)4 Resources (android.content.res.Resources)2 ColorDrawable (android.graphics.drawable.ColorDrawable)2 RequiresApi (android.support.annotation.RequiresApi)2 TargetApi (android.annotation.TargetApi)1 Context (android.content.Context)1 Rect (android.graphics.Rect)1 MenuItem (android.view.MenuItem)1 ResourceValue (com.willowtreeapps.hyperion.attr.collectors.ResourceValue)1