Skip to content

Commit 541ecd9

Browse files
committed
解决web执行手势点击被浮窗遮挡导致点击失败问题
1 parent 6ea8add commit 541ecd9

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

assists-web/src/main/java/com/ven/assists/web/ASJavascriptInterface.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,17 @@ class ASJavascriptInterface(val webView: WebView) {
345345

346346
CallMethod.clickByGesture -> {
347347
CoroutineWrapper.launch {
348+
val switchWindowIntervalDelay = request.arguments?.get("switchWindowIntervalDelay")?.asLong ?: 250
349+
val clickDuration = request.arguments?.get("clickDuration")?.asLong ?: 25
350+
AssistsWindowManager.nonTouchableByAll()
351+
delay(switchWindowIntervalDelay)
348352
val result =
349-
AssistsCore.gestureClick(x = request.arguments?.get("x")?.asFloat ?: 0f, y = request.arguments?.get("y")?.asFloat ?: 0f)
353+
AssistsCore.gestureClick(
354+
x = request.arguments?.get("x")?.asFloat ?: 0f,
355+
y = request.arguments?.get("y")?.asFloat ?: 0f,
356+
duration = clickDuration
357+
)
358+
AssistsWindowManager.touchableByAll()
350359
if (result) {
351360
callback(CallResponse<Boolean>(code = 0, data = true, callbackId = request.callbackId))
352361
} else {

assists-web/src/main/java/com/ven/assists/web/ASJavascriptInterfaceAsync.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,13 @@ class ASJavascriptInterfaceAsync(val webView: WebView) {
306306
}
307307

308308
CallMethod.clickByGesture -> {
309+
val switchWindowIntervalDelay = request.arguments?.get("switchWindowIntervalDelay")?.asLong ?: 250
310+
val clickDuration = request.arguments?.get("clickDuration")?.asLong ?: 25
311+
AssistsWindowManager.nonTouchableByAll()
312+
delay(switchWindowIntervalDelay)
309313
val result =
310-
AssistsCore.gestureClick(x = request.arguments?.get("x")?.asFloat ?: 0f, y = request.arguments?.get("y")?.asFloat ?: 0f)
311-
314+
AssistsCore.gestureClick(x = request.arguments?.get("x")?.asFloat ?: 0f, y = request.arguments?.get("y")?.asFloat ?: 0f, duration = clickDuration)
315+
AssistsWindowManager.touchableByAll()
312316
val response = request.createResponse(if (result) 0 else -1, data = result)
313317
response
314318
}

assists-web/src/main/java/com/ven/assists/web/ASWebView.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ class ASWebView @JvmOverloads constructor(
5959
add("node", element.asJsonObject)
6060
}
6161
}
62-
if (LogUtils.getConfig().isLogSwitch) {
63-
Log.d(LogUtils.getConfig().globalTag, jsonObject.toString())
64-
}
62+
// if (LogUtils.getConfig().isLogSwitch) {
63+
// Log.d(LogUtils.getConfig().globalTag, jsonObject.toString())
64+
// }
6565
onAccessibilityEvent(CallResponse(code = 0, data = jsonObject))
6666
}.onFailure {
6767
LogUtils.e(it)

0 commit comments

Comments
 (0)