Skip to content

Commit

Permalink
2.1.9 - 修复OCR方案获取倒计时停止时机 提高成熟能量球识别率
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperMonster003 committed Aug 20, 2021
1 parent 09e656e commit 6e93a95
Show file tree
Hide file tree
Showing 15 changed files with 314 additions and 168 deletions.
21 changes: 7 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@

[comment]: <> (Version history only shows last 3 versions)

# v2.1.9
###### 2021/08/20
* `修复` 配置工具无法设置排行榜滑动距离等相关配置项的问题
* `修复` 获取能量球数据缓存时逻辑错误导致效率提升无效的问题
* `修复` OCR方案获取倒计时耗时过久未能按预期及时停止的问题
* `优化` 霍夫变换覆盖检测方法优化以提高成熟能量球识别率 _[`issue #508`](https://github.com/SuperMonster003/Ant-Forest/issues/508#issuecomment-900102913)_

# v2.1.8
###### 2021/08/13
* `修复` 配置工具对话框监听器this指针绑定失效的问题 _[`issue #513`](https://github.com/SuperMonster003/Ant-Forest/issues/513)_ _[`#511`](https://github.com/SuperMonster003/Ant-Forest/issues/511#issuecomment-896448713)_
Expand All @@ -134,20 +141,6 @@
* `优化` 及时回收图片资源避免可能的内存泄漏 _[`issue #497`](https://github.com/SuperMonster003/Ant-Forest/issues/497)_
* `优化` 能量雨收集工具条件判断完善及网络异常适配

# v2.1.6
###### 2021/07/19
* `新增` Root权限功能配置
* `修复` 模块交叉引用导致部分模块独立引用失败的问题
* `修复` 版本忽略管理匹配输入时结果可能出现错误的问题
* `修复` 配置工具设备通话状态值无法直接填入空闲值的问题
* `修复` 排行榜自定义标题无效导致初始状态准备失败的问题 _[`issue #498`](https://github.com/SuperMonster003/Ant-Forest/issues/498)_
* `修复` 排行榜页面更新导致的好友信息获取异常的问题 _[`issue #499`](https://github.com/SuperMonster003/Ant-Forest/issues/499)_
* `修复` 逛一逛方案获取排行榜倒计时可能出现空指针引用的问题
* `优化` 默认关闭Root权限结束应用防止Floaty结果显示异常
* `优化` 替换设备通话状态值获取方法的代码方案 (试优化)
* `优化` 逛一逛方案获取倒计时排行榜页面滚动速度
* `优化` 排行榜页面底部监测线程的内部检测逻辑

##### 更多版本历史可参阅

* [CHANGELOG-2.md](https://github.com/SuperMonster003/Ant-Forest/blob/master/documents/CHANGELOG-2.md) ( 2.x 版本 )
Expand Down
30 changes: 13 additions & 17 deletions ant-forest-launcher.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Alipay ant forest intelligent collection script launcher
* @since Aug 13, 2021
* @version 2.1.8
* @since Aug 20, 2021
* @version 2.1.9
* @author SuperMonster003
* @see https://github.com/SuperMonster003/Ant-Forest
*/
Expand Down Expand Up @@ -3305,7 +3305,7 @@ let $$init = {
/** @type {Object.<string,GlobEventMonitorOptions>|Object} */
_glob_e_preset_options: {
phone: {
_getCurState() {
_getStoState() {
let _self = {
state_key: 'phone_call_state_idle_value',
get cur_state() {
Expand Down Expand Up @@ -3375,7 +3375,7 @@ let $$init = {
},
switching: 'phone_call_state_monitor_switch',
trigger() {
return devicex.getCallState() !== this._getCurState();
return devicex.getCallState() !== this._getStoState();
},
onRelease() {
debugInfo('前置"支付宝"应用');
Expand Down Expand Up @@ -3441,7 +3441,7 @@ let $$init = {
$$toast('闹钟界面置于后台时\n脚本将自动继续', 'L', 'F');
},
trigger() {
return !devicex.checkNextAlarmClockTriggerTime(this._thrd);
return devicex.isNextAlarmClockTriggered(this._thrd);
},
onTrigger() {
this._saveInnerPkgIFN();
Expand Down Expand Up @@ -3955,7 +3955,7 @@ let $$init = {
unlock() {
let _is_scr_on = devicex.is_init_screen_on;
let _is_unlked = devicex.isUnlocked();
let _err = m => {
let _err = (m) => {
messageAction('脚本无法继续', 4, 0, 0, -1);
messageAction(m, 8, 4, 1, 1);
};
Expand Down Expand Up @@ -4435,7 +4435,7 @@ let $$af = {
*/
eballs(type, options) {
let _opt = options || {};
if (!_opt.is_cache || Object.size(this.home_balls_info) > 0) {
if (!(_opt.is_cache && Object.size(this.home_balls_info) > 0)) {
this.home_balls_info = imagesx.findAFBallsByHough({
is_debug_info: _opt.is_debug_info,
});
Expand Down Expand Up @@ -4689,13 +4689,9 @@ let $$af = {
function _getOwnRipeTs() {
timeRecorder('ctd_data');

let _tt = 12e3;
let _alive = thd => thd && thd.isAlive();
let _kill = (thd) => {
thd && thd.interrupt();
thd = null;
};
let _remainT = () => _tt - timeRecorder('ctd_data', 'L');
let _kill = thd => thd && thd.interrupt();

let _ctd_data = [];
let _thd_ocr = threadsx.start(_thdOcr);
let _thd_toast = threadsx.start(_thdToast);
Expand All @@ -4708,12 +4704,12 @@ let $$af = {
debugInfo('强制停止Toast监控线程');
}

_thd_ocr.join(Math.max(_remainT(), 0));
let _tt = 9e3;
_thd_ocr.join(Math.max(_tt - timeRecorder('ctd_data', 'L'), 0));

if (_remainT() < 0) {
_kill(_thd_toast);
if (_alive(_thd_ocr)) {
_kill(_thd_ocr);
messageAction('获取自己能量倒计时超时', 3);
messageAction('获取自己能量倒计时超时', 3, 1);
_ctd_data.length
? messageAction('最小倒计时数据可能不准确', 3, 0, 0, 1)
: messageAction('最小倒计时数据获取失败', 3, 0, 0, 1);
Expand Down
80 changes: 50 additions & 30 deletions ant-forest-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ let $$init = {
};
let _range = [_mini, _maxi];
let _range_p = [_mini_p, _maxi_p];
let _n = $$view.diag.checkInputRange(d, _range, _range_p);
if (!$$F(_n) && (!_opt.positiveAddn || _opt.positiveAddn(d, _n, _f))) {
let _n = $$view.diag.getInputNumStrByCheckRange(d, _range, _range_p);
if ($$str(_n) && (!_opt.positiveAddn || _opt.positiveAddn(d, _n, _f))) {
return _f();
}
})
Expand Down Expand Up @@ -449,22 +449,25 @@ let $$init = {
: () => null)
.show();
},
checkInputRange(d) {
/**
* @param {JsDialog$|MaterialDialog$} d
* @param {...number|number[]} ranges
* @returns {string|void}
*/
getInputNumStrByCheckRange(d, ranges) {
let _input = dialogsx.getInputText(d);
if (!_input) {
d.dismiss();
return false;
return d.dismiss();
}
let _max = 3;
while (_input.match('%') && _max--) {
_input = _input.replace(/(\d+(\.\d+)?\s*)%/g, ($0, $1) => {
return $1 / 100 + '';
return String($1 / 100);
});
}
let _num = +_input;
if (isNaN(_num)) {
dialogsx.alertTitle(d, '输入值类型不合法');
return false;
return dialogsx.alertTitle(d, '输入值类型不合法');
}

let _len = arguments.length;
Expand All @@ -483,9 +486,7 @@ let $$init = {
return _num.toString();
}
}

dialogsx.alertTitle(d, '输入值范围不合法');
return false;
return dialogsx.alertTitle(d, '输入值范围不合法');
},
},
hint: {
Expand Down Expand Up @@ -720,6 +721,7 @@ let $$init = {

let hint = opt.hint;
if (hint) {
/** @type {com.stardust.autojs.core.ui.widget.JsLinearLayout} */
let _hint_view = ui.inflate(
<horizontal id="_hints">
<horizontal>
Expand Down Expand Up @@ -756,11 +758,14 @@ let $$init = {
if ($$str(hint)) {
_hint_view['_hint'].setText(hint);
}
_v['_content'].addView(_hint_view);
/** @type {JsLinearLayout$} */
let _v_content = _v['_content'];
_v_content.addView(_hint_view);
}

if (type === 'radio') {
_v['_item_area'].removeAllViews();
/** @type {android.widget.RadioGroup} */
let radiogroup_view = ui.inflate(
<radiogroup
id="_radiogroup" orientation="horizontal" padding="-6 0 0 0"
Expand All @@ -769,12 +774,15 @@ let $$init = {
let title = opt.title;

title.forEach((val) => {
/** @type {android.widget.RadioButton} */
let radio_view = ui.inflate(<radio padding="0 0 12 0"/>);
radio_view.setText(val);
Object.keys(opt.listeners).forEach((listener) => {
radio_view.on(listener, opt.listeners[listener].bind(opt));
});
radiogroup_view['_radiogroup'].addView(radio_view);
/** @type {android.widget.RadioGroup} */
let _v_radiogroup = radiogroup_view['_radiogroup'];
_v_radiogroup.addView(radio_view);
});
_v.addView(radiogroup_view);
}
Expand Down Expand Up @@ -837,6 +845,7 @@ let $$init = {
};

// noinspection HtmlUnknownTarget,HtmlRequiredAltAttribute
/** @type {com.stardust.autojs.core.ui.widget.JsLinearLayout} */
let _page_enter_view = ui.inflate(
<vertical id="_chevron_icon">
<img id="img" h="31" paddingLeft="10"
Expand All @@ -860,6 +869,7 @@ let $$init = {
}, 100);
} else if (type === 'button') {
// noinspection HtmlUnknownTarget,HtmlRequiredAltAttribute
/** @type {com.stardust.autojs.core.ui.widget.JsLinearLayout} */
let help_view = ui.inflate(
<vertical id="_info_icon" visibility="gone">
<img id="img" src="@drawable/ic_info_outline_black_48dp"
Expand Down Expand Up @@ -1911,7 +1921,7 @@ let $$init = {
let _abs_size_span = new style.AbsoluteSizeSpan(text_size, true);
let _see = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
_span_str.setSpan(_abs_size_span, 0, _span_str.length(), _see);
edit_text_view.setHint(new SpannedString(_span_str));
edit_text_view.setHint(new SpannedString(_span_str.toString()));
}
});
_info_input_view['info_input_view_main'].addView(ui.inflate(
Expand Down Expand Up @@ -2425,7 +2435,11 @@ let $$init = {
});

let _thd_calc_n_set_input = null;
let _watcher = new android.text.TextWatcher({afterTextChanged: _afterTextChanged});
let _watcher = new android.text.TextWatcher({
afterTextChanged: _afterTextChanged,
beforeTextChanged: () => void 0,
onTextChanged: () => void 0,
});
_search_view['input'].addTextChangedListener(_watcher);

if ($$func(refresh_btn)) {
Expand Down Expand Up @@ -2654,8 +2668,8 @@ let $$init = {
d.dismiss();
})
.on('positive', (d) => {
let _n = $$view.diag.checkInputRange(d, 1, 600);
if (_n) {
let _n = $$view.diag.getInputNumStrByCheckRange(d, 1, 600);
if ($$str(_n)) {
refreshItems(_pref, Math.trunc(+_n));
d.dismiss();
}
Expand Down Expand Up @@ -2919,7 +2933,7 @@ let $$init = {
function setViewDisabled(view, dependencies) {
let hint_text = '';
if (Array.isArray(dependencies)) {
dependencies.forEach(conj_text => {
dependencies.forEach((conj_text) => {
hint_text += $$ses.title[conj_text] + ' ';
});
if (dependencies.length > 1) {
Expand Down Expand Up @@ -2947,7 +2961,7 @@ let $$init = {
}
},
collapseSoftKeyboard(view) {
context.getSystemService(context.INPUT_METHOD_SERVICE)
context.getSystemService(android.content.Context.INPUT_METHOD_SERVICE)
.hideSoftInputFromWindow(view.getWindowToken(), 0);
},
commonItemBindCheckboxClickListener(checkbox_view, item_holder) {
Expand Down Expand Up @@ -3196,7 +3210,7 @@ let $$init = {

if ($$und($$ses.list_data_min_ts)) {
let _data = $$ses.db.rawQueryData$('select timestamp as ts from ant_forest');
$$ses.list_data_min_ts = Math.mini(_data.map(o => o.ts)) * 1e3;
$$ses.list_data_min_ts = Math.mini(_data.map(o => Number(o.ts))) * 1e3;
}

_show_other && _db_data.unshift({
Expand Down Expand Up @@ -4528,7 +4542,7 @@ $$view.page.new('可收取目标采集', 'collectable_samples_page', (t) => {
newWindow() {
if ($$cfg.ses.rank_list_scan_strategy === 'swipe') {
let _icon_h = cYx(46);
let _safe = (uH - staH - actH - _icon_h);
let _safe = uH - $$disp.status_bar_height - $$disp.action_bar_default_height - _icon_h;
$$view.diag.numSetter.call(this, 0.4, 0.9, {
title: '设置排行榜页面滑动距离',
hint_set: 'R',
Expand All @@ -4537,7 +4551,7 @@ $$view.page.new('可收取目标采集', 'collectable_samples_page', (t) => {
'参数示例:\n' +
'1260: 每次滑动 1260 像素\n' +
'0.6: 每次滑动 60% 屏幕距离',
true,
'%show_valid_and_default_values%',
'安全值: ' + _safe + ' [ ' +
(_safe / H).toFixedNum(2) + ' ]',
],
Expand All @@ -4560,12 +4574,18 @@ $$view.page.new('可收取目标采集', 'collectable_samples_page', (t) => {
dialogsx.builds(['滑动距离安全值', '', 0, 0, 'B'], {
content: '安全值指排行榜滑动时' +
'可避免采集目标遗漏的理论最大值\n\n' +
'计算方法:\n屏幕高度 [ ' + H + ' ]\n' +
'减去 导航栏高度 [ ' + navH + ' ]\n' +
'减去 状态栏高度 [ ' + staH + ' ]\n' +
'减去 ActionBar默认高度 [ ' + actH + ' ]\n' +
'减去 排行榜图标缩放高度 [ ' + _icon_h + ' ]\n' +
'得到 安全值 [ ' + _safe + ' ]\n\n' +
'计算方法:\n屏幕高度' +
' [ ' + H + ' ]\n' +
'减去 导航栏高度' +
' [ ' + $$disp.navigation_bar_height + ' ]\n' +
'减去 状态栏高度' +
' [ ' + $$disp.status_bar_height + ' ]\n' +
'减去 ActionBar默认高度' +
' [ ' + $$disp.action_bar_default_height + ' ]\n' +
'减去 排行榜图标缩放高度' +
' [ ' + _icon_h + ' ]\n' +
'得到 安全值' +
' [ ' + _safe + ' ]\n\n' +
'* 括号中的数据均源自当前设备\n' +
'* 安全值为理论值\n-- 不代表真实可操作的最佳值',
}).show();
Expand Down Expand Up @@ -6597,8 +6617,8 @@ $$view.page.new('延时接力区间', 'timers_uninterrupted_check_sections_page'
content: null,
neutral: null,
positive(d, min, max) {
let _n = $$view.diag.checkInputRange(d, min, max);
if (_n) {
let _n = $$view.diag.getInputNumStrByCheckRange(d, min, max);
if ($$str(_n)) {
refreshItems(_pref, Math.trunc(+_n));
d.dismiss();
}
Expand Down
7 changes: 7 additions & 0 deletions documents/CHANGELOG-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
### 版本历史 - 2.x
******

# v2.1.9
###### 2021/08/20
* `修复` 配置工具无法设置排行榜滑动距离等相关配置项的问题
* `修复` 获取能量球数据缓存时逻辑错误导致效率提升无效的问题
* `修复` OCR方案获取倒计时耗时过久未能按预期及时停止的问题
* `优化` 霍夫变换覆盖检测方法优化以提高成熟能量球识别率 _[`issue #508`](https://github.com/SuperMonster003/Ant-Forest/issues/508#issuecomment-900102913)_

# v2.1.8
###### 2021/08/13
* `修复` 配置工具对话框监听器this指针绑定失效的问题 _[`issue #513`](https://github.com/SuperMonster003/Ant-Forest/issues/513)_ _[`#511`](https://github.com/SuperMonster003/Ant-Forest/issues/511#issuecomment-896448713)_
Expand Down
Loading

0 comments on commit 6e93a95

Please sign in to comment.