refactor: remove legacy ToolApp back strips
This commit is contained in:
@@ -102,8 +102,6 @@ var ConfigValidator = {
|
||||
CLICK_SLOP_DP: { type: "int", min: 2, max: 20, default: 6 },
|
||||
TOOLAPP_BACK_GESTURE_MODE: { type: "enum", values: ["edge", "surface", "off"], default: "surface" },
|
||||
TOOLAPP_BACK_EDGE_WIDTH_DP: { type: "int", min: 1, max: 120, default: 72 },
|
||||
ENABLE_TOOLAPP_INNER_BACK_STRIPS: { type: "bool", default: false },
|
||||
ENABLE_TOOLAPP_SCREEN_BACK_STRIPS: { type: "bool", default: false },
|
||||
TOOLAPP_BACK_COMMIT_DISTANCE_DP: { type: "int", min: 1, max: 480, default: 36 },
|
||||
TOOLAPP_BACK_SURFACE_SLOP_DP: { type: "int", min: 8, max: 96, default: 24 },
|
||||
TOOLAPP_BACK_PROGRESS_DISTANCE_DP: { type: "int", min: 1, max: 720, default: 96 },
|
||||
@@ -740,8 +738,6 @@ var ConfigManager = {
|
||||
CLICK_SLOP_DP: 6,
|
||||
TOOLAPP_BACK_GESTURE_MODE: "surface",
|
||||
TOOLAPP_BACK_EDGE_WIDTH_DP: 72,
|
||||
ENABLE_TOOLAPP_INNER_BACK_STRIPS: false,
|
||||
ENABLE_TOOLAPP_SCREEN_BACK_STRIPS: false,
|
||||
TOOLAPP_BACK_COMMIT_DISTANCE_DP: 36,
|
||||
TOOLAPP_BACK_SURFACE_SLOP_DP: 24,
|
||||
TOOLAPP_BACK_PROGRESS_DISTANCE_DP: 96,
|
||||
@@ -852,16 +848,14 @@ var ConfigManager = {
|
||||
{ key: "BOUNCE_STEP_MS", name: "回弹步进时长(ms)", type: "int", min: 20, max: 500, step: 10 },
|
||||
{ key: "BOUNCE_DECAY", name: "回弹衰减(0~1)", type: "float", min: 0.30, max: 0.95, step: 0.01 },
|
||||
|
||||
{ type: "section", name: "触摸与手势" },
|
||||
{ type: "section", name: "动作与手势" },
|
||||
{ key: "CLICK_SLOP_DP", name: "点击位移阈值(dp)", type: "int", min: 1, max: 40, step: 1 },
|
||||
{ key: "TOOLAPP_BACK_GESTURE_MODE", name: "设置页滑动返回模式", type: "single_choice", options: [
|
||||
{ label: "全表面横滑", value: "surface" },
|
||||
{ label: "仅面板内部左右边缘", value: "edge" },
|
||||
{ label: "关闭", value: "off" }
|
||||
]},
|
||||
{ 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_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_SURFACE_SLOP_DP", name: "表面横滑起手阈值", type: "int", min: 8, max: 96, step: 1 },
|
||||
{ key: "TOOLAPP_BACK_PROGRESS_DISTANCE_DP", name: "设置页返回动画距离", type: "int", min: 1, max: 720, step: 1 },
|
||||
@@ -902,7 +896,10 @@ var ConfigManager = {
|
||||
var needReset = false;
|
||||
if (s) {
|
||||
var sStr = JSON.stringify(s);
|
||||
if (sStr.indexOf("ENABLE_SNAP_TO_EDGE") < 0 || sStr.indexOf("ENABLE_ANIMATIONS") < 0 || sStr.indexOf("BALL_IDLE_ALPHA") < 0 || sStr.indexOf("PANEL_POS_GRAVITY") < 0 || sStr.indexOf("single_choice") < 0 || sStr.indexOf("ball_shortx_icon") < 0 || sStr.indexOf("ball_color") < 0 || sStr.indexOf("SETTINGS_THEME") < 0 || sStr.indexOf("BALL_BG_COLOR_HEX") < 0 || sStr.indexOf("BALL_ICON_SIZE_DP") < 0 || sStr.indexOf("TOOLAPP_BACK_GESTURE_MODE") < 0 || sStr.indexOf("TOOLAPP_BACK_EDGE_WIDTH_DP") < 0 || sStr.indexOf("ENABLE_TOOLAPP_INNER_BACK_STRIPS") < 0 || sStr.indexOf("ENABLE_TOOLAPP_SCREEN_BACK_STRIPS") < 0 || sStr.indexOf("TOOLAPP_BACK_COMMIT_DISTANCE_DP") < 0 || sStr.indexOf("TOOLAPP_BACK_SURFACE_SLOP_DP") < 0 || sStr.indexOf("TOOLAPP_BACK_PROGRESS_DISTANCE_DP") < 0 || sStr.indexOf("LONG_PRESS_TRIGGERED_MOVE_SLOP_DP") < 0) {
|
||||
if (sStr.indexOf("ENABLE_SNAP_TO_EDGE") < 0 || sStr.indexOf("ENABLE_ANIMATIONS") < 0 || sStr.indexOf("BALL_IDLE_ALPHA") < 0 || sStr.indexOf("PANEL_POS_GRAVITY") < 0 || sStr.indexOf("single_choice") < 0 || sStr.indexOf("ball_shortx_icon") < 0 || sStr.indexOf("ball_color") < 0 || sStr.indexOf("SETTINGS_THEME") < 0 || sStr.indexOf("BALL_BG_COLOR_HEX") < 0 || sStr.indexOf("BALL_ICON_SIZE_DP") < 0 || sStr.indexOf("TOOLAPP_BACK_GESTURE_MODE") < 0 || sStr.indexOf("TOOLAPP_BACK_EDGE_WIDTH_DP") < 0 || sStr.indexOf("TOOLAPP_BACK_COMMIT_DISTANCE_DP") < 0 || sStr.indexOf("TOOLAPP_BACK_SURFACE_SLOP_DP") < 0 || sStr.indexOf("TOOLAPP_BACK_PROGRESS_DISTANCE_DP") < 0 || sStr.indexOf("LONG_PRESS_TRIGGERED_MOVE_SLOP_DP") < 0) {
|
||||
needReset = true;
|
||||
}
|
||||
if (!needReset && (sStr.indexOf("ENABLE_TOOLAPP_INNER_BACK_STRIPS") >= 0 || sStr.indexOf("ENABLE_TOOLAPP_SCREEN_BACK_STRIPS") >= 0)) {
|
||||
needReset = true;
|
||||
}
|
||||
|
||||
@@ -935,8 +932,6 @@ var ConfigManager = {
|
||||
schemaItemDiffers("BALL_BG_COLOR_HEX", ["name", "type"]) ||
|
||||
schemaItemDiffers("TOOLAPP_BACK_GESTURE_MODE", ["name", "type"]) ||
|
||||
schemaItemDiffers("TOOLAPP_BACK_EDGE_WIDTH_DP", ["name", "type", "min", "max", "step"]) ||
|
||||
schemaItemDiffers("ENABLE_TOOLAPP_INNER_BACK_STRIPS", ["name", "type"]) ||
|
||||
schemaItemDiffers("ENABLE_TOOLAPP_SCREEN_BACK_STRIPS", ["name", "type"]) ||
|
||||
schemaItemDiffers("TOOLAPP_BACK_COMMIT_DISTANCE_DP", ["name", "type", "min", "max", "step"]) ||
|
||||
schemaItemDiffers("TOOLAPP_BACK_SURFACE_SLOP_DP", ["name", "type", "min", "max", "step"]) ||
|
||||
schemaItemDiffers("TOOLAPP_BACK_PROGRESS_DISTANCE_DP", ["name", "type", "min", "max", "step"]) ||
|
||||
|
||||
@@ -56,7 +56,6 @@ function FloatBallAppWM(logger) {
|
||||
toolAppBackPreviewView: null,
|
||||
toolAppBackPreviewRoute: null,
|
||||
toolAppBackPreviewReady: false,
|
||||
toolAppScreenBackStrips: [],
|
||||
toolAppTitleView: null,
|
||||
toolAppBackButton: null,
|
||||
settingsGroupKey: null,
|
||||
|
||||
@@ -319,28 +319,7 @@ FloatBallAppWM.prototype.applyImmediateEffectsForKey = function(k) {
|
||||
}
|
||||
if (k === "BALL_SIZE_DP" || k === "BALL_PNG_MODE" || k === "BALL_ICON_TYPE" || k === "BALL_ICON_FILE_PATH" || k === "BALL_ICON_RES_ID" || k === "BALL_ICON_RES_NAME" || k === "BALL_ICON_SIZE_DP" || k === "BALL_ICON_TINT_HEX" || k === "BALL_BG_COLOR_HEX") { this.rebuildBallForNewSize(); return; }
|
||||
|
||||
if (k === "TOOLAPP_BACK_EDGE_WIDTH_DP" || k === "ENABLE_TOOLAPP_INNER_BACK_STRIPS") {
|
||||
try {
|
||||
if (this.state.toolAppActive) {
|
||||
if (k === "ENABLE_TOOLAPP_INNER_BACK_STRIPS" && this.showToolApp) {
|
||||
this.showToolApp(this.state.toolAppRoute || "settings", false);
|
||||
}
|
||||
if (this.refreshToolAppScreenBackStrips) this.refreshToolAppScreenBackStrips();
|
||||
}
|
||||
} catch(eBackStrip) {
|
||||
safeLog(this.L, "w", "apply back strip fail: " + String(eBackStrip));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (k === "ENABLE_TOOLAPP_SCREEN_BACK_STRIPS") {
|
||||
try {
|
||||
if (this.state.toolAppActive && this.refreshToolAppScreenBackStrips) {
|
||||
this.refreshToolAppScreenBackStrips();
|
||||
}
|
||||
} catch(eScreenBackStrip) {
|
||||
safeLog(this.L, "w", "apply screen back strip fail: " + String(eScreenBackStrip));
|
||||
}
|
||||
if (k === "TOOLAPP_BACK_EDGE_WIDTH_DP") {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,6 @@ FloatBallAppWM.prototype.safeRemoveView = function(v, whichName) {
|
||||
try {
|
||||
if (!v) return { ok: true, skipped: true };
|
||||
try { if (this.unregisterPanelPredictiveBack) this.unregisterPanelPredictiveBack(v); } catch (eBack) {}
|
||||
try { if (whichName === "viewerPanel" && this.state && String(this.state.viewerPanelType || "") === "tool_app" && this.hideToolAppScreenBackStrips) this.hideToolAppScreenBackStrips(); } catch (eStrip) {}
|
||||
this.state.wm.removeView(v);
|
||||
return { ok: true };
|
||||
} catch (e) {
|
||||
@@ -196,7 +195,6 @@ FloatBallAppWM.prototype.hideViewerPanel = function() {
|
||||
this.state.toolAppBackPreviewView = null;
|
||||
this.state.toolAppBackPreviewRoute = null;
|
||||
this.state.toolAppBackPreviewReady = false;
|
||||
try { if (this.hideToolAppScreenBackStrips) this.hideToolAppScreenBackStrips(); } catch (eStrip) {}
|
||||
this.state.toolAppTitleView = null;
|
||||
this.state.toolAppBackButton = null;
|
||||
}
|
||||
@@ -608,7 +606,6 @@ FloatBallAppWM.prototype._clearHeavyCachesIfAllHidden = function(reason) {
|
||||
};
|
||||
|
||||
FloatBallAppWM.prototype.hideAllPanels = function() {
|
||||
try { if (this.hideToolAppScreenBackStrips) this.hideToolAppScreenBackStrips(); } catch (eStrip) {}
|
||||
this.hideMainPanel();
|
||||
this.hideSettingsPanel();
|
||||
this.hideViewerPanel();
|
||||
@@ -995,10 +992,6 @@ 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 +
|
||||
|
||||
@@ -557,7 +557,6 @@ FloatBallAppWM.prototype.closeToolApp = function() {
|
||||
this.state.toolAppBackPreviewReady = false;
|
||||
this.state.toolAppBackPreviewStackVersion = null;
|
||||
this.state.toolAppBackPreviewEntryKey = null;
|
||||
try { if (this.hideToolAppScreenBackStrips) this.hideToolAppScreenBackStrips(); } catch (eStrip) {}
|
||||
this.state.toolAppTitleView = null;
|
||||
this.state.toolAppBackButton = null;
|
||||
} catch (e) { safeLog(this.L, 'e', "closeToolApp fail: " + String(e)); }
|
||||
@@ -1121,81 +1120,6 @@ FloatBallAppWM.prototype.finishToolAppBackPreview = function(edge, complete) {
|
||||
}
|
||||
};
|
||||
|
||||
FloatBallAppWM.prototype.createToolAppEdgeBackStrip = function(edge) {
|
||||
var self = this;
|
||||
var strip = new android.view.View(context);
|
||||
strip.setBackgroundColor(android.graphics.Color.TRANSPARENT);
|
||||
var downX = 0;
|
||||
var downY = 0;
|
||||
var active = false;
|
||||
var moved = false;
|
||||
strip.setOnTouchListener(new android.view.View.OnTouchListener({
|
||||
onTouch: function(v, event) {
|
||||
try {
|
||||
if (!event) return false;
|
||||
var action = event.getActionMasked();
|
||||
if (action === android.view.MotionEvent.ACTION_DOWN) {
|
||||
downX = event.getRawX();
|
||||
downY = event.getRawY();
|
||||
active = !!(self.state && self.state.toolAppActive && self.hasToolAppBackTarget && self.hasToolAppBackTarget());
|
||||
moved = false;
|
||||
if (active) self.prepareToolAppBackPreview(edge);
|
||||
return active;
|
||||
}
|
||||
if (!active) return false;
|
||||
if (action === android.view.MotionEvent.ACTION_MOVE) {
|
||||
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(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 || 96);
|
||||
if (isNaN(triggerDp)) triggerDp = 96;
|
||||
if (triggerDp < 1) triggerDp = 1;
|
||||
if (triggerDp > 720) triggerDp = 720;
|
||||
var triggerDistance = self.dp(triggerDp);
|
||||
var p = Math.min(1, Math.abs(mx) / triggerDistance);
|
||||
self.applyToolAppBackPreviewProgress(edge, p, Math.abs(mx));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
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 || 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) * 0.85;
|
||||
active = false;
|
||||
self.finishToolAppBackPreview(edge, ok);
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
try { self.clearToolAppBackPreview(true); } catch (eClear) {}
|
||||
try { safeLog(self.L, 'w', "tool app edge back fail: " + String(e)); } catch(eLog) {}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}));
|
||||
return strip;
|
||||
};
|
||||
|
||||
FloatBallAppWM.prototype.hideToolAppScreenBackStrips = function() {
|
||||
try {
|
||||
var arr = this.state.toolAppScreenBackStrips || [];
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
try { if (arr[i] && this.state.wm) this.state.wm.removeView(arr[i]); } catch (eRm) {}
|
||||
}
|
||||
this.state.toolAppScreenBackStrips = [];
|
||||
} catch (e) { safeLog(this.L, 'w', "hide tool app screen back strips fail: " + String(e)); }
|
||||
};
|
||||
|
||||
FloatBallAppWM.prototype.getToolAppBackEdgeWidthPx = function() {
|
||||
var stripDp = 72;
|
||||
try {
|
||||
@@ -1209,33 +1133,6 @@ FloatBallAppWM.prototype.getToolAppBackEdgeWidthPx = function() {
|
||||
return this.dp(stripDp);
|
||||
};
|
||||
|
||||
FloatBallAppWM.prototype.isToolAppScreenBackStripsEnabled = function() {
|
||||
// 旧版 WindowManager 透明边缘热区已禁用:它可能抢 ACTION_DOWN,影响按钮、列表、SeekBar、Switch。
|
||||
// 保留函数和清理路径仅为兼容历史状态;正式返回手势由 ToolApp root surface 接管。
|
||||
try { this.hideToolAppScreenBackStrips(); } catch(eHide) {}
|
||||
return false;
|
||||
};
|
||||
|
||||
FloatBallAppWM.prototype.showToolAppScreenBackStrips = function() {
|
||||
// 旧版 WindowManager 透明边缘热区已禁用;不要再创建额外触摸层。
|
||||
try { this.hideToolAppScreenBackStrips(); } catch(eHide) {}
|
||||
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));
|
||||
@@ -1585,13 +1482,6 @@ 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);
|
||||
|
||||
// 兼容旧设置:不再添加页面内透明返回热区。
|
||||
// 返回手势由 root.onInterceptTouchEvent 延迟拦截;surface 模式会排除交互控件,edge 模式保留边缘起手。
|
||||
try {
|
||||
this.state.toolAppInnerBackLeftStrip = null;
|
||||
this.state.toolAppInnerBackRightStrip = null;
|
||||
} catch (eStrip) { safeLog(this.L, 'w', "clear edge back strip state fail: " + String(eStrip)); }
|
||||
|
||||
this.state.toolAppRoot = root;
|
||||
this.state.toolAppBody = body;
|
||||
this.state.toolAppContentHost = host;
|
||||
@@ -1602,36 +1492,6 @@ 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;
|
||||
@@ -1764,7 +1624,6 @@ FloatBallAppWM.prototype.showToolApp = function(route, resetStack) {
|
||||
} catch (eUpd) { safeLog(this.L, 'w', "tool_app update layout fail: " + String(eUpd)); }
|
||||
try { shell.requestFocus(); } catch (eFocus) {}
|
||||
}
|
||||
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));
|
||||
|
||||
Reference in New Issue
Block a user