feat: add ToolHub badge and back gesture settings

This commit is contained in:
7015725
2026-05-19 00:26:11 +08:00
parent 4c054dd4a3
commit 1a7cefc630
6 changed files with 56 additions and 35 deletions

View File

@@ -91,7 +91,7 @@ var ConfigValidator = {
// 图标配置
BALL_ICON_TYPE: { type: "enum", values: ["app", "file", "android", "shortx"], default: "app" },
BALL_ICON_RES_ID: { type: "int", min: 0, max: 999999, default: 0 },
BALL_ICON_SIZE_DP: { type: "int", min: 16, max: 64, default: 22 },
BALL_ICON_SIZE_DP: { type: "int", min: 12, max: 80, default: 22 },
BALL_PNG_MODE: { type: "int", min: 0, max: 2, default: 1 },
BALL_IDLE_ALPHA: { type: "float", min: 0.1, max: 1.0, default: 0.6 },
@@ -99,6 +99,9 @@ var ConfigValidator = {
LONG_PRESS_MS: { type: "int", min: 200, max: 2000, default: 600 },
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: 12, max: 48, default: 22 },
TOOLAPP_BACK_COMMIT_DISTANCE_DP: { type: "int", min: 48, max: 160, default: 72 },
TOOLAPP_BACK_PROGRESS_DISTANCE_DP: { type: "int", min: 120, max: 320, default: 180 },
// 功能开关
ENABLE_SNAP_TO_EDGE: { type: "bool", default: true },
@@ -729,6 +732,9 @@ var ConfigManager = {
ENABLE_LONG_PRESS: true,
LONG_PRESS_MS: 520,
CLICK_SLOP_DP: 6,
TOOLAPP_BACK_EDGE_WIDTH_DP: 22,
TOOLAPP_BACK_COMMIT_DISTANCE_DP: 72,
TOOLAPP_BACK_PROGRESS_DISTANCE_DP: 180,
ENABLE_BOUNCE: true,
BOUNCE_TIMES: 2,
BOUNCE_MAX_SCALE: 0.88,
@@ -796,6 +802,7 @@ var ConfigManager = {
{ key: "BALL_ICON_FILE_PATH", name: "已选择的图标文件", type: "text" },
{ key: "BALL_ICON_RES_NAME", name: "岛上图标", type: "ball_shortx_icon" },
{ key: "BALL_ICON_TINT_HEX", name: "徽章颜色", type: "ball_color" },
{ key: "BALL_ICON_SIZE_DP", name: "徽章大小", type: "int", min: 12, max: 80, step: 1 },
{ key: "BALL_BG_COLOR_HEX", name: "球体背景", type: "ball_color" },
{ key: "BALL_IDLE_ALPHA", name: "安静时透明度", type: "float", min: 0.1, max: 1.0, step: 0.05 },
@@ -837,6 +844,9 @@ 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: 12, max: 48, step: 1 },
{ key: "TOOLAPP_BACK_COMMIT_DISTANCE_DP", name: "设置页返回触发距离", type: "int", min: 48, max: 160, step: 1 },
{ key: "TOOLAPP_BACK_PROGRESS_DISTANCE_DP", name: "设置页返回动画距离", type: "int", min: 120, max: 320, step: 1 },
{ key: "ENABLE_LONG_PRESS", name: "启用长按", type: "bool" },
{ key: "LONG_PRESS_MS", name: "长按判定(ms)", type: "int", min: 200, max: 2000, step: 10 },
{ key: "LONG_PRESS_HAPTIC_ENABLE", name: "长按震动反馈", type: "bool" },
@@ -873,7 +883,7 @@ 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) {
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_EDGE_WIDTH_DP") < 0 || sStr.indexOf("TOOLAPP_BACK_COMMIT_DISTANCE_DP") < 0 || sStr.indexOf("TOOLAPP_BACK_PROGRESS_DISTANCE_DP") < 0) {
needReset = true;
}
} else {

View File

@@ -319,6 +319,18 @@ 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") {
try {
if (this.state.toolAppActive && this.hideToolAppScreenBackStrips && this.showToolAppScreenBackStrips) {
this.hideToolAppScreenBackStrips();
this.showToolAppScreenBackStrips();
}
} catch(eBackStrip) {
safeLog(this.L, "w", "apply back edge width fail: " + String(eBackStrip));
}
return;
}
if (k === "PANEL_ROWS" || k === "PANEL_COLS" ||
k === "PANEL_ITEM_SIZE_DP" || k === "PANEL_GAP_DP" ||
k === "PANEL_PADDING_DP" || k === "PANEL_ICON_SIZE_DP" ||

View File

@@ -332,11 +332,9 @@ FloatBallAppWM.prototype.buildSettingsHomePanelView = function() {
if (useMonetHome) {
this.createSettingsHomeSectionHeader(box, "▦", "工具与配置");
this.createSettingsHomeEntry(box, "工具", "添加、整理和排序工具入口", "", function() { self.pushToolAppPage("btn_editor"); });
this.createSettingsHomeEntry(box, "配置结构", "编辑分组、布局和高级结构", "", function() { self.pushToolAppPage("schema_editor"); });
} else {
this.createSettingsHomeSectionHeader(box, "🧰", "布局与管理");
this.createSettingsHomeEntry(box, "工具伙伴", "添加、整理和安排你的工具伙伴", "", function() { self.pushToolAppPage("btn_editor"); });
this.createSettingsHomeEntry(box, "岛屿蓝图", "自定义岛屿布局,适合进阶布置", "", function() { self.pushToolAppPage("schema_editor"); });
this.addSettingsHomeDashedDivider(box);
}
var defs = this.getSettingsGroupDefs();
@@ -370,6 +368,11 @@ FloatBallAppWM.prototype.buildSettingsHomePanelView = function() {
});
})(defs[k]);
}
this.createSettingsHomeEntry(box, "高级蓝图", "编辑设置页结构和高级配置,适合进阶用户", "", function() { self.pushToolAppPage("schema_editor"); });
} else {
this.addSettingsHomeDashedDivider(box);
this.createSettingsHomeSectionHeader(box, "⚙", "高级设置");
this.createSettingsHomeEntry(box, "高级蓝图", "编辑设置页结构和高级配置,适合进阶用户", "", function() { self.pushToolAppPage("schema_editor"); });
}
contentCard.addView(scroll, new android.widget.LinearLayout.LayoutParams(-1, 0, 1));
panel.addView(contentCard, new android.widget.LinearLayout.LayoutParams(-1, 0, 1));

