Add option to disable for hours
Signed-off-by: William Brawner <me@wbrawner.com>
This commit is contained in:
parent
53cd8c7312
commit
b6bf045fd0
3 changed files with 25 additions and 17 deletions
|
@ -132,18 +132,19 @@ class MainFragment : Fragment() {
|
|||
.create()
|
||||
.apply {
|
||||
setOnShowListener {
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setSuspendingOnClickListener(
|
||||
lifecycleScope
|
||||
) {
|
||||
getButton(AlertDialog.BUTTON_POSITIVE)
|
||||
.setSuspendingOnClickListener(lifecycleScope) {
|
||||
try {
|
||||
val rawTime = dialogView.time
|
||||
.text
|
||||
.toString()
|
||||
.toLong()
|
||||
val checkedId =
|
||||
dialogView.timeUnit.checkedRadioButtonId
|
||||
val computedTime = if (checkedId == R.id.seconds) rawTime
|
||||
else rawTime * 60
|
||||
val computedTime =
|
||||
when (dialogView.timeUnit.checkedRadioButtonId) {
|
||||
R.id.seconds -> rawTime
|
||||
R.id.minutes -> rawTime * 60
|
||||
else -> rawTime * 3600
|
||||
}
|
||||
viewModel.disablePiHole(computedTime)
|
||||
dismiss()
|
||||
} catch (e: Exception) {
|
||||
|
|
|
@ -40,5 +40,11 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/duration_minutes" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/hours"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/duration_hours" />
|
||||
</RadioGroup>
|
||||
</LinearLayout>
|
|
@ -46,4 +46,5 @@
|
|||
<string name="action_authenticate_api_key">Authenticate with API Key</string>
|
||||
<string name="connecting_to_pihole">Connecting to Pi-hole…</string>
|
||||
<string name="action_cancel">Cancel</string>
|
||||
<string name="duration_hours">Hours</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue