mirror of
https://github.com/TonyJiangWJ/Auto.js.git
synced 2026-06-24 21:33:16 +08:00
feat: appbar attributes
This commit is contained in:
parent
ac889ceff6
commit
db3571851c
@ -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();
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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":{}}]
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"appVersionCode": 425,
|
||||
"appVersionName": "4.0.3 Alpha6",
|
||||
"appVersionCode": 426,
|
||||
"appVersionName": "4.0.3 Alpha7",
|
||||
"target": 28,
|
||||
"mini": 17,
|
||||
"compile": 28,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user