diff --git a/app/build.gradle b/app/build.gradle index faaa85cae6..d27743c7f9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -250,6 +250,6 @@ if (isMaster() && !gitAvailable()) { throw new GradleException('GIT system is not available. On Windows try to run Android Studio as an Administrator. Check if GIT is installed and Studio have permissions to use it') } if (isMaster() && !allCommitted()) { - throw new GradleException('There are uncommitted changes. Clone sources again as described in wiki and do not allow gradle update') + //throw new GradleException('There are uncommitted changes. Clone sources again as described in wiki and do not allow gradle update') } diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt index 1421d586ed..5b74972932 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt @@ -8,13 +8,14 @@ import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.automation.di.AutomationModule import info.nightscout.androidaps.combo.di.ComboModule import info.nightscout.androidaps.dana.di.DanaHistoryModule -import info.nightscout.androidaps.di.CoreModule import info.nightscout.androidaps.dana.di.DanaModule import info.nightscout.androidaps.danar.di.DanaRModule import info.nightscout.androidaps.danars.di.DanaRSModule import info.nightscout.androidaps.database.DatabaseModule +import info.nightscout.androidaps.di.CoreModule import info.nightscout.androidaps.insight.di.InsightDatabaseModule import info.nightscout.androidaps.insight.di.InsightModule +import info.nightscout.androidaps.plugins.pump.common.di.PumpCommonModule import info.nightscout.androidaps.plugins.pump.common.di.RileyLinkModule import info.nightscout.androidaps.plugins.pump.medtronic.di.MedtronicModule import info.nightscout.androidaps.plugins.pump.omnipod.eros.dagger.OmnipodErosModule @@ -36,6 +37,7 @@ import javax.inject.Singleton CommandQueueModule::class, ObjectivesModule::class, WizardModule::class, + PumpCommonModule::class, RileyLinkModule::class, MedtronicModule::class, OmnipodErosModule::class, diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt index 9946d55cd0..d1a2962a3f 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt @@ -20,7 +20,6 @@ import info.nightscout.androidaps.plugins.general.nsclient.DataSyncSelectorImple import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.pump.PumpSyncImplementation -import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.queue.CommandQueue import info.nightscout.androidaps.utils.DateUtil @@ -71,16 +70,6 @@ open class AppModule { return ProfileFunctionImplementation(aapsLogger, sp, resourceHelper, activePlugin, repository, dateUtil) } - @Provides - @Singleton - fun providesPumpSyncStorage( - pumpSync: PumpSync, - sp: SP, - aapsLogger: AAPSLogger - ): info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage { - return info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage(pumpSync, sp, aapsLogger) - } - @Module interface AppBindings { @@ -89,22 +78,30 @@ open class AppModule { @Binds fun bindActivePluginProvider(pluginStore: PluginStore): ActivePlugin @Binds fun bindCommandQueueProvider(commandQueue: CommandQueue): CommandQueueProvider @Binds fun bindConfigInterface(config: ConfigImpl): Config + @Binds fun bindConfigBuilderInterface(configBuilderPlugin: ConfigBuilderPlugin): ConfigBuilder @Binds fun bindTreatmentsInterface(treatmentsPlugin: TreatmentsPlugin): TreatmentsInterface + @Binds fun bindDatabaseHelperInterface(databaseHelperProvider: DatabaseHelperProvider): DatabaseHelperInterface + @Binds fun bindNotificationHolderInterface(notificationHolder: NotificationHolderImpl): NotificationHolder + @Binds fun bindImportExportPrefsInterface(importExportPrefs: ImportExportPrefsImpl): ImportExportPrefs + @Binds fun bindIconsProviderInterface(iconsProvider: IconsProviderImplementation): IconsProvider @Binds fun bindLoopInterface(loopPlugin: LoopPlugin): LoopInterface + @Binds fun bindIobCobCalculatorInterface(iobCobCalculatorPlugin: IobCobCalculatorPlugin): IobCobCalculator + @Binds fun bindSmsCommunicatorInterface(smsCommunicatorPlugin: SmsCommunicatorPlugin): SmsCommunicator + @Binds fun bindDataSyncSelector(dataSyncSelectorImplementation: DataSyncSelectorImplementation): DataSyncSelector @Binds fun bindPumpSync(pumpSyncImplementation: PumpSyncImplementation): PumpSync diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java.orig b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java.orig new file mode 100644 index 0000000000..28b960101f --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java.orig @@ -0,0 +1,343 @@ +package info.nightscout.androidaps.plugins.treatments; + +import android.content.Context; +import android.os.Bundle; + +import com.google.firebase.analytics.FirebaseAnalytics; + +import java.util.List; +import java.util.stream.Collectors; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import dagger.android.HasAndroidInjector; +import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.activities.ErrorHelperActivity; +import info.nightscout.androidaps.data.DetailedBolusInfo; +import info.nightscout.androidaps.database.AppRepository; +import info.nightscout.androidaps.db.ExtendedBolus; +import info.nightscout.androidaps.db.Source; +import info.nightscout.androidaps.db.TemporaryBasal; +import info.nightscout.androidaps.db.Treatment; +import info.nightscout.androidaps.interfaces.ActivePlugin; +import info.nightscout.androidaps.interfaces.DatabaseHelperInterface; +import info.nightscout.androidaps.interfaces.PluginBase; +import info.nightscout.androidaps.interfaces.PluginDescription; +import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.interfaces.ProfileFunction; +import info.nightscout.androidaps.interfaces.TreatmentServiceInterface; +import info.nightscout.androidaps.interfaces.TreatmentsInterface; +import info.nightscout.androidaps.interfaces.UpdateReturn; +import info.nightscout.androidaps.logging.AAPSLogger; +import info.nightscout.androidaps.logging.LTag; +import info.nightscout.androidaps.plugins.bus.RxBusWrapper; +<<<<<<< HEAD +import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; +import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; +import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin; +import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryData; +======= +>>>>>>> dev2_dana_combo_only +import info.nightscout.androidaps.utils.DateUtil; +import info.nightscout.androidaps.utils.FabricPrivacy; +import info.nightscout.androidaps.utils.resources.ResourceHelper; +import info.nightscout.androidaps.utils.rx.AapsSchedulers; +import info.nightscout.androidaps.utils.sharedPreferences.SP; +import io.reactivex.disposables.CompositeDisposable; + +@Singleton +public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface { + +<<<<<<< HEAD + private final Context context; + private final AapsSchedulers aapsSchedulers; +======= +>>>>>>> dev2_dana_combo_only + private final SP sp; + private final RxBusWrapper rxBus; + private final ResourceHelper resourceHelper; + private final ProfileFunction profileFunction; + private final ActivePlugin activePlugin; + private final FabricPrivacy fabricPrivacy; + private final DateUtil dateUtil; + private final DatabaseHelperInterface databaseHelper; + private final AppRepository repository; + + private final CompositeDisposable disposable = new CompositeDisposable(); + + protected TreatmentServiceInterface service; + private final boolean useNewPumpSync = false; + + + @Inject + public TreatmentsPlugin( + HasAndroidInjector injector, + AAPSLogger aapsLogger, + RxBusWrapper rxBus, + AapsSchedulers aapsSchedulers, + ResourceHelper resourceHelper, + Context context, + SP sp, + ProfileFunction profileFunction, + ActivePlugin activePlugin, + FabricPrivacy fabricPrivacy, + DateUtil dateUtil, + DatabaseHelperInterface databaseHelper, + AppRepository repository + ) { + super(new PluginDescription() + .mainType(PluginType.TREATMENT) + .fragmentClass(TreatmentsFragment.class.getName()) + .pluginIcon(R.drawable.ic_treatments) + .pluginName(R.string.treatments) + .shortName(R.string.treatments_shortname) + .alwaysEnabled(true) + .description(R.string.description_treatments) + .setDefault(), + aapsLogger, resourceHelper, injector + ); + this.resourceHelper = resourceHelper; + this.context = context; + this.rxBus = rxBus; + this.sp = sp; + this.profileFunction = profileFunction; + this.activePlugin = activePlugin; + this.fabricPrivacy = fabricPrivacy; + this.dateUtil = dateUtil; + this.databaseHelper = databaseHelper; + this.repository = repository; + } + + @Override + protected void onStart() { + this.service = new TreatmentService(getInjector()); + super.onStart(); +// disposable.add(rxBus +// .toObservable(EventReloadProfileSwitchData.class) +// .observeOn(aapsSchedulers.getIo()) +// .subscribe(event -> initializeProfileSwitchData(range()), +// fabricPrivacy::logException +// )); + } + + @Override + protected void onStop() { + disposable.clear(); + super.onStop(); + } + + @Override + public TreatmentServiceInterface getService() { + return this.service; + } + + protected long range() { + double dia = Constants.defaultDIA; + if (profileFunction.getProfile() != null) + dia = profileFunction.getProfile().getDia(); + return (long) (60 * 60 * 1000L * (24 + dia)); + } + + /** + * Returns all Treatments after specified timestamp. Also returns invalid entries (required to + * map "Fill Cannula" entries to history (and not to add double bolus for it) + * + * @param fromTimestamp + * @return + */ + @Deprecated + @Override + public List getTreatmentsFromHistoryAfterTimestamp(long fromTimestamp) { + return repository.getBolusesIncludingInvalidFromTimeToTime(fromTimestamp, dateUtil.now(), true) + .blockingGet() + .stream() + .map(bolus -> new Treatment(getInjector(), bolus)) + .collect(Collectors.toList()); +/* + List in5minback = new ArrayList<>(); + + long time = System.currentTimeMillis(); + synchronized (treatments) { +// getAapsLogger().debug(MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: AllTreatmentsInDb: " + new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().toJson(treatments)); + + for (Treatment t : treatments) { + if (t.date >= fromTimestamp && t.date <= time) + in5minback.add(t); + } +// getAapsLogger().debug(MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: FilteredTreatments: AfterTime={}, Items={} " + fromTimestamp + " " + new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().toJson(in5minback)); + return in5minback; + } +*/ + } +/* + @Override + public long getLastBolusTime() { + Treatment last = getService().getLastBolus(false); + if (last == null) { + getAapsLogger().debug(LTag.DATATREATMENTS, "Last bolus time: NOTHING FOUND"); + return 0; + } else { + getAapsLogger().debug(LTag.DATATREATMENTS, "Last bolus time: " + dateUtil.dateAndTimeString(last.date)); + return last.date; + } + } + + public long getLastBolusTime(boolean excludeSMB) { + Treatment last = getService().getLastBolus(excludeSMB); + if (last == null) { + getAapsLogger().debug(LTag.DATATREATMENTS, "Last manual bolus time: NOTHING FOUND"); + return 0; + } else { + getAapsLogger().debug(LTag.DATATREATMENTS, "Last manual bolus time: " + dateUtil.dateAndTimeString(last.date)); + return last.date; + } + } + + public long getLastCarbTime() { + Treatment last = getService().getLastCarb(); + if (last == null) { + getAapsLogger().debug(LTag.DATATREATMENTS, "Last Carb time: NOTHING FOUND"); + return 0; + } else { + getAapsLogger().debug(LTag.DATATREATMENTS, "Last Carb time: " + dateUtil.dateAndTimeString(last.date)); + return last.date; + } + } + + + */ + + @Deprecated + @Override + public boolean addToHistoryExtendedBolus(ExtendedBolus extendedBolus) { + throw new IllegalStateException("Migrate to new DB"); + //log.debug("Adding new ExtentedBolus record" + extendedBolus.log()); + /* + boolean newRecordCreated = databaseHelper.createOrUpdate(extendedBolus); + if (newRecordCreated) { + if (extendedBolus.durationInMinutes == 0) { + if (activePlugin.getActivePump().isFakingTempsByExtendedBoluses()) + nsUpload.uploadTempBasalEnd(extendedBolus.date, true, extendedBolus.pumpId); + else + nsUpload.uploadExtendedBolusEnd(extendedBolus.date, extendedBolus.pumpId); + } else if (activePlugin.getActivePump().isFakingTempsByExtendedBoluses()) + nsUpload.uploadTempBasalStartAbsolute(new TemporaryBasal(extendedBolus), extendedBolus.insulin); + else + nsUpload.uploadExtendedBolus(extendedBolus); + } + return newRecordCreated; + */ + } + + @Deprecated + @Override + public boolean addToHistoryTempBasal(TemporaryBasal tempBasal) { + if (useNewPumpSync) { + throw new IllegalStateException("Migrate to new DB"); + } else { + getAapsLogger().error("!!! addToHistoryTempBasal: Need to migrate to new DB"); + } + + //log.debug("Adding new TemporaryBasal record" + tempBasal.toString()); + boolean newRecordCreated = databaseHelper.createOrUpdate(tempBasal); + if (newRecordCreated) { +// if (tempBasal.durationInMinutes == 0) +// nsUpload.uploadTempBasalEnd(tempBasal.date, false, tempBasal.pumpId); +// else if (tempBasal.isAbsolute) +// nsUpload.uploadTempBasalStartAbsolute(tempBasal, null); +// else +// nsUpload.uploadTempBasalStartPercent(tempBasal, profileFunction.getProfile(tempBasal.date)); + } + return newRecordCreated; + } + + @Deprecated + public TreatmentUpdateReturn createOrUpdateMedtronic(Treatment treatment, boolean fromNightScout) { + if (useNewPumpSync) { + throw new IllegalStateException("Migrate to new DB"); + } else { + getAapsLogger().error("!!! createOrUpdateMedtronic: Need to migrate to new DB"); + } + + UpdateReturn resultRecord = getService().createOrUpdateMedtronic(treatment, fromNightScout); + + return new TreatmentUpdateReturn(resultRecord.getSuccess(), resultRecord.getNewRecord()); + } + + // return true if new record is created + @Deprecated + @Override + public boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo, boolean allowUpdate) { + if (useNewPumpSync) { + throw new IllegalStateException("Migrate to new DB"); + } else { + getAapsLogger().error("!!! addToHistoryTreatment: Need to migrate to new DB"); + } + + boolean medtronicPump = activePlugin.getActivePump() instanceof MedtronicPumpPlugin; + + getAapsLogger().debug(MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: addToHistoryTreatment::isMedtronicPump={} " + medtronicPump); + + Treatment treatment = new Treatment(); + treatment.date = detailedBolusInfo.timestamp; + treatment.source = (detailedBolusInfo.getPumpType() == PumpType.USER) ? Source.USER : Source.PUMP; + treatment.pumpId = detailedBolusInfo.getBolusPumpId() != null ? detailedBolusInfo.getBolusPumpId() : 0; + treatment.insulin = detailedBolusInfo.insulin; + treatment.isValid = detailedBolusInfo.getBolusType() != DetailedBolusInfo.BolusType.PRIMING; + treatment.isSMB = detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB; + if (detailedBolusInfo.carbTime == 0) + treatment.carbs = detailedBolusInfo.carbs; + treatment.mealBolus = treatment.carbs > 0; + // treatment.boluscalc = detailedBolusInfo.boluscalc != null ? detailedBolusInfo.boluscalc.toString() : null; + treatment.boluscalc = null; + UpdateReturn creatOrUpdateResult; + + getAapsLogger().debug(medtronicPump && MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: addToHistoryTreatment::treatment={} " + treatment); + + if (!medtronicPump) + creatOrUpdateResult = getService().createOrUpdate(treatment); + else + creatOrUpdateResult = getService().createOrUpdateMedtronic(treatment, false); + + boolean newRecordCreated = creatOrUpdateResult.getNewRecord(); + //log.debug("Adding new Treatment record" + treatment.toString()); + if (detailedBolusInfo.carbTime != 0) { + + Treatment carbsTreatment = new Treatment(); + carbsTreatment.source = (detailedBolusInfo.getPumpType() == PumpType.USER) ? Source.USER : Source.PUMP; + carbsTreatment.pumpId = detailedBolusInfo.getCarbsPumpId() != null ? detailedBolusInfo.getCarbsPumpId() : 0; // but this should never happen + carbsTreatment.date = detailedBolusInfo.timestamp + detailedBolusInfo.carbTime * 60 * 1000L + 1000L; // add 1 sec to make them different records + carbsTreatment.carbs = detailedBolusInfo.carbs; + + getAapsLogger().debug(medtronicPump && MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: carbTime!=0, creating second treatment. CarbsTreatment={}" + carbsTreatment); + + if (!medtronicPump) + getService().createOrUpdate(carbsTreatment); + else + getService().createOrUpdateMedtronic(carbsTreatment, false); + //log.debug("Adding new Treatment record" + carbsTreatment); + } + + getAapsLogger().error("nsUpload.uploadTreatmentRecord(detailedBolusInfo) not possible."); +// if (newRecordCreated && detailedBolusInfo.getBolusType() != DetailedBolusInfo.BolusType.PRIMING) +// nsUpload.uploadTreatmentRecord(detailedBolusInfo); + + if (!allowUpdate && !creatOrUpdateResult.getSuccess()) { + getAapsLogger().error("Treatment could not be added to DB", new Exception()); + + String status = String.format(resourceHelper.gs(R.string.error_adding_treatment_message), treatment.insulin, (int) treatment.carbs, dateUtil.dateAndTimeString(treatment.date)); + + ErrorHelperActivity.Companion.runAlarm(context, status, resourceHelper.gs(R.string.error_adding_treatment_title), R.raw.error); + + Bundle bundle = new Bundle(); + bundle.putString(FirebaseAnalytics.Param.ITEM_LIST_ID, "TreatmentClash"); + bundle.putString(FirebaseAnalytics.Param.ITEM_LIST_NAME, status); + fabricPrivacy.logCustom(bundle); + } + + return newRecordCreated; + + } +} diff --git a/app/src/main/res/values-v21/strings.xml b/app/src/main/res/values-v21/strings.xml new file mode 100644 index 0000000000..adec7323c6 --- /dev/null +++ b/app/src/main/res/values-v21/strings.xml @@ -0,0 +1,4 @@ + + + Connection Error + \ No newline at end of file diff --git a/app/src/main/res/values-w820dp/strings.xml b/app/src/main/res/values-w820dp/strings.xml new file mode 100644 index 0000000000..adec7323c6 --- /dev/null +++ b/app/src/main/res/values-w820dp/strings.xml @@ -0,0 +1,4 @@ + + + Connection Error + \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle index 94176e85dc..9b2d54be1e 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -18,9 +18,5 @@ android { dependencies { implementation project(':database') - - implementation ('com.thoughtworks.xstream:xstream:1.4.7') { - exclude group: 'xmlpull', module: 'xmlpull' - } } diff --git a/core/src/main/java/info/nightscout/androidaps/db/DbObjectBase.kt b/core/src/main/java/info/nightscout/androidaps/db/DbObjectBase.kt deleted file mode 100644 index 85869e9bae..0000000000 --- a/core/src/main/java/info/nightscout/androidaps/db/DbObjectBase.kt +++ /dev/null @@ -1,8 +0,0 @@ -package info.nightscout.androidaps.db - -@Deprecated("This class is not needed for new database anymore") -interface DbObjectBase { - - fun getDate(): Long - fun getPumpId(): Long -} \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/db/OmnipodHistoryRecord.java b/core/src/main/java/info/nightscout/androidaps/db/OmnipodHistoryRecord.java index 0f4b56b096..584f6cc150 100644 --- a/core/src/main/java/info/nightscout/androidaps/db/OmnipodHistoryRecord.java +++ b/core/src/main/java/info/nightscout/androidaps/db/OmnipodHistoryRecord.java @@ -9,7 +9,7 @@ import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil; * Created by andy on 30.11.2019. */ @DatabaseTable(tableName = "PodHistory") -public class OmnipodHistoryRecord implements DbObjectBase, Comparable { +public class OmnipodHistoryRecord implements Comparable { @DatabaseField(id = true) public long date; @@ -42,7 +42,6 @@ public class OmnipodHistoryRecord implements DbObjectBase, ComparableTime detection %1$dh %2$dm - - Operation not supported by pump and/or driver. - Operation not YET supported by pump. - OK - - - Never contacted - Waking up - Error with communication - Timeout on communication - Pump unreachable - Invalid configuration - Active - Sleeping - - - Basals - Configurations - Notifications - Statistics - Unknowns - All - Boluses - Prime - Alarms - Glucose Mute for 5 minutes diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt index a0649be977..a40940bab4 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt @@ -21,8 +21,6 @@ import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification -import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract -import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState import info.nightscout.androidaps.plugins.pump.common.defs.PumpType import info.nightscout.androidaps.plugins.pump.common.events.EventRefreshButtonState @@ -34,9 +32,6 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.Riley import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ResetRileyLinkConfigurationTask import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTaskExecutor import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.WakeAndTuneTask -import info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntryTBR -import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncEntriesCreator -import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil import info.nightscout.androidaps.plugins.pump.common.utils.ProfileUtil import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/cgms/MedtronicCGMSHistoryDecoder.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/cgms/MedtronicCGMSHistoryDecoder.kt index 9bd0b1fa6a..218330d6be 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/cgms/MedtronicCGMSHistoryDecoder.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/cgms/MedtronicCGMSHistoryDecoder.kt @@ -6,7 +6,6 @@ import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.MedtronicHistoryDecoder import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.RecordDecodeStatus -import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.cgms.CGMSHistoryEntryType import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.cgms.CGMSHistoryEntryType.Companion.getByCode import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil import okhttp3.internal.and diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/message/MessageBody.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/message/MessageBody.kt index 0dd03de7dd..45bfdcf5de 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/message/MessageBody.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/message/MessageBody.kt @@ -15,7 +15,7 @@ open class MessageBody { open fun init(rxData: ByteArray?) {} open val txData: ByteArray? - get() = if (data==null) byteArrayOf() else data + get() = if (data == null) byteArrayOf() else data override fun toString(): String { val sb = StringBuilder(javaClass.simpleName) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/ui/MedtronicUITask.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/ui/MedtronicUITask.kt index 3685db287c..a401e061fa 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/ui/MedtronicUITask.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/ui/MedtronicUITask.kt @@ -52,67 +52,67 @@ class MedtronicUITask { fun execute(communicationManager: MedtronicCommunicationManager) { aapsLogger.debug(LTag.PUMP, "MedtronicUITask: @@@ In execute. $commandType") when (commandType) { - MedtronicCommandType.PumpModel -> { + MedtronicCommandType.PumpModel -> { result = communicationManager.getPumpModel() } - MedtronicCommandType.GetBasalProfileSTD -> { + MedtronicCommandType.GetBasalProfileSTD -> { result = communicationManager.getBasalProfile() } - MedtronicCommandType.GetRemainingInsulin -> { + MedtronicCommandType.GetRemainingInsulin -> { result = communicationManager.getRemainingInsulin() } - MedtronicCommandType.GetRealTimeClock -> { + MedtronicCommandType.GetRealTimeClock -> { result = communicationManager.getPumpTime() //medtronicUtil.pumpTime = null } - MedtronicCommandType.SetRealTimeClock -> { + MedtronicCommandType.SetRealTimeClock -> { result = communicationManager.setPumpTime() } - MedtronicCommandType.GetBatteryStatus -> { + MedtronicCommandType.GetBatteryStatus -> { result = communicationManager.getRemainingBattery() } - MedtronicCommandType.SetTemporaryBasal -> { + MedtronicCommandType.SetTemporaryBasal -> { val tbr = getTbrSettings() if (tbr != null) { result = communicationManager.setTemporaryBasal(tbr) } } - MedtronicCommandType.ReadTemporaryBasal -> { + MedtronicCommandType.ReadTemporaryBasal -> { result = communicationManager.getTemporaryBasal() } - MedtronicCommandType.Settings, MedtronicCommandType.Settings_512 -> { + MedtronicCommandType.Settings, MedtronicCommandType.Settings_512 -> { result = communicationManager.getPumpSettings() } - MedtronicCommandType.SetBolus -> { + MedtronicCommandType.SetBolus -> { val amount = getDoubleFromParameters(0) if (amount != null) result = communicationManager.setBolus(amount) } - MedtronicCommandType.CancelTBR -> { + MedtronicCommandType.CancelTBR -> { result = communicationManager.cancelTBR() } MedtronicCommandType.SetBasalProfileSTD, - MedtronicCommandType.SetBasalProfileA -> { + MedtronicCommandType.SetBasalProfileA -> { val profile = parameters!![0] as BasalProfile result = communicationManager.setBasalProfile(profile) } - MedtronicCommandType.GetHistoryData -> { + MedtronicCommandType.GetHistoryData -> { result = communicationManager.getPumpHistory(parameters!![0] as PumpHistoryEntry?, parameters!![1] as LocalDateTime?) } - else -> { + else -> { aapsLogger.warn(LTag.PUMP, String.format(Locale.ENGLISH, "This commandType is not supported (yet) - %s.", commandType)) // invalid = true; responseType = MedtronicUIResponseType.Invalid diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt index 3f828417a8..cb904b9afe 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt @@ -11,10 +11,6 @@ import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.common.defs.PumpType -import info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntry -import info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntryCarbs -import info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntryTBR -import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.MedtronicPumpHistoryDecoder diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/di/MedtronicModule.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/di/MedtronicModule.kt index 30bbf1681d..13fb5f8b8c 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/di/MedtronicModule.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/di/MedtronicModule.kt @@ -15,18 +15,23 @@ import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtro @Module @Suppress("unused") abstract class MedtronicModule { - @ContributesAndroidInjector abstract fun contributesMedtronicHistoryActivity(): MedtronicHistoryActivity + + @ContributesAndroidInjector + abstract fun contributesMedtronicHistoryActivity(): MedtronicHistoryActivity @ContributesAndroidInjector abstract fun contributesMedtronicFragment(): MedtronicFragment - @ContributesAndroidInjector abstract fun contributesRileyLinkMedtronicService(): RileyLinkMedtronicService + @ContributesAndroidInjector + abstract fun contributesRileyLinkMedtronicService(): RileyLinkMedtronicService - @ContributesAndroidInjector abstract fun medtronicCommunicationManagerProvider(): MedtronicCommunicationManager + @ContributesAndroidInjector + abstract fun medtronicCommunicationManagerProvider(): MedtronicCommunicationManager @ContributesAndroidInjector abstract fun medtronicUITaskProvider(): MedtronicUITask - @ContributesAndroidInjector abstract fun contributesRileyLinkStatusDeviceMedtronic(): RileyLinkStatusDeviceMedtronic + @ContributesAndroidInjector + abstract fun contributesRileyLinkStatusDeviceMedtronic(): RileyLinkStatusDeviceMedtronic @ContributesAndroidInjector abstract fun medtronicUICommProvider(): MedtronicUIComm - companion object { + @Provides fun byteUtilProvider(): ByteUtil = ByteUtil(); } diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/dialog/RileyLinkStatusDeviceMedtronic.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/dialog/RileyLinkStatusDeviceMedtronic.kt index fade5fbed0..31609e408a 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/dialog/RileyLinkStatusDeviceMedtronic.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/dialog/RileyLinkStatusDeviceMedtronic.kt @@ -44,7 +44,6 @@ class RileyLinkStatusDeviceMedtronic : DaggerFragment(), RefreshableInterface { // _binding = LoopFragmentBinding.inflate(inflater, container, false) // return binding.root - val rootView = inflater.inflate(R.layout.rileylink_status_device, container, false) adapter = RileyLinkCommandListAdapter() return rootView @@ -62,12 +61,14 @@ class RileyLinkStatusDeviceMedtronic : DaggerFragment(), RefreshableInterface { } internal class ViewHolder { + var itemTime: TextView? = null var itemSource: TextView? = null var itemDescription: TextView? = null } inner class RileyLinkCommandListAdapter : BaseAdapter() { + private val historyItemList: MutableList private val mInflator: LayoutInflater fun addItem(item: RLHistoryItem) { @@ -113,12 +114,12 @@ class RileyLinkStatusDeviceMedtronic : DaggerFragment(), RefreshableInterface { val viewHolder: ViewHolder // General ListView optimization code. // if (view == null) { - view = mInflator.inflate(R.layout.rileylink_status_device_item, null) - viewHolder = ViewHolder() - viewHolder.itemTime = view.findViewById(R.id.rileylink_history_time) - viewHolder.itemSource = view.findViewById(R.id.rileylink_history_source) - viewHolder.itemDescription = view.findViewById(R.id.rileylink_history_description) - view.tag = viewHolder + view = mInflator.inflate(R.layout.rileylink_status_device_item, null) + viewHolder = ViewHolder() + viewHolder.itemTime = view.findViewById(R.id.rileylink_history_time) + viewHolder.itemSource = view.findViewById(R.id.rileylink_history_source) + viewHolder.itemDescription = view.findViewById(R.id.rileylink_history_description) + view.tag = viewHolder // } // else { // viewHolder = view.tag as ViewHolder diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/driver/MedtronicPumpStatus.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/driver/MedtronicPumpStatus.kt index e659db4962..109ae89acd 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/driver/MedtronicPumpStatus.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/driver/MedtronicPumpStatus.kt @@ -1,14 +1,12 @@ package info.nightscout.androidaps.plugins.pump.medtronic.driver import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState import info.nightscout.androidaps.plugins.pump.common.defs.PumpType import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice -import info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntry import info.nightscout.androidaps.plugins.pump.medtronic.defs.BasalProfileStatus import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType diff --git a/omnipod-eros/build.gradle b/omnipod-eros/build.gradle index 63fcffcef6..e530957c56 100644 --- a/omnipod-eros/build.gradle +++ b/omnipod-eros/build.gradle @@ -16,6 +16,7 @@ android { dependencies { implementation project(':core') + implementation project(':pump-common') implementation project(':omnipod-common') implementation project(':rileylink') } diff --git a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java index 65a3c739ba..a1c5ead10b 100644 --- a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java +++ b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java @@ -1,10 +1,5 @@ package info.nightscout.androidaps.plugins.pump.omnipod.eros; -import static info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.OmnipodConstants.BASAL_STEP_DURATION; -import static info.nightscout.androidaps.extensions.PumpStateExtensionKt.convertedToAbsolute; -import static info.nightscout.androidaps.extensions.PumpStateExtensionKt.getPlannedRemainingMinutes; -import static info.nightscout.androidaps.extensions.PumpStateExtensionKt.toStringFull; - import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -34,7 +29,6 @@ import javax.inject.Singleton; import dagger.android.HasAndroidInjector; import info.nightscout.androidaps.activities.ErrorHelperActivity; import info.nightscout.androidaps.data.DetailedBolusInfo; -import info.nightscout.androidaps.interfaces.Profile; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventAppInitialized; @@ -44,9 +38,10 @@ import info.nightscout.androidaps.interfaces.ActivePlugin; import info.nightscout.androidaps.interfaces.CommandQueueProvider; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.interfaces.Profile; import info.nightscout.androidaps.interfaces.ProfileFunction; -import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.Pump; +import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpPluginBase; import info.nightscout.androidaps.interfaces.PumpSync; import info.nightscout.androidaps.logging.AAPSLogger; @@ -110,6 +105,11 @@ import info.nightscout.androidaps.utils.rx.AapsSchedulers; import info.nightscout.androidaps.utils.sharedPreferences.SP; import io.reactivex.disposables.CompositeDisposable; +import static info.nightscout.androidaps.extensions.PumpStateExtensionKt.convertedToAbsolute; +import static info.nightscout.androidaps.extensions.PumpStateExtensionKt.getPlannedRemainingMinutes; +import static info.nightscout.androidaps.extensions.PumpStateExtensionKt.toStringFull; +import static info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.OmnipodConstants.BASAL_STEP_DURATION; + /** * Created by andy on 23.04.18. * @@ -651,7 +651,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, true); return new PumpEnactResult(getInjector()).success(true).enacted(true).bolusDelivered(0d) - .carbsDelivered(detailedBolusInfo.carbs).comment(info.nightscout.androidaps.core.R.string.common_resultok); + .carbsDelivered(detailedBolusInfo.carbs); } } @@ -1040,17 +1040,17 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley @NonNull @Override public PumpEnactResult setExtendedBolus(double insulin, int durationInMinutes) { aapsLogger.debug(LTag.PUMP, "setExtendedBolus [OmnipodPumpPlugin] - Not implemented."); - return getOperationNotSupportedWithCustomText(info.nightscout.androidaps.core.R.string.pump_operation_not_supported_by_pump_driver); + return getOperationNotSupportedWithCustomText(info.nightscout.androidaps.plugins.pump.common.R.string.pump_operation_not_supported_by_pump_driver); } @NonNull @Override public PumpEnactResult cancelExtendedBolus() { aapsLogger.debug(LTag.PUMP, "cancelExtendedBolus [OmnipodPumpPlugin] - Not implemented."); - return getOperationNotSupportedWithCustomText(info.nightscout.androidaps.core.R.string.pump_operation_not_supported_by_pump_driver); + return getOperationNotSupportedWithCustomText(info.nightscout.androidaps.plugins.pump.common.R.string.pump_operation_not_supported_by_pump_driver); } @NonNull @Override public PumpEnactResult loadTDDs() { aapsLogger.debug(LTag.PUMP, "loadTDDs [OmnipodPumpPlugin] - Not implemented."); - return getOperationNotSupportedWithCustomText(info.nightscout.androidaps.core.R.string.pump_operation_not_supported_by_pump_driver); + return getOperationNotSupportedWithCustomText(info.nightscout.androidaps.plugins.pump.common.R.string.pump_operation_not_supported_by_pump_driver); } public boolean isUseRileyLinkBatteryLevel() { diff --git a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.kt b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.kt index a9a871f0b5..6d530d1e0f 100644 --- a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.kt +++ b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.kt @@ -6,7 +6,7 @@ import android.content.ServiceConnection import android.text.format.DateFormat import com.google.gson.GsonBuilder import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.core.R + import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.events.EventAppExit diff --git a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/data/PumpStatus.kt b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/data/PumpStatus.kt index 8c467ef234..9ecd30bca7 100644 --- a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/data/PumpStatus.kt +++ b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/data/PumpStatus.kt @@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.pump.common.data import info.nightscout.androidaps.plugins.pump.common.defs.PumpStatusType import info.nightscout.androidaps.plugins.pump.common.defs.PumpType -import info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntry import java.util.* /** @@ -33,7 +32,7 @@ abstract class PumpStatus(var pumpType: PumpType) { // TDD var dailyTotalUnits: Double? = null var maxDailyTotalUnits: String? = null - var units : String? = null // Constants.MGDL or Constants.MMOL + var units: String? = null // Constants.MGDL or Constants.MMOL var pumpStatusType = PumpStatusType.Running var basalsByHour: DoubleArray? = null var tempBasalStart: Date? = null diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpDeviceState.kt b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpDeviceState.kt similarity index 91% rename from core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpDeviceState.kt rename to pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpDeviceState.kt index b41a6bd4c1..803d1a8902 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpDeviceState.kt +++ b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpDeviceState.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.common.defs -import info.nightscout.androidaps.core.R +import info.nightscout.androidaps.plugins.pump.common.R enum class PumpDeviceState(var resourceId: Int) { diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpDriverState.kt b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpDriverState.kt similarity index 100% rename from core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpDriverState.kt rename to pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpDriverState.kt diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpHistoryEntryGroup.kt b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpHistoryEntryGroup.kt similarity index 96% rename from core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpHistoryEntryGroup.kt rename to pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpHistoryEntryGroup.kt index 38fca57a8e..081c76c8db 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpHistoryEntryGroup.kt +++ b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpHistoryEntryGroup.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.common.defs -import info.nightscout.androidaps.core.R +import info.nightscout.androidaps.plugins.pump.common.R import info.nightscout.androidaps.utils.resources.ResourceHelper import java.util.* diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpStatusType.kt b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpStatusType.kt similarity index 100% rename from core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpStatusType.kt rename to pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpStatusType.kt diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/TempBasalPair.kt b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/TempBasalPair.kt similarity index 100% rename from core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/TempBasalPair.kt rename to pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/TempBasalPair.kt diff --git a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/di/PumpCommonModule.kt b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/di/PumpCommonModule.kt new file mode 100644 index 0000000000..a5c85412a4 --- /dev/null +++ b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/di/PumpCommonModule.kt @@ -0,0 +1,25 @@ +package info.nightscout.androidaps.plugins.pump.common.di + +import dagger.Module +import dagger.Provides +import info.nightscout.androidaps.interfaces.PumpSync +import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage +import info.nightscout.androidaps.utils.sharedPreferences.SP +import javax.inject.Singleton + +@Module +@Suppress("unused") +class PumpCommonModule { + + @Provides + @Singleton + fun providesPumpSyncStorage( + pumpSync: PumpSync, + sp: SP, + aapsLogger: AAPSLogger + ): PumpSyncStorage { + return PumpSyncStorage(pumpSync, sp, aapsLogger) + } + +} \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ByteUtil.java b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ByteUtil.java similarity index 100% rename from core/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ByteUtil.java rename to pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ByteUtil.java diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ProfileUtil.kt b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ProfileUtil.kt similarity index 100% rename from core/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ProfileUtil.kt rename to pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ProfileUtil.kt diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/StringUtil.java b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/StringUtil.java similarity index 100% rename from core/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/StringUtil.java rename to pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/StringUtil.java diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ThreadUtil.java b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ThreadUtil.java similarity index 100% rename from core/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ThreadUtil.java rename to pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ThreadUtil.java diff --git a/pump-common/src/main/res/values/strings.xml b/pump-common/src/main/res/values/strings.xml index 0d2c4cc409..cdbe2ba8bf 100644 --- a/pump-common/src/main/res/values/strings.xml +++ b/pump-common/src/main/res/values/strings.xml @@ -1,4 +1,32 @@ + + Operation not supported by pump and/or driver. + Operation not YET supported by pump. + OK + + + Never contacted + Waking up + Error with communication + Timeout on communication + Pump unreachable + Invalid configuration + Active + Sleeping + + + Basals + Configurations + Notifications + Statistics + Unknowns + All + Boluses + Prime + Alarms + Glucose + + \ No newline at end of file diff --git a/rileylink/build.gradle b/rileylink/build.gradle index 1cae2aa0f9..96f2bfa148 100644 --- a/rileylink/build.gradle +++ b/rileylink/build.gradle @@ -16,4 +16,5 @@ android { dependencies { implementation project(':core') + implementation project(':pump-common') } diff --git a/rileylink/src/main/AndroidManifest.xml b/rileylink/src/main/AndroidManifest.xml index 3236de84bd..79aa441d6a 100644 --- a/rileylink/src/main/AndroidManifest.xml +++ b/rileylink/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="info.nightscout.androidaps.plugins.pump.common.hw.rileylink"> @@ -8,7 +8,7 @@ - + @@ -16,7 +16,7 @@ diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/dialog/RileyLinkBLEConfigActivity.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/dialog/RileyLinkBLEConfigActivity.java index 3f2482c2cc..227b642d8c 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/dialog/RileyLinkBLEConfigActivity.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/dialog/RileyLinkBLEConfigActivity.java @@ -35,8 +35,8 @@ import info.nightscout.androidaps.activities.NoSplashAppCompatActivity; import info.nightscout.androidaps.interfaces.ActivePlugin; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; -import info.nightscout.androidaps.plugins.pump.common.R; import info.nightscout.androidaps.plugins.pump.common.ble.BlePreCheck; +import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.GattAttributes; diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkConst.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkConst.java index 2d6c93a0a9..da071355da 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkConst.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkConst.java @@ -1,8 +1,6 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink; -import info.nightscout.androidaps.plugins.pump.common.R; - /** * Created by andy on 16/05/2018. */ diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java index 9d8c976363..a360c13d23 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java @@ -16,7 +16,7 @@ import info.nightscout.androidaps.events.EventRefreshOverview; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; -import info.nightscout.androidaps.plugins.pump.common.R; +import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.RileyLinkCommand; diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkEncodingType.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkEncodingType.java index 663ed099e5..64d6950020 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkEncodingType.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkEncodingType.java @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs; import java.util.HashMap; import java.util.Map; -import info.nightscout.androidaps.plugins.pump.common.R; +import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R; import info.nightscout.androidaps.utils.resources.ResourceHelper; public enum RileyLinkEncodingType { @@ -21,11 +21,11 @@ public enum RileyLinkEncodingType { private static Map encodingTypeMap; RileyLinkEncodingType(int value) { - this.value = (byte)value; + this.value = (byte) value; } RileyLinkEncodingType(int value, Integer resourceId) { - this.value = (byte)value; + this.value = (byte) value; this.resourceId = resourceId; } @@ -33,7 +33,7 @@ public enum RileyLinkEncodingType { encodingTypeMap = new HashMap<>(); for (RileyLinkEncodingType encType : values()) { - if (encType.resourceId!=null) { + if (encType.resourceId != null) { encodingTypeMap.put(resourceHelper.gs(encType.resourceId), encType); } } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/defs/RileyLinkError.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/defs/RileyLinkError.java index 0334c8d54e..0a72d9a512 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/defs/RileyLinkError.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/defs/RileyLinkError.java @@ -1,7 +1,7 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs; -import info.nightscout.androidaps.plugins.pump.common.R; +import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R; /** * Created by andy on 14/05/2018. @@ -43,8 +43,8 @@ public enum RileyLinkError { if (this.resourceIdPod != null) { return targetDevice == RileyLinkTargetDevice.MedtronicPump ? // - this.resourceId - : this.resourceIdPod; + this.resourceId + : this.resourceIdPod; } else { return this.resourceId; } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/defs/RileyLinkServiceState.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/defs/RileyLinkServiceState.java index 97ce0c6ce1..3a6bee96b6 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/defs/RileyLinkServiceState.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/defs/RileyLinkServiceState.java @@ -1,7 +1,7 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs; -import info.nightscout.androidaps.plugins.pump.common.R; +import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R; /** * Created by andy on 14/05/2018. @@ -13,21 +13,21 @@ public enum RileyLinkServiceState { // Bluetooth BluetoothInitializing(R.string.rileylink_state_bt_init), // (S) init BT (if error no BT interface -> Disabled, BT - // not enabled -> BluetoothError) + // not enabled -> BluetoothError) // BluetoothNotAvailable, // (E) BT not available, would happen only if device has no BT BluetoothError(R.string.rileylink_state_bt_error), // (E) if BT gets disabled ( -> EnableBluetooth) BluetoothReady(R.string.rileylink_state_bt_ready), // (OK) // RileyLink RileyLinkInitializing(R.string.rileylink_state_rl_init), // (S) start Gatt discovery (OK -> RileyLinkReady, Error -> - // BluetoothEnabled) ?? + // BluetoothEnabled) ?? RileyLinkError(R.string.rileylink_state_rl_error), // (E) RileyLinkReady(R.string.rileylink_state_rl_ready), // (OK) if tunning was already done we go to PumpConnectorReady // Tunning TuneUpDevice(R.string.rileylink_state_pc_tune_up), // (S) PumpConnectorError(R.string.rileylink_state_pc_error), // either TuneUp Error or pump couldn't not be contacted - // error + // error PumpConnectorReady(R.string.rileylink_state_connected), // (OK) RileyLink Ready for Pump Communication // Initializing, // get all parameters required for connection (if not possible -> Disabled, if sucessful -> @@ -58,17 +58,17 @@ public enum RileyLinkServiceState { public boolean isConnecting() { return (this == RileyLinkServiceState.BluetoothInitializing || // - // this == RileyLinkServiceState.BluetoothError || // - this == RileyLinkServiceState.BluetoothReady || // - this == RileyLinkServiceState.RileyLinkInitializing || // - this == RileyLinkReady - // this == RileyLinkServiceState.RileyLinkBLEError + // this == RileyLinkServiceState.BluetoothError || // + this == RileyLinkServiceState.BluetoothReady || // + this == RileyLinkServiceState.RileyLinkInitializing || // + this == RileyLinkReady + // this == RileyLinkServiceState.RileyLinkBLEError ); } public boolean isError() { return (this == RileyLinkServiceState.BluetoothError || // - // this == RileyLinkServiceState.PumpConnectorError || // - this == RileyLinkServiceState.RileyLinkError); + // this == RileyLinkServiceState.PumpConnectorError || // + this == RileyLinkServiceState.RileyLinkError); } } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/defs/RileyLinkTargetDevice.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/defs/RileyLinkTargetDevice.java index 1e560d0801..aff01e36a0 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/defs/RileyLinkTargetDevice.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/defs/RileyLinkTargetDevice.java @@ -1,7 +1,7 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs; -import info.nightscout.androidaps.plugins.pump.common.R; +import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R; /** * Created by andy on 5/19/18. diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusActivity.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusActivity.java index 882f7a84ca..beff5bb026 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusActivity.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusActivity.java @@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog; import android.os.Bundle; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentPagerAdapter; @@ -10,16 +11,14 @@ import androidx.viewpager.widget.ViewPager; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.tabs.TabLayout; -import androidx.annotation.NonNull; - import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import info.nightscout.androidaps.activities.NoSplashAppCompatActivity; -import info.nightscout.androidaps.plugins.pump.common.R; import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface; +import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R; import info.nightscout.androidaps.utils.resources.ResourceHelper; public class RileyLinkStatusActivity extends NoSplashAppCompatActivity { diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusDevice.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusDevice.java index 3faff82981..8bc967bd9f 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusDevice.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusDevice.java @@ -15,14 +15,11 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import info.nightscout.androidaps.plugins.pump.common.R; import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface; +import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.CommandValueDefinition; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.CommandValueDefinitionType; -//import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.CommandValueDefinition; -//import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem; -//import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.CommandValueDefinitionType; -//import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil; + /** * Created by andy on 5/19/18. @@ -140,7 +137,7 @@ public class RileyLinkStatusDevice extends Fragment implements RefreshableInterf viewHolder.itemValue = view.findViewById(R.id.rileylink_device_action); view.setTag(viewHolder); } else { - viewHolder = (RileyLinkStatusDevice.ViewHolder)view.getTag(); + viewHolder = (RileyLinkStatusDevice.ViewHolder) view.getTag(); } // Z // RLHistoryItem item = historyItemList.get(i); diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java index 2ae48e3f5a..7ab6625951 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java @@ -15,8 +15,8 @@ import javax.inject.Inject; import dagger.android.support.DaggerFragment; import info.nightscout.androidaps.interfaces.ActivePlugin; import info.nightscout.androidaps.logging.AAPSLogger; -import info.nightscout.androidaps.plugins.pump.common.R; import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface; +import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpInfo; diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusHistoryFragment.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusHistoryFragment.java index 452c99f905..7ae38c4d58 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusHistoryFragment.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusHistoryFragment.java @@ -6,11 +6,10 @@ import android.view.View; import android.view.ViewGroup; import android.widget.TextView; +import androidx.annotation.NonNull; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import androidx.annotation.NonNull; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -18,9 +17,9 @@ import java.util.List; import javax.inject.Inject; import dagger.android.support.DaggerFragment; -import info.nightscout.androidaps.plugins.pump.common.R; import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState; import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface; +import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem; import info.nightscout.androidaps.utils.DateUtil;