View File

@@ -507,7 +507,7 @@ FloatBallAppWM.prototype.getToolAppTitle = function(route) {
if (this.state.editingSchemaIndex !== null && this.state.editingSchemaIndex !== undefined) {
return (this.state.editingSchemaIndex === -1) ? "新增蓝图项" : "编辑蓝图项";
}
return "岛屿蓝图";
return "高级蓝图";
}
return "ToolHub";
};
@@ -786,15 +786,11 @@ FloatBallAppWM.prototype.createToolAppEdgeBackStrip = function(edge) {
var validDir = (edge === 0 && mx > 0) || (edge === 1 && mx < 0);
if (validDir && Math.abs(mx) > self.dp(4) && Math.abs(mx) > Math.abs(my)) {
moved = true;
var panelW = 0;
try { panelW = Number((self.state.viewerPanelLp && self.state.viewerPanelLp.width) || 0); } catch (ePanelW0) {}
if (!panelW || panelW < self.dp(120)) {
try { panelW = Number((self.state.toolAppRoot && self.state.toolAppRoot.getWidth && self.state.toolAppRoot.getWidth()) || 0); } catch (ePanelW1) {}
}
if (!panelW || panelW < self.dp(120)) panelW = self.dp(420);
var triggerDistance = panelW * 0.38;
if (triggerDistance < self.dp(160)) triggerDistance = self.dp(160);
if (triggerDistance > self.dp(260)) triggerDistance = self.dp(260);
var triggerDp = Number(self.config.TOOLAPP_BACK_PROGRESS_DISTANCE_DP || 180);
if (isNaN(triggerDp)) triggerDp = 180;
if (triggerDp < 120) triggerDp = 120;
if (triggerDp > 320) triggerDp = 320;
var triggerDistance = self.dp(triggerDp);
var p = Math.min(1, Math.abs(mx) / triggerDistance);
self.applyToolAppBackPreviewProgress(edge, p);
}
@@ -803,15 +799,11 @@ 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 panelW2 = 0;
try { panelW2 = Number((self.state.viewerPanelLp && self.state.viewerPanelLp.width) || 0); } catch (ePanelW2) {}
if (!panelW2 || panelW2 < self.dp(120)) {
try { panelW2 = Number((self.state.toolAppRoot && self.state.toolAppRoot.getWidth && self.state.toolAppRoot.getWidth()) || 0); } catch (ePanelW3) {}
}
if (!panelW2 || panelW2 < self.dp(120)) panelW2 = self.dp(420);
var completeDistance = panelW2 * 0.18;
if (completeDistance < self.dp(64)) completeDistance = self.dp(64);
if (completeDistance > self.dp(120)) completeDistance = self.dp(120);
var commitDp = Number(self.config.TOOLAPP_BACK_COMMIT_DISTANCE_DP || 72);
if (isNaN(commitDp)) commitDp = 72;
if (commitDp < 48) commitDp = 48;
if (commitDp > 160) commitDp = 160;
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.2;
active = false;
@@ -852,7 +844,11 @@ FloatBallAppWM.prototype.showToolAppScreenBackStrips = function() {
if (sw <= 1) {
try { var ss = this.getScreenSizePx(); sw = ss.w; } catch (eScreen) {}
}
var stripW = this.dp(22);
var stripDp = Number(this.config.TOOLAPP_BACK_EDGE_WIDTH_DP || 22);
if (isNaN(stripDp)) stripDp = 22;
if (stripDp < 12) stripDp = 12;
if (stripDp > 48) stripDp = 48;
var stripW = this.dp(stripDp);
var flags = android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
@@ -1307,7 +1303,7 @@ FloatBallAppWM.prototype.showPanelAvoidBall = function(which) {
var titleMap = {
"settings": "设置",
"btn_editor": "按钮管理",
"schema_editor": "布局管理"
"schema_editor": "高级蓝图"
};
var title = titleMap[which] || "面板";