feat: appbar attributes

This commit is contained in:
hyb1996 2018-10-13 13:57:52 +08:00
parent ac889ceff6
commit db3571851c
6 changed files with 58 additions and 3 deletions

View File

@ -0,0 +1,24 @@
package com.stardust.autojs.core.ui.attribute;
import android.support.design.widget.AppBarLayout;
import android.view.View;
import com.stardust.autojs.core.ui.inflater.ResourceParser;
public class AppbarAttributes extends ViewAttributes {
public AppbarAttributes(ResourceParser resourceParser, View view) {
super(resourceParser, view);
}
@Override
protected void onRegisterAttrs() {
super.onRegisterAttrs();
registerPixelAttr("elevation", getView()::setTargetElevation);
registerBooleanAttr("expanded", getView()::setExpanded);
}
@Override
public AppBarLayout getView() {
return (AppBarLayout) super.getView();
}
}

View File

@ -351,10 +351,18 @@ public class ViewAttributes {
this::parseDrawable, applier)));
}
protected void registerPixelAttr(String name, ValueApplier<Float> applier) {
registerAttr(name, this::parseDimensionToPixel, applier);
}
protected void registerIntPixelAttr(String name, ValueApplier<Integer> applier) {
registerAttr(name, this::parseDimensionToIntPixel, applier);
}
protected void registerIdAttr(String name, ValueApplier<Integer> applier) {
registerAttr(name, Ids::parse, applier);
}
protected void registerBooleanAttr(String name, ValueApplier<Boolean> applier) {
registerAttr(name, Boolean::parseBoolean, applier);
}

View File

@ -1,7 +1,10 @@
package com.stardust.autojs.core.ui.attribute;
import android.support.design.widget.AppBarLayout;
import android.view.View;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.TextView;
import com.stardust.autojs.core.ui.inflater.ResourceParser;
@ -17,6 +20,8 @@ public class ViewAttributesFactory {
static {
sViewAttributesCreators.put(ImageView.class, ImageViewAttributes::new);
sViewAttributesCreators.put(AppBarLayout.class, AppbarAttributes::new);
sViewAttributesCreators.put(TextView.class, TextViewAttributes::new);
}
public static void put(Class<? extends View> clazz, ViewAttributesCreator creator) {

View File

@ -30,6 +30,12 @@ import java.util.Map;
public class TextViewInflater<V extends TextView> extends BaseViewInflater<V> {
private static final int LEFT = 0;
private static final int TOP = 1;
private static final int RIGHT = 2;
private static final int BOTTOM = 3;
private static final ValueMapper<Integer> AUTO_LINK_MASKS = new ValueMapper<Integer>("autoLink")
.map("all", Linkify.ALL)
.map("email", Linkify.EMAIL_ADDRESSES)
@ -368,6 +374,18 @@ public class TextViewInflater<V extends TextView> extends BaseViewInflater<V> {
mAutoText = false;
}
private void setDrawable(V view, int d) {
Drawable[] drawables = view.getCompoundDrawables();
view.setCompoundDrawables(
mDrawableLeft != null ? mDrawableLeft : drawables[0],
mDrawableTop != null ? mDrawableTop : drawables[1],
mDrawableRight != null ? mDrawableRight : drawables[2],
mDrawableBottom != null ? mDrawableBottom : drawables[3]
);
mDrawableLeft = mDrawableBottom = mDrawableRight = mDrawableTop = null;
}
private void setDrawables(V view) {
Drawable[] drawables = view.getCompoundDrawables();
view.setCompoundDrawables(

View File

@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":425,"versionName":"4.0.3 Alpha6","enabled":true,"outputFile":"commonRelease-4.0.3 Alpha6.apk","fullName":"commonRelease","baseName":"common-release"},"path":"commonRelease-4.0.3 Alpha6.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":426,"versionName":"4.0.3 Alpha7","enabled":true,"outputFile":"commonRelease-4.0.3 Alpha7.apk","fullName":"commonRelease","baseName":"common-release"},"path":"commonRelease-4.0.3 Alpha7.apk","properties":{}}]

View File

@ -1,6 +1,6 @@
{
"appVersionCode": 425,
"appVersionName": "4.0.3 Alpha6",
"appVersionCode": 426,
"appVersionName": "4.0.3 Alpha7",
"target": 28,
"mini": 17,
"compile": 28,