fix(color-picker): 修复颜色面板确认后无回写问题
- 确认按钮添加 try-catch,确保 onSelect 异常不阻断 closePopup - finalColor 强制 String() 转换,避免 undefined 传入 Java setText - onSelect 回调添加异常隔离 + invalidate() 强制刷新 - 同步两个调用点(颜色按钮 + 调色板选择按钮)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user