Commit cffd024e authored by vvb2060's avatar vvb2060 Committed by John Wu

Ignore the response until showDialog done

parent 8c858592
...@@ -73,7 +73,8 @@ class SuRequestViewModel( ...@@ -73,7 +73,8 @@ class SuRequestViewModel(
val itemBinding = ItemBinding.of<String>(BR.item, R.layout.item_spinner) val itemBinding = ItemBinding.of<String>(BR.item, R.layout.item_spinner)
private val handler = SuRequestHandler(AppContext.packageManager, policyDB) private val handler = SuRequestHandler(AppContext.packageManager, policyDB)
private var timer: CountDownTimer? = null private lateinit var timer: CountDownTimer
private var initialized = false
fun grantPressed() { fun grantPressed() {
cancelTimer() cancelTimer()
...@@ -122,10 +123,16 @@ class SuRequestViewModel( ...@@ -122,10 +123,16 @@ class SuRequestViewModel(
// Actually show the UI // Actually show the UI
ShowUIEvent(if (Config.suTapjack) EmptyAccessibilityDelegate else null).publish() ShowUIEvent(if (Config.suTapjack) EmptyAccessibilityDelegate else null).publish()
initialized = true
} }
private fun respond(action: Int) { private fun respond(action: Int) {
timer?.cancel() if (!initialized) {
// ignore the response until showDialog done
return
}
timer.cancel()
val pos = selectedItemPosition val pos = selectedItemPosition
timeoutPrefs.edit().putInt(handler.pkgInfo.packageName, pos).apply() timeoutPrefs.edit().putInt(handler.pkgInfo.packageName, pos).apply()
...@@ -138,7 +145,7 @@ class SuRequestViewModel( ...@@ -138,7 +145,7 @@ class SuRequestViewModel(
} }
private fun cancelTimer() { private fun cancelTimer() {
timer?.cancel() timer.cancel()
denyText.seconds = 0 denyText.seconds = 0
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment