Skip to content

Commit

Permalink
2.1.1 - 新增简易能量雨收集工具 修复排行榜列表数据采集/逛一逛方案结束条件 去除部分工具模块依赖
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperMonster003 committed May 17, 2021
1 parent 5c9d0e9 commit 6dfeabb
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 111 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,13 @@
[comment]: <> (Version history only shows last 3 versions)

# v2.1.1
###### 2021/05/16
###### 2021/05/17
* `新增` 能量雨收集工具 (简易) (/tools/energy-rain-harvesting.js)
* `修复` 配置工具采集排行榜列表数据功能异常 _[`issue #462`](https://github.com/SuperMonster003/Ant-Forest/issues/462)_
* `修复` 部署工具备份本地项目时无法处理空项目目录的问题 _[`issue #459`](https://github.com/SuperMonster003/Ant-Forest/issues/459)_
* `优化` 完善Auto.js版本异常检测列表及异常提示界面样式
* `优化` 逛一逛按钮采集方案结束页面判断条件 _[`issue #391`](https://github.com/SuperMonster003/Ant-Forest/issues/391#issuecomment-840679845)_
* `优化` 去除"修改系统设置权限"辅助工具的模块依赖 _[`issue #465`](https://github.com/SuperMonster003/Ant-Forest/issues/465)_

# v2.1.0
###### 2021/04/15
Expand Down
4 changes: 2 additions & 2 deletions ant-forest-launcher.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Alipay ant forest intelligent collection script launcher
* @since May 16, 2021
* @since May 17, 2021
* @version 2.1.1
* @author SuperMonster003
* @see https://github.com/SuperMonster003/Ant-Forest
Expand All @@ -17,7 +17,7 @@ let $$init = {
console.error('ext-app模块不存在');
console.error('请检查项目目录结构');
}
throw e;
throw Error(e);
}
},
check() {
Expand Down
2 changes: 1 addition & 1 deletion ant-forest-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let $$init = {
console.error('ext-app模块不存在');
console.error('请检查项目目录结构');
}
throw e;
throw Error(e);
}
},
check() {
Expand Down
3 changes: 2 additions & 1 deletion documents/CHANGELOG-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
### 版本历史 - 2.x
******
# v2.1.1
###### 2021/05/16
###### 2021/05/17
* `新增` 能量雨收集工具 (简易) (/tools/energy-rain-harvesting.js)
* `修复` 配置工具采集排行榜列表数据功能异常 _[`issue #462`](https://github.com/SuperMonster003/Ant-Forest/issues/462)_
* `修复` 部署工具备份本地项目时无法处理空项目目录的问题 _[`issue #459`](https://github.com/SuperMonster003/Ant-Forest/issues/459)_
* `优化` 完善Auto.js版本异常检测列表及异常提示界面样式
* `优化` 逛一逛按钮采集方案结束页面判断条件 _[`issue #391`](https://github.com/SuperMonster003/Ant-Forest/issues/391#issuecomment-840679845)_
* `优化` 去除"修改系统设置权限"辅助工具的模块依赖 _[`issue #465`](https://github.com/SuperMonster003/Ant-Forest/issues/465)_

# v2.1.0
###### 2021/04/15
Expand Down
2 changes: 1 addition & 1 deletion project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
],
"packageName": "com.sm003.ant.forest",
"versionName": "2.1.1",
"versionCode": 388,
"versionCode": 389,
"launchConfig": {
"displaySplash": false,
"hideLogs": false,
Expand Down
179 changes: 74 additions & 105 deletions tools/auto.js-write-settings-permission-helper.js
Original file line number Diff line number Diff line change
@@ -1,108 +1,77 @@
!function () {
try {
auto.waitFor();
} catch (e) {
auto();
}
let _cont = {
about: '当Auto.js拥有该权限时\n' +
'可以通过代码修改系统设置的参数值\n' +
'如亮度设置/音量设置/屏幕超时等\n\n' +
'如"蚂蚁森林"项目的关屏策略之一\n' +
'就是利用此权限实现关屏的\n' +
'详情可点击"适用场景"\n\n' +
'点击"跳转设置页面"\n' +
'可跳转到权限设置页面\n' +
'用户可自行决定打开或关闭\n' +
'Auto.js的"修改系统设置"权限\n' +
'页面跳转后此对话框将自动关闭',
situation: '1. 利用修改屏幕超时实现关屏\n\n' +
'通常在"屏幕"或"显示"设置中\n' +
'包含"屏幕超时时间"的设置\n' +
'如"1分钟"表示在设备没有接收到\n' +
'屏幕触碰事件或按键响应事件后\n' +
'屏幕将自动关闭\n' +
'使用代码将此值修改为最小值后\n' +
'屏幕将在几秒钟内自动关闭\n' +
'进而实现非Root设备无法实现\n' +
'的代码关屏功能\n\n' +
'注意:\n' +
'1. 在等待屏幕关闭期间\n' +
'要避免触碰屏幕或按键\n' +
'否则屏幕超时时间将被重置\n' +
'由此可能导致在指定时间内\n' +
'屏幕无法按时关闭\n' +
'进而导致屏幕关闭失败\n' +
'2. 此功能在无人值守时\n' +
'可能才会有较高的使用价值\n' +
'3. 部分用户可能开启了\n' +
'充电保持屏幕唤醒的功能\n' +
'代码中已考虑并适用此情形\n' +
'4. 代码会在屏幕关闭的瞬间\n' +
'立即恢复修改之前的设置值\n' +
'因此用户无需手动改回',
};
let _colors = {
default_aj_4: '#01a9f3', // Auto.js 4.1.1 Alpha2
caution: '#ff3d00',
hint: '#0da798',
attraction: '#7b1fa2',
};

_updateRequire();
require('../modules/ext-dialogs').load();
_showDiag();

// tool function(s) //

function _updateRequire() {
_updateMethod(global, 'require', (args) => {
let path = args[0] || '';
path = './' + path.replace(/^([./]*)(?=\w)/, '').replace(/(\.js)*$/, '') + '.js';
for (let i = 0; ; i += 1) {
if (files.exists(path)) {
return [path];
}
if (i === 3) {
return [args[0]];
}
path = '.' + path;
}
});

// tool function(s) //

function _updateMethod(o, name, f) {
let old = o[name];
o[name] = function () {
let isFunction = f => typeof f === 'function';
if (!isFunction(old)) return old;
return old.apply(this, isFunction(f) ? f(arguments) : arguments);
};
}
}

function _showDiag() {
let _cont = {
about: '当Auto.js拥有该权限时\n' +
'可以通过代码修改系统设置的参数值\n' +
'如亮度设置/音量设置/屏幕超时等\n\n' +
'如"蚂蚁森林"项目的关屏策略之一\n' +
'就是利用此权限实现关屏的\n' +
'详情可点击"适用场景"\n\n' +
'点击"跳转设置页面"\n' +
'可跳转到权限设置页面\n' +
'用户可自行决定打开或关闭\n' +
'Auto.js的"修改系统设置"权限\n' +
'页面跳转后此对话框将自动关闭',
situation: '1. 利用修改屏幕超时实现关屏\n\n' +
'通常在"屏幕"或"显示"设置中\n' +
'包含"屏幕超时时间"的设置\n' +
'如"1分钟"表示在设备没有接收到\n' +
'屏幕触碰事件或按键响应事件后\n' +
'屏幕将自动关闭\n' +
'使用代码将此值修改为最小值后\n' +
'屏幕将在几秒钟内自动关闭\n' +
'进而实现非Root设备无法实现\n' +
'的代码关屏功能\n\n' +
'注意:\n' +
'1. 在等待屏幕关闭期间\n' +
'要避免触碰屏幕或按键\n' +
'否则屏幕超时时间将被重置\n' +
'由此可能导致在指定时间内\n' +
'屏幕无法按时关闭\n' +
'进而导致屏幕关闭失败\n' +
'2. 此功能在无人值守时\n' +
'可能才会有较高的使用价值\n' +
'3. 部分用户可能开启了\n' +
'充电保持屏幕唤醒的功能\n' +
'代码中已考虑并适用此情形\n' +
'4. 代码会在屏幕关闭的瞬间\n' +
'立即恢复修改之前的设置值\n' +
'因此用户无需手动改回',
};

dialogsx.builds(['关于"修改系统设置"权限', _cont.about,
'适用场景', 'X', '跳转设置页面', 1])
.on('neutral', () => {
dialogsx.builds(['权限在Auto.js的使用场景',
_cont.situation, 0, 0, 'B', 1])
.on('positive', ds => ds.dismiss())
.show();
})
.on('negative', (d) => {
d.dismiss();
})
.on('positive', (d) => {
d.dismiss();
_activity();
})
.show();

// tool function(s) //

function _activity() {
let _s = android.provider.Settings.ACTION_MANAGE_WRITE_SETTINGS;
let _intent = new android.content.Intent(_s)
.setData(android.net.Uri.parse('package:' + context.packageName))
.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
app.startActivity(_intent);
}
}
dialogs.build({
title: '关于"修改系统设置"权限',
content: _cont.about,
neutral: '适用场景',
neutralColor: _colors.hint,
negative: '退出',
negativeColor: _colors.caution,
positive: '跳转设置页面',
positiveColor: _colors.attraction,
autoDismiss: false,
canceledOnTouchOutside: false,
}).on('neutral', () => {
dialogs.build({
title: '权限在Auto.js的使用场景',
content: _cont.situation,
positive: '返回',
positiveColor: _colors.default_aj_4,
autoDismiss: false,
canceledOnTouchOutside: false,
}).on('positive', ds => ds.dismiss()).show();
}).on('negative', (d) => {
d.dismiss();
}).on('positive', (d) => {
d.dismiss();
let _s = android.provider.Settings.ACTION_MANAGE_WRITE_SETTINGS;
let _intent = new android.content.Intent(_s)
.setData(android.net.Uri.parse('package:' + context.packageName))
.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
app.startActivity(_intent);
}).show();
}();

0 comments on commit 6dfeabb

Please sign in to comment.