- extended ErrorDialog to support adding to clipboard

- changed PodDebug code to send code there...
- fixed Bolus code
This commit is contained in:
Andy Rozman 2019-12-30 18:34:49 +01:00
parent b463f915e1
commit 17ab0db4c3
6 changed files with 34 additions and 9 deletions

View file

@ -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)

View file

@ -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)) {

View file

@ -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");
}

View file

@ -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);
}

View file

@ -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();
}
}

View file

@ -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];