use of com.willowtreeapps.hyperion.attr.MutableBooleanViewAttribute in project Hyperion-Android by willowtreeapps.
the class ViewAttributeCollector method collect.
@NonNull
@Override
public List<ViewAttribute> collect(final View view, AttributeTranslator attributeTranslator) {
List<ViewAttribute> attributes = new ArrayList<>();
Rect rect = new Rect();
String value;
attributes.add(new ViewAttribute<>("Id", new ResourceValue(view.getResources(), view.getId())));
value = attributeTranslator.translatePx(view.getHeight());
attributes.add(new ViewAttribute<>("Height", value));
value = attributeTranslator.translatePx(view.getWidth());
attributes.add(new ViewAttribute<>("Width", value));
attributes.add(new ViewAttribute<>("Baseline", view.getBaseline()));
view.getGlobalVisibleRect(rect);
attributes.add(new ViewAttribute<>("GlobalLeft", String.valueOf(rect.left)));
attributes.add(new ViewAttribute<>("GlobalTop", String.valueOf(rect.top)));
attributes.add(new ViewAttribute<>("GlobalRight", String.valueOf(rect.right)));
attributes.add(new ViewAttribute<>("GlobalBottom", String.valueOf(rect.bottom)));
view.getLocalVisibleRect(rect);
attributes.add(new ViewAttribute<>("LocalLeft", String.valueOf(rect.left)));
attributes.add(new ViewAttribute<>("LocalTop", String.valueOf(rect.top)));
attributes.add(new ViewAttribute<>("LocalRight", String.valueOf(rect.right)));
attributes.add(new ViewAttribute<>("LocalBottom", String.valueOf(rect.bottom)));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
attributes.add(new ViewAttribute<>("InLayout", view.isInLayout()));
}
attributes.add(new MutableBooleanViewAttribute("Clickable", view.isClickable()) {
@Override
protected void mutate(Boolean value) {
view.setClickable(value);
}
});
attributes.add(new MutableBooleanViewAttribute("LongClickable", view.isLongClickable()) {
@Override
protected void mutate(Boolean value) {
view.setLongClickable(value);
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
attributes.add(new ViewAttribute<>("ContextClickable", view.isContextClickable()));
}
attributes.add(new MutableBooleanViewAttribute("Enabled", view.isEnabled()) {
@Override
protected void mutate(Boolean value) {
view.setEnabled(value);
}
});
attributes.add(new MutableBooleanViewAttribute("Activated", view.isActivated()) {
@Override
protected void mutate(Boolean value) {
view.setActivated(value);
}
});
attributes.add(new MutableBooleanViewAttribute("Selected", view.isSelected()) {
@Override
protected void mutate(Boolean value) {
view.setSelected(value);
}
});
attributes.add(new ViewAttribute<>("AttachedToWindow", ViewCompat.isAttachedToWindow(view)));
attributes.add(new ViewAttribute<>("Dirty", view.isDirty()));
attributes.add(new MutableBooleanViewAttribute("IsFocusable", view.isFocusable()) {
@Override
protected void mutate(Boolean value) {
view.setFocusable(value);
}
});
attributes.add(new MutableBooleanViewAttribute("IsFocusableInTouchMode", view.isFocusableInTouchMode()) {
@Override
protected void mutate(Boolean value) {
view.setFocusableInTouchMode(value);
}
});
attributes.add(new ViewAttribute<>("HasFocus", view.hasFocus()));
attributes.add(new ViewAttribute<>("HasFocusable", view.hasFocusable()));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
attributes.add(new ViewAttribute<>("HasTransientState", view.hasTransientState()));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
attributes.add(new ViewAttribute<>("ForegroundGravity", new GravityValue(view.getForegroundGravity())));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
attributes.add(new MutableStringViewAttribute("TransitionName", view.getTransitionName()) {
@Override
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
protected void mutate(CharSequence value) {
view.setTransitionName(value.toString());
}
});
attributes.add(new ViewAttribute<>("Elevation", view.getElevation()));
}
attributes.add(new ViewAttribute<>("BackgroundTintMode", new PorterDuffModeValue(ViewCompat.getBackgroundTintMode(view))));
attributes.add(Collectors.createColorAttribute(view, "BackgroundTint", ViewCompat.getBackgroundTintList(view)));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
attributes.add(new ViewAttribute<>("AccessibilityClassName", view.getAccessibilityClassName()));
}
return attributes;
}
use of com.willowtreeapps.hyperion.attr.MutableBooleanViewAttribute in project Hyperion-Android by willowtreeapps.
the class ViewGroupAttributeCollector method collect.
@NonNull
@Override
public List<ViewAttribute> collect(final ViewGroup view, AttributeTranslator attributeTranslator) {
List<ViewAttribute> attributes = new ArrayList<>();
attributes.add(new ViewAttribute<>("ChildCount", view.getChildCount()));
attributes.add(new MutableBooleanViewAttribute("MotionEventSplittingEnabled", view.isMotionEventSplittingEnabled()) {
@Override
protected void mutate(Boolean value) {
view.setMotionEventSplittingEnabled(value);
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
attributes.add(new ViewAttribute<>("LayoutMode", new LayoutModeValue(view.getLayoutMode())));
attributes.add(new MutableBooleanViewAttribute("ClipChildren", view.getClipChildren()) {
@Override
protected void mutate(Boolean value) {
view.setClipChildren(value);
}
});
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
attributes.add(new MutableBooleanViewAttribute("ClipToPadding", view.getClipToPadding()) {
@Override
protected void mutate(Boolean value) {
view.setClipToPadding(value);
}
});
attributes.add(new ViewAttribute<>("TouchscreenBlocksFocus", view.getTouchscreenBlocksFocus()));
attributes.add(new MutableBooleanViewAttribute("IsTransitionGroup", view.isTransitionGroup()) {
@Override
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
protected void mutate(Boolean value) {
view.setTransitionGroup(value);
}
});
}
attributes.add(new ViewAttribute<>("DelayChildPressed", view.shouldDelayChildPressedState()));
return attributes;
}
use of com.willowtreeapps.hyperion.attr.MutableBooleanViewAttribute 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;
}
use of com.willowtreeapps.hyperion.attr.MutableBooleanViewAttribute 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;
}
use of com.willowtreeapps.hyperion.attr.MutableBooleanViewAttribute 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;
}
Aggregations