6.3.1 - 新增发布通知权限 / WS 实例创建; 修复 floaty 模块异常 / 安卓 7.x 异常; UI 模式增强; 迁移至 View Binding
This commit is contained in:
@@ -62,6 +62,9 @@ module.exports = function (scriptRuntime, scope) {
|
||||
|
||||
Color.prototype = {
|
||||
constructor: Color,
|
||||
toString() {
|
||||
return this.digest();
|
||||
},
|
||||
digest() {
|
||||
return colors.digest.apply(colors, [ this.color ].concat(Array.from(arguments)));
|
||||
},
|
||||
@@ -78,6 +81,9 @@ module.exports = function (scriptRuntime, scope) {
|
||||
this.color = colors.setAlpha(this.color, alpha);
|
||||
return this;
|
||||
},
|
||||
setAlphaRelative(percentage) {
|
||||
return this.setAlpha(this.getAlpha() * _.parseRelativePercentage(percentage));
|
||||
},
|
||||
getAlpha() {
|
||||
return colors.alpha(this.color);
|
||||
},
|
||||
@@ -98,6 +104,9 @@ module.exports = function (scriptRuntime, scope) {
|
||||
this.color = colors.setRed(this.color, red);
|
||||
return this;
|
||||
},
|
||||
setRedRelative(percentage) {
|
||||
return this.setRed(this.getRed() * _.parseRelativePercentage(percentage));
|
||||
},
|
||||
getRed() {
|
||||
return colors.red(this.color);
|
||||
},
|
||||
@@ -118,6 +127,9 @@ module.exports = function (scriptRuntime, scope) {
|
||||
this.color = colors.setGreen(this.color, green);
|
||||
return this;
|
||||
},
|
||||
setGreenRelative(percentage) {
|
||||
return this.setGreen(this.getGreen() * _.parseRelativePercentage(percentage));
|
||||
},
|
||||
getGreen() {
|
||||
return colors.green(this.color);
|
||||
},
|
||||
@@ -138,6 +150,9 @@ module.exports = function (scriptRuntime, scope) {
|
||||
this.color = colors.setBlue(this.color, blue);
|
||||
return this;
|
||||
},
|
||||
setBlueRelative(percentage) {
|
||||
return this.setBlue(this.getBlue() * _.parseRelativePercentage(percentage));
|
||||
},
|
||||
getBlue() {
|
||||
return colors.blue(this.color);
|
||||
},
|
||||
@@ -267,6 +282,9 @@ module.exports = function (scriptRuntime, scope) {
|
||||
let [ r, g, b ] = this.toRgb(color);
|
||||
return this.toInt(this.argb(alpha, r, g, b));
|
||||
},
|
||||
setAlphaRelative(color, percentage) {
|
||||
return this.setAlpha(color, this.getAlpha(color) * _.parseRelativePercentage(percentage));
|
||||
},
|
||||
removeAlpha(color) {
|
||||
return this.setAlpha(color, 0);
|
||||
},
|
||||
@@ -293,6 +311,9 @@ module.exports = function (scriptRuntime, scope) {
|
||||
let [ a, , g, b ] = this.toArgb(color);
|
||||
return this.toInt(this.argb(a, red, g, b));
|
||||
},
|
||||
setRedRelative(color, percentage) {
|
||||
return this.setRed(color, this.getRed(color) * _.parseRelativePercentage(percentage));
|
||||
},
|
||||
removeRed(color) {
|
||||
return this.setRed(color, 0);
|
||||
},
|
||||
@@ -319,6 +340,9 @@ module.exports = function (scriptRuntime, scope) {
|
||||
let [ a, r, , b ] = this.toArgb(color);
|
||||
return this.toInt(this.argb(a, r, green, b));
|
||||
},
|
||||
setGreenRelative(color, percentage) {
|
||||
return this.getGreen(color, this.getGreen(color) * _.parseRelativePercentage(percentage));
|
||||
},
|
||||
removeGreen(color) {
|
||||
return this.setGreen(color, 0);
|
||||
},
|
||||
@@ -345,75 +369,27 @@ module.exports = function (scriptRuntime, scope) {
|
||||
let [ a, r, g ] = this.toArgb(color);
|
||||
return this.toInt(this.argb(a, r, g, blue));
|
||||
},
|
||||
setBlueRelative(color, percentage) {
|
||||
return this.setBlue(color, this.getBlue(color) * _.parseRelativePercentage(percentage));
|
||||
},
|
||||
removeBlue(color) {
|
||||
return this.setBlue(color, 0);
|
||||
},
|
||||
toInt(color) {
|
||||
try {
|
||||
return _.parseColor(typeof color === 'number' ? _.toJavaIntegerRange(color) : this.toFullHex(color));
|
||||
} catch (e) {
|
||||
scriptRuntime.console.error(`Passed color: ${color}`);
|
||||
throw Error(e + '\n' + e.stack);
|
||||
if (color instanceof _.Color) {
|
||||
color = color.color;
|
||||
}
|
||||
return ColorUtils.toInt.apply(ColorUtils, [ color ]);
|
||||
},
|
||||
toHex(color, alphaOrLength) {
|
||||
let [ _ignoredArg0, arg1 /* alpha | length */ ] = arguments;
|
||||
|
||||
if (color instanceof _.Color) {
|
||||
return this.toHex.apply(this, [ color.color ].concat(Array.from(arguments).slice(1)));
|
||||
}
|
||||
if (color instanceof ThemeColor) {
|
||||
return this.toHex.apply(this, [ color.getColorPrimary() ].concat(Array.from(arguments).slice(1)));
|
||||
}
|
||||
if (typeof color === 'number') {
|
||||
color = rtColors.toString(_.toJavaIntegerRange(color));
|
||||
if (isNullish(alphaOrLength)) {
|
||||
return ColorUtils.toHex.apply(ColorUtils, [ color ]);
|
||||
} else {
|
||||
color = String(color);
|
||||
return ColorUtils.toHex.apply(ColorUtils, [ color, alphaOrLength ]);
|
||||
}
|
||||
if (color.startsWith('#')) {
|
||||
if (color.length === 4) {
|
||||
color = color.replace(/(#)(\w)(\w)(\w)/, '$1$2$2$3$3$4$4');
|
||||
}
|
||||
} else {
|
||||
if (color === parseInt(color).toString()) {
|
||||
return this.toHex.apply(this, [ parseInt(color) ].concat(Array.from(arguments).slice(1)));
|
||||
}
|
||||
let colorByName = ColorTable.getColorByName(color, true);
|
||||
if (colorByName !== null) {
|
||||
return this.toHex.apply(this, [ colorByName.intValue() ].concat(Array.from(arguments).slice(1)));
|
||||
}
|
||||
}
|
||||
if (!/^#[A-F\d]{3}([A-F\d]{3}([A-F\d]{2})?)?$/i.test(color)) {
|
||||
throw TypeError(`Invalid color string format: ${color}`);
|
||||
}
|
||||
return ( /* @IIFE(toColorHex) */ () => {
|
||||
if (arg1 /* alpha */ === true || arg1 /* alpha */ === 'keep' || arg1 /* length */ === 8) {
|
||||
if (color.length === 7) {
|
||||
color = `#FF${color.slice(1)}`;
|
||||
}
|
||||
return color;
|
||||
}
|
||||
if (arg1 /* alpha */ === false || arg1 /* alpha */ === 'none' || arg1 /* length */ === 6) {
|
||||
return `#${color.slice(-6)}`;
|
||||
}
|
||||
if (arg1 /* length */ === 3) {
|
||||
if (!/^#(?:([A-F\d]){2})?([A-F\d])\2([A-F\d])\3([A-F\d])\4$/i.test(color)) {
|
||||
throw TypeError(`Can't convert color ${color} to #RGB with unexpected color format.`);
|
||||
}
|
||||
let [ r, g, b ] = [ color.slice(-6, -5), color.slice(-4, -3), color.slice(-2, -1) ];
|
||||
return `#${r}${g}${b}`;
|
||||
}
|
||||
if (arg1 /* alpha */ === undefined || arg1 /* alpha */ === 'auto') {
|
||||
return /^#FF([A-F\d]){6}$/i.test(color) ? `#${color.slice(3)}` : color;
|
||||
}
|
||||
throw TypeError('Unknown type of alpha for colors.toString()');
|
||||
})().toUpperCase();
|
||||
},
|
||||
/**
|
||||
* Color to full hex like '#BF110523'.
|
||||
*/
|
||||
toFullHex(color) {
|
||||
return this.toHex(color, 8);
|
||||
return ColorUtils.toFullHex.apply(ColorUtils, [ color ]);
|
||||
},
|
||||
/**
|
||||
* Get hex code string of a color.
|
||||
@@ -870,15 +846,12 @@ module.exports = function (scriptRuntime, scope) {
|
||||
parseNumber(num, def) {
|
||||
return typeof num === 'number' ? num : typeof def === 'function' ? def() : def || 0;
|
||||
},
|
||||
/**
|
||||
* @param {number|string} color
|
||||
* @returns {number}
|
||||
*/
|
||||
parseColor(color) {
|
||||
if (typeof color === 'string') {
|
||||
return rtColors.parseColor(color);
|
||||
parseRelativePercentage(percentage) {
|
||||
let p = Numberx.parseAny(percentage);
|
||||
if (isNaN(p) || p < 0) {
|
||||
throw TypeError(`Relative percentage must be in range 0..255, instead of ${percentage}`)
|
||||
}
|
||||
return color;
|
||||
return p;
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -11,8 +11,9 @@ let { files, util, s13n } = global;
|
||||
module.exports = function (scriptRuntime, scope) {
|
||||
const Log = android.util.Log;
|
||||
const Level = org.apache.log4j.Level;
|
||||
const ConsoleUtils = org.autojs.autojs.util.ConsoleUtils;
|
||||
const LogManager = org.apache.log4j.LogManager;
|
||||
const LogConfigurator = de.mindpipe.android.logging.log4j.LogConfigurator;
|
||||
const ConsoleUtils = org.autojs.autojs.util.ConsoleUtils;
|
||||
|
||||
// noinspection JSValidateTypes
|
||||
/** @type {org.autojs.autojs.core.console.GlobalConsole} */
|
||||
@@ -92,8 +93,14 @@ module.exports = function (scriptRuntime, scope) {
|
||||
Boolean(typeof value === 'function' ? value() : value),
|
||||
message || util.getClassName(java.lang.AssertionError));
|
||||
},
|
||||
input(data, param) {
|
||||
return eval(String(this.rawInput(data, param)));
|
||||
input() {
|
||||
// @Abandoned by SuperMonster003 as of May 3, 2023.
|
||||
// return eval(String(this.rawInput(data, param)));
|
||||
throw Error(context.getString(R.strings.error_abandoned_method, 'console.input'));
|
||||
},
|
||||
rawInput() {
|
||||
// @Abandoned by SuperMonster003 as of May 3, 2023.
|
||||
throw Error(context.getString(R.strings.error_abandoned_method, 'console.rawInput'));
|
||||
},
|
||||
log() {
|
||||
rtConsole.log(util.format.apply(util, arguments));
|
||||
@@ -247,6 +254,9 @@ module.exports = function (scriptRuntime, scope) {
|
||||
configurator.setResetConfiguration(_.parseOption(config.resetConfiguration, true));
|
||||
configurator.configure();
|
||||
},
|
||||
resetGlobalLogConfig() {
|
||||
LogManager.getLoggerRepository().resetConfiguration();
|
||||
},
|
||||
launch() {
|
||||
ConsoleUtils.launch();
|
||||
},
|
||||
|
||||
@@ -484,6 +484,11 @@ module.exports = function (runtime, scope) {
|
||||
delete this.$appropriateProtect;
|
||||
},
|
||||
},
|
||||
legacies: {
|
||||
isObjectSpecies(o) {
|
||||
return species.isObject(o);
|
||||
},
|
||||
},
|
||||
ensureNonUiThread() {
|
||||
if (ui.isUiThread()) {
|
||||
throw Error('不能在ui线程执行阻塞操作,请在子线程或子脚本执行,或者使用setInterval循环检测当前activity和package.');
|
||||
@@ -533,7 +538,7 @@ module.exports = function (runtime, scope) {
|
||||
},
|
||||
};
|
||||
|
||||
Object.assign(scope, _.extensions);
|
||||
Object.assign(scope, _.extensions, _.legacies);
|
||||
|
||||
// Object.keys(_.extensions)
|
||||
// .filter(key => !key.startsWith('$'))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
// noinspection JSUnusedGlobalSymbols,JSUnusedLocalSymbols,UnnecessaryLocalVariableJS
|
||||
|
||||
/* Overwritten protection. */
|
||||
|
||||
@@ -10,7 +10,8 @@ let { ui } = global;
|
||||
* @return {Internal.Http}
|
||||
*/
|
||||
module.exports = function (scriptRuntime, scope) {
|
||||
const PFile = org.autojs.pio.PFile;
|
||||
|
||||
const PFile = org.autojs.autojs.pio.PFile;
|
||||
const Request = okhttp3.Request;
|
||||
const RequestBody = okhttp3.RequestBody;
|
||||
const MultipartBody = okhttp3.MultipartBody;
|
||||
@@ -31,6 +32,13 @@ module.exports = function (scriptRuntime, scope) {
|
||||
Http.prototype = {
|
||||
constructor: Http,
|
||||
__okhttp__: new MutableOkHttp(),
|
||||
/**
|
||||
* @example
|
||||
* http.client() === http.client(); // true
|
||||
*/
|
||||
client() {
|
||||
return this.__okhttp__.client();
|
||||
},
|
||||
/**
|
||||
* @param {string} url
|
||||
* @param {Http.RequestBuilderOptions} [options]
|
||||
@@ -83,6 +91,7 @@ module.exports = function (scriptRuntime, scope) {
|
||||
return body;
|
||||
}
|
||||
if (typeof body === 'string') {
|
||||
// noinspection JSDeprecatedSymbols
|
||||
return RequestBody.create(MediaType.parse(this.options.contentType), body);
|
||||
}
|
||||
if (typeof body === 'function') {
|
||||
@@ -119,6 +128,7 @@ module.exports = function (scriptRuntime, scope) {
|
||||
let file = new PFile(path);
|
||||
fileName = fileName || file.getName();
|
||||
mimeType = mimeType || this.parseMimeType(file.getExtension());
|
||||
// noinspection JSDeprecatedSymbols
|
||||
let requestBody = RequestBody.create(MediaType.parse(mimeType), file);
|
||||
builder.addFormDataPart(key, fileName, requestBody);
|
||||
});
|
||||
|
||||
@@ -14,7 +14,13 @@ module.exports = function (scriptRuntime, scope) {
|
||||
const BigTextStyle = androidx.core.app.NotificationCompat.BigTextStyle;
|
||||
const Notification = android.app.Notification;
|
||||
const NotificationManager = android.app.NotificationManager;
|
||||
const NotificationManagerCompat = androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
// @Caution by SuperMonster003 on May 6, 2023.
|
||||
// ! On device running with Android 7.x,
|
||||
// ! importing NotificationManagerCompat will cause java.lang.ClassNotFoundException:
|
||||
// ! Didn't find class "android.app.NotificationChannel" on path: DexPathList ...
|
||||
|
||||
// const NotificationManagerCompat = androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
const configDefaults = {
|
||||
/**
|
||||
@@ -511,7 +517,9 @@ module.exports = function (scriptRuntime, scope) {
|
||||
if (!isNullish(id)) {
|
||||
let niceId = Number(id);
|
||||
if (!isNaN(niceId)) {
|
||||
NotificationManagerCompat.from(context).cancel(niceId);
|
||||
if (util.version.sdkInt >= util.versionCodes.O) {
|
||||
androidx.core.app.NotificationManagerCompat.from(context).cancel(niceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -65,11 +65,11 @@ module.exports = function (scriptRuntime, scope) {
|
||||
__asGlobal__(scriptRuntime.timers, methods, scope);
|
||||
|
||||
Object.assign(scope, {
|
||||
/**
|
||||
* @global
|
||||
*/
|
||||
/** @global */
|
||||
loop() {
|
||||
return scriptRuntime.console.warn('Method loop() is deprecated and has no effect.');
|
||||
// @Abandoned by SuperMonster003 as of May 3, 2023.
|
||||
// scriptRuntime.console.warn('Method loop() is deprecated and has no effect.');
|
||||
throw Error(context.getString(R.strings.error_abandoned_method, 'global.loop'));
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
@@ -12,17 +12,20 @@ let { files } = global;
|
||||
module.exports = function (scriptRuntime, scope) {
|
||||
const Looper = android.os.Looper;
|
||||
const Runnable = java.lang.Runnable;
|
||||
const Color = android.graphics.Color;
|
||||
const ContextThemeWrapper = android.view.ContextThemeWrapper;
|
||||
const ViewExtras = org.autojs.autojs.core.ui.ViewExtras;
|
||||
const JsListView = org.autojs.autojs.core.ui.widget.JsListView;
|
||||
const JsGridView = org.autojs.autojs.core.ui.widget.JsGridView;
|
||||
const JsViewHelper = org.autojs.autojs.core.ui.JsViewHelper;
|
||||
const ThemeColor = org.autojs.autojs.theme.ThemeColor;
|
||||
const DynamicLayoutInflater = org.autojs.autojs.core.ui.inflater.DynamicLayoutInflater;
|
||||
const ColorDrawable = android.graphics.drawable.ColorDrawable;
|
||||
|
||||
require('object-observe-lite.min').call(scope);
|
||||
require('array-observe.min').call(scope);
|
||||
|
||||
let isAndroidLayout = null;
|
||||
|
||||
// noinspection JSValidateTypes
|
||||
let _ = {
|
||||
// @Coerce by SuperMonster003 on Nov 9, 2022.
|
||||
@@ -142,6 +145,15 @@ module.exports = function (scriptRuntime, scope) {
|
||||
: activity);
|
||||
return layoutInflater.inflate(_.toXMLString(xml), parent || null, Boolean(isAttachedToParent));
|
||||
},
|
||||
useAndroidLayout(b) {
|
||||
if (typeof b === 'boolean') {
|
||||
isAndroidLayout = b;
|
||||
} else if (b === undefined) {
|
||||
isAndroidLayout = true;
|
||||
} else {
|
||||
isAndroidLayout = null;
|
||||
}
|
||||
},
|
||||
run(action) {
|
||||
if (this.isUiThread()) {
|
||||
return action();
|
||||
@@ -175,11 +187,16 @@ module.exports = function (scriptRuntime, scope) {
|
||||
scriptRuntime.getUiHandler().postDelayed(_.wrapUiAction(action), delay);
|
||||
}
|
||||
},
|
||||
layout(layout) {
|
||||
layout(xml) {
|
||||
_.ensureActivity();
|
||||
layoutInflater.setContext(activity);
|
||||
// noinspection JSCheckFunctionSignatures
|
||||
this.setContentView(layoutInflater.inflate(layout, activity.window.decorView, false));
|
||||
layoutInflater.setContext(activity);
|
||||
// noinspection JSCheckFunctionSignatures,JSTypeOfValues
|
||||
this.setContentView(layoutInflater.inflate(
|
||||
typeof xml === 'xml' ? xml.toXMLString() : String(xml),
|
||||
activity.window.decorView,
|
||||
false,
|
||||
));
|
||||
},
|
||||
layoutFile(path) {
|
||||
this.layout(files.read(path));
|
||||
@@ -200,18 +217,13 @@ module.exports = function (scriptRuntime, scope) {
|
||||
},
|
||||
statusBarColor(color) {
|
||||
_.ensureActivity();
|
||||
let colorInt = (/* @IIFE */ () => {
|
||||
if (typeof color === 'string') {
|
||||
if (Number(color).toString() === color) {
|
||||
color = Number(color);
|
||||
}
|
||||
}
|
||||
if (typeof color === 'number') {
|
||||
return color;
|
||||
}
|
||||
return scriptRuntime.colors.parseColor(String(color));
|
||||
})();
|
||||
this.run(() => activity.window.setStatusBarColor(colorInt));
|
||||
this.run(() => activity.window.setStatusBarColor(colors.toInt(color)));
|
||||
},
|
||||
backgroundColor(color) {
|
||||
_.ensureActivity();
|
||||
this.run(() => activity.window.setBackgroundDrawable(new ColorDrawable(
|
||||
Color(color).setAlpha(1.0).toInt(),
|
||||
)));
|
||||
},
|
||||
findById(id) {
|
||||
return this.view ? this.findByStringId(this.view, id) : null;
|
||||
@@ -235,28 +247,19 @@ module.exports = function (scriptRuntime, scope) {
|
||||
*/
|
||||
layoutInflaterDelegate: {
|
||||
beforeConvertXml(context, xml) {
|
||||
if (isAndroidLayout === true || isAndroidLayout === null && /\bxmlns:\w+="\w+:\/\/|\b(android|app):\w+=".+"/.test(xml)) {
|
||||
// noinspection JSTypeOfValues
|
||||
return typeof xml === 'xml' ? xml.toXMLString() : String(xml);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
afterConvertXml(context, xml) {
|
||||
return xml;
|
||||
},
|
||||
beforeInflation(context, xml, parent) {
|
||||
return null;
|
||||
},
|
||||
afterInflation(context, result, xml, parent) {
|
||||
return result;
|
||||
},
|
||||
beforeInflateView(context, node, parent, attachToParent) {
|
||||
return null;
|
||||
},
|
||||
afterInflateView(context, view, node, parent, attachToParent) {
|
||||
let { widget } = view;
|
||||
if (widget && context.get('root') !== widget) {
|
||||
widget.notifyAfterInflation(view);
|
||||
}
|
||||
return view;
|
||||
},
|
||||
beforeCreateView(context, node, viewName, parent, attrs) {
|
||||
beforeCreateView(context, node, viewName, parent) {
|
||||
if (uiProxy.__widgets__.hasOwnProperty(viewName)) {
|
||||
let Widget = uiProxy.__widgets__[viewName];
|
||||
let widget = new Widget();
|
||||
@@ -267,7 +270,13 @@ module.exports = function (scriptRuntime, scope) {
|
||||
}
|
||||
return null;
|
||||
},
|
||||
afterCreateView(context, view, node, viewName, parent, attrs) {
|
||||
beforeInflation(context, xml, parent) {
|
||||
return null;
|
||||
},
|
||||
afterInflation(context, result, xml, parent) {
|
||||
return result;
|
||||
},
|
||||
afterCreateView(context, view, node, viewName, parent) {
|
||||
if (view instanceof JsListView || view instanceof JsGridView) {
|
||||
_.initListView(view);
|
||||
}
|
||||
@@ -275,11 +284,13 @@ module.exports = function (scriptRuntime, scope) {
|
||||
if (widget !== null) {
|
||||
widget.view = view;
|
||||
view.widget = widget;
|
||||
ViewExtras.getViewAttributes(view, layoutInflater.getResourceParser()).setViewAttributeDelegate({
|
||||
has: name => widget.hasAttr(name),
|
||||
get: (view, name, getter) => widget.getAttr(view, name, getter),
|
||||
set: (view, name, value, setter) => widget.setAttr(view, name, value, setter),
|
||||
});
|
||||
ViewExtras
|
||||
.getViewAttributes(view, layoutInflater.getResourceParser())
|
||||
.setViewAttributeDelegate({
|
||||
has: name => widget.hasAttr(name),
|
||||
get: (view, name, getter) => widget.getAttr(view, name, getter),
|
||||
set: (view, name, value, setter) => widget.setAttr(view, name, value, setter),
|
||||
});
|
||||
widget.notifyViewCreated(view);
|
||||
}
|
||||
return view;
|
||||
@@ -287,6 +298,27 @@ module.exports = function (scriptRuntime, scope) {
|
||||
beforeApplyAttributes(context, view, inflater, attrs, parent) {
|
||||
return false;
|
||||
},
|
||||
beforeApplyAttribute(context, inflater, view, ns, attrName, value, parent) {
|
||||
let isDynamic = layoutInflater.isDynamicValue(value);
|
||||
return isDynamic && layoutInflater.getInflateFlags() === DynamicLayoutInflater.FLAG_IGNORES_DYNAMIC_ATTRS
|
||||
|| !isDynamic && layoutInflater.getInflateFlags() === DynamicLayoutInflater.FLAG_JUST_DYNAMIC_ATTRS
|
||||
|| (/* @IIFE */ () => {
|
||||
value = _.bind(value);
|
||||
let widget = context.get('widget');
|
||||
if (widget !== null && widget.hasAttr(attrName)) {
|
||||
widget.setAttr(view, attrName, value, (view, attrName, value) => {
|
||||
inflater.setAttr(view, ns, attrName, value, parent);
|
||||
});
|
||||
} else {
|
||||
inflater.setAttr(view, ns, attrName, value, parent);
|
||||
}
|
||||
this.afterApplyAttribute(context, inflater, view, ns, attrName, value, parent);
|
||||
return true;
|
||||
})();
|
||||
},
|
||||
afterApplyAttribute(context, inflater, view, ns, attrName, value, parent) {
|
||||
// Empty method body
|
||||
},
|
||||
afterApplyAttributes(context, view, inflater, attrs, parent) {
|
||||
context.remove('widget');
|
||||
},
|
||||
@@ -302,26 +334,12 @@ module.exports = function (scriptRuntime, scope) {
|
||||
afterApplyPendingAttributesOfChildren(context, inflater, view) {
|
||||
// Empty method body
|
||||
},
|
||||
beforeApplyAttribute(context, inflater, view, ns, attrName, value, parent, attrs) {
|
||||
let isDynamic = layoutInflater.isDynamicValue(value);
|
||||
return isDynamic && layoutInflater.getInflateFlags() === DynamicLayoutInflater.FLAG_IGNORES_DYNAMIC_ATTRS
|
||||
|| !isDynamic && layoutInflater.getInflateFlags() === DynamicLayoutInflater.FLAG_JUST_DYNAMIC_ATTRS
|
||||
|| (/* @IIFE */ () => {
|
||||
value = _.bind(value);
|
||||
let widget = context.get('widget');
|
||||
if (widget !== null && widget.hasAttr(attrName)) {
|
||||
widget.setAttr(view, attrName, value, (view, attrName, value) => {
|
||||
inflater.setAttr(view, ns, attrName, value, parent, attrs);
|
||||
});
|
||||
} else {
|
||||
inflater.setAttr(view, ns, attrName, value, parent, attrs);
|
||||
}
|
||||
this.afterApplyAttribute(context, inflater, view, ns, attrName, value, parent, attrs);
|
||||
return true;
|
||||
})();
|
||||
},
|
||||
afterApplyAttribute(context, inflater, view, ns, attrName, value, parent, attrs) {
|
||||
// Empty method body
|
||||
afterInflateView(context, view, node, parent, attachToParent) {
|
||||
let { widget } = view;
|
||||
if (widget && context.get('root') !== widget) {
|
||||
widget.notifyAfterInflation(view);
|
||||
}
|
||||
return view;
|
||||
},
|
||||
},
|
||||
bind(value) {
|
||||
@@ -333,7 +351,8 @@ module.exports = function (scriptRuntime, scope) {
|
||||
if (j < 0) {
|
||||
return value;
|
||||
}
|
||||
value = value.slice(0, i) + _.evalInContext(value.slice(i + 2, j), ctx) + value.slice(j + 2);
|
||||
let evaluated = _.evalInContext(value.slice(i + 2, j), ctx);
|
||||
value = value.slice(0, i) + _.attrValueConvert(evaluated) + value.slice(j + 2);
|
||||
i = j + 1;
|
||||
}
|
||||
return value;
|
||||
@@ -401,6 +420,18 @@ module.exports = function (scriptRuntime, scope) {
|
||||
setLayoutInflaterDelegate() {
|
||||
layoutInflater.setLayoutInflaterDelegate(this.layoutInflaterDelegate);
|
||||
},
|
||||
attrValueConvert(o) {
|
||||
if (typeof o === 'string') {
|
||||
return o;
|
||||
}
|
||||
if (o instanceof scope.Color) {
|
||||
return o.toHex();
|
||||
}
|
||||
if (o instanceof ThemeColor) {
|
||||
return o.getColorPrimary();
|
||||
}
|
||||
return o;
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
|
||||
/* Overwritten protection. */
|
||||
|
||||
let { http } = global;
|
||||
|
||||
/**
|
||||
* @param {org.autojs.autojs.runtime.ScriptRuntime} scriptRuntime
|
||||
* @param {org.mozilla.javascript.Scriptable | global} scope
|
||||
@@ -38,6 +42,9 @@ module.exports = function (scriptRuntime, scope) {
|
||||
newInjectableWebClient() {
|
||||
return new InjectableWebClient(Context.getCurrentContext(), scope);
|
||||
},
|
||||
newWebSocket(url) {
|
||||
return new org.autojs.autojs.core.web.WebSocket(http.__okhttp__, url);
|
||||
},
|
||||
};
|
||||
|
||||
return Web;
|
||||
@@ -46,7 +53,7 @@ module.exports = function (scriptRuntime, scope) {
|
||||
/**
|
||||
* @type {(keyof Internal.Web)[]}
|
||||
*/
|
||||
let methods = [ 'newInjectableWebView', 'newInjectableWebClient' ];
|
||||
let methods = [ 'newInjectableWebView', 'newInjectableWebClient', 'newWebSocket' ];
|
||||
__asGlobal__(web, methods, scope);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
module.exports = function(){
|
||||
Object.observe&&!Array.observe&&function(t,e){"use strict";var n=t.getNotifier,r="performChange",i="_original",o="splice";var u={push:function h(t){var e=arguments,u=h[i].apply(this,e);n(this)[r](o,function(){return{index:u-e.length,addedCount:e.length,removed:[]}});return u},unshift:function d(t){var e=arguments,u=d[i].apply(this,e);n(this)[r](o,function(){return{index:0,addedCount:e.length,removed:[]}});return u},pop:function a(){var t=this.length,e=a[i].call(this);if(this.length!==t)n(this)[r](o,function(){return{index:this.length,addedCount:0,removed:[e]}},this);return e},shift:function l(){var t=this.length,e=l[i].call(this);if(this.length!==t)n(this)[r](o,function(){return{index:0,addedCount:0,removed:[e]}},this);return e},splice:function f(t,e){var u=arguments,s=f[i].apply(this,u);if(s.length||u.length>2)n(this)[r](o,function(){return{index:t,addedCount:u.length-2,removed:s}},this);return s}};for(var s in u){u[s][i]=e.prototype[s];e.prototype[s]=u[s]}e.observe=function(e,n){return t.observe(e,n,["add","update","delete",o])};e.unobserve=t.unobserve}(Object,Array);
|
||||
Object.observe&&!Array.observe&&function(t,e){var n=t.getNotifier,r="performChange",i="_original",o="splice";var u={push:function h(t){var e=arguments,u=h[i].apply(this,e);n(this)[r](o,function(){return{index:u-e.length,addedCount:e.length,removed:[]}});return u},unshift:function d(t){var e=arguments,u=d[i].apply(this,e);n(this)[r](o,function(){return{index:0,addedCount:e.length,removed:[]}});return u},pop:function a(){var t=this.length,e=a[i].call(this);if(this.length!==t)n(this)[r](o,function(){return{index:this.length,addedCount:0,removed:[e]}},this);return e},shift:function l(){var t=this.length,e=l[i].call(this);if(this.length!==t)n(this)[r](o,function(){return{index:0,addedCount:0,removed:[e]}},this);return e},splice:function f(t,e){var u=arguments,s=f[i].apply(this,u);if(s.length||u.length>2)n(this)[r](o,function(){return{index:t,addedCount:u.length-2,removed:s}},this);return s}};for(var s in u){u[s][i]=e.prototype[s];e.prototype[s]=u[s]}e.observe=function(e,n){return t.observe(e,n,["add","update","delete",o])};e.unobserve=t.unobserve}(Object,Array);
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
( /* @ModuleIIFE */ () => {
|
||||
|
||||
"use strict";
|
||||
|
||||
var _createClass = function () {
|
||||
function defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
* @see https://raw.githubusercontent.com/taylorhakes/promise-polyfill/master/dist/polyfill.js
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @type {PromiseConstructorLike}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user