style: apply minimal button management layout

This commit is contained in:
7015725
2026-05-13 08:21:12 +08:00
parent 648b45585a
commit e9b6052c6a
4 changed files with 51 additions and 82 deletions

View File

@@ -557,6 +557,23 @@ FloatBallAppWM.prototype.createButtonManagerActionChip = function(text, textColo
return tv;
};
FloatBallAppWM.prototype.createButtonManagerTextAction = function(text, textColor, onClickFn) {
var tv = new android.widget.TextView(context);
tv.setText(String(text || ""));
tv.setGravity(android.view.Gravity.CENTER);
tv.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 12);
tv.setTextColor(textColor);
tv.setMinHeight(this.dp(30));
tv.setPadding(this.dp(8), 0, this.dp(8), 0);
if (onClickFn) {
tv.setOnClickListener(new android.view.View.OnClickListener({ onClick: function() {
try { onClickFn(); } catch(eClick) { safeLog(null, 'e', "catch " + String(eClick)); }
}}));
}
return tv;
};
FloatBallAppWM.prototype.createButtonManagerPolishedCard = function(parent, title, subtitle, statText) {
var isDark = this.isDarkTheme();
var C = this.ui.colors;
@@ -589,34 +606,6 @@ FloatBallAppWM.prototype.createButtonManagerPolishedCard = function(parent, titl
return card;
};
FloatBallAppWM.prototype.createButtonEditorHeroCard = function(parent, modeText, subtitle) {
var isDark = this.isDarkTheme();
var C = this.ui.colors;
var card = new android.widget.LinearLayout(context);
card.setOrientation(android.widget.LinearLayout.VERTICAL);
card.setPadding(this.dp(14), this.dp(12), this.dp(14), this.dp(12));
card.setBackground(this.ui.createRoundDrawable(isDark ? this.withAlpha(C.cardDark, 0.70) : this.withAlpha(C.cardLight, 0.72), this.dp(18)));
try { card.setElevation(this.dp(2)); } catch(eElev) {}
var title = new android.widget.TextView(context);
title.setText("按钮编辑工作台");
title.setTextColor(isDark ? C.textPriDark : C.textPriLight);
title.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 16);
title.setTypeface(null, android.graphics.Typeface.BOLD);
card.addView(title);
var sub = new android.widget.TextView(context);
sub.setText(String(subtitle || "常用内容默认展开,低频配置可折叠"));
sub.setTextColor(isDark ? C.textSecDark : C.textSecLight);
sub.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 12);
sub.setPadding(0, this.dp(4), 0, this.dp(8));
card.addView(sub);
var chip = this.createButtonManagerActionChip(String(modeText || "编辑按钮"), C.primary, this.withAlpha(C.primary, 0.32), null);
card.addView(chip);
var lp = new android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(this.dp(2), this.dp(2), this.dp(2), this.dp(10));
parent.addView(card, lp);
return card;
};
FloatBallAppWM.prototype.addButtonEditorField = function(parent, view) {
try {
var lp = new android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT);
@@ -776,7 +765,7 @@ FloatBallAppWM.prototype.buildButtonEditorPanelView = function() {
// 提示文字 (左侧)
var hintTv = new android.widget.TextView(context);
hintTv.setText("点卡片编辑");
hintTv.setText("共 " + buttons.length + " 个按钮");
hintTv.setTextColor(subTextColor);
hintTv.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 12);
header.addView(hintTv);
@@ -808,26 +797,6 @@ FloatBallAppWM.prototype.buildButtonEditorPanelView = function() {
else enabledCount++;
}
} catch(eCnt) { safeLog(null, 'e', "catch " + String(eCnt)); }
var statsStrip = new android.widget.LinearLayout(context);
statsStrip.setOrientation(android.widget.LinearLayout.VERTICAL);
statsStrip.setPadding(self.dp(12), self.dp(8), self.dp(12), self.dp(8));
statsStrip.setBackground(self.ui.createRoundDrawable(isDark ? self.withAlpha(C.cardDark, 0.42) : self.withAlpha(C.cardLight, 0.48), self.dp(14)));
var statsTv = new android.widget.TextView(context);
statsTv.setText("共 " + buttons.length + " 个 · 已启用 " + enabledCount + " · 已禁用 " + disabledCount);
statsTv.setTextColor(textColor);
statsTv.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 13);
statsTv.setTypeface(null, android.graphics.Typeface.BOLD);
statsStrip.addView(statsTv);
var statsHint = new android.widget.TextView(context);
statsHint.setText("点卡片进入编辑;用上移/下移调整顺序");
statsHint.setTextColor(subTextColor);
statsHint.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 11);
statsHint.setPadding(0, self.dp(3), 0, 0);
statsStrip.addView(statsHint);
var statsLp = new android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT);
statsLp.setMargins(self.dp(2), 0, self.dp(2), self.dp(8));
panel.addView(statsStrip, statsLp);
// 按钮管理搜索卡片:搜索输入与操作按钮收在同一张卡片里,避免顶部显得零散。
var searchSurface = new android.widget.LinearLayout(context);
searchSurface.setOrientation(android.widget.LinearLayout.VERTICAL);
@@ -973,7 +942,7 @@ FloatBallAppWM.prototype.buildButtonEditorPanelView = function() {
actions.setPadding(self.dp(42), 0, 0, 0);
var canUp = (idx > 0);
var btnUp = self.createButtonManagerActionChip("上移", canUp ? subTextColor : self.withAlpha(subTextColor, 0.25), self.withAlpha(subTextColor, canUp ? 0.24 : 0.12), canUp ? function() {
var btnUp = self.createButtonManagerTextAction("上移", canUp ? subTextColor : self.withAlpha(subTextColor, 0.25), canUp ? function() {
var temp = buttons[idx];
buttons[idx] = buttons[idx - 1];
buttons[idx - 1] = temp;
@@ -983,7 +952,7 @@ FloatBallAppWM.prototype.buildButtonEditorPanelView = function() {
actions.addView(btnUp);
var canDown = (idx < buttons.length - 1);
var btnDown = self.createButtonManagerActionChip("下移", canDown ? subTextColor : self.withAlpha(subTextColor, 0.25), self.withAlpha(subTextColor, canDown ? 0.24 : 0.12), canDown ? function() {
var btnDown = self.createButtonManagerTextAction("下移", canDown ? subTextColor : self.withAlpha(subTextColor, 0.25), canDown ? function() {
var temp = buttons[idx];
buttons[idx] = buttons[idx + 1];
buttons[idx + 1] = temp;
@@ -997,7 +966,7 @@ FloatBallAppWM.prototype.buildButtonEditorPanelView = function() {
} catch(eDownLp) {}
actions.addView(btnDown);
var btnToggle = self.createButtonManagerActionChip(__enabled ? "禁用" : "启用", __enabled ? self.withAlpha(subTextColor, 0.9) : self.withAlpha(C.success, 0.9), self.withAlpha(__enabled ? subTextColor : C.success, 0.24), function() {
var btnToggle = self.createButtonManagerTextAction(__enabled ? "禁用" : "启用", __enabled ? self.withAlpha(subTextColor, 0.9) : self.withAlpha(C.success, 0.9), function() {
try {
btnCfg.enabled = (btnCfg.enabled === false) ? true : false;
ConfigManager.saveButtons(buttons);
@@ -1011,7 +980,7 @@ FloatBallAppWM.prototype.buildButtonEditorPanelView = function() {
} catch(eLpTg) {}
actions.addView(btnToggle);
var btnDel = self.createButtonManagerActionChip("删除", self.withAlpha(C.danger, 0.85), self.withAlpha(C.danger, 0.28), function() {
var btnDel = self.createButtonManagerTextAction("删除", self.withAlpha(C.danger, 0.85), function() {
buttons.splice(idx, 1);
refreshPanel();
});
@@ -1086,8 +1055,9 @@ FloatBallAppWM.prototype.buildButtonEditorPanelView = function() {
// 底部按钮栏
var bottomBar = new android.widget.LinearLayout(context);
bottomBar.setOrientation(android.widget.LinearLayout.HORIZONTAL);
bottomBar.setGravity(android.view.Gravity.END | android.view.Gravity.CENTER_VERTICAL);
bottomBar.setPadding(0, self.dp(12), 0, 0);
bottomBar.setGravity(android.view.Gravity.CENTER_VERTICAL);
bottomBar.setPadding(self.dp(4), self.dp(8), self.dp(4), self.dp(8));
bottomBar.setBackground(self.ui.createRoundDrawable(isDark ? C.bgDark : C.bgLight, self.dp(12)));
var btnListCancel = self.ui.createFlatButton(self, "取消更改", subTextColor, function() {
self.state.tempButtons = null;
@@ -1126,13 +1096,7 @@ FloatBallAppWM.prototype.buildButtonEditorPanelView = function() {
try { scroll.setVerticalScrollBarEnabled(false); } catch(e) { safeLog(null, 'e', "catch " + String(e)); }
var form = new android.widget.LinearLayout(context);
form.setOrientation(android.widget.LinearLayout.VERTICAL);
form.setPadding(self.dp(4), self.dp(4), self.dp(4), self.dp(4));
// 顶部说明卡:比散落的一行提示更清晰,强调一页式编辑的操作路径。
self.createButtonEditorHeroCard(form,
(editIdx === -1 ? "新增按钮" : "编辑按钮"),
"常用内容默认展开,低频配置可折叠;底部统一暂存。"
);
form.setPadding(self.dp(4), self.dp(4), self.dp(4), self.dp(18));
var basicSectionBody = self.createButtonEditorCollapsibleSection(form, "基础信息", "先填写名称,便于在按钮管理列表中识别", true);
@@ -3603,8 +3567,9 @@ shortcutWrap.addView(scBody);
// 底部
var bottomBar = new android.widget.LinearLayout(context);
bottomBar.setOrientation(android.widget.LinearLayout.HORIZONTAL);
bottomBar.setGravity(android.view.Gravity.END | android.view.Gravity.CENTER_VERTICAL);
bottomBar.setPadding(0, self.dp(12), 0, 0);
bottomBar.setGravity(android.view.Gravity.CENTER_VERTICAL);
bottomBar.setPadding(self.dp(4), self.dp(8), self.dp(4), self.dp(8));
bottomBar.setBackground(self.ui.createRoundDrawable(isDark ? C.bgDark : C.bgLight, self.dp(12)));
var btnCancel = self.ui.createFlatButton(self, "取消", subTextColor, function() {
self.state.editingButtonIndex = null;
@@ -3613,11 +3578,10 @@ shortcutWrap.addView(scBody);
self.popToolAppPage("button_edit_cancel");
} else refreshPanel();
});
bottomBar.addView(btnCancel);
var space = new android.view.View(context);
space.setLayoutParams(new android.widget.LinearLayout.LayoutParams(self.dp(12), 1));
bottomBar.addView(space);
var btnCancelLp = new android.widget.LinearLayout.LayoutParams(0, self.dp(44));
btnCancelLp.weight = 1;
btnCancelLp.rightMargin = self.dp(8);
bottomBar.addView(btnCancel, btnCancelLp);
var btnSave = self.ui.createSolidButton(self, "暂存修改", C.primary, android.graphics.Color.WHITE, function() {
try {
@@ -3720,9 +3684,13 @@ try {
self.toast("暂存失败: " + e);
}
});
bottomBar.addView(btnSave);
var btnSaveLp = new android.widget.LinearLayout.LayoutParams(0, self.dp(44));
btnSaveLp.weight = 1;
bottomBar.addView(btnSave, btnSaveLp);
panel.addView(bottomBar);
var bottomLp = new android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT);
bottomLp.setMargins(0, self.dp(6), 0, 0);
panel.addView(bottomBar, bottomLp);
}
return panel;

View File

@@ -54,8 +54,8 @@
"size": 20386
},
"th_14_panels.js": {
"sha256": "37ed575c0d6b86ebd5980555d7a148702042ef67a04e61bf9adabb851a04a0db",
"size": 241799
"sha256": "7c895dd1cfbb2524b9d60bc442c329a553efbaa5d5067192991f00a22e94b6a3",
"size": 239551
},
"th_15_extra.js": {
"sha256": "44d19f0012f4182b9f9831d4f5a747b43d3b726f98e0480e6c79f54eeff70a5e",
@@ -68,5 +68,5 @@
},
"keyId": "toolhub-targets-2026-rsa3072",
"schema": 2,
"version": 20260513001538
"version": 20260513002103
}

View File

@@ -1 +1 @@
Gbl+DdtfJl2MYIMvlBUqDpmakkCpoEk+kpOF5HU2MtSz3AkC8XDz9QMIDZ0keff3fciptxdvYYIg8QqOfKob40akvscjyX4yQWos9CCPytMBrNrjjPMOpUSXsER8gZTb2pdGvweaVRr8ZZuWtoVPnqgIBlivvNMXfXBIZ973d12OeSsQiQrUCE8qXQm1R3t+hVhoht7yePxRC+6r3jKi8arWQOFOWNhTCDWNtWmvjvLUBxVuAHM82j8q8cD+bNstChRhNKeQfa2s/yod2LhBqM9ELd1rGtK9PXkizmeCW/mTR7s7Y3Mll2Fp+rNvV4xY8x9ql0uedUQ5UK7W3m/GSjPSNFZ/9UxobO8XIgGPf7V7a/weoa80vlvUkZs4YNFpnch7K7u/9tA30mfbayAQb9gR1JKahQJXPOz7Ru3++wOP5C53ZrzizVPUkLk7aGrUBLuZtolq7neJ/F398P6bIJou+bQ3DJT/1hYbVQTjuqGeu3YnpnRzoN3SGdVSaWDJ
hEqgzyJCqEHftLOT+w+T0aZOpmhk7HF9p+tSjp4/2bmC5uAkQMEaUXh3dQARGlZgfsZr28oTLxcCh6UcTKaysAoBGnw8ukmhQ/rVuPCnTJ0euJ6zLDZp4kKBcHvK+iSQ2UDJo0VTa1iw5gzRsLJLuV9UI4ufZ55zQeVTFQ6XijsBtKjgVdXvmD0ONZ7DvElAT95Eg5JS18m86F5uw/dlE+KQX9Bb37swwRgP/vi/EAZukUwevPQ7KTTBoBgyBjEyvPkjHhgtlo5I0956uqtQ7bW/hmHLYNdYLehCrd9IgW49UGFgBZvM1+pk7Rqcjh+6BAV4kcUwzmTVE4HkTjMNpQ8dhHgfloAYTV7MQ3L4JagQvGc4wkr3NmBs9FmRJ2p64IAx8bofTC4zR3I2DmfITlWcyAYgY59NzSSiVFKRAFGE82FS9oGYO3u0MKQUFEZrxYg7/QqnA6M4hG/ZQEfkv0hwm4fLeXvioUQJIGNouu4XnRzytKX93mfqho/MPF4x

View File

@@ -1,21 +1,22 @@
#!/usr/bin/env python3
import pathlib
import re
import sys
root = pathlib.Path(__file__).resolve().parents[1]
text = (root / "code" / "th_14_panels.js").read_text(encoding="utf-8")
checks = [
("manager has action chip helper", "createButtonManagerActionChip" in text),
("manager has action chip helper for search", "createButtonManagerActionChip" in text),
("manager has text action helper for card actions", "createButtonManagerTextAction" in text),
("manager card has two-row layout marker", "按钮管理列表卡片:上信息、下操作" in text),
("manager has search surface marker", "按钮管理搜索卡片" in text),
("manager no false long-press sort text", "长按卡片排序" not in text),
("manager no homepage title block", "按钮管理首页" not in text),
("manager uses textual sort chips", "上移" in text and "下移" in text and "孤立箭头" in text),
("manager uses delete chip", "createButtonManagerActionChip(\"删除\"" in text),
("editor has hero helper", "createButtonEditorHeroCard" in text),
("manager no homepage block text", "按钮管理首页" not in text),
("manager header count only", "\" + buttons.length + \" 个按钮" in text),
("manager card actions are text actions", "createButtonManagerTextAction(\"上移\"" in text and "createButtonManagerTextAction(\"下移\"" in text and "createButtonManagerTextAction(\"删除\"" in text),
("editor no useless workbench", "按钮编辑工作台" not in text and "createButtonEditorHeroCard" not in text),
("editor has field spacing helper", "addButtonEditorField" in text),
("editor hero visible text", "按钮编辑工作台" in text),
("editor sections improved", "常用内容默认展开,低频配置可折叠" in text),
("editor fixed footer has equal buttons", "btnCancelLp.weight = 1" in text and "btnSaveLp.weight = 1" in text and "self.dp(44)" in text),
]
failed = [name for name, ok in checks if not ok]
if failed: