|
@@ -13,6 +13,7 @@ import android.os.Handler
|
|
|
import android.os.Looper
|
|
import android.os.Looper
|
|
|
import android.util.DisplayMetrics
|
|
import android.util.DisplayMetrics
|
|
|
import android.util.Log
|
|
import android.util.Log
|
|
|
|
|
+import android.util.TypedValue
|
|
|
import android.view.Gravity
|
|
import android.view.Gravity
|
|
|
import android.view.LayoutInflater
|
|
import android.view.LayoutInflater
|
|
|
import android.view.MotionEvent
|
|
import android.view.MotionEvent
|
|
@@ -23,6 +24,7 @@ import android.view.accessibility.AccessibilityEvent
|
|
|
import android.view.accessibility.AccessibilityNodeInfo
|
|
import android.view.accessibility.AccessibilityNodeInfo
|
|
|
import android.widget.CompoundButton
|
|
import android.widget.CompoundButton
|
|
|
import android.widget.FrameLayout
|
|
import android.widget.FrameLayout
|
|
|
|
|
+import androidx.core.content.ContextCompat
|
|
|
import androidx.core.view.ViewCompat
|
|
import androidx.core.view.ViewCompat
|
|
|
import androidx.datastore.core.DataStore
|
|
import androidx.datastore.core.DataStore
|
|
|
import androidx.datastore.preferences.core.Preferences
|
|
import androidx.datastore.preferences.core.Preferences
|
|
@@ -674,6 +676,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
requesting.observeForever {
|
|
requesting.observeForever {
|
|
|
binding.btnReq.isEnabled = !it
|
|
binding.btnReq.isEnabled = !it
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
binding.btnReq.setOnClickListener {
|
|
binding.btnReq.setOnClickListener {
|
|
|
requestNumberCount = 6
|
|
requestNumberCount = 6
|
|
|
CoroutineScope(Dispatchers.IO).launch {
|
|
CoroutineScope(Dispatchers.IO).launch {
|
|
@@ -759,6 +762,8 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private suspend fun requestNumber() {
|
|
private suspend fun requestNumber() {
|
|
|
|
|
+ val color = ContextCompat.getColorStateList(binding.root.context, R.color.btn_color)
|
|
|
|
|
+ binding.btnReq.backgroundTintList = color
|
|
|
if (getSharedPreferences("settings", Context.MODE_PRIVATE)
|
|
if (getSharedPreferences("settings", Context.MODE_PRIVATE)
|
|
|
.getBoolean("do_not_request", false)
|
|
.getBoolean("do_not_request", false)
|
|
|
) {
|
|
) {
|
|
@@ -772,6 +777,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
var requestSuccess = false
|
|
var requestSuccess = false
|
|
|
withTimeoutOrNull(1.hours) {
|
|
withTimeoutOrNull(1.hours) {
|
|
|
while (true) {
|
|
while (true) {
|
|
|
|
|
+ delay(200)
|
|
|
try {
|
|
try {
|
|
|
rcsConfigureState.postValue(RcsConfigureState.NOT_CONFIGURED)
|
|
rcsConfigureState.postValue(RcsConfigureState.NOT_CONFIGURED)
|
|
|
|
|
|
|
@@ -814,6 +820,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
if (requestNumberCount > 5) {
|
|
if (requestNumberCount > 5) {
|
|
|
val resetSuccess = withTimeoutOrNull(5.minutes) {
|
|
val resetSuccess = withTimeoutOrNull(5.minutes) {
|
|
|
while (true) {
|
|
while (true) {
|
|
|
|
|
+ delay(200)
|
|
|
withContext(Dispatchers.Main) {
|
|
withContext(Dispatchers.Main) {
|
|
|
binding.tvLog.text = "Waiting for RCS switch on..."
|
|
binding.tvLog.text = "Waiting for RCS switch on..."
|
|
|
}
|
|
}
|
|
@@ -995,6 +1002,11 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
} else {
|
|
} else {
|
|
|
canSend = false
|
|
canSend = false
|
|
|
Log.e(TAG, "requestNumber failed")
|
|
Log.e(TAG, "requestNumber failed")
|
|
|
|
|
+
|
|
|
|
|
+ withContext(Dispatchers.Main) {
|
|
|
|
|
+ binding.btnReq.backgroundTintList =
|
|
|
|
|
+ ContextCompat.getColorStateList(binding.root.context, R.color.btn_color_error)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1061,11 +1073,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
} else {
|
|
} else {
|
|
|
Log.i(TAG, "checkRcsAvailability: RCS not detected")
|
|
Log.i(TAG, "checkRcsAvailability: RCS not detected")
|
|
|
}
|
|
}
|
|
|
- try {
|
|
|
|
|
- delay(200)
|
|
|
|
|
- } catch (e: InterruptedException) {
|
|
|
|
|
- e.printStackTrace()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ delay(200)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (s == true) {
|
|
if (s == true) {
|