diff --git a/app/src/main/java/com/wbrawner/pihelper/MainFragment.kt b/app/src/main/java/com/wbrawner/pihelper/MainFragment.kt
index e631084..5acfcff 100644
--- a/app/src/main/java/com/wbrawner/pihelper/MainFragment.kt
+++ b/app/src/main/java/com/wbrawner/pihelper/MainFragment.kt
@@ -132,24 +132,25 @@ class MainFragment : Fragment() {
.create()
.apply {
setOnShowListener {
- 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
- viewModel.disablePiHole(computedTime)
- dismiss()
- } catch (e: Exception) {
- dialogView.time.error = "Failed to disable Pi-hole"
+ getButton(AlertDialog.BUTTON_POSITIVE)
+ .setSuspendingOnClickListener(lifecycleScope) {
+ try {
+ val rawTime = dialogView.time
+ .text
+ .toString()
+ .toLong()
+ 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) {
+ dialogView.time.error = "Failed to disable Pi-hole"
+ }
}
- }
}
}
.show()
diff --git a/app/src/main/res/layout/dialog_disable_custom_time.xml b/app/src/main/res/layout/dialog_disable_custom_time.xml
index 5f6b7e9..dc6c14a 100644
--- a/app/src/main/res/layout/dialog_disable_custom_time.xml
+++ b/app/src/main/res/layout/dialog_disable_custom_time.xml
@@ -40,5 +40,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/duration_minutes" />
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 3f240bf..5106b73 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -46,4 +46,5 @@
Authenticate with API Key
Connecting to Pi-holeā¦
Cancel
+ Hours