diff --git a/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt b/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt
index aba0f3be62..edaff653ba 100644
--- a/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt
+++ b/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt
@@ -1,6 +1,7 @@
package info.nightscout.androidaps.dialogs
import android.os.Bundle
+import android.os.Handler
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@@ -9,9 +10,10 @@ import android.view.WindowManager
import dagger.android.support.DaggerDialogFragment
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.core.R
+import info.nightscout.androidaps.core.databinding.DialogErrorBinding
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.services.AlarmSoundServiceHelper
-import kotlinx.android.synthetic.main.dialog_error.*
+import info.nightscout.androidaps.utils.T
import javax.inject.Inject
class ErrorDialog : DaggerDialogFragment() {
@@ -24,8 +26,16 @@ class ErrorDialog : DaggerDialogFragment() {
var title: String = ""
var sound: Int = 0
+ private var loopHandler = Handler()
+
+ private var _binding: DialogErrorBinding? = null
+
+ // This property is only valid between onCreateView and
+ // onDestroyView.
+ private val binding get() = _binding!!
+
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
- savedInstanceState: Bundle?): View? {
+ savedInstanceState: Bundle?): View {
dialog?.window?.requestFeature(Window.FEATURE_NO_TITLE)
dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)
isCancelable = true
@@ -37,21 +47,27 @@ class ErrorDialog : DaggerDialogFragment() {
sound = bundle.getInt("sound", R.raw.error)
}
aapsLogger.debug("Error dialog displayed")
- return inflater.inflate(R.layout.dialog_error, container, false)
+ _binding = DialogErrorBinding.inflate(inflater, container, false)
+ return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- error_title.text = title
- overview_error_ok.setOnClickListener {
+ binding.title.text = title
+ binding.ok.setOnClickListener {
aapsLogger.debug("USER ENTRY: Error dialog ok button pressed")
dismiss()
}
- overview_error_mute.setOnClickListener {
+ binding.mute.setOnClickListener {
aapsLogger.debug("USER ENTRY: Error dialog mute button pressed")
stopAlarm()
}
+ binding.mute5min.setOnClickListener {
+ aapsLogger.debug("USER ENTRY: Error dialog mute 5 min button pressed")
+ stopAlarm()
+ loopHandler.postDelayed(this::startAlarm, T.mins(5).msecs())
+ }
startAlarm()
}
@@ -69,12 +85,18 @@ class ErrorDialog : DaggerDialogFragment() {
override fun onResume() {
super.onResume()
- overview_error_status.text = status
+ binding.status.text = status
+ }
+
+ override fun onDestroyView() {
+ super.onDestroyView()
+ _binding = null
}
override fun dismiss() {
super.dismissAllowingStateLoss()
helperActivity?.finish()
+ loopHandler.removeCallbacksAndMessages(null)
stopAlarm()
}
diff --git a/core/src/main/res/layout/dialog_error.xml b/core/src/main/res/layout/dialog_error.xml
index 6256c1c721..0a345a7ea3 100644
--- a/core/src/main/res/layout/dialog_error.xml
+++ b/core/src/main/res/layout/dialog_error.xml
@@ -21,7 +21,7 @@
app:srcCompat="@drawable/ic_error_red_48dp" />
+ android:textAppearance="@style/TextAppearance.AppCompat.Large" />
+
+
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index daca62fb65..0540641181 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -262,6 +262,7 @@
Prime
Alarms
Glucose
+ Mute for 5 minutes