Added pump log SP values to initialize after pref import

This commit is contained in:
youn7986 2022-04-29 14:01:39 +09:00
parent ee78a24ac8
commit 507632d9a7
3 changed files with 20 additions and 0 deletions

View file

@ -21,6 +21,7 @@ import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.entities.UserEntry
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.diaconn.events.EventDiaconnG8PumpLogReset
import info.nightscout.androidaps.events.EventAppExit import info.nightscout.androidaps.events.EventAppExit
import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.interfaces.ImportExportPrefs import info.nightscout.androidaps.interfaces.ImportExportPrefs
@ -339,6 +340,7 @@ class ImportExportPrefsImpl @Inject constructor(
} }
private fun restartAppAfterImport(context: Context) { private fun restartAppAfterImport(context: Context) {
rxBus.send(EventDiaconnG8PumpLogReset())
sp.putBoolean(R.string.key_setupwizard_processed, true) sp.putBoolean(R.string.key_setupwizard_processed, true)
OKDialog.show(context, rh.gs(R.string.setting_imported), rh.gs(R.string.restartingapp)) { OKDialog.show(context, rh.gs(R.string.setting_imported), rh.gs(R.string.restartingapp)) {
uel.log(Action.IMPORT_SETTINGS, Sources.Maintenance) uel.log(Action.IMPORT_SETTINGS, Sources.Maintenance)

View file

@ -0,0 +1,5 @@
package info.nightscout.androidaps.diaconn.events
import info.nightscout.androidaps.events.Event
class EventDiaconnG8PumpLogReset : Event()

View file

@ -15,6 +15,7 @@ import info.nightscout.androidaps.diaconn.DiaconnG8Plugin
import info.nightscout.androidaps.diaconn.DiaconnG8Pump import info.nightscout.androidaps.diaconn.DiaconnG8Pump
import info.nightscout.androidaps.diaconn.R import info.nightscout.androidaps.diaconn.R
import info.nightscout.androidaps.diaconn.events.EventDiaconnG8NewStatus import info.nightscout.androidaps.diaconn.events.EventDiaconnG8NewStatus
import info.nightscout.androidaps.diaconn.events.EventDiaconnG8PumpLogReset
import info.nightscout.androidaps.diaconn.packet.* import info.nightscout.androidaps.diaconn.packet.*
import info.nightscout.androidaps.diaconn.pumplog.PumplogUtil import info.nightscout.androidaps.diaconn.pumplog.PumplogUtil
import info.nightscout.androidaps.dialogs.BolusProgressDialog import info.nightscout.androidaps.dialogs.BolusProgressDialog
@ -85,6 +86,13 @@ class DiaconnG8Service : DaggerService() {
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
.subscribe({ stopSelf() }) { fabricPrivacy.logException(it) } .subscribe({ stopSelf() }) { fabricPrivacy.logException(it) }
) )
disposable.add(rxBus
.toObservable(EventDiaconnG8PumpLogReset::class.java)
.observeOn(aapsSchedulers.io)
.subscribe {
pumpLogResetAfterPrefImport()
}
)
} }
inner class LocalBinder : Binder() { inner class LocalBinder : Binder() {
@ -641,6 +649,11 @@ class DiaconnG8Service : DaggerService() {
sp.putInt(rh.gs(R.string.apsWrappingCount), apsWrappingCount) sp.putInt(rh.gs(R.string.apsWrappingCount), apsWrappingCount)
} }
private fun pumpLogResetAfterPrefImport() {
sp.putInt(rh.gs(R.string.apslastLogNum), 0)
sp.putInt(rh.gs(R.string.apsWrappingCount), 0)
}
private fun processConfirm(msgType: Byte): Boolean { private fun processConfirm(msgType: Byte): Boolean {
// pump confirm // pump confirm
if (diaconnG8Pump.otpNumber == 0) { if (diaconnG8Pump.otpNumber == 0) {