feat(icon): \u5206\u9875 + \u81ea\u9002\u5e94\u5e03\u5c40 + \u66f4\u5927\u5f39\u7a97

1. \u5f39\u7a97\u5c3a\u5bf8\u4ece 340x520dp \u589e\u5927\u5230 400x640dp\n2. \u6062\u590d\u5206\u9875\u529f\u80fd\uff1a\u4e0a\u4e00\u9875/\u4e0b\u4e00\u9875 + \u9875\u7801\u663e\u793a\n3. \u81ea\u9002\u5e94\u5e03\u5c40\uff1a\u6839\u636e\u5f39\u7a97\u5bbd\u5ea6\u52a8\u6001\u8ba1\u7b97\u5217\u6570\u548c\u6bcf\u9875\u56fe\u6807\u6570\n4. \u4fdd\u7559\u5b89\u5168\u989c\u8272\u548c try-catch \u4fdd\u62a4
This commit is contained in:
Hermes
2026-04-20 18:40:53 +08:00
parent d5482852ef
commit 5ae3b986be

View File

@@ -3684,12 +3684,12 @@ FloatBallAppWM.prototype.showPopupOverlay = function(opts) {
var card = new android.widget.LinearLayout(context);
card.setOrientation(android.widget.LinearLayout.VERTICAL);
var cardLp = new android.widget.FrameLayout.LayoutParams(
self.dp(340), self.dp(520)
self.dp(400), self.dp(640)
);
cardLp.gravity = android.view.Gravity.CENTER;
card.setLayoutParams(cardLp);
card.setBackground(self.ui.createRoundDrawable(isDark ? C.cardDark : C.cardLight, self.dp(16)));
card.setPadding(self.dp(12), self.dp(12), self.dp(12), self.dp(12));
card.setPadding(self.dp(16), self.dp(16), self.dp(16), self.dp(16));
var header = new android.widget.LinearLayout(context);
header.setOrientation(android.widget.LinearLayout.HORIZONTAL);
@@ -3888,7 +3888,6 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
title: "\u9009\u62e9 ShortX \u56fe\u6807",
onDismiss: onDismiss,
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;
@@ -3910,6 +3909,35 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
statusTv.setPadding(self.dp(8), self.dp(4), self.dp(8), self.dp(4));
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, "\u4e0a\u4e00\u9875", safeSubTextColor, function() {
if (popupState.currentPage > 0) {
popupState.currentPage--;
renderGrid();
}
});
pageBar.addView(btnPrev);
var pageInfo = new android.widget.TextView(context);
pageInfo.setTextColor(safeTextColor);
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, "\u4e0b\u4e00\u9875", safePrimary, function() {
popupState.currentPage++;
renderGrid();
});
pageBar.addView(btnNext);
content.addView(pageBar);
var gridScroll = new android.widget.ScrollView(context);
var gridScrollLp = new android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, 0);
gridScrollLp.weight = 1;
@@ -3966,9 +3994,11 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
var q = String(searchEt.getText() || "");
var matched = filterCatalog(q, "all");
statusTv.setText("\u5171 " + matched.length + " \u4e2a\u56fe\u6807");
if (matched.length === 0) {
statusTv.setText("\u672a\u627e\u5230\u5339\u914d\u7684\u56fe\u6807");
pageInfo.setText("0 / 0");
btnPrev.setEnabled(false);
btnNext.setEnabled(false);
var emptyTv = new android.widget.TextView(context);
emptyTv.setText("\u672a\u627e\u5230\u5339\u914d\u7684\u56fe\u6807");
emptyTv.setTextColor(safeSubTextColor);
@@ -3979,11 +4009,33 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
return;
}
var cols = 4;
// \u81ea\u9002\u5e94\u5e03\u5c40\uff1a\u6839\u636e\u5f39\u7a97\u5bbd\u5ea6\u8ba1\u7b97\u5217\u6570\n var gridW = grid.getWidth();
var gridH = grid.getHeight();
if (gridW <= 0) gridW = self.dp(368); // 400 - 16*2 - 8*2
if (gridH <= 0) gridH = self.dp(480); // 640 - 16*2 - \u5176\u4ed6UI\u7ea6180dp
resolvePageSize(gridW, gridH);
var size = popupState.pageSize;
var cols = popupState.pageCols;
if (size < 1) size = 12;
if (cols < 1) cols = 4;
var totalPages = Math.ceil(matched.length / size);
if (popupState.currentPage >= totalPages) popupState.currentPage = totalPages - 1;
if (popupState.currentPage < 0) popupState.currentPage = 0;
var start = popupState.currentPage * size;
var pageItems = matched.slice(start, start + size);
statusTv.setText("\u5171 " + matched.length + " \u4e2a\uff0c\u7b2c " + (popupState.currentPage + 1) + "/" + totalPages + " \u9875\uff0c\u6bcf\u9875 " + size + " \u4e2a");
pageInfo.setText((popupState.currentPage + 1) + " / " + totalPages);
btnPrev.setEnabled(popupState.currentPage > 0);
btnNext.setEnabled(popupState.currentPage < totalPages - 1);
grid.setColumnCount(cols);
var idx;
for (idx = 0; idx < matched.length; idx++) {
for (idx = 0; idx < pageItems.length; idx++) {
(function(item) {
var cell = new android.widget.LinearLayout(context);
cell.setOrientation(android.widget.LinearLayout.VERTICAL);
@@ -3992,9 +4044,7 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
cell.setClickable(true);
var bgColor = safeCard;
try {
bgColor = self.withAlpha(safeCard, 0.96);
} catch(e) {}
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);
@@ -4045,11 +4095,11 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
}));
var cellLp = new android.widget.GridLayout.LayoutParams();
cellLp.width = self.dp(72);
cellLp.width = popupState.cellWidthPx || self.dp(72);
cellLp.height = android.widget.GridLayout.LayoutParams.WRAP_CONTENT;
cell.setLayoutParams(cellLp);
grid.addView(cell);
})(matched[idx]);
})(pageItems[idx]);
}
} catch(eRender) {
safeLog(self.L, 'e', "renderGrid err=" + String(eRender));
@@ -4066,7 +4116,6 @@ FloatBallAppWM.prototype.showShortXIconPickerPopup = function(opts) {
afterTextChanged: function() {}
}));
// 直接渲染,不依赖分页
renderGrid();
}
});