1
0
forked from BRT/arc

Refine sum field detection logic in findSumEditText to account for an additional EditText above the anchor.

This commit is contained in:
slava 2026-05-07 23:09:56 +07:00
parent 46aca63341
commit daa0123f7f

View File

@ -527,7 +527,9 @@ Node ScreenXmlParser::findEditTextByHint(const QString &hint) {
} }
Node ScreenXmlParser::findSumEditText() { Node ScreenXmlParser::findSumEditText() {
// Якорь: View "Мин. сумма: ..." расположен сразу под полем суммы. // Якорь: View "Мин. сумма: ..." расположен под полем "Комментарий",
// которое следует за полем суммы. То есть над якорем два EditText'а:
// ближайший = "Комментарий", следующий вверх = "Сумма".
Node anchor; Node anchor;
for (const Node &node : m_nodes) { for (const Node &node : m_nodes) {
if (node.contentDesc.contains(QString::fromUtf8("Мин. сумма"))) { if (node.contentDesc.contains(QString::fromUtf8("Мин. сумма"))) {
@ -537,14 +539,20 @@ Node ScreenXmlParser::findSumEditText() {
} }
if (anchor.x1() < 0) return {}; if (anchor.x1() < 0) return {};
// Ближайший EditText, который заканчивается выше якоря. QList<Node> aboveAnchor;
Node best;
for (const Node &node : m_nodes) { for (const Node &node : m_nodes) {
if (node.className != "android.widget.EditText") continue; if (node.className != "android.widget.EditText") continue;
if (node.y2() > anchor.y1()) continue; if (node.y2() > anchor.y1()) continue;
if (best.x1() < 0 || node.y2() > best.y2()) best = node; aboveAnchor.append(node);
} }
return best; // Сортируем по нижней границе по убыванию: [0] — ближайший (Комментарий),
// [1] — следующий выше (Сумма).
std::sort(aboveAnchor.begin(), aboveAnchor.end(),
[](const Node &a, const Node &b) { return a.y2() > b.y2(); });
if (aboveAnchor.size() >= 2) return aboveAnchor[1];
if (aboveAnchor.size() == 1) return aboveAnchor[0]; // нестандартная разметка
return {};
} }
Node ScreenXmlParser::tryToFindSystemPermissionDenyButton() { Node ScreenXmlParser::tryToFindSystemPermissionDenyButton() {