Unverified Commit 10eb159e authored by Fox2Code's avatar Fox2Code Committed by GitHub

Disable Grant Button for 1 seconds after popup display

parent 36897ceb
......@@ -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>
......
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