Merge pull request #1492 from Andries-Smit/feat/protection-request-in-menu
Feat: protection request in menu
This commit is contained in:
commit
78b58091cf
20 changed files with 243 additions and 185 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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,23 +10,26 @@ import android.widget.*
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import dagger.android.support.DaggerFragment
|
import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.interfaces.Config
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.PreferencesActivity
|
import info.nightscout.androidaps.activities.PreferencesActivity
|
||||||
|
import info.nightscout.androidaps.activities.SingleFragmentActivity
|
||||||
import info.nightscout.androidaps.databinding.ConfigbuilderFragmentBinding
|
import info.nightscout.androidaps.databinding.ConfigbuilderFragmentBinding
|
||||||
import info.nightscout.androidaps.events.EventRebuildTabs
|
import info.nightscout.androidaps.events.EventRebuildTabs
|
||||||
import info.nightscout.androidaps.interfaces.*
|
import info.nightscout.androidaps.extensions.toVisibility
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
|
import info.nightscout.androidaps.interfaces.Config
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.events.EventConfigBuilderUpdateGui
|
import info.nightscout.androidaps.plugins.configBuilder.events.EventConfigBuilderUpdateGui
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
|
||||||
import info.nightscout.androidaps.extensions.toVisibility
|
|
||||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.PREFERENCES
|
||||||
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 io.reactivex.rxjava3.disposables.CompositeDisposable
|
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
import java.util.*
|
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ConfigBuilderFragment : DaggerFragment() {
|
class ConfigBuilderFragment : DaggerFragment() {
|
||||||
|
@ -44,48 +47,36 @@ class ConfigBuilderFragment : DaggerFragment() {
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
private val pluginViewHolders = ArrayList<PluginViewHolder>()
|
private val pluginViewHolders = ArrayList<PluginViewHolder>()
|
||||||
|
private var inMenu = false
|
||||||
|
private var queryingProtection = false
|
||||||
private var _binding: ConfigbuilderFragmentBinding? = null
|
private var _binding: ConfigbuilderFragmentBinding? = 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 onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
savedInstanceState: Bundle?): View {
|
|
||||||
_binding = ConfigbuilderFragmentBinding.inflate(inflater, container, false)
|
_binding = ConfigbuilderFragmentBinding.inflate(inflater, container, false)
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
val parentClass = this.activity?.let { it::class.java }
|
||||||
if (protectionCheck.isLocked(ProtectionCheck.Protection.PREFERENCES))
|
inMenu = parentClass == SingleFragmentActivity::class.java
|
||||||
binding.mainLayout.visibility = View.GONE
|
updateProtectedUi()
|
||||||
else
|
binding.unlock.setOnClickListener { queryProtection() }
|
||||||
binding.unlock.visibility = View.GONE
|
|
||||||
|
|
||||||
binding.unlock.setOnClickListener {
|
|
||||||
activity?.let { activity ->
|
|
||||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.PREFERENCES, {
|
|
||||||
activity.runOnUiThread {
|
|
||||||
binding.mainLayout.visibility = View.VISIBLE
|
|
||||||
binding.unlock.visibility = View.GONE
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
if (inMenu) queryProtection() else updateProtectedUi()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventConfigBuilderUpdateGui::class.java)
|
.toObservable(EventConfigBuilderUpdateGui::class.java)
|
||||||
.observeOn(aapsSchedulers.main)
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
for (pluginViewHolder in pluginViewHolders) pluginViewHolder.update()
|
for (pluginViewHolder in pluginViewHolders) pluginViewHolder.update()
|
||||||
}, fabricPrivacy::logException)
|
}, fabricPrivacy::logException)
|
||||||
updateGUI()
|
updateGUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,4 +206,21 @@ class ConfigBuilderFragment : DaggerFragment() {
|
||||||
return type == PluginType.GENERAL || type == PluginType.CONSTRAINTS || type == PluginType.LOOP
|
return type == PluginType.GENERAL || type == PluginType.CONSTRAINTS || type == PluginType.LOOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateProtectedUi() {
|
||||||
|
val isLocked = protectionCheck.isLocked(PREFERENCES)
|
||||||
|
binding.mainLayout.visibility = isLocked.not().toVisibility()
|
||||||
|
binding.unlock.visibility = isLocked.toVisibility()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun queryProtection() {
|
||||||
|
val isLocked = protectionCheck.isLocked(PREFERENCES)
|
||||||
|
if (isLocked && !queryingProtection) {
|
||||||
|
activity?.let { activity ->
|
||||||
|
queryingProtection = true
|
||||||
|
val doUpdate = { activity.runOnUiThread { queryingProtection = false; updateProtectedUi() } }
|
||||||
|
protectionCheck.queryProtection(activity, PREFERENCES, doUpdate, doUpdate, doUpdate)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import dagger.android.support.DaggerFragment
|
import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.activities.SingleFragmentActivity
|
||||||
import info.nightscout.androidaps.dana.database.DanaHistoryDatabase
|
import info.nightscout.androidaps.dana.database.DanaHistoryDatabase
|
||||||
import info.nightscout.androidaps.database.AppRepository
|
import info.nightscout.androidaps.database.AppRepository
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
||||||
|
@ -14,6 +15,7 @@ import info.nightscout.androidaps.database.entities.UserEntry.Sources
|
||||||
import info.nightscout.androidaps.databinding.MaintenanceFragmentBinding
|
import info.nightscout.androidaps.databinding.MaintenanceFragmentBinding
|
||||||
import info.nightscout.androidaps.diaconn.database.DiaconnHistoryDatabase
|
import info.nightscout.androidaps.diaconn.database.DiaconnHistoryDatabase
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange
|
import info.nightscout.androidaps.events.EventPreferenceChange
|
||||||
|
import info.nightscout.androidaps.extensions.toVisibility
|
||||||
import info.nightscout.androidaps.insight.database.InsightDatabase
|
import info.nightscout.androidaps.insight.database.InsightDatabase
|
||||||
import info.nightscout.androidaps.interfaces.DataSyncSelector
|
import info.nightscout.androidaps.interfaces.DataSyncSelector
|
||||||
import info.nightscout.androidaps.interfaces.ImportExportPrefs
|
import info.nightscout.androidaps.interfaces.ImportExportPrefs
|
||||||
|
@ -28,6 +30,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.Das
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryDatabase
|
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryDatabase
|
||||||
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.PREFERENCES
|
||||||
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 io.reactivex.rxjava3.core.Completable.fromAction
|
import io.reactivex.rxjava3.core.Completable.fromAction
|
||||||
|
@ -57,11 +60,11 @@ class MaintenanceFragment : DaggerFragment() {
|
||||||
@Inject lateinit var overviewData: OverviewData
|
@Inject lateinit var overviewData: OverviewData
|
||||||
|
|
||||||
private val compositeDisposable = CompositeDisposable()
|
private val compositeDisposable = CompositeDisposable()
|
||||||
|
private var inMenu = false
|
||||||
|
private var queryingProtection = false
|
||||||
private var _binding: MaintenanceFragmentBinding? = null
|
private var _binding: MaintenanceFragmentBinding? = 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 onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
|
@ -71,6 +74,9 @@ class MaintenanceFragment : DaggerFragment() {
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
val parentClass = this.activity?.let { it::class.java }
|
||||||
|
inMenu = parentClass == SingleFragmentActivity::class.java
|
||||||
|
updateProtectedUi()
|
||||||
binding.logSend.setOnClickListener { maintenancePlugin.sendLogs() }
|
binding.logSend.setOnClickListener { maintenancePlugin.sendLogs() }
|
||||||
binding.logDelete.setOnClickListener {
|
binding.logDelete.setOnClickListener {
|
||||||
uel.log(Action.DELETE_LOGS, Sources.Maintenance)
|
uel.log(Action.DELETE_LOGS, Sources.Maintenance)
|
||||||
|
@ -131,22 +137,12 @@ class MaintenanceFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (protectionCheck.isLocked(ProtectionCheck.Protection.PREFERENCES)) {
|
binding.unlock.setOnClickListener { queryProtection() }
|
||||||
binding.mainLayout.visibility = View.GONE
|
}
|
||||||
} else {
|
|
||||||
binding.unlock.visibility = View.GONE
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.unlock.setOnClickListener {
|
override fun onResume() {
|
||||||
activity?.let { activity ->
|
super.onResume()
|
||||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.PREFERENCES, {
|
if (inMenu) queryProtection() else updateProtectedUi()
|
||||||
activity.runOnUiThread {
|
|
||||||
binding.mainLayout.visibility = View.VISIBLE
|
|
||||||
binding.unlock.visibility = View.GONE
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
|
@ -155,4 +151,21 @@ class MaintenanceFragment : DaggerFragment() {
|
||||||
compositeDisposable.clear()
|
compositeDisposable.clear()
|
||||||
_binding = null
|
_binding = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateProtectedUi() {
|
||||||
|
val isLocked = protectionCheck.isLocked(PREFERENCES)
|
||||||
|
binding.mainLayout.visibility = isLocked.not().toVisibility()
|
||||||
|
binding.unlock.visibility = isLocked.toVisibility()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun queryProtection() {
|
||||||
|
val isLocked = protectionCheck.isLocked(PREFERENCES)
|
||||||
|
if (isLocked && !queryingProtection) {
|
||||||
|
activity?.let { activity ->
|
||||||
|
queryingProtection = true
|
||||||
|
val doUpdate = { activity.runOnUiThread { queryingProtection = false; updateProtectedUi() } }
|
||||||
|
protectionCheck.queryProtection(activity, PREFERENCES, doUpdate, doUpdate, doUpdate)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -12,12 +12,14 @@ import android.widget.ArrayAdapter
|
||||||
import dagger.android.support.DaggerFragment
|
import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.activities.SingleFragmentActivity
|
||||||
import info.nightscout.androidaps.data.ProfileSealed
|
import info.nightscout.androidaps.data.ProfileSealed
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Sources
|
import info.nightscout.androidaps.database.entities.UserEntry.Sources
|
||||||
import info.nightscout.androidaps.database.entities.ValueWithUnit
|
import info.nightscout.androidaps.database.entities.ValueWithUnit
|
||||||
import info.nightscout.androidaps.databinding.LocalprofileFragmentBinding
|
import info.nightscout.androidaps.databinding.LocalprofileFragmentBinding
|
||||||
import info.nightscout.androidaps.dialogs.ProfileSwitchDialog
|
import info.nightscout.androidaps.dialogs.ProfileSwitchDialog
|
||||||
|
import info.nightscout.androidaps.extensions.toVisibility
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.androidaps.interfaces.GlucoseUnit
|
import info.nightscout.androidaps.interfaces.GlucoseUnit
|
||||||
import info.nightscout.androidaps.interfaces.Profile
|
import info.nightscout.androidaps.interfaces.Profile
|
||||||
|
@ -56,7 +58,8 @@ class LocalProfileFragment : DaggerFragment() {
|
||||||
@Inject lateinit var uel: UserEntryLogger
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
private var inMenu = false
|
||||||
|
private var queryingProtection = false
|
||||||
private var basalView: TimeListEdit? = null
|
private var basalView: TimeListEdit? = null
|
||||||
|
|
||||||
private val save = Runnable {
|
private val save = Runnable {
|
||||||
|
@ -99,6 +102,9 @@ class LocalProfileFragment : DaggerFragment() {
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
val parentClass = this.activity?.let { it::class.java }
|
||||||
|
inMenu = parentClass == SingleFragmentActivity::class.java
|
||||||
|
updateProtectedUi()
|
||||||
// activate DIA tab
|
// activate DIA tab
|
||||||
processVisibilityOnClick(binding.diaTab)
|
processVisibilityOnClick(binding.diaTab)
|
||||||
binding.diaPlaceholder.visibility = View.VISIBLE
|
binding.diaPlaceholder.visibility = View.VISIBLE
|
||||||
|
@ -125,22 +131,7 @@ class LocalProfileFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
binding.dia.editText?.id?.let { binding.diaLabel.labelFor = it }
|
binding.dia.editText?.id?.let { binding.diaLabel.labelFor = it }
|
||||||
|
|
||||||
if (protectionCheck.isLocked(ProtectionCheck.Protection.PREFERENCES)) {
|
binding.unlock.setOnClickListener { queryProtection() }
|
||||||
binding.mainLayout.visibility = View.GONE
|
|
||||||
} else {
|
|
||||||
binding.unlock.visibility = View.GONE
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.unlock.setOnClickListener {
|
|
||||||
activity?.let { activity ->
|
|
||||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.PREFERENCES, {
|
|
||||||
activity.runOnUiThread {
|
|
||||||
binding.mainLayout.visibility = View.VISIBLE
|
|
||||||
binding.unlock.visibility = View.GONE
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun build() {
|
fun build() {
|
||||||
|
@ -345,6 +336,7 @@ class LocalProfileFragment : DaggerFragment() {
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
if (inMenu) queryProtection() else updateProtectedUi()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventLocalProfileChanged::class.java)
|
.toObservable(EventLocalProfileChanged::class.java)
|
||||||
.observeOn(aapsSchedulers.main)
|
.observeOn(aapsSchedulers.main)
|
||||||
|
@ -421,4 +413,21 @@ class LocalProfileFragment : DaggerFragment() {
|
||||||
binding.basal.visibility = View.GONE
|
binding.basal.visibility = View.GONE
|
||||||
binding.target.visibility = View.GONE
|
binding.target.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateProtectedUi() {
|
||||||
|
val isLocked = protectionCheck.isLocked(ProtectionCheck.Protection.PREFERENCES)
|
||||||
|
binding.mainLayout.visibility = isLocked.not().toVisibility()
|
||||||
|
binding.unlock.visibility = isLocked.toVisibility()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun queryProtection() {
|
||||||
|
val isLocked = protectionCheck.isLocked(ProtectionCheck.Protection.PREFERENCES)
|
||||||
|
if (isLocked && !queryingProtection) {
|
||||||
|
activity?.let { activity ->
|
||||||
|
queryingProtection = true
|
||||||
|
val doUpdate = { activity.runOnUiThread { queryingProtection = false; updateProtectedUi() } }
|
||||||
|
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.PREFERENCES, doUpdate, doUpdate, doUpdate)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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…
Reference in a new issue