Add Treatments source
This commit is contained in:
parent
2bd2510bd8
commit
23c44b388b
|
@ -69,7 +69,7 @@ class TreatmentsBolusFragment : DaggerFragment() {
|
|||
binding.refreshFromNightscout.setOnClickListener {
|
||||
activity?.let { activity ->
|
||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.refresheventsfromnightscout) + "?") {
|
||||
uel.log(Action.TREATMENTS_NS_REFRESH)
|
||||
uel.log(Action.TREATMENTS_NS_REFRESH, ValueWithUnit(Sources.Treatments))
|
||||
treatmentsPlugin.service.resetTreatments()
|
||||
rxBus.send(EventNSClientRestart())
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class TreatmentsBolusFragment : DaggerFragment() {
|
|||
binding.deleteFutureTreatments.setOnClickListener {
|
||||
activity?.let { activity ->
|
||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), resourceHelper.gs(R.string.deletefuturetreatments) + "?", Runnable {
|
||||
uel.log(Action.DELETE_FUTURE_TREATMENTS)
|
||||
uel.log(Action.DELETE_FUTURE_TREATMENTS, ValueWithUnit(Sources.Treatments))
|
||||
val futureTreatments = treatmentsPlugin.service.getTreatmentDataFromTime(DateUtil.now() + 1000, true)
|
||||
for (treatment in futureTreatments) {
|
||||
if (NSUpload.isIdValid(treatment._id))
|
||||
|
@ -175,7 +175,7 @@ class TreatmentsBolusFragment : DaggerFragment() {
|
|||
resourceHelper.gs(R.string.carbs) + ": " + resourceHelper.gs(R.string.format_carbs, treatment.carbs.toInt()) + "\n" +
|
||||
resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(treatment.date)
|
||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
|
||||
uel.log(Action.TREATMENT_REMOVED, ValueWithUnit(treatment.date, Units.Timestamp), ValueWithUnit(treatment.insulin, Units.U, treatment.insulin != 0.0), ValueWithUnit(treatment.carbs.toInt(), Units.G, treatment.carbs != 0.0))
|
||||
uel.log(Action.TREATMENT_REMOVED, ValueWithUnit(Sources.Treatments), ValueWithUnit(treatment.date, Units.Timestamp), ValueWithUnit(treatment.insulin, Units.U, treatment.insulin != 0.0), ValueWithUnit(treatment.carbs.toInt(), Units.G, treatment.carbs != 0.0))
|
||||
if (treatment.source == Source.PUMP) {
|
||||
treatment.isValid = false
|
||||
treatmentsPlugin.service.update(treatment)
|
||||
|
|
|
@ -79,7 +79,7 @@ class TreatmentsCareportalFragment : DaggerFragment() {
|
|||
binding.refreshFromNightscout.setOnClickListener {
|
||||
activity?.let { activity ->
|
||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal), resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", Runnable {
|
||||
uel.log(Action.CAREPORTAL_NS_REFRESH)
|
||||
uel.log(Action.CAREPORTAL_NS_REFRESH, ValueWithUnit(Sources.Treatments))
|
||||
disposable += Completable.fromAction { repository.deleteAllTherapyEventsEntries() }
|
||||
.subscribeOn(aapsSchedulers.io)
|
||||
.observeOn(aapsSchedulers.main)
|
||||
|
@ -94,7 +94,7 @@ class TreatmentsCareportalFragment : DaggerFragment() {
|
|||
binding.removeAndroidapsStartedEvents.setOnClickListener {
|
||||
activity?.let { activity ->
|
||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal), resourceHelper.gs(R.string.careportal_removestartedevents), Runnable {
|
||||
uel.log(Action.RESTART_EVENTS_REMOVED)
|
||||
uel.log(Action.RESTART_EVENTS_REMOVED, ValueWithUnit(Sources.Treatments))
|
||||
// val events = databaseHelper.getCareportalEvents(false)
|
||||
repository.runTransactionForResult(InvalidateAAPSStartedTherapyEventTransaction())
|
||||
.subscribe({ result ->
|
||||
|
@ -196,7 +196,7 @@ class TreatmentsCareportalFragment : DaggerFragment() {
|
|||
resourceHelper.gs(R.string.notes_label) + ": " + (therapyEvent.note ?: "") + "\n" +
|
||||
resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(therapyEvent.timestamp)
|
||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
|
||||
uel.log(Action.CAREPORTAL_REMOVED, therapyEvent.note , ValueWithUnit(therapyEvent.timestamp, Units.Timestamp), ValueWithUnit(therapyEvent.type.text, Units.TherapyEvent))
|
||||
uel.log(Action.CAREPORTAL_REMOVED, therapyEvent.note, ValueWithUnit(Sources.Treatments), ValueWithUnit(therapyEvent.timestamp, Units.Timestamp), ValueWithUnit(therapyEvent.type.text, Units.TherapyEvent))
|
||||
disposable += repository.runTransactionForResult(InvalidateTherapyEventTransaction(therapyEvent.id))
|
||||
.subscribe({
|
||||
val id = therapyEvent.interfaceIDs.nightscoutId
|
||||
|
|
|
@ -123,7 +123,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() {
|
|||
${resourceHelper.gs(R.string.extended_bolus)}
|
||||
${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(extendedBolus.date)}
|
||||
""".trimIndent(), { _: DialogInterface, _: Int ->
|
||||
uel.log(Action.EXTENDED_BOLUS_REMOVED)
|
||||
uel.log(Action.EXTENDED_BOLUS_REMOVED, ValueWithUnit(Sources.Treatments))
|
||||
val id = extendedBolus._id
|
||||
if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id)
|
||||
else uploadQueue.removeByMongoId("dbAdd", id)
|
||||
|
|
|
@ -71,7 +71,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
|
|||
|
||||
binding.refreshFromNightscout.setOnClickListener {
|
||||
activity?.let { activity ->
|
||||
uel.log(Action.PROFILE_SWITCH_NS_REFRESH)
|
||||
uel.log(Action.PROFILE_SWITCH_NS_REFRESH, ValueWithUnit(Sources.Treatments))
|
||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.refresheventsfromnightscout) + "?") {
|
||||
databaseHelper.resetProfileSwitch()
|
||||
rxBus.send(EventNSClientRestart())
|
||||
|
@ -148,7 +148,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
|
|||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord),
|
||||
resourceHelper.gs(R.string.careportal_profileswitch) + ": " + profileSwitch.profileName +
|
||||
"\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(profileSwitch.date), Runnable {
|
||||
uel.log(Action.PROFILE_SWITCH_REMOVED, profileSwitch.profileName, ValueWithUnit(profileSwitch.date, Units.Timestamp))
|
||||
uel.log(Action.PROFILE_SWITCH_REMOVED, profileSwitch.profileName, ValueWithUnit(Sources.Treatments), ValueWithUnit(profileSwitch.date, Units.Timestamp))
|
||||
val id = profileSwitch._id
|
||||
if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id)
|
||||
else uploadQueue.removeByMongoId("dbAdd", id)
|
||||
|
@ -161,7 +161,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
|
|||
val profileSwitch = it.tag as ProfileSwitch
|
||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), resourceHelper.gs(R.string.copytolocalprofile) + "\n" + profileSwitch.customizedName + "\n" + dateUtil.dateAndTimeString(profileSwitch.date), Runnable {
|
||||
profileSwitch.profileObject?.let {
|
||||
uel.log(Action.PROFILE_SWITCH_CLONED, ValueWithUnit(profileSwitch.date, Units.Timestamp), ValueWithUnit(profileSwitch.profileName, Units.None))
|
||||
uel.log(Action.PROFILE_SWITCH_CLONED, ValueWithUnit(Sources.Treatments), ValueWithUnit(profileSwitch.date, Units.Timestamp), ValueWithUnit(profileSwitch.profileName, Units.None))
|
||||
val nonCustomized = it.convertToNonCustomizedProfile()
|
||||
if (nonCustomized.isValid(resourceHelper.gs(R.string.careportal_profileswitch, false))) {
|
||||
localProfilePlugin.addProfile(localProfilePlugin.copyFrom(nonCustomized, profileSwitch.customizedName + " " + dateUtil.dateAndTimeString(profileSwitch.date).replace(".", "_")))
|
||||
|
|
|
@ -86,7 +86,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() {
|
|||
binding.refreshFromNightscout.setOnClickListener {
|
||||
context?.let { context ->
|
||||
OKDialog.showConfirmation(context, resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", {
|
||||
uel.log(Action.TT_NS_REFRESH)
|
||||
uel.log(Action.TT_NS_REFRESH, ValueWithUnit(Sources.Treatments))
|
||||
disposable += Completable.fromAction { repository.deleteAllTempTargetEntries() }
|
||||
.subscribeOn(aapsSchedulers.io)
|
||||
.observeOn(aapsSchedulers.main)
|
||||
|
@ -196,7 +196,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() {
|
|||
${dateUtil.dateAndTimeString(tempTarget.timestamp)}
|
||||
""".trimIndent(),
|
||||
{ _: DialogInterface?, _: Int ->
|
||||
uel.log(Action.TT_REMOVED, ValueWithUnit(tempTarget.timestamp, Units.Timestamp), ValueWithUnit(tempTarget.reason.text, Units.TherapyEvent), ValueWithUnit(tempTarget.lowTarget, Units.Mg_Dl), ValueWithUnit(tempTarget.highTarget, Units.Mg_Dl, tempTarget.lowTarget != tempTarget.highTarget), ValueWithUnit(tempTarget.duration.toInt(), Units.M))
|
||||
uel.log(Action.TT_REMOVED, ValueWithUnit(Sources.Treatments), ValueWithUnit(tempTarget.timestamp, Units.Timestamp), ValueWithUnit(tempTarget.reason.text, Units.TherapyEvent), ValueWithUnit(tempTarget.lowTarget, Units.Mg_Dl), ValueWithUnit(tempTarget.highTarget, Units.Mg_Dl, tempTarget.lowTarget != tempTarget.highTarget), ValueWithUnit(tempTarget.duration.toInt(), Units.M))
|
||||
disposable += repository.runTransactionForResult(InvalidateTemporaryTargetTransaction(tempTarget.id))
|
||||
.subscribe({
|
||||
val id = tempTarget.interfaceIDs.nightscoutId
|
||||
|
|
|
@ -164,7 +164,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() {
|
|||
${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(tempBasal.date)}
|
||||
""".trimIndent(),
|
||||
{ _: DialogInterface?, _: Int ->
|
||||
uel.log(Action.TT_REMOVED, ValueWithUnit(tempBasal.date, Units.Timestamp))
|
||||
uel.log(Action.TT_REMOVED, ValueWithUnit(Sources.Treatments), ValueWithUnit(tempBasal.date, Units.Timestamp))
|
||||
activePlugin.activeTreatments.removeTempBasal(tempBasal)
|
||||
}, null)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.treatments.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.renderscript.Sampler
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -63,7 +64,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
|
|||
binding.ueExportToXml.setOnClickListener {
|
||||
activity?.let { activity ->
|
||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.ue_export_to_csv) + "?") {
|
||||
uel.log(Action.EXPORT_CSV)
|
||||
uel.log(Action.EXPORT_CSV, ValueWithUnit(Sources.Treatments))
|
||||
importExportPrefs.exportUserEntriesCsv(activity, repository.getAllUserEntries())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ fun Sources.iconId(): Int {
|
|||
Sources.Question -> R.drawable.ic_cp_question
|
||||
Sources.Announcement -> R.drawable.ic_cp_announcement
|
||||
Sources.Maintenance -> R.drawable.ic_maintenance
|
||||
Sources.Treatments -> R.drawable.ic_treatments
|
||||
Sources.Actions -> R.drawable.ic_action
|
||||
Sources.Automation -> R.drawable.ic_automation
|
||||
Sources.Loop -> R.drawable.ic_loop_closed_white
|
||||
|
|
|
@ -160,6 +160,7 @@ data class UserEntry(
|
|||
@SerializedName("NSClient") NSClient ("NSClient"), //From NSClient plugin
|
||||
@SerializedName("Pump") Pump ("Pump"), //From Pump plugin (for example from pump history)
|
||||
@SerializedName("SMS") SMS ("SMS"), //From SMS plugin
|
||||
@SerializedName("Treatments") Treatments ("Treatments"), //From Treatments plugin
|
||||
@SerializedName("Wear") Wear ("Wear"), //From Wear plugin
|
||||
@SerializedName("Food") Food ("Food"), //From Food plugin
|
||||
@SerializedName("Unknown") Unknown ("Unknown") //if necessary
|
||||
|
|
Loading…
Reference in a new issue