Log user actions
This commit is contained in:
parent
850e79a068
commit
a79393c65a
15 changed files with 47 additions and 3 deletions
|
@ -56,6 +56,7 @@ class CalibrationDialog : DialogFragmentWithDate() {
|
|||
if (bg > 0) {
|
||||
activity?.let { activity ->
|
||||
OKDialog.showConfirmation(activity, MainApp.gs(R.string.overview_calibration), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||
log.debug("USER ENTRY: CALIBRATION $bg")
|
||||
XdripCalibrations.confirmAndSendCalibration(bg, context)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -177,6 +177,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
|||
activity?.let { activity ->
|
||||
OKDialog.showConfirmation(activity, MainApp.gs(R.string.carbs), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||
if (activitySelected) {
|
||||
log.debug("USER ENTRY: TEMPTARGET ACTIVITY $activityTT duration: $activityTTDuration")
|
||||
val tempTarget = TempTarget()
|
||||
.date(eventTime)
|
||||
.duration(activityTTDuration)
|
||||
|
@ -186,6 +187,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
|||
.high(Profile.toMgdl(activityTT, ProfileFunctions.getSystemUnits()))
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget)
|
||||
} else if (eatingSoonSelected) {
|
||||
log.debug("USER ENTRY: TEMPTARGET EATING SOON $eatingSoonTT duration: $eatingSoonTTDuration")
|
||||
val tempTarget = TempTarget()
|
||||
.date(eventTime)
|
||||
.duration(eatingSoonTTDuration)
|
||||
|
@ -195,6 +197,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
|||
.high(Profile.toMgdl(eatingSoonTT, ProfileFunctions.getSystemUnits()))
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget)
|
||||
} else if (hypoSelected) {
|
||||
log.debug("USER ENTRY: TEMPTARGET HYPO $hypoTT duration: $hypoTTDuration")
|
||||
val tempTarget = TempTarget()
|
||||
.date(eventTime)
|
||||
.duration(hypoTTDuration)
|
||||
|
@ -206,8 +209,10 @@ class CarbsDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
if (carbsAfterConstraints > 0) {
|
||||
if (duration == 0) {
|
||||
log.debug("USER ENTRY: CARBS $carbsAfterConstraints time: $time")
|
||||
CarbsGenerator.createCarb(carbsAfterConstraints, time, CareportalEvent.CARBCORRECTION, notes)
|
||||
} else {
|
||||
log.debug("USER ENTRY: CARBS $carbsAfterConstraints time: $time duration: $duration")
|
||||
CarbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes)
|
||||
NSUpload.uploadEvent(CareportalEvent.NOTE, time - 2000, MainApp.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset))
|
||||
}
|
||||
|
|
|
@ -180,6 +180,7 @@ class CareDialog : DialogFragmentWithDate() {
|
|||
EventType.EXERCISE -> CareportalEvent.EXERCISE
|
||||
}
|
||||
careportalEvent.json = json.toString()
|
||||
log.debug("USER ENTRY: CAREPORTAL ${careportalEvent.eventType} json: ${careportalEvent.json}")
|
||||
MainApp.getDbHelper().createOrUpdate(careportalEvent)
|
||||
NSUpload.uploadCareportalEntryToNS(json)
|
||||
}, null)
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.slf4j.LoggerFactory
|
|||
import java.util.*
|
||||
|
||||
abstract class DialogFragmentWithDate : DialogFragment() {
|
||||
private val log = LoggerFactory.getLogger(DialogFragmentWithDate::class.java)
|
||||
val log = LoggerFactory.getLogger(DialogFragmentWithDate::class.java)
|
||||
|
||||
var eventTime = DateUtil.now()
|
||||
var eventTimeChanged = false
|
||||
|
|
|
@ -36,6 +36,7 @@ class ErrorDialog : DialogFragment() {
|
|||
bundle.getString("title")?.let { title = it }
|
||||
sound = bundle.getInt("sound", R.raw.error)
|
||||
}
|
||||
log.debug("Error dialog displayed")
|
||||
return inflater.inflate(R.layout.dialog_error, container, false)
|
||||
}
|
||||
|
||||
|
@ -44,11 +45,11 @@ class ErrorDialog : DialogFragment() {
|
|||
|
||||
error_title.text = title
|
||||
overview_error_ok.setOnClickListener {
|
||||
log.debug("Error dialog ok button pressed")
|
||||
log.debug("USER ENTRY: Error dialog ok button pressed")
|
||||
dismiss()
|
||||
}
|
||||
overview_error_mute.setOnClickListener {
|
||||
log.debug("Error dialog mute button pressed")
|
||||
log.debug("USER ENTRY: Error dialog mute button pressed")
|
||||
stopAlarm()
|
||||
}
|
||||
startAlarm()
|
||||
|
|
|
@ -63,6 +63,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
|
|||
|
||||
activity?.let { activity ->
|
||||
OKDialog.showConfirmation(activity, MainApp.gs(R.string.extended_bolus), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||
log.debug("USER ENTRY: EXTENDED BOLUS $insulinAfterConstraint duration: $durationInMinutes")
|
||||
ConfigBuilderPlugin.getPlugin().commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() {
|
||||
override fun run() {
|
||||
if (!result.success) {
|
||||
|
|
|
@ -102,13 +102,16 @@ class FillDialog : DialogFragmentWithDate() {
|
|||
activity?.let { activity ->
|
||||
OKDialog.showConfirmation(activity, MainApp.gs(R.string.primefill), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||
if (insulinAfterConstraints > 0) {
|
||||
log.debug("USER ENTRY: PRIME BOLUS $insulinAfterConstraints")
|
||||
requestPrimeBolus(insulinAfterConstraints, notes)
|
||||
}
|
||||
if (siteChange) {
|
||||
log.debug("USER ENTRY: SITE CHANGE")
|
||||
generateCareportalEvent(CareportalEvent.SITECHANGE, eventTime, notes)
|
||||
}
|
||||
if (insulinChange) {
|
||||
// add a second for case of both checked
|
||||
log.debug("USER ENTRY: INSULIN CHANGE")
|
||||
generateCareportalEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes)
|
||||
}
|
||||
}, null)
|
||||
|
|
|
@ -147,6 +147,7 @@ class InsulinDialog : DialogFragmentWithDate() {
|
|||
activity?.let { activity ->
|
||||
OKDialog.showConfirmation(activity, MainApp.gs(R.string.bolus), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||
if (eatingSoonChecked) {
|
||||
log.debug("USER ENTRY: TEMPTARGET EATING SOON $eatingSoonTT duration: $eatingSoonTTDuration")
|
||||
val tempTarget = TempTarget()
|
||||
.date(System.currentTimeMillis())
|
||||
.duration(eatingSoonTTDuration)
|
||||
|
@ -164,9 +165,11 @@ class InsulinDialog : DialogFragmentWithDate() {
|
|||
detailedBolusInfo.source = Source.USER
|
||||
detailedBolusInfo.notes = notes
|
||||
if (recordOnlyChecked) {
|
||||
log.debug("USER ENTRY: BOLUS RECORD ONLY $insulinAfterConstraints")
|
||||
detailedBolusInfo.date = time
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false)
|
||||
} else {
|
||||
log.debug("USER ENTRY: BOLUS $insulinAfterConstraints")
|
||||
detailedBolusInfo.date = DateUtil.now()
|
||||
ConfigBuilderPlugin.getPlugin().commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
||||
override fun run() {
|
||||
|
|
|
@ -97,6 +97,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
|
|||
|
||||
activity?.let { activity ->
|
||||
OKDialog.showConfirmation(activity, MainApp.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||
log.debug("USER ENTRY: PROFILE SWITCH $profile percent: $percent timeshift: $timeShift duration: $duration")
|
||||
ProfileFunctions.doProfileSwitch(profileStore, profile, duration.toInt(), percent, timeShift, eventTime)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -104,8 +104,10 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
}
|
||||
if (isPercentPump) {
|
||||
log.debug("USER ENTRY: TEMP BASAL $percent% duration: $durationInMinutes")
|
||||
ConfigBuilderPlugin.getPlugin().commandQueue.tempBasalPercent(percent, durationInMinutes, true, profile, callback)
|
||||
} else {
|
||||
log.debug("USER ENTRY: TEMP BASAL $absolute duration: $durationInMinutes")
|
||||
ConfigBuilderPlugin.getPlugin().commandQueue.tempBasalAbsolute(absolute, durationInMinutes, true, profile, callback)
|
||||
}
|
||||
})
|
||||
|
|
|
@ -127,6 +127,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
|||
|
||||
activity?.let { activity ->
|
||||
OKDialog.showConfirmation(activity, MainApp.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||
log.debug("USER ENTRY: TEMP TARGET $target duration: $duration")
|
||||
if (target == 0.0 || duration == 0.0) {
|
||||
val tempTarget = TempTarget()
|
||||
.date(eventTime)
|
||||
|
|
|
@ -99,6 +99,7 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
|||
if (insulinAfterConstraints > 0 || carbsAfterConstraints > 0) {
|
||||
activity?.let { activity ->
|
||||
OKDialog.showConfirmation(activity, MainApp.gs(R.string.overview_treatment_label), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||
log.debug("USER ENTRY: BOLUS insulin $insulin carbs: $carbs")
|
||||
val detailedBolusInfo = DetailedBolusInfo()
|
||||
if (insulinAfterConstraints == 0.0) detailedBolusInfo.eventType = CareportalEvent.CARBCORRECTION
|
||||
if (carbsAfterConstraints == 0) detailedBolusInfo.eventType = CareportalEvent.CORRECTIONBOLUS
|
||||
|
|
|
@ -27,6 +27,7 @@ import info.nightscout.androidaps.plugins.general.careportal.CareportalFragment
|
|||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||
import info.nightscout.androidaps.dialogs.ProfileSwitchDialog
|
||||
import info.nightscout.androidaps.dialogs.TempTargetDialog
|
||||
import info.nightscout.androidaps.logging.L
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.utils.*
|
||||
|
@ -34,9 +35,11 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
|||
import io.reactivex.disposables.CompositeDisposable
|
||||
import kotlinx.android.synthetic.main.actions_fragment.*
|
||||
import kotlinx.android.synthetic.main.careportal_stats_fragment.*
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.util.*
|
||||
|
||||
class ActionsFragment : Fragment() {
|
||||
private val log = LoggerFactory.getLogger(L.CORE)
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
|
@ -67,6 +70,7 @@ class ActionsFragment : Fragment() {
|
|||
}
|
||||
actions_extendedbolus_cancel.setOnClickListener {
|
||||
if (TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress) {
|
||||
log.debug("USER ENTRY: CANCEL EXTENDED BOLUS")
|
||||
ConfigBuilderPlugin.getPlugin().commandQueue.cancelExtended(object : Callback() {
|
||||
override fun run() {
|
||||
if (!result.success) {
|
||||
|
@ -86,6 +90,7 @@ class ActionsFragment : Fragment() {
|
|||
}
|
||||
actions_canceltempbasal.setOnClickListener {
|
||||
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress) {
|
||||
log.debug("USER ENTRY: CANCEL TEMP BASAL")
|
||||
ConfigBuilderPlugin.getPlugin().commandQueue.cancelTempBasal(true, object : Callback() {
|
||||
override fun run() {
|
||||
if (!result.success) {
|
||||
|
|
|
@ -667,6 +667,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
return true;
|
||||
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||
if (item.getTitle().equals(MainApp.gs(R.string.disableloop))) {
|
||||
log.debug("USER ENTRY: LOOP DISABLED");
|
||||
loopPlugin.setPluginEnabled(PluginType.LOOP, false);
|
||||
loopPlugin.setFragmentVisible(PluginType.LOOP, false);
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("DisablingLoop");
|
||||
|
@ -682,6 +683,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
LoopPlugin.getPlugin().createOfflineEvent(24 * 60); // upload 24h, we don't know real duration
|
||||
return true;
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.enableloop))) {
|
||||
log.debug("USER ENTRY: LOOP ENABLED");
|
||||
loopPlugin.setPluginEnabled(PluginType.LOOP, true);
|
||||
loopPlugin.setFragmentVisible(PluginType.LOOP, true);
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("EnablingLoop");
|
||||
|
@ -690,6 +692,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
return true;
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.resume)) ||
|
||||
item.getTitle().equals(MainApp.gs(R.string.reconnect))) {
|
||||
log.debug("USER ENTRY: RESUME");
|
||||
loopPlugin.suspendTo(0L);
|
||||
updateGUI("suspendmenu");
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
|
@ -704,39 +707,48 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
LoopPlugin.getPlugin().createOfflineEvent(0);
|
||||
return true;
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.suspendloopfor1h))) {
|
||||
log.debug("USER ENTRY: SUSPEND 1h");
|
||||
LoopPlugin.getPlugin().suspendLoop(60);
|
||||
updateGUI("suspendmenu");
|
||||
return true;
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.suspendloopfor2h))) {
|
||||
log.debug("USER ENTRY: SUSPEND 2h");
|
||||
LoopPlugin.getPlugin().suspendLoop(120);
|
||||
updateGUI("suspendmenu");
|
||||
return true;
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.suspendloopfor3h))) {
|
||||
log.debug("USER ENTRY: SUSPEND 3h");
|
||||
LoopPlugin.getPlugin().suspendLoop(180);
|
||||
updateGUI("suspendmenu");
|
||||
return true;
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.suspendloopfor10h))) {
|
||||
log.debug("USER ENTRY: SUSPEND 10h");
|
||||
LoopPlugin.getPlugin().suspendLoop(600);
|
||||
updateGUI("suspendmenu");
|
||||
return true;
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.disconnectpumpfor15m))) {
|
||||
log.debug("USER ENTRY: DISCONNECT 15m");
|
||||
LoopPlugin.getPlugin().disconnectPump(15, profile);
|
||||
updateGUI("suspendmenu");
|
||||
return true;
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.disconnectpumpfor30m))) {
|
||||
log.debug("USER ENTRY: DISCONNECT 30m");
|
||||
LoopPlugin.getPlugin().disconnectPump(30, profile);
|
||||
updateGUI("suspendmenu");
|
||||
return true;
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.disconnectpumpfor1h))) {
|
||||
log.debug("USER ENTRY: DISCONNECT 1h");
|
||||
LoopPlugin.getPlugin().disconnectPump(60, profile);
|
||||
SP.putBoolean(R.string.key_objectiveusedisconnect, true);
|
||||
updateGUI("suspendmenu");
|
||||
return true;
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.disconnectpumpfor2h))) {
|
||||
log.debug("USER ENTRY: DISCONNECT 2h");
|
||||
LoopPlugin.getPlugin().disconnectPump(120, profile);
|
||||
updateGUI("suspendmenu");
|
||||
return true;
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.disconnectpumpfor3h))) {
|
||||
log.debug("USER ENTRY: DISCONNECT 3h");
|
||||
LoopPlugin.getPlugin().disconnectPump(180, profile);
|
||||
updateGUI("suspendmenu");
|
||||
return true;
|
||||
|
@ -754,6 +766,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
if (manager != null)
|
||||
pvd.show(manager, "ProfileViewDialog");
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.eatingsoon))) {
|
||||
log.debug("USER ENTRY: TEMP TARGET EATING SOON");
|
||||
double target = Profile.toMgdl(DefaultValueHelper.determineEatingSoonTT(), ProfileFunctions.getSystemUnits());
|
||||
TempTarget tempTarget = new TempTarget()
|
||||
.date(System.currentTimeMillis())
|
||||
|
@ -764,6 +777,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
.high(target);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.activity))) {
|
||||
log.debug("USER ENTRY: TEMP TARGET ACTIVITY");
|
||||
double target = Profile.toMgdl(DefaultValueHelper.determineActivityTT(), ProfileFunctions.getSystemUnits());
|
||||
TempTarget tempTarget = new TempTarget()
|
||||
.date(now())
|
||||
|
@ -774,6 +788,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
.high(target);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.hypo))) {
|
||||
log.debug("USER ENTRY: TEMP TARGET HYPO");
|
||||
double target = Profile.toMgdl(DefaultValueHelper.determineHypoTT(), ProfileFunctions.getSystemUnits());
|
||||
TempTarget tempTarget = new TempTarget()
|
||||
.date(now())
|
||||
|
@ -788,6 +803,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
if (manager != null)
|
||||
new TempTargetDialog().show(manager, "Overview");
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.cancel))) {
|
||||
log.debug("USER ENTRY: TEMP TARGET CANCEL");
|
||||
TempTarget tempTarget = new TempTarget()
|
||||
.source(Source.USER)
|
||||
.date(now())
|
||||
|
@ -907,6 +923,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
|
||||
if (finalLastRun != null && finalLastRun.lastAPSRun != null && finalLastRun.constraintsProcessed.isChangeRequested()) {
|
||||
OKDialog.showConfirmation(context, MainApp.gs(R.string.pump_tempbasal_label), finalLastRun.constraintsProcessed.toSpanned(), () -> {
|
||||
log.debug("USER ENTRY: ACCEPT TEMP BASAL");
|
||||
hideTempRecommendation();
|
||||
clearNotification();
|
||||
LoopPlugin.getPlugin().acceptChangeRequest();
|
||||
|
|
|
@ -277,6 +277,7 @@ class BolusWizard @JvmOverloads constructor(val profile: Profile,
|
|||
OKDialog.showConfirmation(context, MainApp.gs(R.string.boluswizard), HtmlHelper.fromHtml(confirmMessage), Runnable {
|
||||
if (insulinAfterConstraints > 0 || carbs > 0) {
|
||||
if (useSuperBolus) {
|
||||
log.debug("USER ENTRY: SUPERBOLUS TBR")
|
||||
val loopPlugin = LoopPlugin.getPlugin()
|
||||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000)
|
||||
|
@ -325,6 +326,7 @@ class BolusWizard @JvmOverloads constructor(val profile: Profile,
|
|||
detailedBolusInfo.boluscalc = nsJSON()
|
||||
detailedBolusInfo.source = Source.USER
|
||||
detailedBolusInfo.notes = notes
|
||||
log.debug("USER ENTRY: BOLUS insulin $insulinAfterConstraints carbs: $carbs")
|
||||
if (detailedBolusInfo.insulin > 0 || ConfigBuilderPlugin.getPlugin().activePump?.pumpDescription?.storesCarbInfo == true) {
|
||||
ConfigBuilderPlugin.getPlugin().commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
||||
override fun run() {
|
||||
|
|
Loading…
Reference in a new issue