fix toolapp inner back edge width setting

This commit is contained in:
7015725
2026-05-19 01:02:41 +08:00
parent eda34d24b1
commit 6d8f50267c
5 changed files with 56 additions and 12 deletions

View File

@@ -844,7 +844,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: "TOOLAPP_BACK_COMMIT_DISTANCE_DP", name: "设置页返回触发距离", type: "int", min: 1, max: 480, step: 1 },
{ key: "TOOLAPP_BACK_PROGRESS_DISTANCE_DP", name: "设置页返回动画距离", type: "int", min: 1, max: 720, step: 1 },
{ key: "ENABLE_LONG_PRESS", name: "启用长按", type: "bool" },

View File

@@ -321,9 +321,8 @@ FloatBallAppWM.prototype.applyImmediateEffectsForKey = function(k) {
if (k === "TOOLAPP_BACK_EDGE_WIDTH_DP") {
try {
if (this.state.toolAppActive && this.hideToolAppScreenBackStrips && this.showToolAppScreenBackStrips) {
this.hideToolAppScreenBackStrips();
this.showToolAppScreenBackStrips();
if (this.state.toolAppActive && this.updateToolAppInnerBackEdgeWidth) {
this.updateToolAppInnerBackEdgeWidth();
}
} catch(eBackStrip) {
safeLog(this.L, "w", "apply back edge width fail: " + String(eBackStrip));

View File

@@ -830,6 +830,19 @@ FloatBallAppWM.prototype.hideToolAppScreenBackStrips = function() {
} catch (e) { safeLog(this.L, 'w', "hide tool app screen back strips fail: " + String(e)); }
};
FloatBallAppWM.prototype.getToolAppBackEdgeWidthPx = function() {
var stripDp = 48;
try {
stripDp = Number(this.config.TOOLAPP_BACK_EDGE_WIDTH_DP || 48);
if (isNaN(stripDp)) stripDp = 48;
if (stripDp < 1) stripDp = 1;
if (stripDp > 120) stripDp = 120;
} catch(e) {
stripDp = 48;
}
return this.dp(stripDp);
};
FloatBallAppWM.prototype.showToolAppScreenBackStrips = function() {
try {
if (!this.state.wm || !this.state.toolAppActive) return false;
@@ -961,7 +974,7 @@ FloatBallAppWM.prototype.buildToolAppShell = function(contentView, title, canBac
body.addView(host, hostLp);
try {
var stripW = this.dp(48);
var stripW = this.getToolAppBackEdgeWidthPx ? this.getToolAppBackEdgeWidthPx() : this.dp(48);
var leftStrip = this.createToolAppEdgeBackStrip(0);
var leftLp = new android.widget.FrameLayout.LayoutParams(stripW, -1);
leftLp.gravity = android.view.Gravity.START | android.view.Gravity.TOP;
@@ -970,6 +983,8 @@ FloatBallAppWM.prototype.buildToolAppShell = function(contentView, title, canBac
var rightLp = new android.widget.FrameLayout.LayoutParams(stripW, -1);
rightLp.gravity = android.view.Gravity.END | android.view.Gravity.TOP;
root.addView(rightStrip, rightLp);
this.state.toolAppInnerBackLeftStrip = leftStrip;
this.state.toolAppInnerBackRightStrip = rightStrip;
} catch (eStrip) { safeLog(this.L, 'w', "add edge back strip fail: " + String(eStrip)); }
this.state.toolAppRoot = root;
@@ -982,6 +997,36 @@ FloatBallAppWM.prototype.buildToolAppShell = function(contentView, title, canBac
return root;
};
FloatBallAppWM.prototype.updateToolAppInnerBackEdgeWidth = function() {
try {
var w = this.getToolAppBackEdgeWidthPx ? this.getToolAppBackEdgeWidthPx() : this.dp(48);
var left = this.state.toolAppInnerBackLeftStrip;
var right = this.state.toolAppInnerBackRightStrip;
if (left) {
var lpL = left.getLayoutParams();
if (lpL) {
lpL.width = w;
left.setLayoutParams(lpL);
}
}
if (right) {
var lpR = right.getLayoutParams();
if (lpR) {
lpR.width = w;
right.setLayoutParams(lpR);
}
}
return true;
} catch(e) {
safeLog(this.L, "w", "update inner back edge width fail: " + String(e));
}
return false;
};
FloatBallAppWM.prototype.ensureToolAppShell = function() {
try {
if (this.state.toolAppRoot && this.state.toolAppContentHost) return this.state.toolAppRoot;