diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/ErrorDialog.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/ErrorDialog.kt index 8ea499d4ef..e37864c820 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/ErrorDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/ErrorDialog.kt @@ -1,6 +1,9 @@ package info.nightscout.androidaps.plugins.general.overview.dialogs +import android.content.ClipData +import android.content.ClipboardManager +import android.content.Context import android.content.Intent import android.os.Build import android.os.Bundle @@ -13,6 +16,7 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.services.AlarmSoundService import kotlinx.android.synthetic.main.overview_error_dialog.* import org.slf4j.LoggerFactory +import java.util.* class ErrorDialog : DialogFragment() { private val log = LoggerFactory.getLogger(ErrorDialog::class.java) @@ -21,6 +25,7 @@ class ErrorDialog : DialogFragment() { var status: String = "" var title: String = "" var sound: Int = 0 + var clipboardContent: String = "" override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { @@ -46,9 +51,18 @@ class ErrorDialog : DialogFragment() { log.debug("Error dialog mute button pressed") stopAlarm() } + copyToClipboard() startAlarm() } + private fun copyToClipboard() { + if (clipboardContent.length > 0) { + val clipboard = MainApp.instance().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + val clip = ClipData.newPlainText(UUID.randomUUID().toString(), clipboardContent) + clipboard.primaryClip = clip + } + } + override fun onSaveInstanceState(bundle: Bundle) { super.onSaveInstanceState(bundle) bundle.putString("status", status) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/ErrorHelperActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/ErrorHelperActivity.kt index 15840d3499..276dfb2a6c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/ErrorHelperActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/ErrorHelperActivity.kt @@ -16,6 +16,7 @@ class ErrorHelperActivity : NoSplashAppCompatActivity() { errorDialog.status = intent.getStringExtra("status") errorDialog.sound = intent.getIntExtra("soundid", R.raw.error) errorDialog.title = intent.getStringExtra("title") + errorDialog.clipboardContent = intent.getStringExtra("clipboardContent") errorDialog.show(supportFragmentManager, "Error") if (SP.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) { 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 5b8f8667df..2ec7952cad 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 @@ -9,10 +9,14 @@ import android.content.ServiceConnection; import android.os.Bundle; import android.os.IBinder; import android.os.SystemClock; +import android.view.View; import androidx.annotation.NonNull; +import com.tech.freak.wizardpager.model.Page; + import org.joda.time.LocalDateTime; +import org.mozilla.javascript.tools.jsc.Main; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,6 +27,7 @@ import java.util.GregorianCalendar; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.UUID; import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.MainApp; @@ -41,6 +46,7 @@ import info.nightscout.androidaps.plugins.bus.RxBus; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; 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.OverviewPlugin; import info.nightscout.androidaps.plugins.general.overview.dialogs.ErrorHelperActivity; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; @@ -387,14 +393,11 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump } else { LOG.warn("Result was NOT null."); - ClipboardManager clipboard = (ClipboardManager) MainApp.instance().getSystemService(Context.CLIPBOARD_SERVICE); - ClipData clip = ClipData.newPlainText("PodInfoRecentPulseLog", result.toString()); - clipboard.setPrimaryClip(clip); - Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class); - i.putExtra("soundid", R.raw.boluserror); + i.putExtra("soundid", 0); i.putExtra("status", "Pulse Log (copied to clipboard):\n" + result.toString()); i.putExtra("title", MainApp.gs(R.string.combo_warning)); + i.putExtra("clipboardContent", result.toString()); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); MainApp.instance().startActivity(i); @@ -655,11 +658,11 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump PumpEnactResult result = responseTask.getResult(); - setRefreshButtonEnabled(true); + //setRefreshButtonEnabled(true); LOG.info(getLogPrefix() + "stopBolusDelivering - wasSuccess={}", result.success); - finishAction("Bolus"); + //finishAction("Bolus"); } 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 ca67490122..ff73d899c8 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 @@ -290,6 +290,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface bolusStarted = new Date(); } catch (Exception ex) { String comment = handleAndTranslateException(ex); + addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.SetBolus, comment); return new PumpEnactResult().success(false).enacted(false).comment(comment); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIPostprocessor.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIPostprocessor.java index 4f5ba5d896..c86db544b8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIPostprocessor.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIPostprocessor.java @@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory; import java.util.Date; +import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin; @@ -41,11 +42,13 @@ public class OmnipodUIPostprocessor { PumpEnactResult result = uiTask.returnData; + DetailedBolusInfo detailedBolusInfo = (DetailedBolusInfo)uiTask.getObjectFromParameters(0); + if (result.success) { - boolean isSmb = uiTask.getBooleanFromParameters(1); + boolean isSmb = detailedBolusInfo.isSMB; if (!isSmb) { - pumpStatus.lastBolusAmount = uiTask.getDoubleFromParameters(0); + pumpStatus.lastBolusAmount = detailedBolusInfo.insulin; pumpStatus.lastBolusTime = new Date(); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUITask.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUITask.java index e7dce48a5c..527c8f9b62 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUITask.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUITask.java @@ -153,6 +153,9 @@ public class OmnipodUITask { return (Float) parameters[index]; } + public Object getObjectFromParameters(int index) { + return parameters[index]; + } public Double getDoubleFromParameters(int index) { return (Double) parameters[index];