more AAPSLogger and ResourceHelper injections
This commit is contained in:
parent
1ab0938a38
commit
2b62f801c5
|
@ -5,6 +5,7 @@ import dagger.android.ContributesAndroidInjector
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.services.NSClientService
|
import info.nightscout.androidaps.plugins.general.nsclient.services.NSClientService
|
||||||
import info.nightscout.androidaps.plugins.general.persistentNotification.DummyService
|
import info.nightscout.androidaps.plugins.general.persistentNotification.DummyService
|
||||||
import info.nightscout.androidaps.plugins.general.wear.wearintegration.WatchUpdaterService
|
import info.nightscout.androidaps.plugins.general.wear.wearintegration.WatchUpdaterService
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkService
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.services.AbstractDanaRExecutionService
|
import info.nightscout.androidaps.plugins.pump.danaR.services.AbstractDanaRExecutionService
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.services.DanaRExecutionService
|
import info.nightscout.androidaps.plugins.pump.danaR.services.DanaRExecutionService
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRKorean.services.DanaRKoreanExecutionService
|
import info.nightscout.androidaps.plugins.pump.danaRKorean.services.DanaRKoreanExecutionService
|
||||||
|
@ -12,6 +13,7 @@ import info.nightscout.androidaps.plugins.pump.danaRS.services.DanaRSService
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRv2.services.DanaRv2ExecutionService
|
import info.nightscout.androidaps.plugins.pump.danaRv2.services.DanaRv2ExecutionService
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.InsightAlertService
|
import info.nightscout.androidaps.plugins.pump.insight.InsightAlertService
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.connection_service.InsightConnectionService
|
import info.nightscout.androidaps.plugins.pump.insight.connection_service.InsightConnectionService
|
||||||
|
import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService
|
||||||
import info.nightscout.androidaps.services.AlarmSoundService
|
import info.nightscout.androidaps.services.AlarmSoundService
|
||||||
import info.nightscout.androidaps.services.DataService
|
import info.nightscout.androidaps.services.DataService
|
||||||
import info.nightscout.androidaps.services.LocationService
|
import info.nightscout.androidaps.services.LocationService
|
||||||
|
@ -33,4 +35,6 @@ abstract class ServicesModule {
|
||||||
@ContributesAndroidInjector abstract fun contributesWatchUpdaterService(): WatchUpdaterService
|
@ContributesAndroidInjector abstract fun contributesWatchUpdaterService(): WatchUpdaterService
|
||||||
@ContributesAndroidInjector abstract fun contributesInsightAlertService(): InsightAlertService
|
@ContributesAndroidInjector abstract fun contributesInsightAlertService(): InsightAlertService
|
||||||
@ContributesAndroidInjector abstract fun contributesInsightConnectionService(): InsightConnectionService
|
@ContributesAndroidInjector abstract fun contributesInsightConnectionService(): InsightConnectionService
|
||||||
|
@ContributesAndroidInjector abstract fun contributesRileyLinkService(): RileyLinkService
|
||||||
|
@ContributesAndroidInjector abstract fun contributesRileyLinkMedtronicService(): RileyLinkMedtronicService
|
||||||
}
|
}
|
|
@ -12,6 +12,7 @@ interface AAPSLogger {
|
||||||
fun debug(tag: LTag, format: String, vararg arguments: Any?)
|
fun debug(tag: LTag, format: String, vararg arguments: Any?)
|
||||||
fun warn(tag: LTag, message: String)
|
fun warn(tag: LTag, message: String)
|
||||||
fun info(tag: LTag, message: String)
|
fun info(tag: LTag, message: String)
|
||||||
|
fun info(tag: LTag, format: String, vararg arguments: Any?)
|
||||||
fun error(tag: LTag, message: String)
|
fun error(tag: LTag, message: String)
|
||||||
fun error(tag: LTag, message: String, throwable: Throwable)
|
fun error(tag: LTag, message: String, throwable: Throwable)
|
||||||
fun error(tag: LTag, format: String, vararg arguments: Any?)
|
fun error(tag: LTag, format: String, vararg arguments: Any?)
|
||||||
|
|
|
@ -32,6 +32,10 @@ class AAPSLoggerDebug : AAPSLogger {
|
||||||
Log.i(tag.tag, message)
|
Log.i(tag.tag, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun info(tag: LTag, format: String, vararg arguments: Any?) {
|
||||||
|
Log.i(tag.tag, String.format(format, arguments))
|
||||||
|
}
|
||||||
|
|
||||||
override fun error(tag: LTag, message: String) {
|
override fun error(tag: LTag, message: String) {
|
||||||
Log.e(tag.tag, message)
|
Log.e(tag.tag, message)
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,10 @@ class AAPSLoggerProduction : AAPSLogger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun info(tag: LTag, format: String, vararg arguments: Any?) {
|
||||||
|
LoggerFactory.getLogger(tag.tag).info(stackLogMarker() + String.format(format, arguments))
|
||||||
|
}
|
||||||
|
|
||||||
override fun error(tag: LTag, message: String) {
|
override fun error(tag: LTag, message: String) {
|
||||||
if (L.isEnabled(tag.tag)) {
|
if (L.isEnabled(tag.tag)) {
|
||||||
LoggerFactory.getLogger(tag.tag).error(stackLogMarker() + message)
|
LoggerFactory.getLogger(tag.tag).error(stackLogMarker() + message)
|
||||||
|
|
|
@ -21,7 +21,6 @@ import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector;
|
import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.MealData;
|
import info.nightscout.androidaps.data.MealData;
|
||||||
|
@ -37,6 +36,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.SafeParse;
|
import info.nightscout.androidaps.utils.SafeParse;
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
public class DetermineBasalAdapterSMBJS {
|
public class DetermineBasalAdapterSMBJS {
|
||||||
|
@ -44,6 +44,7 @@ public class DetermineBasalAdapterSMBJS {
|
||||||
@Inject AAPSLogger aapsLogger;
|
@Inject AAPSLogger aapsLogger;
|
||||||
@Inject ConstraintChecker constraintChecker;
|
@Inject ConstraintChecker constraintChecker;
|
||||||
@Inject SP sp;
|
@Inject SP sp;
|
||||||
|
@Inject ResourceHelper resourceHelper;
|
||||||
@Inject ProfileFunction profileFunction;
|
@Inject ProfileFunction profileFunction;
|
||||||
@Inject TreatmentsPlugin treatmentsPlugin;
|
@Inject TreatmentsPlugin treatmentsPlugin;
|
||||||
|
|
||||||
|
@ -265,7 +266,7 @@ public class DetermineBasalAdapterSMBJS {
|
||||||
mProfile.put("enableUAM", uamAllowed);
|
mProfile.put("enableUAM", uamAllowed);
|
||||||
mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable);
|
mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable);
|
||||||
|
|
||||||
boolean smbEnabled = sp.getBoolean(MainApp.gs(R.string.key_use_smb), false);
|
boolean smbEnabled = sp.getBoolean(resourceHelper.gs(R.string.key_use_smb), false);
|
||||||
mProfile.put("enableSMB_with_COB", smbEnabled && sp.getBoolean(R.string.key_enableSMB_with_COB, false));
|
mProfile.put("enableSMB_with_COB", smbEnabled && sp.getBoolean(R.string.key_enableSMB_with_COB, false));
|
||||||
mProfile.put("enableSMB_with_temptarget", smbEnabled && sp.getBoolean(R.string.key_enableSMB_with_temptarget, false));
|
mProfile.put("enableSMB_with_temptarget", smbEnabled && sp.getBoolean(R.string.key_enableSMB_with_temptarget, false));
|
||||||
mProfile.put("allowSMB_with_high_temptarget", smbEnabled && sp.getBoolean(R.string.key_allowSMB_with_high_temptarget, false));
|
mProfile.put("allowSMB_with_high_temptarget", smbEnabled && sp.getBoolean(R.string.key_allowSMB_with_high_temptarget, false));
|
||||||
|
|
|
@ -15,7 +15,6 @@ import java.util.List;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector;
|
import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
|
@ -141,7 +140,7 @@ public abstract class Objective {
|
||||||
;
|
;
|
||||||
|
|
||||||
public String getProgress() {
|
public String getProgress() {
|
||||||
return MainApp.gs(isCompleted() ? R.string.completed_well_done : R.string.not_completed_yet);
|
return resourceHelper.gs(isCompleted() ? R.string.completed_well_done : R.string.not_completed_yet);
|
||||||
}
|
}
|
||||||
|
|
||||||
Task hint(Hint hint) {
|
Task hint(Hint hint) {
|
||||||
|
|
|
@ -16,9 +16,8 @@ import android.widget.TextView;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.android.support.DaggerFragment;
|
import dagger.android.support.DaggerFragment;
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientNewLog;
|
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientNewLog;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart;
|
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientUpdateGUI;
|
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientUpdateGUI;
|
||||||
|
@ -33,6 +32,8 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
|
||||||
@Inject NSClientPlugin nsClientPlugin;
|
@Inject NSClientPlugin nsClientPlugin;
|
||||||
@Inject SP sp;
|
@Inject SP sp;
|
||||||
@Inject ResourceHelper resourceHelper;
|
@Inject ResourceHelper resourceHelper;
|
||||||
|
@Inject RxBusWrapper rxBus;
|
||||||
|
@Inject FabricPrivacy fabricPrivacy;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
|
@ -54,31 +55,31 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.nsclientinternal_fragment, container, false);
|
View view = inflater.inflate(R.layout.nsclientinternal_fragment, container, false);
|
||||||
|
|
||||||
logScrollview = (ScrollView) view.findViewById(R.id.nsclientinternal_logscrollview);
|
logScrollview = view.findViewById(R.id.nsclientinternal_logscrollview);
|
||||||
autoscrollCheckbox = (CheckBox) view.findViewById(R.id.nsclientinternal_autoscroll);
|
autoscrollCheckbox = view.findViewById(R.id.nsclientinternal_autoscroll);
|
||||||
autoscrollCheckbox.setChecked(nsClientPlugin.autoscroll);
|
autoscrollCheckbox.setChecked(nsClientPlugin.autoscroll);
|
||||||
autoscrollCheckbox.setOnCheckedChangeListener(this);
|
autoscrollCheckbox.setOnCheckedChangeListener(this);
|
||||||
pausedCheckbox = (CheckBox) view.findViewById(R.id.nsclientinternal_paused);
|
pausedCheckbox = view.findViewById(R.id.nsclientinternal_paused);
|
||||||
pausedCheckbox.setChecked(nsClientPlugin.paused);
|
pausedCheckbox.setChecked(nsClientPlugin.paused);
|
||||||
pausedCheckbox.setOnCheckedChangeListener(this);
|
pausedCheckbox.setOnCheckedChangeListener(this);
|
||||||
logTextView = (TextView) view.findViewById(R.id.nsclientinternal_log);
|
logTextView = view.findViewById(R.id.nsclientinternal_log);
|
||||||
queueTextView = (TextView) view.findViewById(R.id.nsclientinternal_queue);
|
queueTextView = view.findViewById(R.id.nsclientinternal_queue);
|
||||||
urlTextView = (TextView) view.findViewById(R.id.nsclientinternal_url);
|
urlTextView = view.findViewById(R.id.nsclientinternal_url);
|
||||||
statusTextView = (TextView) view.findViewById(R.id.nsclientinternal_status);
|
statusTextView = view.findViewById(R.id.nsclientinternal_status);
|
||||||
|
|
||||||
clearlog = (TextView) view.findViewById(R.id.nsclientinternal_clearlog);
|
clearlog = view.findViewById(R.id.nsclientinternal_clearlog);
|
||||||
clearlog.setOnClickListener(this);
|
clearlog.setOnClickListener(this);
|
||||||
clearlog.setPaintFlags(clearlog.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
clearlog.setPaintFlags(clearlog.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
restart = (TextView) view.findViewById(R.id.nsclientinternal_restart);
|
restart = view.findViewById(R.id.nsclientinternal_restart);
|
||||||
restart.setOnClickListener(this);
|
restart.setOnClickListener(this);
|
||||||
restart.setPaintFlags(restart.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
restart.setPaintFlags(restart.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
delivernow = (TextView) view.findViewById(R.id.nsclientinternal_delivernow);
|
delivernow = view.findViewById(R.id.nsclientinternal_delivernow);
|
||||||
delivernow.setOnClickListener(this);
|
delivernow.setOnClickListener(this);
|
||||||
delivernow.setPaintFlags(delivernow.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
delivernow.setPaintFlags(delivernow.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
clearqueue = (TextView) view.findViewById(R.id.nsclientinternal_clearqueue);
|
clearqueue = view.findViewById(R.id.nsclientinternal_clearqueue);
|
||||||
clearqueue.setOnClickListener(this);
|
clearqueue.setOnClickListener(this);
|
||||||
clearqueue.setPaintFlags(clearqueue.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
clearqueue.setPaintFlags(clearqueue.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
showqueue = (TextView) view.findViewById(R.id.nsclientinternal_showqueue);
|
showqueue = view.findViewById(R.id.nsclientinternal_showqueue);
|
||||||
showqueue.setOnClickListener(this);
|
showqueue.setOnClickListener(this);
|
||||||
showqueue.setPaintFlags(showqueue.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
showqueue.setPaintFlags(showqueue.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
|
|
||||||
|
@ -88,10 +89,10 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
|
||||||
@Override
|
@Override
|
||||||
public synchronized void onResume() {
|
public synchronized void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
disposable.add(RxBus.Companion.getINSTANCE()
|
disposable.add(rxBus
|
||||||
.toObservable(EventNSClientUpdateGUI.class)
|
.toObservable(EventNSClientUpdateGUI.class)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(event -> updateGui(), exception -> FabricPrivacy.getInstance().logException(exception))
|
.subscribe(event -> updateGui(), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
updateGui();
|
updateGui();
|
||||||
}
|
}
|
||||||
|
@ -106,25 +107,25 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
switch (view.getId()) {
|
switch (view.getId()) {
|
||||||
case R.id.nsclientinternal_restart:
|
case R.id.nsclientinternal_restart:
|
||||||
RxBus.Companion.getINSTANCE().send(new EventNSClientRestart());
|
rxBus.send(new EventNSClientRestart());
|
||||||
FabricPrivacy.getInstance().logCustom("NSClientRestart");
|
fabricPrivacy.logCustom("NSClientRestart");
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_delivernow:
|
case R.id.nsclientinternal_delivernow:
|
||||||
nsClientPlugin.resend("GUI");
|
nsClientPlugin.resend("GUI");
|
||||||
FabricPrivacy.getInstance().logCustom("NSClientDeliverNow");
|
fabricPrivacy.logCustom("NSClientDeliverNow");
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_clearlog:
|
case R.id.nsclientinternal_clearlog:
|
||||||
nsClientPlugin.clearLog();
|
nsClientPlugin.clearLog();
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_clearqueue:
|
case R.id.nsclientinternal_clearqueue:
|
||||||
OKDialog.showConfirmation(getContext(), MainApp.gs(R.string.nsclientinternal), MainApp.gs(R.string.clearqueueconfirm), () -> {
|
OKDialog.showConfirmation(getContext(), resourceHelper.gs(R.string.nsclientinternal), resourceHelper.gs(R.string.clearqueueconfirm), () -> {
|
||||||
UploadQueue.clearQueue();
|
UploadQueue.clearQueue();
|
||||||
updateGui();
|
updateGui();
|
||||||
FabricPrivacy.getInstance().logCustom("NSClientClearQueue");
|
fabricPrivacy.logCustom("NSClientClearQueue");
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_showqueue:
|
case R.id.nsclientinternal_showqueue:
|
||||||
RxBus.Companion.getINSTANCE().send(new EventNSClientNewLog("QUEUE", nsClientPlugin.queue().textList()));
|
rxBus.send(new EventNSClientNewLog("QUEUE", nsClientPlugin.queue().textList()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +136,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
|
||||||
case R.id.nsclientinternal_paused:
|
case R.id.nsclientinternal_paused:
|
||||||
nsClientPlugin.pause(isChecked);
|
nsClientPlugin.pause(isChecked);
|
||||||
updateGui();
|
updateGui();
|
||||||
FabricPrivacy.getInstance().logCustom("NSClientPause");
|
fabricPrivacy.logCustom("NSClientPause");
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_autoscroll:
|
case R.id.nsclientinternal_autoscroll:
|
||||||
sp.putBoolean(R.string.key_nsclientinternal_autoscroll, isChecked);
|
sp.putBoolean(R.string.key_nsclientinternal_autoscroll, isChecked);
|
||||||
|
|
|
@ -211,7 +211,7 @@ public class NSDeviceStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fields.contains("clock")) {
|
if (fields.contains("clock")) {
|
||||||
string.append(DateUtil.minAgo(deviceStatusPumpData.clock)).append(" ");
|
string.append(DateUtil.minAgo(resourceHelper, deviceStatusPumpData.clock)).append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fields.contains("status")) {
|
if (fields.contains("status")) {
|
||||||
|
@ -341,7 +341,7 @@ public class NSDeviceStatus {
|
||||||
if (level == Levels.URGENT) string.append("red\">");
|
if (level == Levels.URGENT) string.append("red\">");
|
||||||
|
|
||||||
if (deviceStatusOpenAPSData.clockSuggested != 0) {
|
if (deviceStatusOpenAPSData.clockSuggested != 0) {
|
||||||
string.append(DateUtil.minAgo(deviceStatusOpenAPSData.clockSuggested)).append(" ");
|
string.append(DateUtil.minAgo(resourceHelper, deviceStatusOpenAPSData.clockSuggested)).append(" ");
|
||||||
}
|
}
|
||||||
string.append("</span>"); // color
|
string.append("</span>"); // color
|
||||||
|
|
||||||
|
@ -362,9 +362,9 @@ public class NSDeviceStatus {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (deviceStatusOpenAPSData.enacted != null && deviceStatusOpenAPSData.clockEnacted != deviceStatusOpenAPSData.clockSuggested)
|
if (deviceStatusOpenAPSData.enacted != null && deviceStatusOpenAPSData.clockEnacted != deviceStatusOpenAPSData.clockSuggested)
|
||||||
string.append("<b>").append(DateUtil.minAgo(deviceStatusOpenAPSData.clockEnacted)).append("</b> ").append(deviceStatusOpenAPSData.enacted.getString("reason")).append("<br>");
|
string.append("<b>").append(DateUtil.minAgo(resourceHelper, deviceStatusOpenAPSData.clockEnacted)).append("</b> ").append(deviceStatusOpenAPSData.enacted.getString("reason")).append("<br>");
|
||||||
if (deviceStatusOpenAPSData.suggested != null)
|
if (deviceStatusOpenAPSData.suggested != null)
|
||||||
string.append("<b>").append(DateUtil.minAgo(deviceStatusOpenAPSData.clockSuggested)).append("</b> ").append(deviceStatusOpenAPSData.suggested.getString("reason")).append("<br>");
|
string.append("<b>").append(DateUtil.minAgo(resourceHelper, deviceStatusOpenAPSData.clockSuggested)).append("</b> ").append(deviceStatusOpenAPSData.suggested.getString("reason")).append("<br>");
|
||||||
return Html.fromHtml(string.toString());
|
return Html.fromHtml(string.toString());
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
aapsLogger.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
|
|
|
@ -1187,7 +1187,7 @@ public class OverviewFragment extends DaggerFragment implements View.OnClickList
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
basalText = "T: " + activeTemp.toStringVeryShort();
|
basalText = "T: " + activeTemp.toStringVeryShort();
|
||||||
} else {
|
} else {
|
||||||
basalText = MainApp.gs(R.string.pump_basebasalrate, profile.getBasal());
|
basalText = resourceHelper.gs(R.string.pump_basebasalrate, profile.getBasal());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
|
@ -1293,7 +1293,7 @@ public class OverviewFragment extends DaggerFragment implements View.OnClickList
|
||||||
bgView.setPaintFlags(flag);
|
bgView.setPaintFlags(flag);
|
||||||
|
|
||||||
if (timeAgoView != null)
|
if (timeAgoView != null)
|
||||||
timeAgoView.setText(DateUtil.minAgo(lastBG.date));
|
timeAgoView.setText(DateUtil.minAgo(resourceHelper, lastBG.date));
|
||||||
if (timeAgoShortView != null)
|
if (timeAgoShortView != null)
|
||||||
timeAgoShortView.setText("(" + DateUtil.minAgoShort(lastBG.date) + ")");
|
timeAgoShortView.setText("(" + DateUtil.minAgoShort(lastBG.date) + ")");
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ public class ComboFragment extends DaggerFragment implements View.OnClickListene
|
||||||
}
|
}
|
||||||
|
|
||||||
// last connection
|
// last connection
|
||||||
String minAgo = DateUtil.minAgo(comboPlugin.getPump().lastSuccessfulCmdTime);
|
String minAgo = DateUtil.minAgo(resourceHelper, comboPlugin.getPump().lastSuccessfulCmdTime);
|
||||||
long min = (System.currentTimeMillis() - comboPlugin.getPump().lastSuccessfulCmdTime) / 1000 / 60;
|
long min = (System.currentTimeMillis() - comboPlugin.getPump().lastSuccessfulCmdTime) / 1000 / 60;
|
||||||
if (comboPlugin.getPump().lastSuccessfulCmdTime + 60 * 1000 > System.currentTimeMillis()) {
|
if (comboPlugin.getPump().lastSuccessfulCmdTime + 60 * 1000 > System.currentTimeMillis()) {
|
||||||
lastConnectionView.setText(R.string.combo_pump_connected_now);
|
lastConnectionView.setText(R.string.combo_pump_connected_now);
|
||||||
|
@ -220,7 +220,7 @@ public class ComboFragment extends DaggerFragment implements View.OnClickListene
|
||||||
if ((agoMsc < 60 * 1000)) {
|
if ((agoMsc < 60 * 1000)) {
|
||||||
ago = resourceHelper.gs(R.string.combo_pump_connected_now);
|
ago = resourceHelper.gs(R.string.combo_pump_connected_now);
|
||||||
} else if (bolusMinAgo < 60) {
|
} else if (bolusMinAgo < 60) {
|
||||||
ago = DateUtil.minAgo(bolus.timestamp);
|
ago = DateUtil.minAgo(resourceHelper, bolus.timestamp);
|
||||||
} else {
|
} else {
|
||||||
ago = DateUtil.hourAgo(bolus.timestamp, resourceHelper);
|
ago = DateUtil.hourAgo(bolus.timestamp, resourceHelper);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,14 +25,11 @@ import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -40,11 +37,12 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
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.RileyLinkUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.GattAttributes;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.GattAttributes;
|
||||||
|
@ -52,12 +50,16 @@ import info.nightscout.androidaps.plugins.pump.common.utils.LocationHelper;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpConfigurationChanged;
|
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpConfigurationChanged;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
// IMPORTANT: This activity needs to be called from RileyLinkSelectPreference (see pref_medtronic.xml as example)
|
// IMPORTANT: This activity needs to be called from RileyLinkSelectPreference (see pref_medtronic.xml as example)
|
||||||
public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
|
public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
|
||||||
|
|
||||||
private static final Logger LOG = StacktraceLoggerWrapper.getLogger(RileyLinkBLEScanActivity.class);
|
@Inject AAPSLogger aapsLogger;
|
||||||
|
@Inject SP sp;
|
||||||
|
@Inject RxBusWrapper rxBus;
|
||||||
|
@Inject ResourceHelper resourceHelper;
|
||||||
|
|
||||||
private static final int PERMISSION_REQUEST_COARSE_LOCATION = 30241; // arbitrary.
|
private static final int PERMISSION_REQUEST_COARSE_LOCATION = 30241; // arbitrary.
|
||||||
private static final int REQUEST_ENABLE_BT = 30242; // arbitrary
|
private static final int REQUEST_ENABLE_BT = 30242; // arbitrary
|
||||||
|
@ -91,7 +93,7 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
|
||||||
mHandler = new Handler();
|
mHandler = new Handler();
|
||||||
|
|
||||||
mLeDeviceListAdapter = new LeDeviceListAdapter();
|
mLeDeviceListAdapter = new LeDeviceListAdapter();
|
||||||
listBTScan = (ListView) findViewById(R.id.rileylink_listBTScan);
|
listBTScan = findViewById(R.id.rileylink_listBTScan);
|
||||||
listBTScan.setAdapter(mLeDeviceListAdapter);
|
listBTScan.setAdapter(mLeDeviceListAdapter);
|
||||||
listBTScan.setOnItemClickListener((parent, view, position, id) -> {
|
listBTScan.setOnItemClickListener((parent, view, position, id) -> {
|
||||||
|
|
||||||
|
@ -101,22 +103,22 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
|
||||||
mLEScanner.stopScan(mScanCallback2);
|
mLEScanner.stopScan(mScanCallback2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView textview = (TextView) view.findViewById(R.id.rileylink_device_address);
|
TextView textview = view.findViewById(R.id.rileylink_device_address);
|
||||||
String bleAddress = textview.getText().toString();
|
String bleAddress = textview.getText().toString();
|
||||||
|
|
||||||
SP.putString(RileyLinkConst.Prefs.RileyLinkAddress, bleAddress);
|
sp.putString(RileyLinkConst.Prefs.RileyLinkAddress, bleAddress);
|
||||||
|
|
||||||
RileyLinkUtil.getRileyLinkSelectPreference().setSummary(bleAddress);
|
RileyLinkUtil.getRileyLinkSelectPreference().setSummary(bleAddress);
|
||||||
|
|
||||||
MedtronicPumpStatus pumpStatus = MedtronicUtil.getPumpStatus();
|
MedtronicPumpStatus pumpStatus = MedtronicUtil.getPumpStatus();
|
||||||
pumpStatus.verifyConfiguration(); // force reloading of address
|
pumpStatus.verifyConfiguration(); // force reloading of address
|
||||||
|
|
||||||
RxBus.Companion.getINSTANCE().send(new EventMedtronicPumpConfigurationChanged());
|
rxBus.send(new EventMedtronicPumpConfigurationChanged());
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
});
|
});
|
||||||
|
|
||||||
toolbarBTScan = (Toolbar) findViewById(R.id.rileylink_toolbarBTScan);
|
toolbarBTScan = findViewById(R.id.rileylink_toolbarBTScan);
|
||||||
toolbarBTScan.setTitle(R.string.rileylink_scanner_title);
|
toolbarBTScan.setTitle(R.string.rileylink_scanner_title);
|
||||||
setSupportActionBar(toolbarBTScan);
|
setSupportActionBar(toolbarBTScan);
|
||||||
|
|
||||||
|
@ -128,8 +130,8 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.menu_rileylink_ble_scan, menu);
|
getMenuInflater().inflate(R.menu.menu_rileylink_ble_scan, menu);
|
||||||
|
|
||||||
actionTitleStart = MainApp.gs(R.string.rileylink_scanner_scan_scan);
|
actionTitleStart = resourceHelper.gs(R.string.rileylink_scanner_scan_scan);
|
||||||
actionTitleStop = MainApp.gs(R.string.rileylink_scanner_scan_stop);
|
actionTitleStop = resourceHelper.gs(R.string.rileylink_scanner_scan_stop);
|
||||||
|
|
||||||
menuItem = menu.getItem(0);
|
menuItem = menu.getItem(0);
|
||||||
|
|
||||||
|
@ -272,7 +274,7 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onScanFailed(int errorCode) {
|
public void onScanFailed(int errorCode) {
|
||||||
Log.e("Scan Failed", "Error Code: " + errorCode);
|
Log.e("Scan Failed", "Error Code: " + errorCode);
|
||||||
Toast.makeText(mContext, MainApp.gs(R.string.rileylink_scanner_scanning_error, errorCode),
|
Toast.makeText(mContext, resourceHelper.gs(R.string.rileylink_scanner_scanning_error, errorCode),
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +297,7 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
|
||||||
if (mScanning) {
|
if (mScanning) {
|
||||||
mScanning = false;
|
mScanning = false;
|
||||||
mLEScanner.stopScan(mScanCallback2);
|
mLEScanner.stopScan(mScanCallback2);
|
||||||
LOG.debug("scanLeDevice: Scanning Stop");
|
aapsLogger.debug("scanLeDevice: Scanning Stop");
|
||||||
Toast.makeText(mContext, R.string.rileylink_scanner_scanning_finished, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mContext, R.string.rileylink_scanner_scanning_finished, Toast.LENGTH_SHORT).show();
|
||||||
menuItem.setTitle(actionTitleStart);
|
menuItem.setTitle(actionTitleStart);
|
||||||
}
|
}
|
||||||
|
@ -303,7 +305,7 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
|
||||||
|
|
||||||
mScanning = true;
|
mScanning = true;
|
||||||
mLEScanner.startScan(filters, settings, mScanCallback2);
|
mLEScanner.startScan(filters, settings, mScanCallback2);
|
||||||
LOG.debug("scanLeDevice: Scanning Start");
|
aapsLogger.debug("scanLeDevice: Scanning Start");
|
||||||
Toast.makeText(this, R.string.rileylink_scanner_scanning, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.rileylink_scanner_scanning, Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
menuItem.setTitle(actionTitleStop);
|
menuItem.setTitle(actionTitleStop);
|
||||||
|
@ -313,7 +315,7 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
|
||||||
mScanning = false;
|
mScanning = false;
|
||||||
mLEScanner.stopScan(mScanCallback2);
|
mLEScanner.stopScan(mScanCallback2);
|
||||||
|
|
||||||
LOG.debug("scanLeDevice: Scanning Stop");
|
aapsLogger.debug("scanLeDevice: Scanning Stop");
|
||||||
Toast.makeText(this, R.string.rileylink_scanner_scanning_finished, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.rileylink_scanner_scanning_finished, Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
menuItem.setTitle(actionTitleStart);
|
menuItem.setTitle(actionTitleStart);
|
||||||
|
@ -334,7 +336,7 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
|
||||||
mLeDevices = new ArrayList<>();
|
mLeDevices = new ArrayList<>();
|
||||||
rileyLinkDevices = new HashMap<>();
|
rileyLinkDevices = new HashMap<>();
|
||||||
mInflator = RileyLinkBLEScanActivity.this.getLayoutInflater();
|
mInflator = RileyLinkBLEScanActivity.this.getLayoutInflater();
|
||||||
currentlySelectedAddress = SP.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
currentlySelectedAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -381,8 +383,8 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
view = mInflator.inflate(R.layout.rileylink_scan_item, null);
|
view = mInflator.inflate(R.layout.rileylink_scan_item, null);
|
||||||
viewHolder = new ViewHolder();
|
viewHolder = new ViewHolder();
|
||||||
viewHolder.deviceAddress = (TextView) view.findViewById(R.id.rileylink_device_address);
|
viewHolder.deviceAddress = view.findViewById(R.id.rileylink_device_address);
|
||||||
viewHolder.deviceName = (TextView) view.findViewById(R.id.rileylink_device_name);
|
viewHolder.deviceName = view.findViewById(R.id.rileylink_device_name);
|
||||||
view.setTag(viewHolder);
|
view.setTag(viewHolder);
|
||||||
} else {
|
} else {
|
||||||
viewHolder = (ViewHolder) view.getTag();
|
viewHolder = (ViewHolder) view.getTag();
|
||||||
|
|
|
@ -14,15 +14,19 @@ import com.google.android.material.tabs.TabLayout;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
|
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData;
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
|
||||||
public class RileyLinkStatusActivity extends NoSplashAppCompatActivity {
|
public class RileyLinkStatusActivity extends NoSplashAppCompatActivity {
|
||||||
|
|
||||||
|
@Inject ResourceHelper resourceHelper;
|
||||||
|
|
||||||
TextView connectionStatus;
|
TextView connectionStatus;
|
||||||
TextView configuredAddress;
|
TextView configuredAddress;
|
||||||
TextView connectedDevice;
|
TextView connectedDevice;
|
||||||
|
@ -47,14 +51,14 @@ public class RileyLinkStatusActivity extends NoSplashAppCompatActivity {
|
||||||
// primary sections of the activity.
|
// primary sections of the activity.
|
||||||
|
|
||||||
// Set up the ViewPager with the sections adapter.
|
// Set up the ViewPager with the sections adapter.
|
||||||
mViewPager = (ViewPager) findViewById(R.id.rileylink_settings_container);
|
mViewPager = findViewById(R.id.rileylink_settings_container);
|
||||||
// mViewPager.setAdapter(mSectionsPagerAdapter);
|
// mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||||
setupViewPager(mViewPager);
|
setupViewPager(mViewPager);
|
||||||
|
|
||||||
tabLayout = (TabLayout) findViewById(R.id.rileylink_settings_tabs);
|
tabLayout = findViewById(R.id.rileylink_settings_tabs);
|
||||||
tabLayout.setupWithViewPager(mViewPager);
|
tabLayout.setupWithViewPager(mViewPager);
|
||||||
|
|
||||||
floatingActionButton = (FloatingActionButton) findViewById(R.id.rileylink_settings_fab);
|
floatingActionButton = findViewById(R.id.rileylink_settings_fab);
|
||||||
floatingActionButton.setOnClickListener(v -> {
|
floatingActionButton.setOnClickListener(v -> {
|
||||||
|
|
||||||
RefreshableInterface selectableInterface = (RefreshableInterface) mSectionsPagerAdapter
|
RefreshableInterface selectableInterface = (RefreshableInterface) mSectionsPagerAdapter
|
||||||
|
@ -110,8 +114,8 @@ public class RileyLinkStatusActivity extends NoSplashAppCompatActivity {
|
||||||
|
|
||||||
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||||
|
|
||||||
mSectionsPagerAdapter.addFragment(new RileyLinkStatusGeneral(), MainApp.gs(R.string.rileylink_settings_tab1));
|
mSectionsPagerAdapter.addFragment(new RileyLinkStatusGeneral(), resourceHelper.gs(R.string.rileylink_settings_tab1));
|
||||||
mSectionsPagerAdapter.addFragment(new RileyLinkStatusHistory(), MainApp.gs(R.string.rileylink_settings_tab2));
|
mSectionsPagerAdapter.addFragment(new RileyLinkStatusHistory(), resourceHelper.gs(R.string.rileylink_settings_tab2));
|
||||||
//mSectionsPagerAdapter.addFragment(new RileyLinkStatusDevice(), "Medtronic");
|
//mSectionsPagerAdapter.addFragment(new RileyLinkStatusDevice(), "Medtronic");
|
||||||
|
|
||||||
mViewPager.setAdapter(mSectionsPagerAdapter);
|
mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||||
|
|
|
@ -1,18 +1,15 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service;
|
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service;
|
||||||
|
|
||||||
import static info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil.getRileyLinkCommunicationManager;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import android.app.Service;
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import javax.inject.Inject;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
import dagger.android.DaggerService;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
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.RileyLinkUtil;
|
||||||
|
@ -26,33 +23,47 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
|
import static info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil.getRileyLinkCommunicationManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by andy on 5/6/18.
|
* Created by andy on 5/6/18.
|
||||||
* Split from original file and renamed.
|
* Split from original file and renamed.
|
||||||
*/
|
*/
|
||||||
public abstract class RileyLinkService extends Service {
|
public abstract class RileyLinkService extends DaggerService {
|
||||||
|
|
||||||
|
@Inject AAPSLogger aapsLogger;
|
||||||
|
@Inject SP sp;
|
||||||
|
@Inject Context context;
|
||||||
|
|
||||||
private static final Logger LOG = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public RileyLinkBLE rileyLinkBLE; // android-bluetooth management
|
public RileyLinkBLE rileyLinkBLE; // android-bluetooth management
|
||||||
protected BluetoothAdapter bluetoothAdapter;
|
protected BluetoothAdapter bluetoothAdapter;
|
||||||
protected RFSpy rfspy; // interface for RL xxx Mhz radio.
|
protected RFSpy rfspy; // interface for RL xxx Mhz radio.
|
||||||
protected Context context;
|
|
||||||
protected RileyLinkBroadcastReceiver mBroadcastReceiver;
|
protected RileyLinkBroadcastReceiver mBroadcastReceiver;
|
||||||
protected RileyLinkServiceData rileyLinkServiceData;
|
protected RileyLinkServiceData rileyLinkServiceData;
|
||||||
protected RileyLinkBluetoothStateReceiver bluetoothStateReceiver;
|
protected RileyLinkBluetoothStateReceiver bluetoothStateReceiver;
|
||||||
|
|
||||||
public RileyLinkService(Context context) {
|
@Override
|
||||||
super();
|
public void onCreate() {
|
||||||
this.context = context;
|
super.onCreate();
|
||||||
|
//LOG.debug("onCreate");
|
||||||
|
|
||||||
RileyLinkUtil.setContext(this.context);
|
RileyLinkUtil.setContext(this.context);
|
||||||
RileyLinkUtil.setRileyLinkService(this);
|
RileyLinkUtil.setRileyLinkService(this);
|
||||||
RileyLinkUtil.setEncoding(getEncoding());
|
RileyLinkUtil.setEncoding(getEncoding());
|
||||||
initRileyLinkServiceData();
|
initRileyLinkServiceData();
|
||||||
}
|
|
||||||
|
|
||||||
|
mBroadcastReceiver = new RileyLinkBroadcastReceiver(this, this.context);
|
||||||
|
mBroadcastReceiver.registerBroadcasts();
|
||||||
|
|
||||||
|
|
||||||
|
bluetoothStateReceiver = new RileyLinkBluetoothStateReceiver();
|
||||||
|
bluetoothStateReceiver.registerBroadcasts(this);
|
||||||
|
|
||||||
|
//LOG.debug("onCreate(): It's ALIVE!");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Encoding for RileyLink communication
|
* Get Encoding for RileyLink communication
|
||||||
|
@ -68,14 +79,14 @@ public abstract class RileyLinkService extends Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onUnbind(Intent intent) {
|
public boolean onUnbind(Intent intent) {
|
||||||
//LOG.warn("onUnbind");
|
//aapsLogger.warn(LTag.PUMPCOMM, "onUnbind");
|
||||||
return super.onUnbind(intent);
|
return super.onUnbind(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRebind(Intent intent) {
|
public void onRebind(Intent intent) {
|
||||||
//LOG.warn("onRebind");
|
//aapsLogger.warn(LTag.PUMPCOMM, "onRebind");
|
||||||
super.onRebind(intent);
|
super.onRebind(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,33 +101,17 @@ public abstract class RileyLinkService extends Service {
|
||||||
rileyLinkBLE = null;
|
rileyLinkBLE = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mBroadcastReceiver!=null) {
|
if (mBroadcastReceiver != null) {
|
||||||
mBroadcastReceiver.unregisterBroadcasts();
|
mBroadcastReceiver.unregisterBroadcasts();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bluetoothStateReceiver!=null) {
|
if (bluetoothStateReceiver != null) {
|
||||||
bluetoothStateReceiver.unregisterBroadcasts(this);
|
bluetoothStateReceiver.unregisterBroadcasts(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate() {
|
|
||||||
super.onCreate();
|
|
||||||
//LOG.debug("onCreate");
|
|
||||||
|
|
||||||
mBroadcastReceiver = new RileyLinkBroadcastReceiver(this, this.context);
|
|
||||||
mBroadcastReceiver.registerBroadcasts();
|
|
||||||
|
|
||||||
|
|
||||||
bluetoothStateReceiver = new RileyLinkBluetoothStateReceiver();
|
|
||||||
bluetoothStateReceiver.registerBroadcasts(this);
|
|
||||||
|
|
||||||
//LOG.debug("onCreate(): It's ALIVE!");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefix for Device specific broadcast identifier prefix (for example MSG_PUMP_ for pump or
|
* Prefix for Device specific broadcast identifier prefix (for example MSG_PUMP_ for pump or
|
||||||
* MSG_POD_ for Omnipod)
|
* MSG_POD_ for Omnipod)
|
||||||
|
@ -145,19 +140,18 @@ public abstract class RileyLinkService extends Service {
|
||||||
|
|
||||||
|
|
||||||
public boolean bluetoothInit() {
|
public boolean bluetoothInit() {
|
||||||
if (isLogEnabled())
|
aapsLogger.debug(LTag.PUMPCOMM, "bluetoothInit: attempting to get an adapter");
|
||||||
LOG.debug("bluetoothInit: attempting to get an adapter");
|
|
||||||
RileyLinkUtil.setServiceState(RileyLinkServiceState.BluetoothInitializing);
|
RileyLinkUtil.setServiceState(RileyLinkServiceState.BluetoothInitializing);
|
||||||
|
|
||||||
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
|
||||||
if (bluetoothAdapter == null) {
|
if (bluetoothAdapter == null) {
|
||||||
LOG.error("Unable to obtain a BluetoothAdapter.");
|
aapsLogger.error("Unable to obtain a BluetoothAdapter.");
|
||||||
RileyLinkUtil.setServiceState(RileyLinkServiceState.BluetoothError, RileyLinkError.NoBluetoothAdapter);
|
RileyLinkUtil.setServiceState(RileyLinkServiceState.BluetoothError, RileyLinkError.NoBluetoothAdapter);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (!bluetoothAdapter.isEnabled()) {
|
if (!bluetoothAdapter.isEnabled()) {
|
||||||
LOG.error("Bluetooth is not enabled.");
|
aapsLogger.error("Bluetooth is not enabled.");
|
||||||
RileyLinkUtil.setServiceState(RileyLinkServiceState.BluetoothError, RileyLinkError.BluetoothDisabled);
|
RileyLinkUtil.setServiceState(RileyLinkServiceState.BluetoothError, RileyLinkError.BluetoothDisabled);
|
||||||
} else {
|
} else {
|
||||||
RileyLinkUtil.setServiceState(RileyLinkServiceState.BluetoothReady);
|
RileyLinkUtil.setServiceState(RileyLinkServiceState.BluetoothReady);
|
||||||
|
@ -181,13 +175,11 @@ public abstract class RileyLinkService extends Service {
|
||||||
|
|
||||||
if (rileyLinkBLE.isConnected()) {
|
if (rileyLinkBLE.isConnected()) {
|
||||||
if (deviceAddress.equals(rileyLinkServiceData.rileylinkAddress)) {
|
if (deviceAddress.equals(rileyLinkServiceData.rileylinkAddress)) {
|
||||||
if (isLogEnabled())
|
aapsLogger.info(LTag.PUMPCOMM, "No change to RL address. Not reconnecting.");
|
||||||
LOG.info("No change to RL address. Not reconnecting.");
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (isLogEnabled())
|
aapsLogger.warn(LTag.PUMPCOMM, "Disconnecting from old RL (" + rileyLinkServiceData.rileylinkAddress
|
||||||
LOG.warn("Disconnecting from old RL (" + rileyLinkServiceData.rileylinkAddress
|
+ "), reconnecting to new: " + deviceAddress);
|
||||||
+ "), reconnecting to new: " + deviceAddress);
|
|
||||||
|
|
||||||
rileyLinkBLE.disconnect();
|
rileyLinkBLE.disconnect();
|
||||||
// prolly need to shut down listening thread too?
|
// prolly need to shut down listening thread too?
|
||||||
|
@ -198,12 +190,11 @@ public abstract class RileyLinkService extends Service {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isLogEnabled())
|
aapsLogger.debug(LTag.PUMPCOMM, "Using RL " + deviceAddress);
|
||||||
LOG.debug("Using RL " + deviceAddress);
|
|
||||||
|
|
||||||
if (RileyLinkUtil.getServiceState() == RileyLinkServiceState.NotStarted) {
|
if (RileyLinkUtil.getServiceState() == RileyLinkServiceState.NotStarted) {
|
||||||
if (!bluetoothInit()) {
|
if (!bluetoothInit()) {
|
||||||
LOG.error("RileyLink can't get activated, Bluetooth is not functioning correctly. {}",
|
aapsLogger.error("RileyLink can't get activated, Bluetooth is not functioning correctly. {}",
|
||||||
RileyLinkUtil.getError() != null ? RileyLinkUtil.getError().name() : "Unknown error (null)");
|
RileyLinkUtil.getError() != null ? RileyLinkUtil.getError().name() : "Unknown error (null)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -229,7 +220,7 @@ public abstract class RileyLinkService extends Service {
|
||||||
double lastGoodFrequency = 0.0d;
|
double lastGoodFrequency = 0.0d;
|
||||||
|
|
||||||
if (rileyLinkServiceData.lastGoodFrequency == null) {
|
if (rileyLinkServiceData.lastGoodFrequency == null) {
|
||||||
lastGoodFrequency = SP.getDouble(RileyLinkConst.Prefs.LastGoodDeviceFrequency, 0.0d);
|
lastGoodFrequency = sp.getDouble(RileyLinkConst.Prefs.LastGoodDeviceFrequency, 0.0d);
|
||||||
} else {
|
} else {
|
||||||
lastGoodFrequency = rileyLinkServiceData.lastGoodFrequency;
|
lastGoodFrequency = rileyLinkServiceData.lastGoodFrequency;
|
||||||
}
|
}
|
||||||
|
@ -239,9 +230,8 @@ public abstract class RileyLinkService extends Service {
|
||||||
newFrequency = getDeviceCommunicationManager().tuneForDevice();
|
newFrequency = getDeviceCommunicationManager().tuneForDevice();
|
||||||
|
|
||||||
if ((newFrequency != 0.0) && (newFrequency != lastGoodFrequency)) {
|
if ((newFrequency != 0.0) && (newFrequency != lastGoodFrequency)) {
|
||||||
if (isLogEnabled())
|
aapsLogger.info(LTag.PUMPCOMM, "Saving new pump frequency of {} MHz", newFrequency);
|
||||||
LOG.info("Saving new pump frequency of {} MHz", newFrequency);
|
sp.putDouble(RileyLinkConst.Prefs.LastGoodDeviceFrequency, newFrequency);
|
||||||
SP.putDouble(RileyLinkConst.Prefs.LastGoodDeviceFrequency, newFrequency);
|
|
||||||
rileyLinkServiceData.lastGoodFrequency = newFrequency;
|
rileyLinkServiceData.lastGoodFrequency = newFrequency;
|
||||||
rileyLinkServiceData.tuneUpDone = true;
|
rileyLinkServiceData.tuneUpDone = true;
|
||||||
rileyLinkServiceData.lastTuneUpTime = System.currentTimeMillis();
|
rileyLinkServiceData.lastTuneUpTime = System.currentTimeMillis();
|
||||||
|
@ -277,11 +267,6 @@ public abstract class RileyLinkService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean isLogEnabled() {
|
|
||||||
return L.isEnabled(L.PUMPCOMM);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void changeRileyLinkEncoding(RileyLinkEncodingType encodingType) {
|
public void changeRileyLinkEncoding(RileyLinkEncodingType encodingType) {
|
||||||
if (rfspy != null) {
|
if (rfspy != null) {
|
||||||
rfspy.setRileyLinkEncoding(encodingType);
|
rfspy.setRileyLinkEncoding(encodingType);
|
||||||
|
|
|
@ -257,7 +257,7 @@ class MedtronicFragment : DaggerFragment() {
|
||||||
|
|
||||||
// last connection
|
// last connection
|
||||||
if (pumpStatus.lastConnection != 0L) {
|
if (pumpStatus.lastConnection != 0L) {
|
||||||
val minAgo = DateUtil.minAgo(pumpStatus.lastConnection)
|
val minAgo = DateUtil.minAgo(resourceHelper, pumpStatus.lastConnection)
|
||||||
val min = (System.currentTimeMillis() - pumpStatus.lastConnection) / 1000 / 60
|
val min = (System.currentTimeMillis() - pumpStatus.lastConnection) / 1000 / 60
|
||||||
if (pumpStatus.lastConnection + 60 * 1000 > System.currentTimeMillis()) {
|
if (pumpStatus.lastConnection + 60 * 1000 > System.currentTimeMillis()) {
|
||||||
medtronic_lastconnection.setText(R.string.combo_pump_connected_now)
|
medtronic_lastconnection.setText(R.string.combo_pump_connected_now)
|
||||||
|
@ -295,7 +295,7 @@ class MedtronicFragment : DaggerFragment() {
|
||||||
if (agoMsc < 60 * 1000) {
|
if (agoMsc < 60 * 1000) {
|
||||||
ago = resourceHelper.gs(R.string.combo_pump_connected_now)
|
ago = resourceHelper.gs(R.string.combo_pump_connected_now)
|
||||||
} else if (bolusMinAgo < 60) {
|
} else if (bolusMinAgo < 60) {
|
||||||
ago = DateUtil.minAgo(pumpStatus.lastBolusTime.time)
|
ago = DateUtil.minAgo(resourceHelper, pumpStatus.lastBolusTime.time)
|
||||||
} else {
|
} else {
|
||||||
ago = DateUtil.hourAgo(pumpStatus.lastBolusTime.time, resourceHelper)
|
ago = DateUtil.hourAgo(pumpStatus.lastBolusTime.time, resourceHelper)
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
medtronicUIComm = new MedtronicUIComm();
|
medtronicUIComm = new MedtronicUIComm(aapsLogger, rxBus, getResourceHelper());
|
||||||
medtronicHistoryData = new MedtronicHistoryData(aapsLogger, sp, activePlugin);
|
medtronicHistoryData = new MedtronicHistoryData(aapsLogger, sp, activePlugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,12 +432,12 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
|
|
||||||
if (isPumpNotReachable()) {
|
if (isPumpNotReachable()) {
|
||||||
aapsLogger.error("Pump unreachable.");
|
aapsLogger.error("Pump unreachable.");
|
||||||
MedtronicUtil.sendNotification(MedtronicNotificationType.PumpUnreachable);
|
MedtronicUtil.sendNotification(MedtronicNotificationType.PumpUnreachable, getResourceHelper(), rxBus);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
|
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable, rxBus);
|
||||||
|
|
||||||
|
|
||||||
if (hasTimeDateOrTimeZoneChanged) {
|
if (hasTimeDateOrTimeZoneChanged) {
|
||||||
|
@ -532,14 +532,14 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
if (isRefresh) {
|
if (isRefresh) {
|
||||||
if (isPumpNotReachable()) {
|
if (isPumpNotReachable()) {
|
||||||
aapsLogger.error(getLogPrefix() + "initializePump::Pump unreachable.");
|
aapsLogger.error(getLogPrefix() + "initializePump::Pump unreachable.");
|
||||||
MedtronicUtil.sendNotification(MedtronicNotificationType.PumpUnreachable);
|
MedtronicUtil.sendNotification(MedtronicNotificationType.PumpUnreachable, getResourceHelper(), rxBus);
|
||||||
|
|
||||||
setRefreshButtonEnabled(true);
|
setRefreshButtonEnabled(true);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
|
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable, rxBus);
|
||||||
}
|
}
|
||||||
|
|
||||||
// model (once)
|
// model (once)
|
||||||
|
@ -548,7 +548,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
} else {
|
} else {
|
||||||
if (pumpStatusLocal.medtronicDeviceType != MedtronicUtil.getMedtronicPumpModel()) {
|
if (pumpStatusLocal.medtronicDeviceType != MedtronicUtil.getMedtronicPumpModel()) {
|
||||||
aapsLogger.warn(LTag.PUMP, getLogPrefix() + "Configured pump is not the same as one detected.");
|
aapsLogger.warn(LTag.PUMP, getLogPrefix() + "Configured pump is not the same as one detected.");
|
||||||
MedtronicUtil.sendNotification(MedtronicNotificationType.PumpTypeNotSame);
|
MedtronicUtil.sendNotification(MedtronicNotificationType.PumpTypeNotSame, getResourceHelper(), rxBus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -737,7 +737,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
|
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable, rxBus);
|
||||||
|
|
||||||
medtronicUIComm.executeCommand(MedtronicCommandType.GetRealTimeClock);
|
medtronicUIComm.executeCommand(MedtronicCommandType.GetRealTimeClock);
|
||||||
|
|
||||||
|
@ -769,7 +769,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
} else {
|
} else {
|
||||||
if ((clock.localDeviceTime.getYear() > 2015)) {
|
if ((clock.localDeviceTime.getYear() > 2015)) {
|
||||||
aapsLogger.error("MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference over 24h requested [diff={}]. Doing nothing." + timeDiff);
|
aapsLogger.error("MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference over 24h requested [diff={}]. Doing nothing." + timeDiff);
|
||||||
sendNotification(MedtronicNotificationType.TimeChangeOver24h);
|
sendNotification(MedtronicNotificationType.TimeChangeOver24h, getResourceHelper(), rxBus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -806,7 +806,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
return setNotReachable(true, false);
|
return setNotReachable(true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
|
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable, rxBus);
|
||||||
|
|
||||||
if (bolusDeliveryType == BolusDeliveryType.CancelDelivery) {
|
if (bolusDeliveryType == BolusDeliveryType.CancelDelivery) {
|
||||||
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Delivery Canceled.");
|
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Delivery Canceled.");
|
||||||
|
@ -957,7 +957,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
.comment(getResourceHelper().gs(R.string.medtronic_pump_status_pump_unreachable));
|
.comment(getResourceHelper().gs(R.string.medtronic_pump_status_pump_unreachable));
|
||||||
}
|
}
|
||||||
|
|
||||||
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
|
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable, rxBus);
|
||||||
|
|
||||||
getMDTPumpStatus();
|
getMDTPumpStatus();
|
||||||
|
|
||||||
|
@ -1344,7 +1344,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
.comment(getResourceHelper().gs(R.string.medtronic_pump_status_pump_unreachable));
|
.comment(getResourceHelper().gs(R.string.medtronic_pump_status_pump_unreachable));
|
||||||
}
|
}
|
||||||
|
|
||||||
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
|
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable, rxBus);
|
||||||
setRefreshButtonEnabled(false);
|
setRefreshButtonEnabled(false);
|
||||||
|
|
||||||
TempBasalPair tbrCurrent = readTBR();
|
TempBasalPair tbrCurrent = readTBR();
|
||||||
|
@ -1427,7 +1427,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
.comment(getResourceHelper().gs(R.string.medtronic_pump_status_pump_unreachable));
|
.comment(getResourceHelper().gs(R.string.medtronic_pump_status_pump_unreachable));
|
||||||
}
|
}
|
||||||
|
|
||||||
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
|
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable, rxBus);
|
||||||
|
|
||||||
BasalProfile basalProfile = convertProfileToMedtronicProfile(profile);
|
BasalProfile basalProfile = convertProfileToMedtronicProfile(profile);
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,35 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.ui;
|
package info.nightscout.androidaps.plugins.pump.medtronic.comm.ui;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
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.RileyLinkUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager;
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType;
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by andy on 6/14/18.
|
* Created by andy on 6/14/18.
|
||||||
*/
|
*/
|
||||||
public class MedtronicUIComm {
|
public class MedtronicUIComm {
|
||||||
|
|
||||||
private static final Logger LOG = StacktraceLoggerWrapper.getLogger(L.PUMP);
|
private final AAPSLogger aapsLogger;
|
||||||
|
|
||||||
MedtronicCommunicationManager mcmInstance = null;
|
MedtronicCommunicationManager mcmInstance = null;
|
||||||
MedtronicUIPostprocessor uiPostprocessor = new MedtronicUIPostprocessor();
|
MedtronicUIPostprocessor uiPostprocessor;
|
||||||
|
|
||||||
|
public MedtronicUIComm(
|
||||||
|
AAPSLogger aapsLogger,
|
||||||
|
RxBusWrapper rxBus,
|
||||||
|
ResourceHelper resourceHelper
|
||||||
|
) {
|
||||||
|
this.aapsLogger = aapsLogger;
|
||||||
|
|
||||||
|
uiPostprocessor = new MedtronicUIPostprocessor(aapsLogger, rxBus, resourceHelper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private MedtronicCommunicationManager getCommunicationManager() {
|
private MedtronicCommunicationManager getCommunicationManager() {
|
||||||
|
@ -34,7 +44,7 @@ public class MedtronicUIComm {
|
||||||
public synchronized MedtronicUITask executeCommand(MedtronicCommandType commandType, Object... parameters) {
|
public synchronized MedtronicUITask executeCommand(MedtronicCommandType commandType, Object... parameters) {
|
||||||
|
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.warn("Execute Command: " + commandType.name());
|
aapsLogger.warn(LTag.PUMP, "Execute Command: " + commandType.name());
|
||||||
|
|
||||||
MedtronicUITask task = new MedtronicUITask(commandType, parameters);
|
MedtronicUITask task = new MedtronicUITask(commandType, parameters);
|
||||||
|
|
||||||
|
@ -69,7 +79,7 @@ public class MedtronicUIComm {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (!task.isReceived() && isLogEnabled()) {
|
if (!task.isReceived() && isLogEnabled()) {
|
||||||
LOG.warn("Reply not received for " + commandType);
|
aapsLogger.warn(LTag.PUMP, "Reply not received for " + commandType);
|
||||||
}
|
}
|
||||||
|
|
||||||
task.postProcess(uiPostprocessor);
|
task.postProcess(uiPostprocessor);
|
||||||
|
|
|
@ -2,14 +2,13 @@ package info.nightscout.androidaps.plugins.pump.medtronic.comm.ui;
|
||||||
|
|
||||||
import org.joda.time.DateTimeZone;
|
import org.joda.time.DateTimeZone;
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BasalProfile;
|
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BasalProfile;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BatteryStatusDTO;
|
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BatteryStatusDTO;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.ClockDTO;
|
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.ClockDTO;
|
||||||
|
@ -19,6 +18,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicNotificat
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicUIResponseType;
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicUIResponseType;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
|
||||||
import static info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil.sendNotification;
|
import static info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil.sendNotification;
|
||||||
|
|
||||||
|
@ -26,14 +26,21 @@ import static info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUt
|
||||||
* Created by andy on 6/15/18.
|
* Created by andy on 6/15/18.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MedtronicUIPostprocessor {
|
class MedtronicUIPostprocessor {
|
||||||
|
|
||||||
private static final Logger LOG = StacktraceLoggerWrapper.getLogger(L.PUMP);
|
private final AAPSLogger aapsLogger;
|
||||||
|
private final RxBusWrapper rxBus;
|
||||||
MedtronicPumpStatus pumpStatus;
|
private final ResourceHelper resourceHelper;
|
||||||
|
|
||||||
|
|
||||||
public MedtronicUIPostprocessor() {
|
private MedtronicPumpStatus pumpStatus;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public MedtronicUIPostprocessor(AAPSLogger aapsLogger, RxBusWrapper rxBus, ResourceHelper resourceHelper) {
|
||||||
|
this.aapsLogger = aapsLogger;
|
||||||
|
this.rxBus = rxBus;
|
||||||
|
this.resourceHelper = resourceHelper;
|
||||||
pumpStatus = MedtronicUtil.getPumpStatus();
|
pumpStatus = MedtronicUtil.getPumpStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,10 +74,10 @@ public class MedtronicUIPostprocessor {
|
||||||
} else {
|
} else {
|
||||||
uiTask.responseType = MedtronicUIResponseType.Error;
|
uiTask.responseType = MedtronicUIResponseType.Error;
|
||||||
uiTask.errorDescription = "No profile found.";
|
uiTask.errorDescription = "No profile found.";
|
||||||
LOG.error("Basal Profile was NOT valid. [{}]", basalProfile.basalProfileToStringError());
|
aapsLogger.error("Basal Profile was NOT valid. [{}]", basalProfile.basalProfileToStringError());
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LOG.error("Basal Profile was returned, but was invalid. [{}]", basalProfile.basalProfileToStringError());
|
aapsLogger.error("Basal Profile was returned, but was invalid. [{}]", basalProfile.basalProfileToStringError());
|
||||||
uiTask.responseType = MedtronicUIResponseType.Error;
|
uiTask.responseType = MedtronicUIResponseType.Error;
|
||||||
uiTask.errorDescription = "No profile found.";
|
uiTask.errorDescription = "No profile found.";
|
||||||
}
|
}
|
||||||
|
@ -103,8 +110,7 @@ public class MedtronicUIPostprocessor {
|
||||||
case SetRealTimeClock: {
|
case SetRealTimeClock: {
|
||||||
boolean response = (Boolean) uiTask.returnData;
|
boolean response = (Boolean) uiTask.returnData;
|
||||||
|
|
||||||
if (isLogEnabled())
|
aapsLogger.debug(LTag.PUMP, "New time was {} set.", response ? "" : "NOT");
|
||||||
LOG.debug("New time was {} set.", response ? "" : "NOT");
|
|
||||||
|
|
||||||
if (response) {
|
if (response) {
|
||||||
MedtronicUtil.getPumpTime().timeDifference = 0;
|
MedtronicUtil.getPumpTime().timeDifference = 0;
|
||||||
|
@ -122,17 +128,15 @@ public class MedtronicUIPostprocessor {
|
||||||
pumpStatus.batteryVoltage = batteryStatusDTO.voltage;
|
pumpStatus.batteryVoltage = batteryStatusDTO.voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLogEnabled())
|
aapsLogger.debug(LTag.PUMP, "BatteryStatus: {}", batteryStatusDTO.toString());
|
||||||
LOG.info("BatteryStatus: {}", batteryStatusDTO.toString());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PumpModel: {
|
case PumpModel: {
|
||||||
if (pumpStatus.medtronicDeviceType != MedtronicUtil.getMedtronicPumpModel()) {
|
if (pumpStatus.medtronicDeviceType != MedtronicUtil.getMedtronicPumpModel()) {
|
||||||
if (isLogEnabled())
|
aapsLogger.warn(LTag.PUMP, "Configured pump is different then pump detected !");
|
||||||
LOG.warn("Configured pump is different then pump detected !");
|
sendNotification(MedtronicNotificationType.PumpTypeNotSame, resourceHelper, rxBus);
|
||||||
sendNotification(MedtronicNotificationType.PumpTypeNotSame);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -146,8 +150,7 @@ public class MedtronicUIPostprocessor {
|
||||||
// no postprocessing
|
// no postprocessing
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (isLogEnabled())
|
aapsLogger.error(LTag.PUMP, "Post-processing not implemented for {}.", uiTask.commandType.name());
|
||||||
LOG.trace("Post-processing not implemented for {}.", uiTask.commandType.name());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,9 +168,8 @@ public class MedtronicUIPostprocessor {
|
||||||
|
|
||||||
MedtronicUtil.setPumpTime(clockDTO);
|
MedtronicUtil.setPumpTime(clockDTO);
|
||||||
|
|
||||||
if (isLogEnabled())
|
aapsLogger.debug(LTag.PUMP, "Pump Time: " + clockDTO.localDeviceTime + ", DeviceTime=" + clockDTO.pumpTime + //
|
||||||
LOG.debug("Pump Time: " + clockDTO.localDeviceTime + ", DeviceTime=" + clockDTO.pumpTime + //
|
", diff: " + dur.getStandardSeconds() + " s");
|
||||||
", diff: " + dur.getStandardSeconds() + " s");
|
|
||||||
|
|
||||||
// if (dur.getStandardMinutes() >= 10) {
|
// if (dur.getStandardMinutes() >= 10) {
|
||||||
// if (isLogEnabled())
|
// if (isLogEnabled())
|
||||||
|
@ -193,28 +195,24 @@ public class MedtronicUIPostprocessor {
|
||||||
PumpSettingDTO checkValue = null;
|
PumpSettingDTO checkValue = null;
|
||||||
|
|
||||||
if (pumpStatus == null) {
|
if (pumpStatus == null) {
|
||||||
if (isLogEnabled())
|
aapsLogger.debug(LTag.PUMP, "Pump Status: was null");
|
||||||
LOG.debug("Pump Status: was null");
|
|
||||||
pumpStatus = MedtronicUtil.getPumpStatus();
|
pumpStatus = MedtronicUtil.getPumpStatus();
|
||||||
if (isLogEnabled())
|
aapsLogger.debug(LTag.PUMP, "Pump Status: " + this.pumpStatus);
|
||||||
LOG.debug("Pump Status: " + this.pumpStatus);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pumpStatus.verifyConfiguration();
|
this.pumpStatus.verifyConfiguration();
|
||||||
|
|
||||||
// check profile
|
// check profile
|
||||||
if (!"Yes".equals(settings.get("PCFG_BASAL_PROFILES_ENABLED").value)) {
|
if (!"Yes".equals(settings.get("PCFG_BASAL_PROFILES_ENABLED").value)) {
|
||||||
if (isLogEnabled())
|
aapsLogger.error(LTag.PUMP, "Basal profiles are not enabled on pump.");
|
||||||
LOG.error("Basal profiles are not enabled on pump.");
|
sendNotification(MedtronicNotificationType.PumpBasalProfilesNotEnabled, resourceHelper, rxBus);
|
||||||
sendNotification(MedtronicNotificationType.PumpBasalProfilesNotEnabled);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
checkValue = settings.get("PCFG_ACTIVE_BASAL_PROFILE");
|
checkValue = settings.get("PCFG_ACTIVE_BASAL_PROFILE");
|
||||||
|
|
||||||
if (!"STD".equals(checkValue.value)) {
|
if (!"STD".equals(checkValue.value)) {
|
||||||
if (isLogEnabled())
|
aapsLogger.error("Basal profile set on pump is incorrect (must be STD).");
|
||||||
LOG.error("Basal profile set on pump is incorrect (must be STD).");
|
sendNotification(MedtronicNotificationType.PumpIncorrectBasalProfileSelected, resourceHelper, rxBus);
|
||||||
sendNotification(MedtronicNotificationType.PumpIncorrectBasalProfileSelected);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,9 +221,8 @@ public class MedtronicUIPostprocessor {
|
||||||
checkValue = settings.get("PCFG_TEMP_BASAL_TYPE");
|
checkValue = settings.get("PCFG_TEMP_BASAL_TYPE");
|
||||||
|
|
||||||
if (!"Units".equals(checkValue.value)) {
|
if (!"Units".equals(checkValue.value)) {
|
||||||
if (isLogEnabled())
|
aapsLogger.error("Wrong TBR type set on pump (must be Absolute).");
|
||||||
LOG.error("Wrong TBR type set on pump (must be Absolute).");
|
sendNotification(MedtronicNotificationType.PumpWrongTBRTypeSet, resourceHelper, rxBus);
|
||||||
sendNotification(MedtronicNotificationType.PumpWrongTBRTypeSet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MAXes
|
// MAXes
|
||||||
|
@ -233,22 +230,16 @@ public class MedtronicUIPostprocessor {
|
||||||
checkValue = settings.get("PCFG_MAX_BOLUS");
|
checkValue = settings.get("PCFG_MAX_BOLUS");
|
||||||
|
|
||||||
if (!MedtronicUtil.isSame(Double.parseDouble(checkValue.value), pumpStatus.maxBolus)) {
|
if (!MedtronicUtil.isSame(Double.parseDouble(checkValue.value), pumpStatus.maxBolus)) {
|
||||||
LOG.error("Wrong Max Bolus set on Pump (current={}, required={}).", checkValue.value, pumpStatus.maxBolus);
|
aapsLogger.error("Wrong Max Bolus set on Pump (current={}, required={}).", checkValue.value, pumpStatus.maxBolus);
|
||||||
sendNotification(MedtronicNotificationType.PumpWrongMaxBolusSet, pumpStatus.maxBolus);
|
sendNotification(MedtronicNotificationType.PumpWrongMaxBolusSet, resourceHelper, rxBus, pumpStatus.maxBolus);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkValue = settings.get("PCFG_MAX_BASAL");
|
checkValue = settings.get("PCFG_MAX_BASAL");
|
||||||
|
|
||||||
if (!MedtronicUtil.isSame(Double.parseDouble(checkValue.value), pumpStatus.maxBasal)) {
|
if (!MedtronicUtil.isSame(Double.parseDouble(checkValue.value), pumpStatus.maxBasal)) {
|
||||||
if (isLogEnabled())
|
aapsLogger.error("Wrong Max Basal set on Pump (current={}, required={}).", checkValue.value, pumpStatus.maxBasal);
|
||||||
LOG.error("Wrong Max Basal set on Pump (current={}, required={}).", checkValue.value, pumpStatus.maxBasal);
|
sendNotification(MedtronicNotificationType.PumpWrongMaxBasalSet, resourceHelper, rxBus, pumpStatus.maxBasal);
|
||||||
sendNotification(MedtronicNotificationType.PumpWrongMaxBasalSet, pumpStatus.maxBasal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isLogEnabled() {
|
|
||||||
return L.isEnabled(L.PUMP);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,23 +13,20 @@ import android.widget.TextView;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntryGroup;
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntryGroup;
|
||||||
|
|
||||||
public class MedtronicHistoryActivity extends NoSplashAppCompatActivity {
|
public class MedtronicHistoryActivity extends NoSplashAppCompatActivity {
|
||||||
|
|
||||||
private static Logger LOG = StacktraceLoggerWrapper.getLogger(L.PUMP);
|
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
||||||
|
|
||||||
Spinner historyTypeSpinner;
|
Spinner historyTypeSpinner;
|
||||||
TextView statusView;
|
TextView statusView;
|
||||||
|
@ -46,17 +43,12 @@ public class MedtronicHistoryActivity extends NoSplashAppCompatActivity {
|
||||||
List<TypeList> typeListFull;
|
List<TypeList> typeListFull;
|
||||||
|
|
||||||
|
|
||||||
public MedtronicHistoryActivity() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void filterHistory(PumpHistoryEntryGroup group) {
|
private void filterHistory(PumpHistoryEntryGroup group) {
|
||||||
|
|
||||||
this.filteredHistoryList.clear();
|
this.filteredHistoryList.clear();
|
||||||
|
|
||||||
List<PumpHistoryEntry> list = new ArrayList<>();
|
List<PumpHistoryEntry> list = new ArrayList<>();
|
||||||
list.addAll(MedtronicPumpPlugin.getPlugin().getMedtronicHistoryData().getAllHistory());
|
list.addAll(medtronicPumpPlugin.getMedtronicHistoryData().getAllHistory());
|
||||||
|
|
||||||
//LOG.debug("Items on full list: {}", list.size());
|
//LOG.debug("Items on full list: {}", list.size());
|
||||||
|
|
||||||
|
@ -113,9 +105,9 @@ public class MedtronicHistoryActivity extends NoSplashAppCompatActivity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.medtronic_history_activity);
|
setContentView(R.layout.medtronic_history_activity);
|
||||||
|
|
||||||
historyTypeSpinner = (Spinner) findViewById(R.id.medtronic_historytype);
|
historyTypeSpinner = findViewById(R.id.medtronic_historytype);
|
||||||
statusView = (TextView) findViewById(R.id.medtronic_historystatus);
|
statusView = findViewById(R.id.medtronic_historystatus);
|
||||||
recyclerView = (RecyclerView) findViewById(R.id.medtronic_history_recyclerview);
|
recyclerView = findViewById(R.id.medtronic_history_recyclerview);
|
||||||
|
|
||||||
recyclerView.setHasFixedSize(true);
|
recyclerView.setHasFixedSize(true);
|
||||||
llm = new LinearLayoutManager(this);
|
llm = new LinearLayoutManager(this);
|
||||||
|
@ -245,9 +237,9 @@ public class MedtronicHistoryActivity extends NoSplashAppCompatActivity {
|
||||||
HistoryViewHolder(View itemView) {
|
HistoryViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
// cv = (CardView)itemView.findViewById(R.id.rileylink_history_item);
|
// cv = (CardView)itemView.findViewById(R.id.rileylink_history_item);
|
||||||
timeView = (TextView) itemView.findViewById(R.id.medtronic_history_time);
|
timeView = itemView.findViewById(R.id.medtronic_history_time);
|
||||||
typeView = (TextView) itemView.findViewById(R.id.medtronic_history_source);
|
typeView = itemView.findViewById(R.id.medtronic_history_source);
|
||||||
valueView = (TextView) itemView.findViewById(R.id.medtronic_history_description);
|
valueView = itemView.findViewById(R.id.medtronic_history_description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.service;
|
package info.nightscout.androidaps.plugins.pump.medtronic.service;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import javax.inject.Inject;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
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.RileyLinkUtil;
|
||||||
|
@ -30,14 +29,17 @@ import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RileyLinkMedtronicService is intended to stay running when the gui-app is closed.
|
* RileyLinkMedtronicService is intended to stay running when the gui-app is closed.
|
||||||
*/
|
*/
|
||||||
public class RileyLinkMedtronicService extends RileyLinkService {
|
public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
|
|
||||||
private static final Logger LOG = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
@Inject AAPSLogger aapsLogger;
|
||||||
|
@Inject Context context;
|
||||||
|
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
||||||
|
@Inject SP sp;
|
||||||
|
|
||||||
private static RileyLinkMedtronicService instance;
|
private static RileyLinkMedtronicService instance;
|
||||||
private static ServiceTask currentTask = null;
|
private static ServiceTask currentTask = null;
|
||||||
|
@ -49,12 +51,11 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
|
|
||||||
|
|
||||||
public RileyLinkMedtronicService() {
|
public RileyLinkMedtronicService() {
|
||||||
super(MainApp.instance().getApplicationContext());
|
super();
|
||||||
instance = this;
|
instance = this;
|
||||||
if (isLogEnabled())
|
aapsLogger.debug(LTag.PUMPCOMM, "RileyLinkMedtronicService newly constructed");
|
||||||
LOG.debug("RileyLinkMedtronicService newly constructed");
|
|
||||||
MedtronicUtil.setMedtronicService(this);
|
MedtronicUtil.setMedtronicService(this);
|
||||||
pumpStatus = (MedtronicPumpStatus) MedtronicPumpPlugin.getPlugin().getPumpStatusData();
|
pumpStatus = (MedtronicPumpStatus) medtronicPumpPlugin.getPumpStatusData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,8 +71,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
if (isLogEnabled())
|
aapsLogger.warn(LTag.PUMPCOMM, "onConfigurationChanged");
|
||||||
LOG.warn("onConfigurationChanged");
|
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,10 +98,10 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
RileyLinkUtil.setRileyLinkServiceData(rileyLinkServiceData);
|
RileyLinkUtil.setRileyLinkServiceData(rileyLinkServiceData);
|
||||||
RileyLinkUtil.setTargetDevice(RileyLinkTargetDevice.MedtronicPump);
|
RileyLinkUtil.setTargetDevice(RileyLinkTargetDevice.MedtronicPump);
|
||||||
|
|
||||||
setPumpIDString(SP.getString(MedtronicConst.Prefs.PumpSerial, "000000"));
|
setPumpIDString(sp.getString(MedtronicConst.Prefs.PumpSerial, "000000"));
|
||||||
|
|
||||||
// get most recently used RileyLink address
|
// get most recently used RileyLink address
|
||||||
rileyLinkServiceData.rileylinkAddress = SP.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
rileyLinkServiceData.rileylinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
||||||
|
|
||||||
rileyLinkBLE = new RileyLinkBLE(this.context); // or this
|
rileyLinkBLE = new RileyLinkBLE(this.context); // or this
|
||||||
rfspy = new RFSpy(rileyLinkBLE);
|
rfspy = new RFSpy(rileyLinkBLE);
|
||||||
|
@ -127,29 +127,29 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
|
|
||||||
public void setPumpIDString(String pumpID) {
|
public void setPumpIDString(String pumpID) {
|
||||||
if (pumpID.length() != 6) {
|
if (pumpID.length() != 6) {
|
||||||
LOG.error("setPumpIDString: invalid pump id string: " + pumpID);
|
aapsLogger.error("setPumpIDString: invalid pump id string: " + pumpID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] pumpIDBytes = ByteUtil.fromHexString(pumpID);
|
byte[] pumpIDBytes = ByteUtil.fromHexString(pumpID);
|
||||||
|
|
||||||
if (pumpIDBytes == null) {
|
if (pumpIDBytes == null) {
|
||||||
LOG.error("Invalid pump ID? - PumpID is null.");
|
aapsLogger.error("Invalid pump ID? - PumpID is null.");
|
||||||
|
|
||||||
rileyLinkServiceData.setPumpID("000000", new byte[]{0, 0, 0});
|
rileyLinkServiceData.setPumpID("000000", new byte[]{0, 0, 0});
|
||||||
|
|
||||||
} else if (pumpIDBytes.length != 3) {
|
} else if (pumpIDBytes.length != 3) {
|
||||||
LOG.error("Invalid pump ID? " + ByteUtil.shortHexString(pumpIDBytes));
|
aapsLogger.error("Invalid pump ID? " + ByteUtil.shortHexString(pumpIDBytes));
|
||||||
|
|
||||||
rileyLinkServiceData.setPumpID("000000", new byte[]{0, 0, 0});
|
rileyLinkServiceData.setPumpID("000000", new byte[]{0, 0, 0});
|
||||||
|
|
||||||
} else if (pumpID.equals("000000")) {
|
} else if (pumpID.equals("000000")) {
|
||||||
LOG.error("Using pump ID " + pumpID);
|
aapsLogger.error("Using pump ID " + pumpID);
|
||||||
|
|
||||||
rileyLinkServiceData.setPumpID(pumpID, new byte[]{0, 0, 0});
|
rileyLinkServiceData.setPumpID(pumpID, new byte[]{0, 0, 0});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
LOG.info("Using pump ID " + pumpID);
|
aapsLogger.info(LTag.PUMPBTCOMM, "Using pump ID " + pumpID);
|
||||||
|
|
||||||
String oldId = rileyLinkServiceData.pumpID;
|
String oldId = rileyLinkServiceData.pumpID;
|
||||||
|
|
||||||
|
@ -198,9 +198,4 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
@Override
|
@Override
|
||||||
public void registerDeviceSpecificBroadcasts(IntentFilter intentFilter) {
|
public void registerDeviceSpecificBroadcasts(IntentFilter intentFilter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean isLogEnabled() {
|
|
||||||
return L.isEnabled(L.PUMPCOMM);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
|
||||||
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;
|
||||||
|
@ -41,6 +42,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpSta
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicDeviceStatusChange;
|
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicDeviceStatusChange;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService;
|
import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService;
|
||||||
import info.nightscout.androidaps.utils.OKDialog;
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by andy on 5/9/18.
|
* Created by andy on 5/9/18.
|
||||||
|
@ -227,26 +229,26 @@ public class MedtronicUtil extends RileyLinkUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void sendNotification(MedtronicNotificationType notificationType) {
|
public static void sendNotification(MedtronicNotificationType notificationType, ResourceHelper resourceHelper, RxBusWrapper rxBus) {
|
||||||
Notification notification = new Notification( //
|
Notification notification = new Notification( //
|
||||||
notificationType.getNotificationType(), //
|
notificationType.getNotificationType(), //
|
||||||
MainApp.gs(notificationType.getResourceId()), //
|
resourceHelper.gs(notificationType.getResourceId()), //
|
||||||
notificationType.getNotificationUrgency());
|
notificationType.getNotificationUrgency());
|
||||||
RxBus.Companion.getINSTANCE().send(new EventNewNotification(notification));
|
rxBus.send(new EventNewNotification(notification));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void sendNotification(MedtronicNotificationType notificationType, Object... parameters) {
|
public static void sendNotification(MedtronicNotificationType notificationType, ResourceHelper resourceHelper, RxBusWrapper rxBus, Object... parameters) {
|
||||||
Notification notification = new Notification( //
|
Notification notification = new Notification( //
|
||||||
notificationType.getNotificationType(), //
|
notificationType.getNotificationType(), //
|
||||||
MainApp.gs(notificationType.getResourceId(), parameters), //
|
resourceHelper.gs(notificationType.getResourceId(), parameters), //
|
||||||
notificationType.getNotificationUrgency());
|
notificationType.getNotificationUrgency());
|
||||||
RxBus.Companion.getINSTANCE().send(new EventNewNotification(notification));
|
rxBus.send(new EventNewNotification(notification));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void dismissNotification(MedtronicNotificationType notificationType) {
|
public static void dismissNotification(MedtronicNotificationType notificationType, RxBusWrapper rxBus) {
|
||||||
RxBus.Companion.getINSTANCE().send(new EventDismissNotification(notificationType.getNotificationType()));
|
rxBus.send(new EventDismissNotification(notificationType.getNotificationType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -176,9 +176,9 @@ public class DateUtil {
|
||||||
return dateString(mills) + " " + timeFullString(mills);
|
return dateString(mills) + " " + timeFullString(mills);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String minAgo(long time) {
|
public static String minAgo(ResourceHelper resourceHelper, long time) {
|
||||||
int mins = (int) ((now() - time) / 1000 / 60);
|
int mins = (int) ((now() - time) / 1000 / 60);
|
||||||
return MainApp.gs(R.string.minago, mins);
|
return resourceHelper.gs(R.string.minago, mins);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String minAgoShort(long time) {
|
public static String minAgoShort(long time) {
|
||||||
|
|
Loading…
Reference in a new issue