update 优化关闭服务;优化悬浮窗位置
This commit is contained in:
@@ -16,6 +16,7 @@ import com.blankj.utilcode.constant.PermissionConstants
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.qmuiteam.qmui.widget.dialog.QMUIDialog
|
||||
import org.yameida.worktool.service.PlayNotifyService
|
||||
import org.yameida.worktool.service.WeworkController
|
||||
import org.yameida.worktool.service.fastStartActivity
|
||||
import org.yameida.worktool.utils.*
|
||||
import org.yameida.worktool.utils.capture.MediaProjectionHolder
|
||||
@@ -152,9 +153,7 @@ class ListenActivity : AppCompatActivity() {
|
||||
}
|
||||
} else {
|
||||
if (PermissionHelper.isAccessibilitySettingOn()) {
|
||||
sw_accessibility.isChecked = true
|
||||
val intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
|
||||
startActivity(intent)
|
||||
WeworkController.weworkService.disableSelf()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -18,6 +18,7 @@ import okhttp3.RequestBody
|
||||
import org.json.JSONObject
|
||||
import org.yameida.worktool.Constant
|
||||
import org.yameida.worktool.R
|
||||
import org.yameida.worktool.service.WeworkController
|
||||
import org.yameida.worktool.utils.*
|
||||
|
||||
|
||||
@@ -87,8 +88,7 @@ class SettingsActivity : AppCompatActivity() {
|
||||
bt_open_main.setOnClickListener {
|
||||
freshOpenMain()
|
||||
if (PermissionHelper.isAccessibilitySettingOn()) {
|
||||
val intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
|
||||
startActivity(intent)
|
||||
WeworkController.weworkService.disableSelf()
|
||||
} else {
|
||||
if (Constant.robotId.isBlank()) {
|
||||
ToastUtils.showLong("请先填写并保存链接号~")
|
||||
|
||||
@@ -29,6 +29,7 @@ class WeworkService : AccessibilityService() {
|
||||
lateinit var webSocketManager: WebSocketManager
|
||||
var currentPackage = ""
|
||||
var currentClass = ""
|
||||
var currentClassPackage = ""
|
||||
|
||||
companion object {
|
||||
private var mFileObserver: FileObserver? = null
|
||||
@@ -98,6 +99,7 @@ class WeworkService : AccessibilityService() {
|
||||
if (className.contains(currentPackage)) {
|
||||
LogUtils.d("更新当前页面: currentPackage: ${event.packageName} className: ${event.className}")
|
||||
currentClass = className
|
||||
currentClassPackage = currentPackage
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1323,4 +1323,29 @@ object AccessibilityUtil {
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 等待页面消失
|
||||
* @param clazz 页面Class
|
||||
* @param timeout 检查超时时间
|
||||
*/
|
||||
fun waitForPageMissing(
|
||||
clazz: String,
|
||||
timeout: Long = 5000
|
||||
): Boolean {
|
||||
val service = WeworkController.weworkService
|
||||
val startTime = System.currentTimeMillis()
|
||||
var currentTime = startTime
|
||||
while (currentTime - startTime <= timeout) {
|
||||
if (service.currentClass == clazz || service.currentClass.split(".").last() == clazz) {
|
||||
} else {
|
||||
Log.v(tag, "pageMissing: $clazz")
|
||||
return true
|
||||
}
|
||||
sleep(SHORT_INTERVAL)
|
||||
currentTime = System.currentTimeMillis()
|
||||
}
|
||||
Log.e(tag, "pageMissing: not found: $clazz current: ${service.currentClass}")
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user