Refine sum field detection logic in findSumEditText to account for an additional EditText above the anchor.
This commit is contained in:
parent
ec1f495d76
commit
fbe07819d5
@ -527,7 +527,9 @@ Node ScreenXmlParser::findEditTextByHint(const QString &hint) {
|
||||
}
|
||||
|
||||
Node ScreenXmlParser::findSumEditText() {
|
||||
// Якорь: View "Мин. сумма: ..." расположен сразу под полем суммы.
|
||||
// Якорь: View "Мин. сумма: ..." расположен под полем "Комментарий",
|
||||
// которое следует за полем суммы. То есть над якорем два EditText'а:
|
||||
// ближайший = "Комментарий", следующий вверх = "Сумма".
|
||||
Node anchor;
|
||||
for (const Node &node : m_nodes) {
|
||||
if (node.contentDesc.contains(QString::fromUtf8("Мин. сумма"))) {
|
||||
@ -537,14 +539,20 @@ Node ScreenXmlParser::findSumEditText() {
|
||||
}
|
||||
if (anchor.x1() < 0) return {};
|
||||
|
||||
// Ближайший EditText, который заканчивается выше якоря.
|
||||
Node best;
|
||||
QList<Node> aboveAnchor;
|
||||
for (const Node &node : m_nodes) {
|
||||
if (node.className != "android.widget.EditText") 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() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user