6.6.0 - 内置模块重写; 新增部分模块及方法; 修复高版本安卓系统兼容问题; 优化文件管理器及打包功能体验
This commit is contained in:
@@ -5,7 +5,6 @@ example1();
|
||||
example2();
|
||||
example3();
|
||||
example4();
|
||||
example5();
|
||||
|
||||
function example1(){
|
||||
var res = http.postMultipart("http://posttestserver.com/post.php", {
|
||||
10
app/src/main/assets-app/sample/HTTP/文件下载.js
Normal file
10
app/src/main/assets-app/sample/HTTP/文件下载.js
Normal file
@@ -0,0 +1,10 @@
|
||||
let url = 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png';
|
||||
let res = http.get(url);
|
||||
if (res.statusCode !== 200) {
|
||||
toast('请求失败');
|
||||
exit();
|
||||
}
|
||||
let path = './github-mark.png';
|
||||
files.writeBytes(path, res.body.bytes());
|
||||
toast(`下载成功: ${path}`);
|
||||
app.viewFile(path);
|
||||
14
app/src/main/assets-app/sample/HTTP/获取网页.js
Normal file
14
app/src/main/assets-app/sample/HTTP/获取网页.js
Normal file
@@ -0,0 +1,14 @@
|
||||
let MAX_LENGTH_TO_PRINT = 3000;
|
||||
|
||||
let url = 'https://www.npmjs.com';
|
||||
let res = http.get(url);
|
||||
if (res.statusCode !== 200) {
|
||||
toast(`请求失败: ${res.statusMessage}`);
|
||||
exit();
|
||||
}
|
||||
let str = res.body.string();
|
||||
toastLog(`请求响应体字符长度: ${str.length}`);
|
||||
console.log(str.length > MAX_LENGTH_TO_PRINT
|
||||
? str.slice(0, MAX_LENGTH_TO_PRINT) + '\n\n... ...'
|
||||
: str);
|
||||
console.show();
|
||||
@@ -1,8 +0,0 @@
|
||||
var url = "http://www.autojs.org/assets/uploads/profile/3-profileavatar.png";
|
||||
var res = http.get(url);
|
||||
if(res.statusCode !== 200){
|
||||
toast("请求失败");
|
||||
}
|
||||
files.writeBytes("/sdcard/1.png", res.body.bytes());
|
||||
toast("下载成功");
|
||||
app.viewFile("/sdcard/1.png");
|
||||
@@ -1,9 +0,0 @@
|
||||
var url = "www.baidu.com";
|
||||
var res = http.get(url);
|
||||
if(res.statusCode === 200){
|
||||
toast("请求成功");
|
||||
console.show();
|
||||
log(res.body.string());
|
||||
}else{
|
||||
toast("请求失败:" + res.statusMessage);
|
||||
}
|
||||
@@ -20,9 +20,7 @@ events.on("key", function(code, event){
|
||||
}
|
||||
});
|
||||
|
||||
loop();
|
||||
|
||||
|
||||
// loop();
|
||||
|
||||
function getKeyName(code, event){
|
||||
var keyCodeStr = event.keyCodeToString(code);
|
||||
|
||||
@@ -9,4 +9,4 @@ events.on("touch", function(point){
|
||||
log(point);
|
||||
});
|
||||
|
||||
loop();
|
||||
// loop();
|
||||
@@ -18,7 +18,7 @@ events.onKeyUp("back", function(event){
|
||||
clearTimeout(timeoutId);
|
||||
});
|
||||
|
||||
loop();
|
||||
// loop();
|
||||
|
||||
function backBackBackBack(){
|
||||
while(curPackage === currentPackage()){
|
||||
|
||||
@@ -21,7 +21,7 @@ events.onKeyDown("volume_down", function(event){
|
||||
|
||||
task();
|
||||
|
||||
loop();
|
||||
// loop();
|
||||
|
||||
function task1(){
|
||||
toast("任务1运行中,音量下键结束,音量上键切换任务");
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
ui.layout(
|
||||
<frame bg="#4fc3f7">
|
||||
<text textColor="white" textSize="18sp" layout_gravity="center">
|
||||
UI中使用协程
|
||||
</text>
|
||||
</frame>
|
||||
</frame>,
|
||||
);
|
||||
|
||||
continuation.delay(5000);
|
||||
if (!requestScreenCapture()) {
|
||||
dialogs.alert("请授予软件截图权限").await();
|
||||
}
|
||||
|
||||
images.requestScreenCaptureAsync(() => {
|
||||
toast('截图权限授予成功');
|
||||
});
|
||||
dialogs.alert('请授予软件截图权限').await();
|
||||
|
||||
// 退出应用对话框
|
||||
ui.emitter.on("back_pressed", function (e) {
|
||||
ui.emitter.on('back_pressed', function (e) {
|
||||
e.consumed = true;
|
||||
let exit = dialogs.confirm("确定要退出程序").await();
|
||||
let exit = dialogs.confirm('确定要退出程序').await();
|
||||
if (exit) {
|
||||
ui.finish();
|
||||
}
|
||||
@@ -68,9 +68,7 @@ let $ = {
|
||||
}
|
||||
},
|
||||
parseInputAndSetView(inputText) {
|
||||
let result = util.versionCodes.search(inputText.toString());
|
||||
let infos = Array.isArray(result) ? result : result ? [result] : [];
|
||||
infos.forEach((info) => {
|
||||
util.versionCodes.searchAll(inputText.toString()).forEach((info) => {
|
||||
this.setInfoView(info);
|
||||
this.setSplitLineView();
|
||||
});
|
||||
@@ -84,7 +82,7 @@ let $ = {
|
||||
// e.g. versionCode -> Version Code
|
||||
// e.g. platformVersion -> Platform Version
|
||||
let prop = key.replace(/^([a-z]+)(([A-Z][a-z]+)*)$/, ($, $1, $2) => /* @AXR */ (
|
||||
StringUtils.toUpperCaseFirst($1) + $2.replace(/[A-Z](?=[a-z])/g, ' $&')
|
||||
StringUtils.uppercaseFirstChar($1) + $2.replace(/[A-Z](?=[a-z])/g, ' $&')
|
||||
));
|
||||
infoView['text'].setText(`${prop}: ${info[key]}`);
|
||||
infoView['text'].setTextSize(_.textSize);
|
||||
|
||||
@@ -10,11 +10,14 @@ let test = o => console.log(`Test instance ${o ? `passed` : `failed`}`);
|
||||
test(util.getClass(Clazz) === Clazz);
|
||||
test(util.getClassName(Clazz) === 'android.os.BatteryManager');
|
||||
|
||||
// @Caution by SuperMonster003 on May 25, 2022.
|
||||
// @Caution by SuperMonster003 on Nov 11, 2024.
|
||||
// ! This test won't pass.
|
||||
// ! Use util.getClass(C) instanceof P instead.
|
||||
test(Clazz instanceof java.lang.Class);
|
||||
test(util.getClass(Clazz) instanceof java.lang.Class);
|
||||
// ! Use `util.getClass(C) instanceof P` instead.
|
||||
// ! zh-CN:
|
||||
// ! 当前测试不会通过.
|
||||
// ! 需使用 `C.class instanceof P` 替代.
|
||||
// test(Clazz instanceof java.lang.Class);
|
||||
test(Clazz.class instanceof java.lang.Class);
|
||||
|
||||
test(new java.lang.Integer(0.5).getClass() === java.lang.Integer);
|
||||
test(util.getClass(new java.lang.Integer(0.5)) === java.lang.Integer);
|
||||
@@ -62,6 +62,6 @@ ui.decrypt.click(() => {
|
||||
activity.finish();
|
||||
});
|
||||
ui.decrypt.longClick(() => {
|
||||
toast("You can't decrypt!");
|
||||
toast("You cannot decrypt!");
|
||||
return true;
|
||||
});
|
||||
|
||||
21
app/src/main/assets-app/sample/控件/文本控件 [v6.6.0+].js
Normal file
21
app/src/main/assets-app/sample/控件/文本控件 [v6.6.0+].js
Normal file
@@ -0,0 +1,21 @@
|
||||
'ui';
|
||||
|
||||
ui.layout(
|
||||
<vertical padding="8">
|
||||
<text textSize="40sp" margin="8">大字</text>
|
||||
<text textSize="12sp" margin="8">小字</text>
|
||||
<text w="*" gravity="start" textSize="20sp" margin="8">居首</text>
|
||||
<text w="*" gravity="center" textSize="20sp" margin="8">居中</text>
|
||||
<text w="*" gravity="end" textSize="20sp" margin="8">居尾</text>
|
||||
<text textStyle="bold" textColor="black" margin="8">加粗</text>
|
||||
<text textStyle="italic" margin="8">斜体</text>
|
||||
<text textColor="dark-red" margin="8">深红色</text>
|
||||
<text margin="8">Android 是一种基于 Linux 的自由及开放源代码的操作系统, 主要使用于移动设备, 如智能手机和平板电脑, 由 Google 公司和开放手机联盟领导及开发. 尚未有统一中文名称, 中国大陆地区较多人使用 "安卓" 或 "安致". Android 操作系统最初由 Andy Rubin 开发, 主要支持手机. 2005 年 8 月由 Google 收购注资. 2007 年 11 月, Google 与 84 家硬件制造商, 软件开发商及电信营运商组建开放手机联盟共同研发改良 Android 系统.</text>
|
||||
<text maxLines="1" ellipsize="end" margin="8">Android 是一种基于 Linux 的自由及开放源代码的操作系统, 主要使用于移动设备, 如智能手机和平板电脑, 由 Google 公司和开放手机联盟领导及开发. 尚未有统一中文名称, 中国大陆地区较多人使用 "安卓" 或 "安致". Android 操作系统最初由 Andy Rubin 开发, 主要支持手机. 2005 年 8 月由 Google 收购注资. 2007 年 11 月, Google 与 84 家硬件制造商, 软件开发商及电信营运商组建开放手机联盟共同研发改良 Android 系统.</text>
|
||||
<text maxLines="2" ellipsize="end" margin="8">Android 是一种基于 Linux 的自由及开放源代码的操作系统, 主要使用于移动设备, 如智能手机和平板电脑, 由 Google 公司和开放手机联盟领导及开发. 尚未有统一中文名称, 中国大陆地区较多人使用 "安卓" 或 "安致". Android 操作系统最初由 Andy Rubin 开发, 主要支持手机. 2005 年 8 月由 Google 收购注资. 2007 年 11 月, Google 与 84 家硬件制造商, 软件开发商及电信营运商组建开放手机联盟共同研发改良 Android 系统.</text>
|
||||
<text autoLink="none" margin="8">网址 www.baidu.com, 邮箱 example@qq.com 等</text>
|
||||
<text autoLink="web" margin="8">网址 www.baidu.com, 邮箱 example@qq.com 等</text>
|
||||
<text autoLink="email" margin="8">网址 www.baidu.com, 邮箱 example@qq.com 等</text>
|
||||
<text autoLink="all" margin="8">网址 www.baidu.com, 邮箱 example@qq.com 等</text>
|
||||
</vertical>
|
||||
);
|
||||
@@ -8,5 +8,5 @@ console.error(`Text from \`console.error\``);
|
||||
try {
|
||||
console.assert(false, `Text from \`console.assert\``);
|
||||
} catch (e) {
|
||||
// Ignored.
|
||||
/* Ignored. */
|
||||
}
|
||||
@@ -32,9 +32,11 @@ Promise.resolve().then(() => {
|
||||
// @Test images
|
||||
|
||||
// FIXME by SuperMonster003 on May 7, 2022.
|
||||
// ! Auto.js freezes or won't respond when calling images.requestScreenCapture()
|
||||
// assert(noError(images.requestScreenCapture, images), 'images.requestScreenCapture()');
|
||||
// assert(noError(() => images.captureScreen()), 'images.captureScreen()');
|
||||
// ! AutoJs6 won't respond when calling images.requestScreenCapture() .
|
||||
// ! zh-CN: 当调用 images.requestScreenCapture() 方法时, AutoJs6 应用将会无响应.
|
||||
// !
|
||||
// # assert(noError(images.requestScreenCapture, images), 'images.requestScreenCapture()');
|
||||
// # assert(noError(() => images.captureScreen()), 'images.captureScreen()');
|
||||
|
||||
// @Test dialogs
|
||||
|
||||
@@ -62,8 +64,10 @@ assert(typeof engines.myEngine().getSource().getName() === 'string', 'engines.my
|
||||
// @Test floaty
|
||||
|
||||
// FIXME by SuperMonster003 on May 7, 2022.
|
||||
// ! Auto.js freezes or won't respond when calling floaty.rawWindow()
|
||||
// assert(noError(() => floaty.rawWindow('<vertical/>')), 'floaty.rawWindow()');
|
||||
// ! AutoJs6 won't respond when calling floaty.rawWindow() .
|
||||
// ! zh-CN: 当调用 floaty.rawWindow() 方法时, AutoJs6 应用将会无响应.
|
||||
// !
|
||||
// # assert(noError(() => floaty.rawWindow('<vertical/>')), 'floaty.rawWindow()');
|
||||
assert(noError(() => floaty.closeAll()), 'floaty.closeAll()');
|
||||
|
||||
// @Test continuation
|
||||
|
||||
Reference in New Issue
Block a user