From d03f4d677f36071c3efcd6258d6f7c1f67cf9d16 Mon Sep 17 00:00:00 2001 From: Hermes Date: Mon, 20 Apr 2026 20:51:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(color-picker):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=A2=9C=E8=89=B2=E9=9D=A2=E6=9D=BF=E7=A1=AE=E8=AE=A4=E5=90=8E?= =?UTF-8?q?=E6=97=A0=E5=9B=9E=E5=86=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 确认按钮添加 try-catch,确保 onSelect 异常不阻断 closePopup - finalColor 强制 String() 转换,避免 undefined 传入 Java setText - onSelect 回调添加异常隔离 + invalidate() 强制刷新 - 同步两个调用点(颜色按钮 + 调色板选择按钮) --- code/th_14_panels.js | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/code/th_14_panels.js b/code/th_14_panels.js index ab44a6f..bb6c5cc 100644 --- a/code/th_14_panels.js +++ b/code/th_14_panels.js @@ -933,10 +933,16 @@ FloatBallAppWM.prototype.buildButtonEditorPanelView = function() { currentColor: currentTint, currentIconName: currentShortXIconName, onSelect: function(colorHex) { - if (inputShortXIconTint && inputShortXIconTint.input) { - inputShortXIconTint.input.setText(colorHex); + try { + var safeColor = String(colorHex || ""); + if (inputShortXIconTint && inputShortXIconTint.input) { + inputShortXIconTint.input.setText(safeColor); + try { inputShortXIconTint.input.invalidate(); } catch(e) {} + } + try { if (tintPaletteState.toggleBtn) tintPaletteState.toggleBtn.setText(safeColor || "\u9009\u62e9\u989c\u8272"); } catch(e) {} + } catch(eSelect) { + safeLog(self.L, 'e', "colorPicker callback err=" + String(eSelect)); } - try { if (tintPaletteState.toggleBtn) tintPaletteState.toggleBtn.setText(colorHex || "\u9009\u62e9\u989c\u8272"); } catch(e) {} } }); }); @@ -1491,10 +1497,16 @@ FloatBallAppWM.prototype.buildButtonEditorPanelView = function() { currentColor: currentTint, currentIconName: currentShortXIconName, onSelect: function(colorHex) { - if (inputShortXIconTint && inputShortXIconTint.input) { - inputShortXIconTint.input.setText(colorHex); + try { + var safeColor = String(colorHex || ""); + if (inputShortXIconTint && inputShortXIconTint.input) { + inputShortXIconTint.input.setText(safeColor); + try { inputShortXIconTint.input.invalidate(); } catch(e) {} + } + try { if (tintPaletteState.toggleBtn) tintPaletteState.toggleBtn.setText(safeColor || "\u9009\u62e9\u989c\u8272"); } catch(e) {} + } catch(eSelect) { + safeLog(self.L, 'e', "colorPicker callback err=" + String(eSelect)); } - try { if (tintPaletteState.toggleBtn) tintPaletteState.toggleBtn.setText(colorHex || "\u9009\u62e9\u989c\u8272"); } catch(e) {} } }); }); @@ -4665,11 +4677,19 @@ FloatBallAppWM.prototype.showColorPickerPopup = function(opts) { var btnOk = self.ui.createSolidButton(self, "确定", C.primary, android.graphics.Color.WHITE, function() { self.touchActivity(); - var finalColor = isFollowTheme ? "" : selectedColor; - if (!isFollowTheme && selectedColor) { - pushRecentColor(selectedColor); + try { + var finalColor = isFollowTheme ? "" : String(selectedColor || ""); + if (!isFollowTheme && selectedColor) { + pushRecentColor(selectedColor); + } + if (typeof onSelect === "function") { + try { onSelect(finalColor); } catch(eOnSelect) { + safeLog(self.L, 'e', "colorPicker onSelect err=" + String(eOnSelect)); + } + } + } catch(e) { + safeLog(self.L, 'e', "colorPicker confirm err=" + String(e)); } - if (typeof onSelect === "function") onSelect(finalColor); closePopup(); }); actionRow.addView(btnOk);