diff --git a/app/build.gradle b/app/build.gradle index 4447768343..55ea40dc6e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -111,7 +111,7 @@ android { versionCode 1500 version "omnipod-0.1-SNAPSHOT" buildConfigField "String", "VERSION", '"' + version + '"' - buildConfigField "String", "DEV_VERSION", "2.6-dev" + buildConfigField "String", "DEV_VERSION", '"2.6-dev"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"' buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"' diff --git a/app/libs/com.atech-software.android.library.wizardpager-1.1.0.aar b/app/libs/com.atech-software.android.library.wizardpager-1.1.0.aar index ab5d7f1c98..6da42c6033 100644 Binary files a/app/libs/com.atech-software.android.library.wizardpager-1.1.0.aar and b/app/libs/com.atech-software.android.library.wizardpager-1.1.0.aar differ diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index 372a6f9872..0ff5bab74d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -139,6 +139,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump if (omnipodCommunicationManager == null) { omnipodCommunicationManager = AapsOmnipodManager.getInstance(); omnipodCommunicationManager.setPumpStatus(pumpStatusLocal); + } else { + omnipodCommunicationManager.setPumpStatus(pumpStatusLocal); } omnipodUIComm = new OmnipodUIComm(omnipodCommunicationManager, plugin, pumpStatusLocal); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt index b1f7333d50..2507909651 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt @@ -12,7 +12,9 @@ import info.nightscout.androidaps.activities.NoSplashActivity import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitPodCancelAction import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitPodWizardModel +import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.InitPodRefreshAction import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.removepod.RemovePodWizardModel +import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil import info.nightscout.androidaps.utils.OKDialog import kotlinx.android.synthetic.main.omnipod_pod_mgmt.* @@ -42,6 +44,8 @@ class PodManagementActivity : NoSplashActivity() { showPodHistory() } + refreshButtons(); + } @@ -50,13 +54,15 @@ class PodManagementActivity : NoSplashActivity() { // TODO check if RL is running and that pod is not active val pagerSettings = WizardPagerSettings() + var refreshAction = InitPodRefreshAction(this) pagerSettings.setWizardStepsWayType(WizardStepsWayType.CancelNext) pagerSettings.setFinishStringResourceId(R.string.close) pagerSettings.setFinishButtonBackground(R.drawable.finish_background) pagerSettings.setNextButtonBackground(R.drawable.selectable_item_background) pagerSettings.setBackStringResourceId(R.string.cancel) - pagerSettings.setCancelAction(InitPodCancelAction()) + pagerSettings.cancelAction = refreshAction + pagerSettings.finishAction = refreshAction val wizardPagerContext = WizardPagerContext.getInstance(); @@ -72,13 +78,15 @@ class PodManagementActivity : NoSplashActivity() { // TODO check that pod is active val pagerSettings = WizardPagerSettings() + var refreshAction = InitPodRefreshAction(this) pagerSettings.setWizardStepsWayType(WizardStepsWayType.CancelNext) pagerSettings.setFinishStringResourceId(R.string.close) pagerSettings.setFinishButtonBackground(R.drawable.finish_background) pagerSettings.setNextButtonBackground(R.drawable.selectable_item_background) pagerSettings.setBackStringResourceId(R.string.cancel) - //pagerSettings.setCancelAction(InitPodCancelAction()) + pagerSettings.cancelAction = refreshAction + pagerSettings.finishAction = refreshAction val wizardPagerContext = WizardPagerContext.getInstance(); @@ -105,4 +113,14 @@ class PodManagementActivity : NoSplashActivity() { MainApp.gs(R.string.omnipod_cmd_pod_history_na), null) } + + fun refreshButtons() { + + val isPodSessionActive = (OmnipodUtil.getPodSessionState()!=null) + + initpod_init_pod.isEnabled = !isPodSessionActive + initpod_remove_pod.isEnabled = isPodSessionActive + initpod_reset_pod.isEnabled = isPodSessionActive + } + } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodCancelAction.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodCancelAction.java index b1ecc9bc7f..ac46854646 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodCancelAction.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodCancelAction.java @@ -15,8 +15,10 @@ public class InitPodCancelAction extends AbstractCancelAction { } if (this.cancelActionText.equals("Cancel")) { - AapsOmnipodManager.getInstance().resetPodStatus(); + //AapsOmnipodManager.getInstance().resetPodStatus(); } + //refreshButtons() + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java new file mode 100644 index 0000000000..3e340c4474 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java @@ -0,0 +1,41 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages; + +import com.atech.android.library.wizardpager.defs.action.AbstractCancelAction; +import com.atech.android.library.wizardpager.defs.action.FinishActionInterface; + +import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity; + +/** + * Created by andy on 12/11/2019 + */ +public class InitPodRefreshAction extends AbstractCancelAction implements FinishActionInterface { + + private PodManagementActivity podManagementActivity; + + public InitPodRefreshAction(PodManagementActivity podManagementActivity) { + this.podManagementActivity = podManagementActivity; + } + + @Override + public void execute(String cancelReason) { + if (cancelReason != null && cancelReason.trim().length() > 0) { + this.cancelActionText = cancelReason; + } + + if (this.cancelActionText.equals("Cancel")) { + //AapsOmnipodManager.getInstance().resetPodStatus(); + } + + podManagementActivity.refreshButtons(); + } + + @Override + public void execute() { + podManagementActivity.refreshButtons(); + } + + @Override + public String getFinishActionText() { + return "Finish_OK"; + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java index fdd8787806..051a5c64c1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java @@ -29,7 +29,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalSchedu import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalScheduleEntry; import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState; import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodDbEntryType; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistoryEntryType; import info.nightscout.androidaps.plugins.pump.omnipod.exception.ActionInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.exception.CommandInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.exception.CommunicationException; @@ -308,7 +308,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface } - private void addToHistory(long requestTime, PodDbEntryType entryType, String data, boolean success) { + private void addToHistory(long requestTime, PodHistoryEntryType entryType, String data, boolean success) { // TODO andy needs to be refactored //PodDbEntry entry = new PodDbEntry(requestTime, entryType); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodDbEntry.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodDbEntry.java deleted file mode 100644 index e39994cb19..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodDbEntry.java +++ /dev/null @@ -1,70 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.driver.db; - -import info.nightscout.androidaps.db.DbObjectBase; - -/** - * Created by andy on 24.11.2019 - */ -public class PodDbEntry implements DbObjectBase { - - private long dateTime; - private PodDbEntryType podDbEntryType; - private String data; - private boolean success; - private long pumpId; - private Boolean successConfirmed; - - //private String request; - //private long dateTimeResponse; - //private String response; - - - public PodDbEntry(PodDbEntryType podDbEntryType) { - this.dateTime = System.currentTimeMillis(); - this.podDbEntryType = podDbEntryType; - generatePumpId(); - } - - - public PodDbEntry(long requestTime, PodDbEntryType podDbEntryType) { - this.dateTime = requestTime; - this.podDbEntryType = podDbEntryType; - generatePumpId(); - } - - - - public long getDateTime() { - return dateTime; - } - - public void setDateTime(long dateTime) { - this.dateTime = dateTime; - } - - public PodDbEntryType getPodDbEntryType() { - return podDbEntryType; - } - - public void setPodDbEntryType(PodDbEntryType podDbEntryType) { - this.podDbEntryType = podDbEntryType; - } - - - @Override - public long getDate() { - return this.dateTime; - } - - @Override - public long getPumpId() { - return pumpId; - } - - private void generatePumpId() { - // TODO - // yyyymmddhhMMssxx (time and xx is code of podDbEntryType) - } - - -} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistory.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistory.java index 863236fdd8..a5e1c3e66c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistory.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistory.java @@ -22,7 +22,7 @@ public class PodHistory implements DbObjectBase { @DatabaseField(id = true) public long date; - private PodDbEntryType podDbEntryType; + private PodHistoryEntryType podHistoryEntryType; @DatabaseField private long podEntryTypeCode; @@ -36,21 +36,26 @@ public class PodHistory implements DbObjectBase { @DatabaseField private long pumpId; + @DatabaseField + private String podSerial; + @DatabaseField private Boolean successConfirmed; - public PodHistory(PodDbEntryType podDbEntryType) { + public PodHistory(PodHistoryEntryType podDbEntryType) { this.date = System.currentTimeMillis(); - this.podDbEntryType = podDbEntryType; + this.podHistoryEntryType = podDbEntryType; + this.podEntryTypeCode = podDbEntryType.getCode(); generatePumpId(); } - public PodHistory(long dateTimeInMillis, PodDbEntryType podDbEntryType) { + public PodHistory(long dateTimeInMillis, PodHistoryEntryType podDbEntryType) { this.date = dateTimeInMillis; - this.podDbEntryType = podDbEntryType; + this.podHistoryEntryType = podDbEntryType; + this.podEntryTypeCode = podDbEntryType.getCode(); generatePumpId(); } @@ -64,12 +69,12 @@ public class PodHistory implements DbObjectBase { this.date = date; } - public PodDbEntryType getPodDbEntryType() { - return podDbEntryType; + public PodHistoryEntryType getPodDbEntryType() { + return podHistoryEntryType; } - public void setPodDbEntryType(PodDbEntryType podDbEntryType) { - this.podDbEntryType = podDbEntryType; + public void setPodDbEntryType(PodHistoryEntryType podDbEntryType) { + this.podHistoryEntryType = podDbEntryType; this.podEntryTypeCode = podDbEntryType.getCode(); } @@ -115,4 +120,11 @@ public class PodHistory implements DbObjectBase { } + public String getPodSerial() { + return podSerial; + } + + public void setPodSerial(String podSerial) { + this.podSerial = podSerial; + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodDbEntryType.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistoryEntryType.java similarity index 62% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodDbEntryType.java rename to app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistoryEntryType.java index 1c9ce1af62..23039668ad 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodDbEntryType.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistoryEntryType.java @@ -1,9 +1,12 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.db; +import java.util.HashMap; +import java.util.Map; + /** * Created by andy on 24.11.2019 */ -public enum PodDbEntryType { +public enum PodHistoryEntryType { PairAndPrime(1), InsertCannula(2), @@ -29,9 +32,19 @@ public enum PodDbEntryType { ; private int code; + private static Map instanceMap; - PodDbEntryType(int code) { + static { + instanceMap = new HashMap<>(); + + for (PodHistoryEntryType value : values()) { + instanceMap.put(value.code, value); + } + } + + + PodHistoryEntryType(int code) { this.code = code; }