feat: request protection on resume dialog
This commit is contained in:
parent
542aba6ea3
commit
4a3a264bd7
12 changed files with 170 additions and 5 deletions
|
@ -27,6 +27,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProv
|
|||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.utils.*
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
|
@ -50,6 +51,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
|||
@Inject lateinit var bolusTimer: BolusTimer
|
||||
@Inject lateinit var commandQueue: CommandQueue
|
||||
@Inject lateinit var repository: AppRepository
|
||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||
|
||||
companion object {
|
||||
|
||||
|
@ -377,4 +379,17 @@ class CarbsDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activity?.let { activity ->
|
||||
val cancelFail = {
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,10 @@ import info.nightscout.androidaps.utils.HtmlHelper
|
|||
import info.nightscout.shared.SafeParse
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.extensions.formatColor
|
||||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.shared.logging.LTag
|
||||
import java.text.DecimalFormat
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
@ -36,6 +39,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
|
|||
@Inject lateinit var commandQueue: CommandQueue
|
||||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
@Inject lateinit var uel: UserEntryLogger
|
||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||
|
||||
private var _binding: DialogExtendedbolusBinding? = null
|
||||
|
||||
|
@ -106,4 +110,17 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activity?.let { activity ->
|
||||
val cancelFail = {
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ import info.nightscout.androidaps.utils.HtmlHelper
|
|||
import info.nightscout.shared.SafeParse
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.extensions.formatColor
|
||||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
|
@ -44,6 +46,7 @@ class FillDialog : DialogFragmentWithDate() {
|
|||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
@Inject lateinit var uel: UserEntryLogger
|
||||
@Inject lateinit var repository: AppRepository
|
||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||
|
||||
private val disposable = CompositeDisposable()
|
||||
|
||||
|
@ -196,4 +199,17 @@ class FillDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activity?.let { activity ->
|
||||
val cancelFail = {
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import info.nightscout.androidaps.queue.Callback
|
|||
import info.nightscout.androidaps.utils.*
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.utils.extensions.toSignedString
|
||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.shared.SafeParse
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
|
@ -52,6 +53,7 @@ class InsulinDialog : DialogFragmentWithDate() {
|
|||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var bolusTimer: BolusTimer
|
||||
@Inject lateinit var uel: UserEntryLogger
|
||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||
|
||||
companion object {
|
||||
|
||||
|
@ -255,4 +257,17 @@ class InsulinDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activity?.let { activity ->
|
||||
val cancelFail = {
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
|||
import info.nightscout.androidaps.utils.T
|
||||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
|
@ -62,6 +63,7 @@ class LoopDialog : DaggerDialogFragment() {
|
|||
@Inject lateinit var dateUtil: DateUtil
|
||||
@Inject lateinit var repository: AppRepository
|
||||
@Inject lateinit var objectivePlugin: ObjectivesPlugin
|
||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||
|
||||
private var showOkCancel: Boolean = true
|
||||
private var _binding: DialogLoopBinding? = null
|
||||
|
@ -437,4 +439,17 @@ class LoopDialog : DaggerDialogFragment() {
|
|||
aapsLogger.debug(e.localizedMessage ?: e.toString())
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activity?.let { activity ->
|
||||
val cancelFail = {
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package info.nightscout.androidaps.dialogs
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
|
@ -30,7 +31,9 @@ import info.nightscout.androidaps.utils.DefaultValueHelper
|
|||
import info.nightscout.androidaps.utils.HardLimits
|
||||
import info.nightscout.androidaps.utils.HtmlHelper
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
|
@ -51,6 +54,8 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
|
|||
@Inject lateinit var hardLimits: HardLimits
|
||||
@Inject lateinit var rxBus: RxBus
|
||||
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
||||
@Inject lateinit var ctx: Context
|
||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||
|
||||
private var profileIndex: Int? = null
|
||||
|
||||
|
@ -245,4 +250,17 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activity?.let { activity ->
|
||||
val cancelFail = {
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,10 @@ import info.nightscout.androidaps.utils.HtmlHelper
|
|||
import info.nightscout.shared.SafeParse
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.extensions.formatColor
|
||||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.shared.logging.LTag
|
||||
import java.text.DecimalFormat
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
@ -35,6 +38,7 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
|||
@Inject lateinit var commandQueue: CommandQueue
|
||||
@Inject lateinit var ctx: Context
|
||||
@Inject lateinit var uel: UserEntryLogger
|
||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||
|
||||
private var isPercentPump = true
|
||||
|
||||
|
@ -141,4 +145,17 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activity?.let { activity ->
|
||||
val cancelFail = {
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package info.nightscout.androidaps.dialogs
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
|
@ -26,7 +27,9 @@ import info.nightscout.androidaps.logging.UserEntryLogger
|
|||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||
import info.nightscout.androidaps.utils.HtmlHelper
|
||||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
|
@ -43,6 +46,8 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
|||
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
||||
@Inject lateinit var uel: UserEntryLogger
|
||||
@Inject lateinit var repository: AppRepository
|
||||
@Inject lateinit var ctx: Context
|
||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||
|
||||
private lateinit var reasonList: List<String>
|
||||
|
||||
|
@ -218,4 +223,17 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activity?.let { activity ->
|
||||
val cancelFail = {
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import info.nightscout.shared.SafeParse
|
|||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.extensions.formatColor
|
||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
|
@ -48,6 +49,7 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
|||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var uel: UserEntryLogger
|
||||
@Inject lateinit var repository: AppRepository
|
||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||
|
||||
private val disposable = CompositeDisposable()
|
||||
|
||||
|
@ -201,4 +203,17 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activity?.let { activity ->
|
||||
val cancelFail = {
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import info.nightscout.androidaps.extensions.toVisibility
|
|||
import info.nightscout.androidaps.extensions.valueToUnits
|
||||
import info.nightscout.androidaps.interfaces.*
|
||||
import info.nightscout.androidaps.utils.*
|
||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
|
@ -55,6 +56,7 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
@Inject lateinit var iobCobCalculator: IobCobCalculator
|
||||
@Inject lateinit var repository: AppRepository
|
||||
@Inject lateinit var dateUtil: DateUtil
|
||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||
|
||||
private var wizard: BolusWizard? = null
|
||||
private var calculatedPercentage = 100.0
|
||||
|
@ -497,4 +499,17 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
aapsLogger.debug(e.localizedMessage ?: "")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activity?.let { activity ->
|
||||
val cancelFail = {
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_cancled)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, {}, cancelFail, fail = cancelFail)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1224,4 +1224,5 @@
|
|||
<string name="show_loop">Show loop</string>
|
||||
<string name="count_selected">%1$d selected</string>
|
||||
<string name="sort_label">Sort</string>
|
||||
<string name="dialog_cancled">Dialog canceled</string>
|
||||
</resources>
|
||||
|
|
|
@ -58,6 +58,9 @@ class ProtectionCheck @Inject constructor(
|
|||
R.string.bolus_pin)
|
||||
|
||||
fun isLocked(protection: Protection): Boolean {
|
||||
if (activeSession(protection)) {
|
||||
return false
|
||||
}
|
||||
return when (ProtectionType.values()[sp.getInt(protectionTypeResourceIDs[protection.ordinal], ProtectionType.NONE.ordinal)]) {
|
||||
ProtectionType.NONE -> false
|
||||
ProtectionType.BIOMETRIC -> true
|
||||
|
|
Loading…
Reference in a new issue