Fix ToolApp edge back strip defaults

This commit is contained in:
Hermes
2026-05-22 05:52:12 +08:00
parent a5bd0a5b15
commit be2156a634
6 changed files with 55 additions and 41 deletions

View File

@@ -100,9 +100,9 @@ var ConfigValidator = {
LONG_PRESS_TRIGGERED_MOVE_SLOP_DP: { type: "int", min: 8, max: 80, default: 28 },
LONG_PRESS_VIBRATE_MS: { type: "int", min: 10, max: 100, default: 40 },
CLICK_SLOP_DP: { type: "int", min: 2, max: 20, default: 6 },
TOOLAPP_BACK_EDGE_WIDTH_DP: { type: "int", min: 1, max: 120, default: 48 },
ENABLE_TOOLAPP_INNER_BACK_STRIPS: { type: "bool", default: true },
ENABLE_TOOLAPP_SCREEN_BACK_STRIPS: { type: "bool", default: false },
TOOLAPP_BACK_EDGE_WIDTH_DP: { type: "int", min: 1, max: 120, default: 24 },
ENABLE_TOOLAPP_INNER_BACK_STRIPS: { type: "bool", default: false },
ENABLE_TOOLAPP_SCREEN_BACK_STRIPS: { type: "bool", default: true },
TOOLAPP_BACK_COMMIT_DISTANCE_DP: { type: "int", min: 1, max: 480, default: 72 },
TOOLAPP_BACK_PROGRESS_DISTANCE_DP: { type: "int", min: 1, max: 720, default: 180 },
@@ -736,9 +736,9 @@ var ConfigManager = {
LONG_PRESS_MS: 520,
LONG_PRESS_TRIGGERED_MOVE_SLOP_DP: 28,
CLICK_SLOP_DP: 6,
TOOLAPP_BACK_EDGE_WIDTH_DP: 48,
ENABLE_TOOLAPP_INNER_BACK_STRIPS: true,
ENABLE_TOOLAPP_SCREEN_BACK_STRIPS: false,
TOOLAPP_BACK_EDGE_WIDTH_DP: 24,
ENABLE_TOOLAPP_INNER_BACK_STRIPS: false,
ENABLE_TOOLAPP_SCREEN_BACK_STRIPS: true,
TOOLAPP_BACK_COMMIT_DISTANCE_DP: 72,
TOOLAPP_BACK_PROGRESS_DISTANCE_DP: 180,
ENABLE_BOUNCE: true,
@@ -850,7 +850,7 @@ var ConfigManager = {
{ type: "section", name: "触摸与手势" },
{ key: "CLICK_SLOP_DP", name: "点击位移阈值(dp)", type: "int", min: 1, max: 40, step: 1 },
{ key: "TOOLAPP_BACK_EDGE_WIDTH_DP", name: "页面内返回边界宽度", type: "int", min: 1, max: 120, step: 1 },
{ key: "TOOLAPP_BACK_EDGE_WIDTH_DP", name: "返回热区宽度", type: "int", min: 1, max: 120, step: 1 },
{ key: "ENABLE_TOOLAPP_INNER_BACK_STRIPS", name: "启用页面内左右滑动返回", type: "bool" },
{ key: "ENABLE_TOOLAPP_SCREEN_BACK_STRIPS", name: "启用屏幕边缘返回热区(排查用)", type: "bool" },
{ key: "TOOLAPP_BACK_COMMIT_DISTANCE_DP", name: "设置页返回触发距离", type: "int", min: 1, max: 480, step: 1 },

View File

@@ -327,20 +327,18 @@ FloatBallAppWM.prototype.applyImmediateEffectsForKey = function(k) {
} else if (this.showToolApp) {
this.showToolApp(this.state.toolAppRoute || "settings", false);
}
if (this.refreshToolAppScreenBackStrips) this.refreshToolAppScreenBackStrips();
}
} catch(eBackStrip) {
safeLog(this.L, "w", "apply inner back strip fail: " + String(eBackStrip));
safeLog(this.L, "w", "apply back strip fail: " + String(eBackStrip));
}
return;
}
if (k === "ENABLE_TOOLAPP_SCREEN_BACK_STRIPS") {
try {
if (this.state.toolAppActive) {
var enableScreenBackStrip = false;
try { enableScreenBackStrip = parseBooleanLike(this.config.ENABLE_TOOLAPP_SCREEN_BACK_STRIPS); } catch(eCfg2) { enableScreenBackStrip = false; }
if (enableScreenBackStrip && this.hasToolAppBackTarget && this.hasToolAppBackTarget() && this.showToolAppScreenBackStrips) this.showToolAppScreenBackStrips();
else if (this.hideToolAppScreenBackStrips) this.hideToolAppScreenBackStrips();
if (this.state.toolAppActive && this.refreshToolAppScreenBackStrips) {
this.refreshToolAppScreenBackStrips();
}
} catch(eScreenBackStrip) {
safeLog(this.L, "w", "apply screen back strip fail: " + String(eScreenBackStrip));

View File

@@ -971,6 +971,10 @@ FloatBallAppWM.prototype.onScreenChangedReflow = function(reason) {
try { this.state.wm.updateViewLayout(this.state.ballRoot, this.state.ballLp); } catch(eU) { safeLog(null, 'e', "catch " + String(eU)); }
this.savePos(this.state.ballLp.x, this.state.ballLp.y);
if (this.state.toolAppActive && this.refreshToolAppScreenBackStrips) {
try { this.refreshToolAppScreenBackStrips(); } catch(eBackStrip) { safeLog(this.L, 'w', "screen reflow refresh tool app back strips fail: " + String(eBackStrip)); }
}
safeLog(this.L, 'i',
"screen reflow reason=" + String(reason || "") +
" old=" + oldW + "x" + oldH +

View File

@@ -914,18 +914,24 @@ FloatBallAppWM.prototype.hideToolAppScreenBackStrips = function() {
};
FloatBallAppWM.prototype.getToolAppBackEdgeWidthPx = function() {
var stripDp = 48;
var stripDp = 24;
try {
stripDp = Number(this.config.TOOLAPP_BACK_EDGE_WIDTH_DP || 48);
if (isNaN(stripDp)) stripDp = 48;
stripDp = Number(this.config.TOOLAPP_BACK_EDGE_WIDTH_DP || 24);
if (isNaN(stripDp)) stripDp = 24;
if (stripDp < 1) stripDp = 1;
if (stripDp > 120) stripDp = 120;
} catch(e) {
stripDp = 48;
stripDp = 24;
}
return this.dp(stripDp);
};
FloatBallAppWM.prototype.isToolAppScreenBackStripsEnabled = function() {
try { return parseBooleanLike(this.config.ENABLE_TOOLAPP_SCREEN_BACK_STRIPS); } catch(e) {}
try { return String(this.config.ENABLE_TOOLAPP_SCREEN_BACK_STRIPS || "false") === "true"; } catch(e2) {}
return false;
};
FloatBallAppWM.prototype.showToolAppScreenBackStrips = function() {
try {
if (!this.state.wm || !this.state.toolAppActive) return false;
@@ -933,15 +939,14 @@ FloatBallAppWM.prototype.showToolAppScreenBackStrips = function() {
this.hideToolAppScreenBackStrips();
return false;
}
if (this.state.toolAppScreenBackStrips && this.state.toolAppScreenBackStrips.length === 2) return true;
this.hideToolAppScreenBackStrips();
var sw = Math.max(1, Number(this.state.screen && this.state.screen.w || 0));
if (sw <= 1) {
try { var ss = this.getScreenSizePx(); sw = ss.w; } catch (eScreen) {}
}
var stripDp = Number(this.config.TOOLAPP_BACK_EDGE_WIDTH_DP || 22);
if (isNaN(stripDp)) stripDp = 22;
var stripDp = Number(this.config.TOOLAPP_BACK_EDGE_WIDTH_DP || 24);
if (isNaN(stripDp)) stripDp = 24;
if (stripDp < 1) stripDp = 1;
if (stripDp > 120) stripDp = 120;
var stripW = this.dp(stripDp);
@@ -983,6 +988,20 @@ FloatBallAppWM.prototype.showToolAppScreenBackStrips = function() {
return false;
};
FloatBallAppWM.prototype.refreshToolAppScreenBackStrips = function() {
try {
this.hideToolAppScreenBackStrips();
if (!this.state.toolAppActive) return false;
if (!this.hasToolAppBackTarget || !this.hasToolAppBackTarget()) return false;
if (!this.isToolAppScreenBackStripsEnabled || !this.isToolAppScreenBackStripsEnabled()) return false;
return this.showToolAppScreenBackStrips();
} catch(e) {
try { this.hideToolAppScreenBackStrips(); } catch(eHide) {}
safeLog(this.L, 'w', "refresh tool app screen back strips fail: " + String(e));
}
return false;
};
FloatBallAppWM.prototype.getToolAppResponsiveSpec = function() {
var sw = Math.max(1, Number(this.state.screen && this.state.screen.w || 0));
var sh = Math.max(1, Number(this.state.screen && this.state.screen.h || 0));
@@ -1088,11 +1107,11 @@ FloatBallAppWM.prototype.buildToolAppShell = function(contentView, title, canBac
hostLp.setMargins((spec && (spec.isExpandedWidth || spec.isWideWidth)) ? this.dp(4) : this.dp(6), 0, (spec && (spec.isExpandedWidth || spec.isWideWidth)) ? this.dp(4) : this.dp(6), (spec && (spec.isExpandedWidth || spec.isWideWidth)) ? this.dp(4) : this.dp(6));
body.addView(host, hostLp);
// 自定义边缘返回热区会覆盖左右边缘的真实按钮(返回、关闭、添加、保存装扮等)
// 默认不再叠加透明触摸层;需要排查预测返回时再显式开启
// 页面内透明返回热区可能覆盖内容区左右边缘的真实按钮/列表项/颜色面板
// 默认关闭页面内热区;默认启用更窄的屏幕边缘热区,更贴近全面屏返回习惯
try {
var enableInnerBackStrip = false;
try { enableInnerBackStrip = (String(this.config.ENABLE_TOOLAPP_INNER_BACK_STRIPS || "false") === "true"); } catch(eCfg) { enableInnerBackStrip = false; }
try { enableInnerBackStrip = parseBooleanLike(this.config.ENABLE_TOOLAPP_INNER_BACK_STRIPS); } catch(eCfg) { enableInnerBackStrip = false; }
if (enableInnerBackStrip) {
var stripW = this.getToolAppBackEdgeWidthPx ? this.getToolAppBackEdgeWidthPx() : this.dp(24);
var leftStrip = this.createToolAppEdgeBackStrip(0);
@@ -1286,14 +1305,7 @@ FloatBallAppWM.prototype.showToolApp = function(route, resetStack) {
} catch (eUpd) { safeLog(this.L, 'w', "tool_app update layout fail: " + String(eUpd)); }
try { shell.requestFocus(); } catch (eFocus) {}
}
// 不再默认添加屏幕边缘透明覆盖层:它会抢占 ToolApp 顶栏/内容区左右边缘按钮的触摸。
// 如需临时排查返回手势,可把 ENABLE_TOOLAPP_SCREEN_BACK_STRIPS 设为字符串 "true"。
try {
var enableScreenBackStrip = false;
try { enableScreenBackStrip = (String(this.config.ENABLE_TOOLAPP_SCREEN_BACK_STRIPS || "false") === "true"); } catch(eCfg2) { enableScreenBackStrip = false; }
if (enableScreenBackStrip && this.hasToolAppBackTarget && this.hasToolAppBackTarget()) this.showToolAppScreenBackStrips();
else this.hideToolAppScreenBackStrips();
} catch (eScreenBack) { safeLog(this.L, 'w', "screen edge back strip update fail: " + String(eScreenBack)); }
try { this.refreshToolAppScreenBackStrips(); } catch (eScreenBack) { safeLog(this.L, 'w', "screen edge back strip update fail: " + String(eScreenBack)); }
} catch (e) {
this.state.toolAppActive = false;
safeLog(this.L, 'e', "showToolApp fail route=" + r + " err=" + String(e));