Handle error dialog in GetLastTransactionsScript with "OK" tap and pull-to-refresh; add time pre-filtering and enhanced match validation for transactions.
This commit is contained in:
parent
41bb5e33fd
commit
6647a91c88
@ -286,6 +286,22 @@ void GetLastTransactionsScript::doStart() {
|
||||
bool historyLoaded = false;
|
||||
for (int attempt = 0; attempt < 10; ++attempt) {
|
||||
xmlScreenParser.parseAndSaveXml(AdbUtils::getScreenDumpAsXml(m_deviceId, ++m_counter));
|
||||
|
||||
// Проверяем диалог "Ошибка" — нажимаем "ОК" и обновляем свайпом вниз
|
||||
if (!xmlScreenParser.findNodeByContentDesc(QString::fromUtf8("Ошибка")).isEmpty()) {
|
||||
Node okBtn = xmlScreenParser.findNodeByContentDesc(QString::fromUtf8("ОК"));
|
||||
if (!okBtn.isEmpty()) {
|
||||
qDebug() << "[Dushanbe::GetLastTransactions] Error dialog detected, tapping OK";
|
||||
AdbUtils::makeTap(m_deviceId, okBtn.x(), okBtn.y());
|
||||
QThread::msleep(1000);
|
||||
}
|
||||
// Свайп вниз для обновления (pull-to-refresh)
|
||||
const int x = device.screenWidth / 2;
|
||||
AdbUtils::makeSwipe(m_deviceId, x, device.screenHeight / 4, x, device.screenHeight * 3 / 4);
|
||||
QThread::msleep(3000);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (xmlScreenParser.isHistoryScreen()) {
|
||||
historyLoaded = true;
|
||||
break;
|
||||
@ -326,15 +342,29 @@ void GetLastTransactionsScript::doStart() {
|
||||
qDebug() << "[Dushanbe::GetLastTransactions] Amount match:" << tx.amount
|
||||
<< "phone:" << tx.phone << "time:" << tx.time;
|
||||
|
||||
// Нашли по сумме — тапаем для получения деталей
|
||||
// Предварительная проверка времени из списка (±1 час)
|
||||
if (m_searchTime.isValid() && !tx.time.isEmpty()) {
|
||||
const QTime listTime = QTime::fromString(tx.time, "HH:mm:ss");
|
||||
const QTime searchLocal = m_searchTime.toTimeZone(tjTz).time();
|
||||
if (listTime.isValid() && searchLocal.isValid()) {
|
||||
const int diffSecs = qAbs(listTime.secsTo(searchLocal));
|
||||
if (diffSecs > 3600 && diffSecs < 82800) { // 82800 = 24h - 1h (для полуночи)
|
||||
qDebug() << "[Dushanbe::GetLastTransactions] Time pre-filter skip:"
|
||||
<< tx.time << "vs" << searchLocal.toString("HH:mm:ss")
|
||||
<< "diff=" << diffSecs << "sec";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ищем соответствующий node чтобы по нему тапнуть
|
||||
Node txNode;
|
||||
for (const Node &node : xmlScreenParser.findAllNodes()) {
|
||||
if (node.className != "android.widget.ImageView") continue;
|
||||
if (!node.contentDesc.contains("***")) continue;
|
||||
// Проверяем что содержит нужную сумму
|
||||
QString amountStr = QString::number(tx.amount, 'f', 2);
|
||||
if (node.contentDesc.contains(amountStr)) {
|
||||
// Проверяем что содержит нужную сумму и время
|
||||
const QString amountStr = QString::number(tx.amount, 'f', 2);
|
||||
if (node.contentDesc.contains(amountStr) && node.contentDesc.contains(tx.time)) {
|
||||
txNode = node;
|
||||
break;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user