- extended ErrorDialog to support adding to clipboard
- changed PodDebug code to send code there... - fixed Bolus code
This commit is contained in:
parent
b463f915e1
commit
17ab0db4c3
|
@ -1,6 +1,9 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview.dialogs
|
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.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
@ -13,6 +16,7 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.services.AlarmSoundService
|
import info.nightscout.androidaps.services.AlarmSoundService
|
||||||
import kotlinx.android.synthetic.main.overview_error_dialog.*
|
import kotlinx.android.synthetic.main.overview_error_dialog.*
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
class ErrorDialog : DialogFragment() {
|
class ErrorDialog : DialogFragment() {
|
||||||
private val log = LoggerFactory.getLogger(ErrorDialog::class.java)
|
private val log = LoggerFactory.getLogger(ErrorDialog::class.java)
|
||||||
|
@ -21,6 +25,7 @@ class ErrorDialog : DialogFragment() {
|
||||||
var status: String = ""
|
var status: String = ""
|
||||||
var title: String = ""
|
var title: String = ""
|
||||||
var sound: Int = 0
|
var sound: Int = 0
|
||||||
|
var clipboardContent: String = ""
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?): View? {
|
savedInstanceState: Bundle?): View? {
|
||||||
|
@ -46,9 +51,18 @@ class ErrorDialog : DialogFragment() {
|
||||||
log.debug("Error dialog mute button pressed")
|
log.debug("Error dialog mute button pressed")
|
||||||
stopAlarm()
|
stopAlarm()
|
||||||
}
|
}
|
||||||
|
copyToClipboard()
|
||||||
startAlarm()
|
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) {
|
override fun onSaveInstanceState(bundle: Bundle) {
|
||||||
super.onSaveInstanceState(bundle)
|
super.onSaveInstanceState(bundle)
|
||||||
bundle.putString("status", status)
|
bundle.putString("status", status)
|
||||||
|
|
|
@ -16,6 +16,7 @@ class ErrorHelperActivity : NoSplashAppCompatActivity() {
|
||||||
errorDialog.status = intent.getStringExtra("status")
|
errorDialog.status = intent.getStringExtra("status")
|
||||||
errorDialog.sound = intent.getIntExtra("soundid", R.raw.error)
|
errorDialog.sound = intent.getIntExtra("soundid", R.raw.error)
|
||||||
errorDialog.title = intent.getStringExtra("title")
|
errorDialog.title = intent.getStringExtra("title")
|
||||||
|
errorDialog.clipboardContent = intent.getStringExtra("clipboardContent")
|
||||||
errorDialog.show(supportFragmentManager, "Error")
|
errorDialog.show(supportFragmentManager, "Error")
|
||||||
|
|
||||||
if (SP.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) {
|
if (SP.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) {
|
||||||
|
|
|
@ -9,10 +9,14 @@ import android.content.ServiceConnection;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.tech.freak.wizardpager.model.Page;
|
||||||
|
|
||||||
import org.joda.time.LocalDateTime;
|
import org.joda.time.LocalDateTime;
|
||||||
|
import org.mozilla.javascript.tools.jsc.Main;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -23,6 +27,7 @@ import java.util.GregorianCalendar;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
import info.nightscout.androidaps.BuildConfig;
|
||||||
import info.nightscout.androidaps.MainApp;
|
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.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
||||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
|
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.dialogs.ErrorHelperActivity;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||||
|
@ -387,14 +393,11 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
} else {
|
} else {
|
||||||
LOG.warn("Result was NOT null.");
|
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);
|
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("status", "Pulse Log (copied to clipboard):\n" + result.toString());
|
||||||
i.putExtra("title", MainApp.gs(R.string.combo_warning));
|
i.putExtra("title", MainApp.gs(R.string.combo_warning));
|
||||||
|
i.putExtra("clipboardContent", result.toString());
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
MainApp.instance().startActivity(i);
|
MainApp.instance().startActivity(i);
|
||||||
|
|
||||||
|
@ -655,11 +658,11 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
PumpEnactResult result = responseTask.getResult();
|
PumpEnactResult result = responseTask.getResult();
|
||||||
|
|
||||||
setRefreshButtonEnabled(true);
|
//setRefreshButtonEnabled(true);
|
||||||
|
|
||||||
LOG.info(getLogPrefix() + "stopBolusDelivering - wasSuccess={}", result.success);
|
LOG.info(getLogPrefix() + "stopBolusDelivering - wasSuccess={}", result.success);
|
||||||
|
|
||||||
finishAction("Bolus");
|
//finishAction("Bolus");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -290,6 +290,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
||||||
bolusStarted = new Date();
|
bolusStarted = new Date();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
String comment = handleAndTranslateException(ex);
|
String comment = handleAndTranslateException(ex);
|
||||||
|
addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.SetBolus, comment);
|
||||||
return new PumpEnactResult().success(false).enacted(false).comment(comment);
|
return new PumpEnactResult().success(false).enacted(false).comment(comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
||||||
|
@ -41,11 +42,13 @@ public class OmnipodUIPostprocessor {
|
||||||
|
|
||||||
PumpEnactResult result = uiTask.returnData;
|
PumpEnactResult result = uiTask.returnData;
|
||||||
|
|
||||||
|
DetailedBolusInfo detailedBolusInfo = (DetailedBolusInfo)uiTask.getObjectFromParameters(0);
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
boolean isSmb = uiTask.getBooleanFromParameters(1);
|
boolean isSmb = detailedBolusInfo.isSMB;
|
||||||
|
|
||||||
if (!isSmb) {
|
if (!isSmb) {
|
||||||
pumpStatus.lastBolusAmount = uiTask.getDoubleFromParameters(0);
|
pumpStatus.lastBolusAmount = detailedBolusInfo.insulin;
|
||||||
pumpStatus.lastBolusTime = new Date();
|
pumpStatus.lastBolusTime = new Date();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,6 +153,9 @@ public class OmnipodUITask {
|
||||||
return (Float) parameters[index];
|
return (Float) parameters[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object getObjectFromParameters(int index) {
|
||||||
|
return parameters[index];
|
||||||
|
}
|
||||||
|
|
||||||
public Double getDoubleFromParameters(int index) {
|
public Double getDoubleFromParameters(int index) {
|
||||||
return (Double) parameters[index];
|
return (Double) parameters[index];
|
||||||
|
|
Loading…
Reference in a new issue