mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-27 20:15:29 +00:00
Disable Grant Button for 1 seconds after popup display
This commit is contained in:
parent
36897ceb19
commit
10eb159e1b
@ -39,6 +39,8 @@ class SuRequestViewModel(
|
||||
|
||||
val selectedItemPosition = KObservableField(0)
|
||||
|
||||
val grantEnabled = KObservableField(false)
|
||||
|
||||
private val items = DiffObservableList(ComparableRvItem.callback)
|
||||
private val itemBinding = ItemBinding.of<ComparableRvItem<*>> { binding, _, item ->
|
||||
item.bind(binding)
|
||||
@ -104,7 +106,10 @@ class SuRequestViewModel(
|
||||
val millis = SECONDS.toMillis(Config.suDefaultTimeout.toLong())
|
||||
timer = object : CountDownTimer(millis, 1000) {
|
||||
override fun onTick(remains: Long) {
|
||||
denyText.value = "${res.getString(R.string.deny)} (${remains / 1000})"
|
||||
if (remains <= millis - 1000) {
|
||||
grantEnabled.value = true
|
||||
}
|
||||
denyText.value = "${res.getString(R.string.deny)} (${(remains / 1000) + 1})"
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
|
@ -141,6 +141,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:onClick="@{() -> viewModel.grantPressed()}"
|
||||
android:enabled="@{viewModel.grantEnabled}"
|
||||
android:text="@string/grant" />
|
||||
|
||||
</LinearLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user