Improve ToolApp edge back gesture sensitivity

This commit is contained in:
Hermes
2026-05-22 08:27:23 +08:00
parent 4800536de8
commit adc93338cf
4 changed files with 33 additions and 33 deletions

View File

@@ -1070,13 +1070,13 @@ FloatBallAppWM.prototype.createToolAppEdgeBackStrip = function(edge) {
var mx = event.getRawX() - downX;
var my = event.getRawY() - downY;
var validDir = (edge === 0 && mx > 0) || (edge === 1 && mx < 0);
if (validDir && Math.abs(mx) > self.dp(4) && Math.abs(mx) > Math.abs(my)) {
if (validDir && Math.abs(mx) > self.dp(3) && Math.abs(mx) > Math.abs(my) * 0.85) {
if (!moved) {
try { safeLog(self.L, 'd', 'edge strip move edge=' + String(edge) + ' mx=' + String(mx)); } catch(eMoveLog) {}
}
moved = true;
var triggerDp = Number(self.config.TOOLAPP_BACK_PROGRESS_DISTANCE_DP || 180);
if (isNaN(triggerDp)) triggerDp = 180;
var triggerDp = Number(self.config.TOOLAPP_BACK_PROGRESS_DISTANCE_DP || 96);
if (isNaN(triggerDp)) triggerDp = 96;
if (triggerDp < 1) triggerDp = 1;
if (triggerDp > 720) triggerDp = 720;
var triggerDistance = self.dp(triggerDp);
@@ -1088,13 +1088,13 @@ FloatBallAppWM.prototype.createToolAppEdgeBackStrip = function(edge) {
if (action === android.view.MotionEvent.ACTION_UP || action === android.view.MotionEvent.ACTION_CANCEL) {
var ux = event.getRawX() - downX;
var uy = event.getRawY() - downY;
var commitDp = Number(self.config.TOOLAPP_BACK_COMMIT_DISTANCE_DP || 48);
if (isNaN(commitDp)) commitDp = 48;
var commitDp = Number(self.config.TOOLAPP_BACK_COMMIT_DISTANCE_DP || 36);
if (isNaN(commitDp)) commitDp = 36;
if (commitDp < 1) commitDp = 1;
if (commitDp > 480) commitDp = 480;
var completeDistance = self.dp(commitDp);
var okDir = (edge === 0 && ux > completeDistance) || (edge === 1 && ux < -completeDistance);
var ok = (action === android.view.MotionEvent.ACTION_UP) && moved && okDir && Math.abs(ux) > Math.abs(uy) * 1.05;
var ok = (action === android.view.MotionEvent.ACTION_UP) && moved && okDir && Math.abs(ux) > Math.abs(uy) * 0.85;
active = false;
self.finishToolAppBackPreview(edge, ok);
return true;
@@ -1120,14 +1120,14 @@ FloatBallAppWM.prototype.hideToolAppScreenBackStrips = function() {
};
FloatBallAppWM.prototype.getToolAppBackEdgeWidthPx = function() {
var stripDp = 36;
var stripDp = 56;
try {
stripDp = Number(this.config.TOOLAPP_BACK_EDGE_WIDTH_DP || 36);
if (isNaN(stripDp)) stripDp = 36;
stripDp = Number(this.config.TOOLAPP_BACK_EDGE_WIDTH_DP || 56);
if (isNaN(stripDp)) stripDp = 56;
if (stripDp < 1) stripDp = 1;
if (stripDp > 120) stripDp = 120;
} catch(e) {
stripDp = 36;
stripDp = 56;
}
return this.dp(stripDp);
};
@@ -1216,7 +1216,7 @@ FloatBallAppWM.prototype.buildToolAppShell = function(contentView, title, canBac
rootEdge = -1;
var canBackNow = !!(self.state && self.state.toolAppActive && self.hasToolAppBackTarget && self.hasToolAppBackTarget());
if (canBackNow) {
var edgeW = self.getToolAppBackEdgeWidthPx ? self.getToolAppBackEdgeWidthPx() : self.dp(36);
var edgeW = self.getToolAppBackEdgeWidthPx ? self.getToolAppBackEdgeWidthPx() : self.dp(56);
var rw = 0;
try { rw = this.getWidth(); } catch(eW) { rw = 0; }
if (rootDownX <= edgeW) rootEdge = 0;
@@ -1234,16 +1234,16 @@ FloatBallAppWM.prototype.buildToolAppShell = function(contentView, title, canBac
var validDir = (rootEdge === 0 && dx > 0) || (rootEdge === 1 && dx < 0);
var slopDp = Number(self.config.CLICK_SLOP_DP || 6);
if (isNaN(slopDp)) slopDp = 6;
if (slopDp < 6) slopDp = 6;
if (slopDp < 3) slopDp = 3;
if (slopDp > 18) slopDp = 18;
var touchSlop = self.dp(slopDp);
if (validDir && adx > touchSlop && adx > ady * 1.05) {
if (validDir && adx > touchSlop && adx > ady * 0.85) {
rootBackActive = true;
rootBackMoved = true;
try { self.prepareToolAppBackPreview(rootEdge); } catch(ePrep) { try { safeLog(self.L, 'w', 'root back preview prepare fail: ' + String(ePrep)); } catch(eLogPrep) {} }
try {
var triggerDp0 = Number(self.config.TOOLAPP_BACK_PROGRESS_DISTANCE_DP || 120);
if (isNaN(triggerDp0)) triggerDp0 = 120;
var triggerDp0 = Number(self.config.TOOLAPP_BACK_PROGRESS_DISTANCE_DP || 96);
if (isNaN(triggerDp0)) triggerDp0 = 96;
if (triggerDp0 < 1) triggerDp0 = 1;
if (triggerDp0 > 720) triggerDp0 = 720;
var triggerDistance0 = self.dp(triggerDp0);
@@ -1270,9 +1270,9 @@ FloatBallAppWM.prototype.buildToolAppShell = function(contentView, title, canBac
var mx = ev.getX() - rootDownX;
var my = ev.getY() - rootDownY;
var validDir2 = (rootEdge === 0 && mx > 0) || (rootEdge === 1 && mx < 0);
if (validDir2 && Math.abs(mx) > Math.abs(my) * 1.05) {
var triggerDp = Number(self.config.TOOLAPP_BACK_PROGRESS_DISTANCE_DP || 120);
if (isNaN(triggerDp)) triggerDp = 120;
if (validDir2 && Math.abs(mx) > Math.abs(my) * 0.85) {
var triggerDp = Number(self.config.TOOLAPP_BACK_PROGRESS_DISTANCE_DP || 96);
if (isNaN(triggerDp)) triggerDp = 96;
if (triggerDp < 1) triggerDp = 1;
if (triggerDp > 720) triggerDp = 720;
var triggerDistance = self.dp(triggerDp);
@@ -1284,13 +1284,13 @@ FloatBallAppWM.prototype.buildToolAppShell = function(contentView, title, canBac
if (action === android.view.MotionEvent.ACTION_UP || action === android.view.MotionEvent.ACTION_CANCEL) {
var ux = ev.getX() - rootDownX;
var uy = ev.getY() - rootDownY;
var commitDp = Number(self.config.TOOLAPP_BACK_COMMIT_DISTANCE_DP || 48);
if (isNaN(commitDp)) commitDp = 48;
var commitDp = Number(self.config.TOOLAPP_BACK_COMMIT_DISTANCE_DP || 36);
if (isNaN(commitDp)) commitDp = 36;
if (commitDp < 1) commitDp = 1;
if (commitDp > 480) commitDp = 480;
var completeDistance = self.dp(commitDp);
var okDir = (rootEdge === 0 && ux > completeDistance) || (rootEdge === 1 && ux < -completeDistance);
var ok = (action === android.view.MotionEvent.ACTION_UP) && rootBackMoved && okDir && Math.abs(ux) > Math.abs(uy) * 1.05;
var ok = (action === android.view.MotionEvent.ACTION_UP) && rootBackMoved && okDir && Math.abs(ux) > Math.abs(uy) * 0.85;
var edgeDone = rootEdge;
rootBackActive = false;
rootBackMoved = false;