fix(icon): \u53bb\u6389\u6807\u7b7e\u5206\u7c7b\uff0c\u4fee\u590d\u989c\u8272 undefined \u5bfc\u81f4\u7684\u6e32\u67d3\u5d29\u6e83
\u95ee\u9898: 1. \u6807\u7b7e\u5206\u7c7b UI \u5360\u7528\u7a7a\u95f4\u4e14\u53ef\u80fd\u5bfc\u81f4\u95ed\u5305\u95ee\u9898 2. self.withAlpha(subTextColor, 0.1) \u8fd4\u56de undefined\uff0c\u5bfc\u81f4 GradientDrawable.setColor \u62a5\u9519 \u4fee\u590d: 1. \u5b8c\u5168\u53bb\u6389\u6807\u7b7e\u5206\u7c7b\u548c\u5206\u9875\u680f 2. \u4e3a\u6240\u6709\u989c\u8272\u53d8\u91cf\u6dfb\u52a0\u5b89\u5168\u9ed8\u8ba4\u503c 3. \u5c06 createRippleDrawable \u6539\u56de createRoundDrawable\n4. \u4f7f\u7528 try-catch + \u9ed8\u8ba4\u503c\u4fdd\u62a4\u6240\u6709 withAlpha \u8c03\u7528
This commit is contained in:
@@ -3885,102 +3885,31 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var popupResult = self.showPopupOverlay({
|
var popupResult = self.showPopupOverlay({
|
||||||
title: "选择 ShortX 图标",
|
title: "\u9009\u62e9 ShortX \u56fe\u6807",
|
||||||
onDismiss: onDismiss,
|
onDismiss: onDismiss,
|
||||||
builder: function(content, closePopup) {
|
builder: function(content, closePopup) {
|
||||||
|
// \u5b89\u5168\u83b7\u53d6\u989c\u8272\uff0c\u907f\u514d undefined
|
||||||
|
var safeSubTextColor = subTextColor || 0xFF5F6368;
|
||||||
|
var safeTextColor = textColor || 0xFF202124;
|
||||||
|
var safePrimary = C.primary || 0xFF006C5F;
|
||||||
|
var safeCard = C.card || 0xFFFFFFFF;
|
||||||
|
|
||||||
var searchEt = new android.widget.EditText(context);
|
var searchEt = new android.widget.EditText(context);
|
||||||
searchEt.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 13);
|
searchEt.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 13);
|
||||||
searchEt.setTextColor(textColor);
|
searchEt.setTextColor(safeTextColor);
|
||||||
try { searchEt.setHintTextColor(subTextColor); } catch(e) {}
|
try { searchEt.setHintTextColor(safeSubTextColor); } catch(e) {}
|
||||||
searchEt.setHint("搜索图标名,如 share / home / save");
|
searchEt.setHint("\u641c\u7d22\u56fe\u6807\u540d\uff0c\u5982 share / home / save");
|
||||||
searchEt.setSingleLine(true);
|
searchEt.setSingleLine(true);
|
||||||
searchEt.setPadding(self.dp(10), self.dp(8), self.dp(10), self.dp(8));
|
searchEt.setPadding(self.dp(10), self.dp(8), self.dp(10), self.dp(8));
|
||||||
searchEt.setBackground(self.ui.createStrokeDrawable(isDark ? self.ui.colors.inputBgDark : self.ui.colors.inputBgLight, isDark ? self.ui.colors.dividerDark : self.ui.colors.dividerLight, self.dp(1), self.dp(10)));
|
searchEt.setBackground(self.ui.createStrokeDrawable(isDark ? self.ui.colors.inputBgDark : self.ui.colors.inputBgLight, isDark ? self.ui.colors.dividerDark : self.ui.colors.dividerLight, self.dp(1), self.dp(10)));
|
||||||
content.addView(searchEt);
|
content.addView(searchEt);
|
||||||
|
|
||||||
var tabsScroll = new android.widget.HorizontalScrollView(context);
|
|
||||||
tabsScroll.setHorizontalScrollBarEnabled(false);
|
|
||||||
var tabsRow = new android.widget.LinearLayout(context);
|
|
||||||
tabsRow.setOrientation(android.widget.LinearLayout.HORIZONTAL);
|
|
||||||
tabsRow.setPadding(self.dp(8), self.dp(8), self.dp(8), self.dp(8));
|
|
||||||
tabsScroll.addView(tabsRow);
|
|
||||||
content.addView(tabsScroll);
|
|
||||||
|
|
||||||
var tabButtons = {};
|
|
||||||
var ti;
|
|
||||||
for (ti = 0; ti < tabDefs.length; ti++) {
|
|
||||||
(function(def) {
|
|
||||||
var btn = new android.widget.TextView(context);
|
|
||||||
btn.setText(String(def.label));
|
|
||||||
btn.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 12);
|
|
||||||
btn.setPadding(self.dp(12), self.dp(6), self.dp(12), self.dp(6));
|
|
||||||
var btnLp = new android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT);
|
|
||||||
btnLp.setMargins(0, 0, self.dp(6), 0);
|
|
||||||
btn.setLayoutParams(btnLp);
|
|
||||||
btn.setClickable(true);
|
|
||||||
btn.setOnClickListener(new android.view.View.OnClickListener({
|
|
||||||
onClick: function() {
|
|
||||||
self.touchActivity();
|
|
||||||
popupState.activeTab = def.key;
|
|
||||||
popupState.currentPage = 0;
|
|
||||||
refreshTabs();
|
|
||||||
renderGrid();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
tabsRow.addView(btn);
|
|
||||||
tabButtons[def.key] = btn;
|
|
||||||
})(tabDefs[ti]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function refreshTabs() {
|
|
||||||
var k;
|
|
||||||
for (k in tabButtons) {
|
|
||||||
if (!tabButtons.hasOwnProperty(k)) continue;
|
|
||||||
var btn = tabButtons[k];
|
|
||||||
var active = popupState.activeTab === k;
|
|
||||||
btn.setTextColor(active ? C.primary : subTextColor);
|
|
||||||
try {
|
|
||||||
btn.setBackground(active ? self.ui.createRoundDrawable(self.withAlpha(C.primary, 0.15), self.dp(16)) : null);
|
|
||||||
} catch(e) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
refreshTabs();
|
|
||||||
|
|
||||||
var statusTv = new android.widget.TextView(context);
|
var statusTv = new android.widget.TextView(context);
|
||||||
statusTv.setTextColor(subTextColor);
|
statusTv.setTextColor(safeSubTextColor);
|
||||||
statusTv.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 11);
|
statusTv.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 11);
|
||||||
statusTv.setPadding(self.dp(8), 0, self.dp(8), self.dp(6));
|
statusTv.setPadding(self.dp(8), self.dp(4), self.dp(8), self.dp(4));
|
||||||
content.addView(statusTv);
|
content.addView(statusTv);
|
||||||
|
|
||||||
var pageBar = new android.widget.LinearLayout(context);
|
|
||||||
pageBar.setOrientation(android.widget.LinearLayout.HORIZONTAL);
|
|
||||||
pageBar.setGravity(android.view.Gravity.CENTER_VERTICAL);
|
|
||||||
pageBar.setPadding(self.dp(8), 0, self.dp(8), self.dp(6));
|
|
||||||
|
|
||||||
var btnPrev = self.ui.createFlatButton(self, "上一页", subTextColor, function() {
|
|
||||||
if (popupState.currentPage > 0) {
|
|
||||||
popupState.currentPage--;
|
|
||||||
renderGrid();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
pageBar.addView(btnPrev);
|
|
||||||
|
|
||||||
var pageInfo = new android.widget.TextView(context);
|
|
||||||
pageInfo.setTextColor(textColor);
|
|
||||||
pageInfo.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 12);
|
|
||||||
pageInfo.setGravity(android.view.Gravity.CENTER);
|
|
||||||
pageInfo.setPadding(self.dp(8), 0, self.dp(8), 0);
|
|
||||||
var pageInfoLp = new android.widget.LinearLayout.LayoutParams(0, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, 1);
|
|
||||||
pageInfo.setLayoutParams(pageInfoLp);
|
|
||||||
pageBar.addView(pageInfo);
|
|
||||||
|
|
||||||
var btnNext = self.ui.createFlatButton(self, "下一页", C.primary, function() {
|
|
||||||
popupState.currentPage++;
|
|
||||||
renderGrid();
|
|
||||||
});
|
|
||||||
pageBar.addView(btnNext);
|
|
||||||
content.addView(pageBar);
|
|
||||||
|
|
||||||
var gridScroll = new android.widget.ScrollView(context);
|
var gridScroll = new android.widget.ScrollView(context);
|
||||||
var gridScrollLp = new android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, 0);
|
var gridScrollLp = new android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, 0);
|
||||||
gridScrollLp.weight = 1;
|
gridScrollLp.weight = 1;
|
||||||
@@ -4002,12 +3931,12 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
|
|||||||
selectRow.addView(selectPreview);
|
selectRow.addView(selectPreview);
|
||||||
|
|
||||||
var selectNameTv = new android.widget.TextView(context);
|
var selectNameTv = new android.widget.TextView(context);
|
||||||
selectNameTv.setTextColor(textColor);
|
selectNameTv.setTextColor(safeTextColor);
|
||||||
selectNameTv.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 13);
|
selectNameTv.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 13);
|
||||||
selectNameTv.setPadding(self.dp(8), 0, 0, 0);
|
selectNameTv.setPadding(self.dp(8), 0, 0, 0);
|
||||||
selectRow.addView(selectNameTv);
|
selectRow.addView(selectNameTv);
|
||||||
|
|
||||||
var selectConfirm = self.ui.createSolidButton(self, "确定", C.primary, android.graphics.Color.WHITE, function() {
|
var selectConfirm = self.ui.createSolidButton(self, "\u786e\u5b9a", safePrimary, android.graphics.Color.WHITE, function() {
|
||||||
self.touchActivity();
|
self.touchActivity();
|
||||||
if (typeof onSelect === "function") onSelect(selectedName);
|
if (typeof onSelect === "function") onSelect(selectedName);
|
||||||
closePopup();
|
closePopup();
|
||||||
@@ -4024,7 +3953,7 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
|
|||||||
if (dr) selectPreview.setImageDrawable(dr);
|
if (dr) selectPreview.setImageDrawable(dr);
|
||||||
else selectPreview.setImageDrawable(null);
|
else selectPreview.setImageDrawable(null);
|
||||||
} else {
|
} else {
|
||||||
selectNameTv.setText("未选择");
|
selectNameTv.setText("\u672a\u9009\u62e9");
|
||||||
selectPreview.setImageDrawable(null);
|
selectPreview.setImageDrawable(null);
|
||||||
}
|
}
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
@@ -4035,16 +3964,14 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
|
|||||||
try {
|
try {
|
||||||
grid.removeAllViews();
|
grid.removeAllViews();
|
||||||
var q = String(searchEt.getText() || "");
|
var q = String(searchEt.getText() || "");
|
||||||
var matched = filterCatalog(q, popupState.activeTab);
|
var matched = filterCatalog(q, "all");
|
||||||
|
|
||||||
// 调试:直接显示所有匹配图标,不分页
|
statusTv.setText("\u5171 " + matched.length + " \u4e2a\u56fe\u6807");
|
||||||
statusTv.setText("共 " + matched.length + " 个图标");
|
|
||||||
pageInfo.setText("-");
|
|
||||||
|
|
||||||
if (matched.length === 0) {
|
if (matched.length === 0) {
|
||||||
var emptyTv = new android.widget.TextView(context);
|
var emptyTv = new android.widget.TextView(context);
|
||||||
emptyTv.setText("未找到匹配的图标");
|
emptyTv.setText("\u672a\u627e\u5230\u5339\u914d\u7684\u56fe\u6807");
|
||||||
emptyTv.setTextColor(subTextColor);
|
emptyTv.setTextColor(safeSubTextColor);
|
||||||
emptyTv.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 14);
|
emptyTv.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 14);
|
||||||
emptyTv.setGravity(android.view.Gravity.CENTER);
|
emptyTv.setGravity(android.view.Gravity.CENTER);
|
||||||
emptyTv.setPadding(0, self.dp(40), 0, self.dp(40));
|
emptyTv.setPadding(0, self.dp(40), 0, self.dp(40));
|
||||||
@@ -4052,7 +3979,6 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 固定 4 列,不计算动态布局
|
|
||||||
var cols = 4;
|
var cols = 4;
|
||||||
grid.setColumnCount(cols);
|
grid.setColumnCount(cols);
|
||||||
|
|
||||||
@@ -4064,7 +3990,12 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
|
|||||||
cell.setGravity(android.view.Gravity.CENTER_HORIZONTAL);
|
cell.setGravity(android.view.Gravity.CENTER_HORIZONTAL);
|
||||||
cell.setPadding(self.dp(4), self.dp(6), self.dp(4), self.dp(6));
|
cell.setPadding(self.dp(4), self.dp(6), self.dp(4), self.dp(6));
|
||||||
cell.setClickable(true);
|
cell.setClickable(true);
|
||||||
cell.setBackground(self.ui.createRippleDrawable(C.card, self.withAlpha(C.primary, 0.2), self.dp(10)));
|
|
||||||
|
var bgColor = safeCard;
|
||||||
|
try {
|
||||||
|
bgColor = self.withAlpha(safeCard, 0.96);
|
||||||
|
} catch(e) {}
|
||||||
|
cell.setBackground(self.ui.createRoundDrawable(bgColor, self.dp(10)));
|
||||||
|
|
||||||
var iv = new android.widget.ImageView(context);
|
var iv = new android.widget.ImageView(context);
|
||||||
iv.setLayoutParams(new android.widget.LinearLayout.LayoutParams(self.dp(28), self.dp(28)));
|
iv.setLayoutParams(new android.widget.LinearLayout.LayoutParams(self.dp(28), self.dp(28)));
|
||||||
@@ -4075,7 +4006,9 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
|
|||||||
iv.setImageDrawable(dr);
|
iv.setImageDrawable(dr);
|
||||||
} else {
|
} else {
|
||||||
var placeholder = new android.graphics.drawable.GradientDrawable();
|
var placeholder = new android.graphics.drawable.GradientDrawable();
|
||||||
placeholder.setColor(self.withAlpha(subTextColor, 0.1));
|
var phColor = 0x1A000000;
|
||||||
|
try { phColor = self.withAlpha(safeSubTextColor, 0.1); } catch(e) {}
|
||||||
|
placeholder.setColor(phColor);
|
||||||
placeholder.setCornerRadius(self.dp(6));
|
placeholder.setCornerRadius(self.dp(6));
|
||||||
iv.setBackground(placeholder);
|
iv.setBackground(placeholder);
|
||||||
}
|
}
|
||||||
@@ -4092,10 +4025,14 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
|
|||||||
cell.addView(tv);
|
cell.addView(tv);
|
||||||
|
|
||||||
if (selectedName === item.name) {
|
if (selectedName === item.name) {
|
||||||
try { cell.setBackground(self.ui.createRoundDrawable(self.withAlpha(C.primary, 0.2), self.dp(10))); } catch(e) {}
|
try {
|
||||||
try { tv.setTextColor(C.primary); } catch(e) {}
|
var selBg = 0x33006C5F;
|
||||||
|
try { selBg = self.withAlpha(safePrimary, 0.2); } catch(e) {}
|
||||||
|
cell.setBackground(self.ui.createRoundDrawable(selBg, self.dp(10)));
|
||||||
|
} catch(e) {}
|
||||||
|
try { tv.setTextColor(safePrimary); } catch(e) {}
|
||||||
} else {
|
} else {
|
||||||
try { tv.setTextColor(subTextColor); } catch(e) {}
|
try { tv.setTextColor(safeSubTextColor); } catch(e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
cell.setOnClickListener(new android.view.View.OnClickListener({
|
cell.setOnClickListener(new android.view.View.OnClickListener({
|
||||||
|
|||||||
Reference in New Issue
Block a user