fix: make ToolHub UI actions responsive

This commit is contained in:
7015725
2026-05-22 04:27:45 +08:00
parent 78218ce1f5
commit 32fe099fab
6 changed files with 49 additions and 30 deletions

View File

@@ -281,21 +281,30 @@ FloatBallAppWM.prototype.ui = {
var pasteBtn = this.createFlatButton(app, "粘贴", this.colors.accent, function() {
try {
var cb = context.getSystemService(android.content.Context.CLIPBOARD_SERVICE);
if (cb.hasPrimaryClip()) {
var item = cb.getPrimaryClip().getItemAt(0);
if (item) {
var txt = item.getText();
if (txt) {
var st = String(txt);
var old = String(et.getText());
if (old.length > 0) et.setText(old + st);
else et.setText(st);
et.setSelection(et.getText().length());
}
}
} else {
if (!cb || !cb.hasPrimaryClip()) {
app.toast("剪贴板为空");
return;
}
var clip = cb.getPrimaryClip();
if (!clip || clip.getItemCount() <= 0) {
app.toast("剪贴板为空");
return;
}
var item = clip.getItemAt(0);
if (!item) {
app.toast("剪贴板为空");
return;
}
var txt = item.getText();
if (txt === null || txt === undefined || String(txt).length === 0) {
app.toast("剪贴板不是文本内容");
return;
}
var st = String(txt);
var old = String(et.getText());
if (old.length > 0) et.setText(old + st);
else et.setText(st);
et.setSelection(et.getText().length());
} catch (eP) {
app.toast("粘贴失败: " + eP);
}

View File

@@ -1577,12 +1577,13 @@ FloatBallAppWM.prototype.showIconPicker = function(opts) {
if (e.getAction() === android.view.MotionEvent.ACTION_DOWN) {
try {
var rect = new android.graphics.Rect();
if (state.root) {
state.root.getGlobalVisibleRect(rect);
if (panel) {
panel.getGlobalVisibleRect(rect);
var x = e.getRawX();
var y = e.getRawY();
if (!rect.contains(x, y)) {
hide();
return true;
}
}
} catch(eOut) { safeLog(null, 'e', "catch " + String(eOut)); }

View File

@@ -3453,8 +3453,14 @@ scRefreshTv.setOnClickListener(new android.view.View.OnClickListener({
try { __scIconCache = {}; } catch(eC0) { safeLog(null, 'e', "catch " + String(eC0)); }
try { __scIconKeys = []; } catch(eC1) { safeLog(null, 'e', "catch " + String(eC1)); }
try { __scIconInFlight = {}; } catch(eC2) { safeLog(null, 'e', "catch " + String(eC2)); }
// 若当前已展开,立即触发重新加载与渲染
if (scInlineState.expanded) __scEnsureLoadedAndRender();
// 点击刷新时给用户即时反馈;折叠状态下自动展开并加载,避免看起来无效。
if (!scInlineState.expanded) {
scInlineState.expanded = true;
try { scBody.setVisibility(android.view.View.VISIBLE); } catch(eV) { safeLog(null, 'e', "catch " + String(eV)); }
try { scArrowTv.setText("▲"); } catch(eA) { safeLog(null, 'e', "catch " + String(eA)); }
}
__scEnsureLoadedAndRender();
try { self.toast("正在刷新快捷方式"); } catch(eToast) {}
} catch(eR) { safeLog(null, 'e', "catch " + String(eR)); }
}
}));

View File

@@ -653,7 +653,7 @@ FloatBallAppWM.prototype.buildToolAppPreviewBody = function(entry) {
var btnBack = this.ui.createFlatButton(this, "", T.brown, function() {});
btnBack.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 24);
btnBack.setPadding(this.dp(8), 0, this.dp(8), 0);
try { btnBack.setClickable(false); } catch(eBackClick) {}
try { btnBack.setClickable(false); btnBack.setAlpha(0.45); } catch(eBackClick) {}
try { btnBack.setBackground(this.ui.createStrokeDrawable(T.primarySoft, this.withAlpha(T.primaryDeep, isDark ? 0.30 : 0.22), this.dp(1), this.dp(18))); } catch(eBackBg) {}
bar.addView(btnBack, new android.widget.LinearLayout.LayoutParams(this.dp(42), this.dp(38)));
@@ -674,7 +674,7 @@ FloatBallAppWM.prototype.buildToolAppPreviewBody = function(entry) {
btnClose.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, r === "settings" ? 12 : 18);
btnClose.setTypeface(null, android.graphics.Typeface.BOLD);
btnClose.setPadding(this.dp(10), 0, this.dp(10), 0);
try { btnClose.setClickable(false); } catch(eRightClick) {}
try { btnClose.setClickable(false); btnClose.setAlpha(0.45); } catch(eRightClick) {}
try { btnClose.setBackground(this.ui.createStrokeDrawable(T.primarySoft, this.withAlpha(T.primaryDeep, isDark ? 0.30 : 0.22), this.dp(1), this.dp(18))); } catch(eRightBg) {}
bar.addView(btnClose, new android.widget.LinearLayout.LayoutParams(this.dp(104), this.dp(38)));
var barLp = new android.widget.LinearLayout.LayoutParams(-1, topBarHeight);
@@ -1143,11 +1143,14 @@ FloatBallAppWM.prototype.updateToolAppShellChrome = function(title, canBack) {
var r = String(this.state.toolAppRoute || "");
var titleText = String(title || "ToolHub");
if (r === "settings") titleText = "❧ 岛屿设置 ❧";
var hasBack = false;
try { hasBack = !!(this.hasToolAppBackTarget && this.hasToolAppBackTarget()); } catch(eHasBack) { hasBack = !!canBack; }
if (this.state.toolAppTitleView) this.state.toolAppTitleView.setText(titleText);
if (this.state.toolAppBackButton) {
this.state.toolAppBackButton.setText("");
this.state.toolAppBackButton.setText(hasBack ? "" : "✕");
this.state.toolAppBackButton.setVisibility(android.view.View.VISIBLE);
this.state.toolAppBackButton.setEnabled(true);
try { this.state.toolAppBackButton.setAlpha(1.0); } catch(eAlpha) {}
}
if (this.state.toolAppRightButton) {
if (r === "settings") this.state.toolAppRightButton.setText("📖 岛务手册");