Simplify sum field detection in PayByCardScript by removing resource-id-based strategies and relying on DOM order.
This commit is contained in:
parent
72d582f0ab
commit
98f1d0f9d6
@ -287,30 +287,17 @@ void PayByCardScript::makePayment(
|
|||||||
if (!sumInput.isEmpty()) break;
|
if (!sumInput.isEmpty()) break;
|
||||||
|
|
||||||
// Fallback для устройств, где Ozon WebView не отдаёт hint (TECNO).
|
// Fallback для устройств, где Ozon WebView не отдаёт hint (TECNO).
|
||||||
// На экране "Перевод по номеру карты" всегда 2 EditText: карта (сверху)
|
// На экране "Перевод по номеру карты" всегда 2 EditText в DOM-порядке:
|
||||||
// и сумма (снизу). Стратегии по приоритету:
|
// карта (сверху), сумма (снизу). Оба имеют resource-id="input___xxxx",
|
||||||
// 1) Svelte генерирует resource-id="input___xxxx" ТОЛЬКО для суммы —
|
// поэтому отличать по rid нельзя — берём второй по порядку обхода XML.
|
||||||
// берём этот EditText.
|
QList<Node> editTexts;
|
||||||
// 2) Если rid нет (старая версия Ozon UI) — берём второй EditText
|
|
||||||
// по y-порядку (карта y1=меньше, сумма y1=больше).
|
|
||||||
QList<Node> candidateInputs;
|
|
||||||
for (const Node &n : xmlScreenParser.findAllNodes()) {
|
for (const Node &n : xmlScreenParser.findAllNodes()) {
|
||||||
if (n.className != "android.widget.EditText") continue;
|
if (n.className != "android.widget.EditText") continue;
|
||||||
if (n.height() <= 0 || n.height() > height * 4 / 5) continue;
|
if (n.height() <= 0 || n.height() > height * 4 / 5) continue;
|
||||||
candidateInputs.append(n);
|
editTexts.append(n);
|
||||||
}
|
}
|
||||||
// Strategy 1: rid="input___"
|
if (editTexts.size() >= 2) {
|
||||||
for (const Node &n : candidateInputs) {
|
sumInput = editTexts[1];
|
||||||
if (n.resourceId.startsWith("input___")) {
|
|
||||||
sumInput = n;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Strategy 2: bottom-most по y1 (если их 2 — берём второй)
|
|
||||||
if (sumInput.isEmpty() && candidateInputs.size() >= 2) {
|
|
||||||
std::sort(candidateInputs.begin(), candidateInputs.end(),
|
|
||||||
[](const Node &a, const Node &b) { return a.y1() < b.y1(); });
|
|
||||||
sumInput = candidateInputs.last();
|
|
||||||
}
|
}
|
||||||
if (!sumInput.isEmpty()) break;
|
if (!sumInput.isEmpty()) break;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user