11package com.ven.assists.web
22
33import android.graphics.Bitmap
4+ import android.graphics.Path
45import android.graphics.Rect
56import android.os.Build
67import android.util.Base64
@@ -40,10 +41,11 @@ import com.ven.assists.mp.MPManager.getBitmap
4041import com.ven.assists.service.AssistsService
4142import com.ven.assists.utils.CoroutineWrapper
4243import com.ven.assists.utils.runIO
44+ import com.ven.assists.utils.runMain
45+ import com.ven.assists.web.databinding.WebFloatingWindowBinding
4346import com.ven.assists.window.AssistsWindowManager
4447import com.ven.assists.window.AssistsWindowManager.overlayToast
4548import com.ven.assists.window.AssistsWindowWrapper
46- import com.ven.assists_web.databinding.WebFloatingWindowBinding
4749import kotlinx.coroutines.CoroutineScope
4850import kotlinx.coroutines.Dispatchers
4951import kotlinx.coroutines.delay
@@ -191,11 +193,30 @@ class ASJavascriptInterface(val webView: WebView) {
191193 }))
192194 }
193195
194- CallMethod .dispatchGesture -> {
195- ScreenUtils .getScreenHeight()
196- // AssistsCore.dispatchGesture()
197- //
198- // result = GsonUtils.toJson(CallResponse<List<Node>>(code = 0, data = nodes))
196+ CallMethod .performLinearGesture -> {
197+ CoroutineWrapper .launch {
198+ val startPoint = request.arguments?.get(" startPoint" )?.asJsonObject ? : JsonObject ()
199+ val endPoint = request.arguments?.get(" endPoint" )?.asJsonObject ? : JsonObject ()
200+ val path = Path ()
201+ path.moveTo(startPoint.get(" x" ).asFloat, startPoint.get(" y" ).asFloat)
202+ path.lineTo(endPoint.get(" x" ).asFloat, endPoint.get(" y" ).asFloat)
203+ val switchWindowIntervalDelay = request.arguments?.get(" switchWindowIntervalDelay" )?.asLong ? : 250
204+ CoroutineWrapper .launch {
205+ AssistsWindowManager .nonTouchableByAll()
206+ delay(switchWindowIntervalDelay)
207+ val result =
208+ AssistsCore .gesture(path = path, startTime = 0 , duration = request.arguments?.get(" duration" )?.asLong ? : 1000 )
209+ AssistsWindowManager .touchableByAll()
210+ if (result) {
211+ callback(CallResponse <Boolean >(code = 0 , data = true , callbackId = request.callbackId))
212+ } else {
213+ callback(CallResponse <Boolean >(code = - 1 , data = false , callbackId = request.callbackId))
214+ }
215+ }
216+ }
217+ result = GsonUtils .toJson(CallResponse <JsonObject >(code = 0 , data = JsonObject ().apply {
218+ addProperty(" resultType" , " callback" )
219+ }))
199220 }
200221
201222 CallMethod .getAppScreenSize -> {
@@ -210,14 +231,14 @@ class ASJavascriptInterface(val webView: WebView) {
210231 }))
211232 }
212233
213- CallMethod .gestureClick -> {
234+ CallMethod .clickByGesture -> {
214235 CoroutineWrapper .launch {
215236 AssistsCore .gestureClick(x = request.arguments?.get(" x" )?.asFloat ? : 0f , y = request.arguments?.get(" y" )?.asFloat ? : 0f )
216237 }
217238 result = GsonUtils .toJson(CallResponse <Boolean >(code = 0 , data = true ))
218239 }
219240
220- CallMethod .nodeGestureClick -> {
241+ CallMethod .clickNodeByGesture -> {
221242 CoroutineWrapper .launch {
222243 val offsetX = request.arguments?.get(" offsetX" )?.asFloat ? : (ScreenUtils .getScreenWidth() * 0.01953f )
223244 val offsetY = request.arguments?.get(" offsetY" )?.asFloat ? : (ScreenUtils .getScreenWidth() * 0.01953f )
@@ -236,7 +257,7 @@ class ASJavascriptInterface(val webView: WebView) {
236257 }))
237258 }
238259
239- CallMethod .nodeGestureClickByDouble -> {
260+ CallMethod .doubleClickNodeByGesture -> {
240261 CoroutineWrapper .launch {
241262 val offsetX = request.arguments?.get(" offsetX" )?.asFloat ? : (ScreenUtils .getScreenWidth() * 0.01953f )
242263 val offsetY = request.arguments?.get(" offsetY" )?.asFloat ? : (ScreenUtils .getScreenWidth() * 0.01953f )
0 commit comments