fix: prevent dialog protection trigger many times
This commit is contained in:
parent
2c60ec44e5
commit
71004353d2
17 changed files with 149 additions and 121 deletions
|
@ -28,6 +28,7 @@ import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.*
|
import info.nightscout.androidaps.utils.*
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||||
|
@ -60,6 +61,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
||||||
private const val FAV3_DEFAULT = 20
|
private const val FAV3_DEFAULT = 20
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var queryingProtection = false
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
private val textWatcher: TextWatcher = object : TextWatcher {
|
private val textWatcher: TextWatcher = object : TextWatcher {
|
||||||
|
@ -382,14 +384,17 @@ class CarbsDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
activity?.let { activity ->
|
if(!queryingProtection) {
|
||||||
val cancelFail = {
|
queryingProtection = true
|
||||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
activity?.let { activity ->
|
||||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
val cancelFail = {
|
||||||
dismiss()
|
queryingProtection = false
|
||||||
|
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||||
|
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||||
}
|
}
|
||||||
|
|
||||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.extensions.formatColor
|
import info.nightscout.androidaps.extensions.formatColor
|
||||||
import info.nightscout.androidaps.utils.ToastUtils
|
import info.nightscout.androidaps.utils.ToastUtils
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.shared.logging.LTag
|
import info.nightscout.shared.logging.LTag
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
|
@ -41,10 +42,10 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var uel: UserEntryLogger
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||||
|
|
||||||
|
private var queryingProtection = false
|
||||||
private var _binding: DialogExtendedbolusBinding? = null
|
private var _binding: DialogExtendedbolusBinding? = null
|
||||||
|
|
||||||
// This property is only valid between onCreateView and
|
// This property is only valid between onCreateView and onDestroyView.
|
||||||
// onDestroyView.
|
|
||||||
private val binding get() = _binding!!
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
||||||
|
@ -113,14 +114,17 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
activity?.let { activity ->
|
if(!queryingProtection) {
|
||||||
val cancelFail = {
|
queryingProtection = true
|
||||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
activity?.let { activity ->
|
||||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
val cancelFail = {
|
||||||
dismiss()
|
queryingProtection = false
|
||||||
|
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||||
|
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||||
}
|
}
|
||||||
|
|
||||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.extensions.formatColor
|
import info.nightscout.androidaps.extensions.formatColor
|
||||||
import info.nightscout.androidaps.utils.ToastUtils
|
import info.nightscout.androidaps.utils.ToastUtils
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||||
|
@ -48,12 +49,11 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||||
|
|
||||||
|
private var queryingProtection = false
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
private var _binding: DialogFillBinding? = null
|
private var _binding: DialogFillBinding? = null
|
||||||
|
|
||||||
// This property is only valid between onCreateView and
|
// This property is only valid between onCreateView and onDestroyView.
|
||||||
// onDestroyView.
|
|
||||||
private val binding get() = _binding!!
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
||||||
|
@ -202,14 +202,17 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
activity?.let { activity ->
|
if(!queryingProtection) {
|
||||||
val cancelFail = {
|
queryingProtection = true
|
||||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
activity?.let { activity ->
|
||||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
val cancelFail = {
|
||||||
dismiss()
|
queryingProtection = false
|
||||||
|
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||||
|
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||||
}
|
}
|
||||||
|
|
||||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import info.nightscout.androidaps.utils.*
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.extensions.toSignedString
|
import info.nightscout.androidaps.utils.extensions.toSignedString
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.shared.SafeParse
|
import info.nightscout.shared.SafeParse
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
|
@ -62,7 +63,12 @@ class InsulinDialog : DialogFragmentWithDate() {
|
||||||
private const val PLUS3_DEFAULT = 2.0
|
private const val PLUS3_DEFAULT = 2.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var queryingProtection = false
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
private var _binding: DialogInsulinBinding? = null
|
||||||
|
|
||||||
|
// This property is only valid between onCreateView and onDestroyView.
|
||||||
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
private val textWatcher: TextWatcher = object : TextWatcher {
|
private val textWatcher: TextWatcher = object : TextWatcher {
|
||||||
override fun afterTextChanged(s: Editable) {
|
override fun afterTextChanged(s: Editable) {
|
||||||
|
@ -73,12 +79,6 @@ class InsulinDialog : DialogFragmentWithDate() {
|
||||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
|
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var _binding: DialogInsulinBinding? = null
|
|
||||||
|
|
||||||
// This property is only valid between onCreateView and
|
|
||||||
// onDestroyView.
|
|
||||||
private val binding get() = _binding!!
|
|
||||||
|
|
||||||
private fun validateInputs() {
|
private fun validateInputs() {
|
||||||
val maxInsulin = constraintChecker.getMaxBolusAllowed().value()
|
val maxInsulin = constraintChecker.getMaxBolusAllowed().value()
|
||||||
if (abs(binding.time.value.toInt()) > 12 * 60) {
|
if (abs(binding.time.value.toInt()) > 12 * 60) {
|
||||||
|
@ -260,14 +260,17 @@ class InsulinDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
activity?.let { activity ->
|
if(!queryingProtection) {
|
||||||
val cancelFail = {
|
queryingProtection = true
|
||||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
activity?.let { activity ->
|
||||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
val cancelFail = {
|
||||||
dismiss()
|
queryingProtection = false
|
||||||
|
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||||
|
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||||
}
|
}
|
||||||
|
|
||||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ import info.nightscout.androidaps.utils.T
|
||||||
import info.nightscout.androidaps.utils.ToastUtils
|
import info.nightscout.androidaps.utils.ToastUtils
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
|
@ -65,13 +66,13 @@ class LoopDialog : DaggerDialogFragment() {
|
||||||
@Inject lateinit var objectivePlugin: ObjectivesPlugin
|
@Inject lateinit var objectivePlugin: ObjectivesPlugin
|
||||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||||
|
|
||||||
|
private var queryingProtection = false
|
||||||
private var showOkCancel: Boolean = true
|
private var showOkCancel: Boolean = true
|
||||||
private var _binding: DialogLoopBinding? = null
|
private var _binding: DialogLoopBinding? = null
|
||||||
private var handler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
|
private var handler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
|
||||||
private lateinit var refreshDialog: Runnable
|
private lateinit var refreshDialog: Runnable
|
||||||
|
|
||||||
// This property is only valid between onCreateView and
|
// This property is only valid between onCreateView and onDestroyView.
|
||||||
// onDestroyView.
|
|
||||||
private val binding get() = _binding!!
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
val disposable = CompositeDisposable()
|
val disposable = CompositeDisposable()
|
||||||
|
@ -442,14 +443,17 @@ class LoopDialog : DaggerDialogFragment() {
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
activity?.let { activity ->
|
if(!queryingProtection) {
|
||||||
val cancelFail = {
|
queryingProtection = true
|
||||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
activity?.let { activity ->
|
||||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
val cancelFail = {
|
||||||
dismiss()
|
queryingProtection = false
|
||||||
|
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||||
|
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||||
}
|
}
|
||||||
|
|
||||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import info.nightscout.androidaps.utils.T
|
||||||
import info.nightscout.androidaps.utils.ToastUtils
|
import info.nightscout.androidaps.utils.ToastUtils
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||||
|
@ -57,14 +58,12 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var ctx: Context
|
@Inject lateinit var ctx: Context
|
||||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||||
|
|
||||||
|
private var queryingProtection = false
|
||||||
private var profileIndex: Int? = null
|
private var profileIndex: Int? = null
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
private var _binding: DialogProfileswitchBinding? = null
|
private var _binding: DialogProfileswitchBinding? = null
|
||||||
|
|
||||||
// This property is only valid between onCreateView and
|
// This property is only valid between onCreateView and onDestroyView.
|
||||||
// onDestroyView.
|
|
||||||
private val binding get() = _binding!!
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
private val textWatcher: TextWatcher = object : TextWatcher {
|
private val textWatcher: TextWatcher = object : TextWatcher {
|
||||||
|
@ -253,14 +252,17 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
activity?.let { activity ->
|
if(!queryingProtection) {
|
||||||
val cancelFail = {
|
queryingProtection = true
|
||||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
activity?.let { activity ->
|
||||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
val cancelFail = {
|
||||||
dismiss()
|
queryingProtection = false
|
||||||
|
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||||
|
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||||
}
|
}
|
||||||
|
|
||||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.extensions.formatColor
|
import info.nightscout.androidaps.extensions.formatColor
|
||||||
import info.nightscout.androidaps.utils.ToastUtils
|
import info.nightscout.androidaps.utils.ToastUtils
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.shared.logging.LTag
|
import info.nightscout.shared.logging.LTag
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
|
@ -40,12 +41,11 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var uel: UserEntryLogger
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||||
|
|
||||||
|
private var queryingProtection = false
|
||||||
private var isPercentPump = true
|
private var isPercentPump = true
|
||||||
|
|
||||||
private var _binding: DialogTempbasalBinding? = null
|
private var _binding: DialogTempbasalBinding? = null
|
||||||
|
|
||||||
// This property is only valid between onCreateView and
|
// This property is only valid between onCreateView and onDestroyView.
|
||||||
// onDestroyView.
|
|
||||||
private val binding get() = _binding!!
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
||||||
|
@ -55,8 +55,7 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
||||||
savedInstanceState.putDouble("basalAbsoluteInput", binding.basalAbsoluteInput.value)
|
savedInstanceState.putDouble("basalAbsoluteInput", binding.basalAbsoluteInput.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
savedInstanceState: Bundle?): View {
|
|
||||||
onCreateViewGeneral()
|
onCreateViewGeneral()
|
||||||
_binding = DialogTempbasalBinding.inflate(inflater, container, false)
|
_binding = DialogTempbasalBinding.inflate(inflater, container, false)
|
||||||
return binding.root
|
return binding.root
|
||||||
|
@ -148,14 +147,17 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
activity?.let { activity ->
|
if(!queryingProtection) {
|
||||||
val cancelFail = {
|
queryingProtection = true
|
||||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
activity?.let { activity ->
|
||||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
val cancelFail = {
|
||||||
dismiss()
|
queryingProtection = false
|
||||||
|
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||||
|
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||||
}
|
}
|
||||||
|
|
||||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import info.nightscout.androidaps.utils.HtmlHelper
|
||||||
import info.nightscout.androidaps.utils.ToastUtils
|
import info.nightscout.androidaps.utils.ToastUtils
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||||
|
@ -51,12 +52,11 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
private lateinit var reasonList: List<String>
|
private lateinit var reasonList: List<String>
|
||||||
|
|
||||||
|
private var queryingProtection = false
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
private var _binding: DialogTemptargetBinding? = null
|
private var _binding: DialogTemptargetBinding? = null
|
||||||
|
|
||||||
// This property is only valid between onCreateView and
|
// This property is only valid between onCreateView and onDestroyView.
|
||||||
// onDestroyView.
|
|
||||||
private val binding get() = _binding!!
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
||||||
|
@ -65,8 +65,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
||||||
savedInstanceState.putDouble("tempTarget", binding.temptarget.value)
|
savedInstanceState.putDouble("tempTarget", binding.temptarget.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
savedInstanceState: Bundle?): View {
|
|
||||||
onCreateViewGeneral()
|
onCreateViewGeneral()
|
||||||
_binding = DialogTemptargetBinding.inflate(inflater, container, false)
|
_binding = DialogTemptargetBinding.inflate(inflater, container, false)
|
||||||
return binding.root
|
return binding.root
|
||||||
|
@ -225,14 +224,17 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
activity?.let { activity ->
|
if(!queryingProtection) {
|
||||||
val cancelFail = {
|
queryingProtection = true
|
||||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
activity?.let { activity ->
|
||||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
val cancelFail = {
|
||||||
dismiss()
|
queryingProtection = false
|
||||||
|
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||||
|
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||||
}
|
}
|
||||||
|
|
||||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import info.nightscout.androidaps.utils.ToastUtils
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.extensions.formatColor
|
import info.nightscout.androidaps.extensions.formatColor
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||||
|
@ -51,7 +52,12 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||||
|
|
||||||
|
private var queryingProtection = false
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
private var _binding: DialogTreatmentBinding? = null
|
||||||
|
|
||||||
|
// This property is only valid between onCreateView and onDestroyView.
|
||||||
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
private val textWatcher: TextWatcher = object : TextWatcher {
|
private val textWatcher: TextWatcher = object : TextWatcher {
|
||||||
override fun afterTextChanged(s: Editable) {}
|
override fun afterTextChanged(s: Editable) {}
|
||||||
|
@ -74,12 +80,6 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var _binding: DialogTreatmentBinding? = null
|
|
||||||
|
|
||||||
// This property is only valid between onCreateView and
|
|
||||||
// onDestroyView.
|
|
||||||
private val binding get() = _binding!!
|
|
||||||
|
|
||||||
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
||||||
super.onSaveInstanceState(savedInstanceState)
|
super.onSaveInstanceState(savedInstanceState)
|
||||||
savedInstanceState.putDouble("carbs", binding.carbs.value)
|
savedInstanceState.putDouble("carbs", binding.carbs.value)
|
||||||
|
@ -206,14 +206,17 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
activity?.let { activity ->
|
if(!queryingProtection) {
|
||||||
val cancelFail = {
|
queryingProtection = true
|
||||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
activity?.let { activity ->
|
||||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
val cancelFail = {
|
||||||
dismiss()
|
queryingProtection = false
|
||||||
|
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||||
|
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||||
}
|
}
|
||||||
|
|
||||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.utils.*
|
import info.nightscout.androidaps.utils.*
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.wizard.BolusWizard
|
import info.nightscout.androidaps.utils.wizard.BolusWizard
|
||||||
|
@ -62,15 +63,20 @@ class WizardDialog : DaggerDialogFragment() {
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||||
|
|
||||||
|
private var queryingProtection = false
|
||||||
private var wizard: BolusWizard? = null
|
private var wizard: BolusWizard? = null
|
||||||
private var calculatedPercentage = 100.0
|
private var calculatedPercentage = 100.0
|
||||||
private var calculatedCorrection = 0.0
|
private var calculatedCorrection = 0.0
|
||||||
private var correctionPercent = false
|
private var correctionPercent = false
|
||||||
private var carbsPassedIntoWizard = 0.0
|
private var carbsPassedIntoWizard = 0.0
|
||||||
private var notesPassedIntoWizard = ""
|
private var notesPassedIntoWizard = ""
|
||||||
|
private var okClicked: Boolean = false // one shot guards
|
||||||
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
private var bolusStep = 0.0
|
||||||
|
private var _binding: DialogWizardBinding? = null
|
||||||
|
|
||||||
//one shot guards
|
// This property is only valid between onCreateView and onDestroyView.
|
||||||
private var okClicked: Boolean = false
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
private val textWatcher = object : TextWatcher {
|
private val textWatcher = object : TextWatcher {
|
||||||
override fun afterTextChanged(s: Editable) {}
|
override fun afterTextChanged(s: Editable) {}
|
||||||
|
@ -89,15 +95,6 @@ class WizardDialog : DaggerDialogFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
|
||||||
private var bolusStep = 0.0
|
|
||||||
|
|
||||||
private var _binding: DialogWizardBinding? = null
|
|
||||||
|
|
||||||
// This property is only valid between onCreateView and
|
|
||||||
// onDestroyView.
|
|
||||||
private val binding get() = _binding!!
|
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
dialog?.window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
dialog?.window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||||
|
@ -498,14 +495,17 @@ class WizardDialog : DaggerDialogFragment() {
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
activity?.let { activity ->
|
if(!queryingProtection) {
|
||||||
val cancelFail = {
|
queryingProtection = true
|
||||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
activity?.let { activity ->
|
||||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
val cancelFail = {
|
||||||
dismiss()
|
queryingProtection = false
|
||||||
|
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||||
|
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||||
}
|
}
|
||||||
|
|
||||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -990,5 +990,5 @@
|
||||||
<string name="show_loop">Zobrazit smyčku</string>
|
<string name="show_loop">Zobrazit smyčku</string>
|
||||||
<string name="count_selected">Vybráno: %1$d</string>
|
<string name="count_selected">Vybráno: %1$d</string>
|
||||||
<string name="sort_label">Seřadit</string>
|
<string name="sort_label">Seřadit</string>
|
||||||
<string name="dialog_cancled">Dialog zrušen</string>
|
<string name="dialog_canceled">Dialog zrušen</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -990,5 +990,5 @@
|
||||||
<string name="show_loop">Mostrar lazo</string>
|
<string name="show_loop">Mostrar lazo</string>
|
||||||
<string name="count_selected">%1$d selecionado</string>
|
<string name="count_selected">%1$d selecionado</string>
|
||||||
<string name="sort_label">Ordenar</string>
|
<string name="sort_label">Ordenar</string>
|
||||||
<string name="dialog_cancled">Diálogo cancelado</string>
|
<string name="dialog_canceled">Diálogo cancelado</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -961,5 +961,5 @@
|
||||||
<string name="show_loop">הצג לולאה</string>
|
<string name="show_loop">הצג לולאה</string>
|
||||||
<string name="count_selected">%1$d נבחרו</string>
|
<string name="count_selected">%1$d נבחרו</string>
|
||||||
<string name="sort_label">מיין</string>
|
<string name="sort_label">מיין</string>
|
||||||
<string name="dialog_cancled">דו-שיח בוטל</string>
|
<string name="dialog_canceled">דו-שיח בוטל</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -990,5 +990,5 @@
|
||||||
<string name="show_loop">Vis loop</string>
|
<string name="show_loop">Vis loop</string>
|
||||||
<string name="count_selected">%1$d valgt</string>
|
<string name="count_selected">%1$d valgt</string>
|
||||||
<string name="sort_label">Sorter</string>
|
<string name="sort_label">Sorter</string>
|
||||||
<string name="dialog_cancled">Dialogvindu avbrutt</string>
|
<string name="dialog_canceled">Dialogvindu avbrutt</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -991,5 +991,5 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d
|
||||||
<string name="show_loop">Döngüyü göster</string>
|
<string name="show_loop">Döngüyü göster</string>
|
||||||
<string name="count_selected">%1$d seçildi</string>
|
<string name="count_selected">%1$d seçildi</string>
|
||||||
<string name="sort_label">Sırala</string>
|
<string name="sort_label">Sırala</string>
|
||||||
<string name="dialog_cancled">İletişim kutusu iptal edildi</string>
|
<string name="dialog_canceled">İletişim kutusu iptal edildi</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -990,5 +990,5 @@
|
||||||
<string name="show_loop">显示闭环</string>
|
<string name="show_loop">显示闭环</string>
|
||||||
<string name="count_selected">已选中 %1$d</string>
|
<string name="count_selected">已选中 %1$d</string>
|
||||||
<string name="sort_label">排序</string>
|
<string name="sort_label">排序</string>
|
||||||
<string name="dialog_cancled">对话框已取消</string>
|
<string name="dialog_canceled">对话框已取消</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1236,7 +1236,7 @@
|
||||||
<string name="show_loop">Show loop</string>
|
<string name="show_loop">Show loop</string>
|
||||||
<string name="count_selected">%1$d selected</string>
|
<string name="count_selected">%1$d selected</string>
|
||||||
<string name="sort_label">Sort</string>
|
<string name="sort_label">Sort</string>
|
||||||
<string name="dialog_cancled">Dialog canceled</string>
|
<string name="dialog_canceled">Dialog canceled</string>
|
||||||
<string name="below">Below</string>
|
<string name="below">Below</string>
|
||||||
<string name="in_range">In range</string>
|
<string name="in_range">In range</string>
|
||||||
<string name="above">Above</string>
|
<string name="above">Above</string>
|
||||||
|
|
Loading…
Add table
Reference in a new issue