> = HashMap()
+
+ init {
+ createBroadcastIdentifiers()
+ }
+
+ private val rileyLinkService: RileyLinkService?
+ get() = (activePlugin.activePump as RileyLinkPumpDevice).rileyLinkService
+
+ private fun createBroadcastIdentifiers() {
+
+ // Bluetooth
+ broadcastIdentifiers["Bluetooth"] = listOf(
+ RileyLinkConst.Intents.BluetoothConnected,
+ RileyLinkConst.Intents.BluetoothReconnected
+ )
+
+ // TuneUp
+ broadcastIdentifiers["TuneUp"] = listOf(
+ RileyLinkConst.IPC.MSG_PUMP_tunePump,
+ RileyLinkConst.IPC.MSG_PUMP_quickTune
+ )
+
+ // RileyLink
+ broadcastIdentifiers["RileyLink"] = listOf(
+ RileyLinkConst.Intents.RileyLinkDisconnected,
+ RileyLinkConst.Intents.RileyLinkReady,
+ RileyLinkConst.Intents.RileyLinkDisconnected,
+ RileyLinkConst.Intents.RileyLinkNewAddressSet,
+ RileyLinkConst.Intents.RileyLinkDisconnect
+ )
+ }
+
+ override fun onReceive(context: Context, intent: Intent) {
+ super.onReceive(context, intent)
+ val action = intent.action ?: return
+ handler.post {
+ aapsLogger.debug(LTag.PUMPBTCOMM, "Received Broadcast: $action")
+ if (!processBluetoothBroadcasts(action) && !processRileyLinkBroadcasts(action, context) && !processTuneUpBroadcasts(action))
+ aapsLogger.error(LTag.PUMPBTCOMM, "Unhandled broadcast: action=$action")
+ }
+ }
+
+ fun registerBroadcasts(context: Context) {
+ val intentFilter = IntentFilter()
+ for ((_, value) in broadcastIdentifiers)
+ for (intentKey in value)
+ intentFilter.addAction(intentKey)
+ LocalBroadcastManager.getInstance(context).registerReceiver(this, intentFilter)
+ }
+
+ fun unregisterBroadcasts(context: Context) {
+ LocalBroadcastManager.getInstance(context).unregisterReceiver(this)
+ }
+
+ private fun processRileyLinkBroadcasts(action: String, context: Context): Boolean =
+ when (action) {
+ RileyLinkConst.Intents.RileyLinkDisconnected -> {
+ if ((context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager).adapter.isEnabled)
+ rileyLinkServiceData.setServiceState(RileyLinkServiceState.BluetoothError, RileyLinkError.RileyLinkUnreachable)
+ else
+ rileyLinkServiceData.setServiceState(RileyLinkServiceState.BluetoothError, RileyLinkError.BluetoothDisabled)
+ true
+ }
+
+ RileyLinkConst.Intents.RileyLinkReady -> {
+ aapsLogger.warn(LTag.PUMPBTCOMM, "RileyLinkConst.Intents.RileyLinkReady")
+ // sendIPCNotification(RT2Const.IPC.MSG_note_WakingPump);
+ rileyLinkService?.rileyLinkBLE?.enableNotifications()
+ rileyLinkService?.rfSpy?.startReader() // call startReader from outside?
+ rileyLinkService?.rfSpy?.initializeRileyLink()
+ val bleVersion = rileyLinkService?.rfSpy?.bleVersionCached
+ val rlVersion = rileyLinkServiceData.firmwareVersion
+ aapsLogger.debug(LTag.PUMPBTCOMM, "RfSpy version (BLE113): $bleVersion")
+ rileyLinkService?.rileyLinkServiceData?.versionBLE113 = bleVersion
+
+ aapsLogger.debug(LTag.PUMPBTCOMM, "RfSpy Radio version (CC110): " + rlVersion.name)
+ rileyLinkServiceData.firmwareVersion = rlVersion
+ val task: ServiceTask = InitializePumpManagerTask(injector, context)
+ serviceTaskExecutor.startTask(task)
+ aapsLogger.info(LTag.PUMPBTCOMM, "Announcing RileyLink open For business")
+ true
+ }
+
+ RileyLinkConst.Intents.RileyLinkNewAddressSet -> {
+ val rileylinkBLEAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "")
+ if (rileylinkBLEAddress == "") {
+ aapsLogger.error("No Rileylink BLE Address saved in app")
+ } else rileyLinkService?.reconfigureRileyLink(rileylinkBLEAddress)
+ true
+ }
+
+ RileyLinkConst.Intents.RileyLinkDisconnect -> {
+ rileyLinkService?.disconnectRileyLink()
+ true
+ }
+
+ else -> false
+ }
+
+ private fun processBluetoothBroadcasts(action: String): Boolean =
+ when (action) {
+ RileyLinkConst.Intents.BluetoothConnected -> {
+ aapsLogger.debug(LTag.PUMPBTCOMM, "Bluetooth - Connected")
+ serviceTaskExecutor.startTask(DiscoverGattServicesTask(injector))
+ true
+ }
+
+ RileyLinkConst.Intents.BluetoothReconnected -> {
+ aapsLogger.debug(LTag.PUMPBTCOMM, "Bluetooth - Reconnecting")
+ rileyLinkService?.bluetoothInit()
+ serviceTaskExecutor.startTask(DiscoverGattServicesTask(injector, true))
+ true
+ }
+
+ else -> false
+ }
+
+ private fun processTuneUpBroadcasts(action: String): Boolean =
+ if (broadcastIdentifiers["TuneUp"]?.contains(action) == true) {
+ if (rileyLinkService?.rileyLinkTargetDevice?.isTuneUpEnabled == true) serviceTaskExecutor.startTask(WakeAndTuneTask(injector))
+ true
+ } else false
+}
\ No newline at end of file
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.kt b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.kt
index 4b61ecec25..47449c5c3f 100644
--- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.kt
+++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.kt
@@ -41,18 +41,18 @@ abstract class RileyLinkService : DaggerService() {
@Inject lateinit var rileyLinkServiceData: RileyLinkServiceData
@Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var rileyLinkBLE: RileyLinkBLE // android-bluetooth management
- @Inject lateinit var rfspy: RFSpy // interface for RL xxx Mhz radio.
+ @Inject lateinit var rfSpy: RFSpy // interface for RL xxx Mhz radio.
private val bluetoothAdapter: BluetoothAdapter? get() = (context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager?)?.adapter
- protected var mBroadcastReceiver: RileyLinkBroadcastReceiver? = null
+ protected var broadcastReceiver: RileyLinkBroadcastReceiver? = null
private var bluetoothStateReceiver: RileyLinkBluetoothStateReceiver? = null
override fun onCreate() {
super.onCreate()
rileyLinkUtil.encoding = encoding
initRileyLinkServiceData()
- mBroadcastReceiver = RileyLinkBroadcastReceiver(this)
- mBroadcastReceiver?.registerBroadcasts(this)
+ broadcastReceiver = RileyLinkBroadcastReceiver()
+ broadcastReceiver?.registerBroadcasts(this)
bluetoothStateReceiver = RileyLinkBluetoothStateReceiver()
bluetoothStateReceiver?.registerBroadcasts(this)
}
@@ -80,7 +80,7 @@ abstract class RileyLinkService : DaggerService() {
super.onDestroy()
rileyLinkBLE.disconnect() // dispose of Gatt (disconnect and close)
- mBroadcastReceiver?.unregisterBroadcasts(this)
+ broadcastReceiver?.unregisterBroadcasts(this)
bluetoothStateReceiver?.unregisterBroadcasts(this)
}
@@ -139,7 +139,7 @@ abstract class RileyLinkService : DaggerService() {
}
}
- // FIXME: This needs to be run in a session so that is interruptible, has a separate thread, etc.
+ // FIXME: This needs to be run in a session so that is incorruptible, has a separate thread, etc.
fun doTuneUpDevice() {
rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.TuneUpDevice)
setPumpDeviceState(PumpDeviceState.Sleeping)
@@ -178,7 +178,7 @@ abstract class RileyLinkService : DaggerService() {
get() = rileyLinkServiceData.targetDevice
fun changeRileyLinkEncoding(encodingType: RileyLinkEncodingType?) {
- rfspy.setRileyLinkEncoding(encodingType)
+ rfSpy.setRileyLinkEncoding(encodingType)
}
val error: RileyLinkError?
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/data/ServiceCommand.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/data/ServiceCommand.java
deleted file mode 100644
index 4f43013328..0000000000
--- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/data/ServiceCommand.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data;
-
-import android.os.Bundle;
-
-/**
- * Created by geoff on 6/25/16.
- */
-public class ServiceCommand extends ServiceMessage {
-
- public ServiceCommand() {
- map = new Bundle();
- }
-
-
- // commandID is a string that the client can set on the message.
- // The service does not use this value, but passes it back with the result
- // so that the client can identify it.
- public ServiceCommand(String commandName, String commandID) {
- init();
- map.putString("command", commandName);
- map.putString("commandID", commandID);
- }
-
-
- public ServiceCommand(Bundle commandBundle) {
- if (commandBundle != null) {
- map = commandBundle;
- } else {
- map = new Bundle();
- init();
- map.putString("command", "(null)");
- map.putString("commandID", "(null");
- }
- }
-
-
- @Override
- public void init() {
- map.putString("ServiceMessageType", "ServiceCommand");
- }
-
-
- public String getCommandID() {
- return map.getString("commandID");
- }
-
-
- public String getCommandName() {
- return map.getString("command");
- }
-
-
- public boolean isPumpCommand() {
- switch (getCommandName()) {
- case "FetchPumpHistory":
- case "ReadPumpClock":
- case "RetrieveHistoryPage":
- case "ReadISFProfile":
- case "ReadBolusWizardCarbProfile":
- case "UpdatePumpStatus":
- case "WakeAndTune":
- return true;
- default:
- return false;
- }
- }
-}
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/data/ServiceMessage.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/data/ServiceMessage.java
deleted file mode 100644
index 83e2f57ade..0000000000
--- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/data/ServiceMessage.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data;
-
-import android.os.Bundle;
-
-/**
- * Created by geoff on 7/4/16.
- *
- * Base class for all messages passed between service and client
- */
-public class ServiceMessage {
-
- protected Bundle map = new Bundle();
-
-
- public ServiceMessage() {
- init();
- }
-
-
- public void init() {
- map.putString("ServiceMessageClass", this.getClass().getCanonicalName());
- map.putString("ServiceMessageType", this.getClass().getSimpleName());
- }
-
-
- public Bundle getMap() {
- return map;
- }
-
-
- public void setMap(Bundle map) {
- this.map = map;
- }
-
-
- public String getServiceMessageType() {
- return map.getString("ServiceMessageType");
- }
-
-}
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/data/ServiceNotification.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/data/ServiceNotification.java
deleted file mode 100644
index aad45093f1..0000000000
--- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/data/ServiceNotification.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data;
-
-import android.os.Bundle;
-
-/**
- * Created by geoff on 7/6/16.
- *
- * These are "one liner" messages between client and service. Must still be contained within ServiceTransports
- */
-public class ServiceNotification extends ServiceMessage {
-
- public ServiceNotification() {
- }
-
-
- public ServiceNotification(Bundle b) {
- if (b != null) {
- if ("ServiceNotification".equals(b.getString("ServiceMessageType"))) {
- setMap(b);
- } else {
- throw new IllegalArgumentException();
- }
- }
- }
-
-
- public ServiceNotification(String notificationType) {
- setNotificationType(notificationType);
- }
-
-
- @Override
- public void init() {
- super.init();
- map.putString("ServiceMessageType", "ServiceNotification");
- }
-
-
- public String getNotificationType() {
- return map.getString("NotificationType", "");
- }
-
-
- public void setNotificationType(String notificationType) {
- map.putString("NotificationType", notificationType);
- }
-
-}
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/data/ServiceResult.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/data/ServiceResult.java
deleted file mode 100644
index ecf7d54f99..0000000000
--- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/data/ServiceResult.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data;
-
-import android.os.Bundle;
-
-/**
- * Created by geoff on 6/25/16.
- */
-public class ServiceResult extends ServiceMessage {
-
- public static final int ERROR_MALFORMED_PUMP_RESPONSE = 1;
- public static final int ERROR_NULL_PUMP_RESPONSE = 2;
- public static final int ERROR_INVALID_PUMP_RESPONSE = 3;
- public static final int ERROR_PUMP_BUSY = 4;
-
-
- public ServiceResult() {
- init();
- }
-
-
- public ServiceResult(Bundle resultBundle) {
- if (resultBundle != null) {
- setMap(resultBundle);
- } else {
- init();
- }
- }
-
-
- public static final String getErrorDescription(int errorCode) {
- switch (errorCode) {
- case ERROR_MALFORMED_PUMP_RESPONSE:
- return "Malformed Pump Response";
- case ERROR_NULL_PUMP_RESPONSE:
- return "Null pump response";
- case ERROR_INVALID_PUMP_RESPONSE:
- return "Invalid pump response";
- case ERROR_PUMP_BUSY:
- return "A pump command session is already in progress";
- default:
- return "Unknown error code (" + errorCode + ")";
- }
- }
-
-
- @Override
- public void init() {
- super.init();
- map.putString("ServiceMessageType", "ServiceResult");
- setServiceResultType(this.getClass().getSimpleName());
- setResultError(0, "Uninitialized ServiceResult");
- }
-
-
- public String getServiceResultType() {
- return map.getString("ServiceResultType", "ServiceResult");
- }
-
-
- public void setServiceResultType(String serviceResultType) {
- map.putString("ServiceResultType", serviceResultType);
- }
-
-
- public void setResultOK() {
- map.putString("result", "OK");
- }
-
-
- public void setResultError(int errorCode) {
- setResultError(errorCode, getErrorDescription(errorCode));
- }
-
-
- public void setResultError(int errorCode, String errorDescription) {
- map.putString("result", "error");
- map.putInt("errorCode", errorCode);
- map.putString("errorDescription", errorDescription);
- }
-
-
- public boolean resultIsOK() {
- return ("OK".equals(map.getString("result", "")));
- }
-
-
- public String getErrorDescription() {
- return map.getString("errorDescription", "");
- }
-
-
- public String getResult() {
- return map.getString("result", "");
- }
-
-}
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/data/ServiceTransport.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/data/ServiceTransport.java
deleted file mode 100644
index 99fa32f5e9..0000000000
--- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/data/ServiceTransport.java
+++ /dev/null
@@ -1,150 +0,0 @@
-package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data;
-
-import android.os.Bundle;
-import android.os.Parcel;
-
-/**
- * Created by geoff on 7/6/16.
- *
- * This class exists to hold a ServiceCommand along with transport variables such as time sent, time received, sender.
- * May also contain result, if the command is completed.
- */
-public class ServiceTransport extends ServiceMessage {
-
- private ServiceTransportType serviceTransportType = ServiceTransportType.Undefined;
-
-
- public ServiceTransport() {
- }
-
-
- public ServiceTransport(Bundle b) {
- if (b != null) {
- if ("ServiceTransport".equals(b.getString("ServiceMessageType"))) {
- setMap(b);
- } else {
- throw new IllegalArgumentException();
- }
- }
- }
-
-
- @Override
- public void init() {
- super.init();
- map.putString("ServiceMessageType", "ServiceTransport");
- setTransportType("unknown");
- setSenderHashcode(0);
- }
-
-
- public Integer getSenderHashcode() {
- return map.getInt("senderHashCode", 0);
- }
-
-
- public void setSenderHashcode(Integer senderHashcode) {
- map.putInt("senderHashcode", senderHashcode);
- }
-
-
- public ServiceCommand getServiceCommand() {
- return new ServiceCommand(map.getBundle("ServiceCommand"));
- }
-
-
- public void setServiceCommand(ServiceCommand serviceCommand) {
- map.putBundle("ServiceCommand", serviceCommand.getMap());
- this.serviceTransportType = ServiceTransportType.ServiceCommand;
- }
-
-
- public boolean hasServiceCommand() {
- return (getMap().containsKey("ServiceCommand"));
- }
-
-
- public String getTransportType() {
- return map.getString("transportType", "unknown");
- }
-
-
- // On remote end, this will be converted to the "action" of a local Intent,
- // so can be used for separating types of messages to different internal handlers.
- public void setTransportType(String transportType) {
- map.putString("transportType", transportType);
- }
-
-
- public ServiceResult getServiceResult() {
- return new ServiceResult(map.getBundle("ServiceResult"));
- }
-
-
- public void setServiceResult(ServiceResult serviceResult) {
- map.putBundle("ServiceResult", serviceResult.getMap());
- this.serviceTransportType = ServiceTransportType.ServiceResult;
- }
-
-
- public boolean hasServiceResult() {
- return (getMap().containsKey("ServiceResult"));
- }
-
-
- public ServiceNotification getServiceNotification() {
- return new ServiceNotification(map.getBundle("ServiceNotification"));
- }
-
-
- public void setServiceNotification(ServiceNotification notification) {
- map.putBundle("ServiceNotification", notification.getMap());
- this.serviceTransportType = ServiceTransportType.ServiceNotification;
- }
-
-
- public boolean hasServiceNotification() {
- return (map.containsKey("ServiceNotification"));
- }
-
-
- public boolean commandDidCompleteOK() {
- return getServiceResult().resultIsOK();
- }
-
-
- public String getOriginalCommandName() {
- return getServiceCommand().getCommandName();
- }
-
-
- public String describeContentsShort() {
- String rval = "";
- rval += getTransportType();
-
- if (this.serviceTransportType == ServiceTransportType.ServiceNotification) {
- rval += "note: " + getServiceNotification().getNotificationType();
- } else if (this.serviceTransportType == ServiceTransportType.ServiceCommand) {
- rval += ", cmd=" + getOriginalCommandName();
- } else if (this.serviceTransportType == ServiceTransportType.ServiceResult) {
- rval += ", cmd=" + getOriginalCommandName();
- rval += ", rslt=" + getServiceResult().getResult();
- rval += ", err=" + getServiceResult().getErrorDescription();
- }
- return rval;
- }
-
-
- @Override public ServiceTransport clone() {
- Parcel p = Parcel.obtain();
- Parcel p2 = Parcel.obtain();
- getMap().writeToParcel(p, 0);
- byte[] bytes = p.marshall();
- p2.unmarshall(bytes, 0, bytes.length);
- p2.setDataPosition(0);
- Bundle b = p2.readBundle();
- ServiceTransport rval = new ServiceTransport();
- rval.setMap(b);
- return rval;
- }
-}
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/data/ServiceTransportType.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/data/ServiceTransportType.java
deleted file mode 100644
index 135c217996..0000000000
--- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/data/ServiceTransportType.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data;
-
-/**
- * Created by andy on 31/05/18.
- */
-
-public enum ServiceTransportType {
-
- Undefined, //
- ServiceNotification, //
-
- ServiceCommand, //
- ServiceResult
-
-}
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/DiscoverGattServicesTask.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/DiscoverGattServicesTask.java
deleted file mode 100644
index 38290e3e60..0000000000
--- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/DiscoverGattServicesTask.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks;
-
-import javax.inject.Inject;
-
-import dagger.android.HasAndroidInjector;
-import info.nightscout.shared.logging.AAPSLogger;
-import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice;
-
-/**
- * Created by geoff on 7/9/16.
- */
-public class DiscoverGattServicesTask extends ServiceTask {
-
-
- @Inject AAPSLogger aapsLogger;
-
- public boolean needToConnect = false;
-
-
- public DiscoverGattServicesTask(HasAndroidInjector injector) {
- super(injector);
- }
-
-
- public DiscoverGattServicesTask(HasAndroidInjector injector, boolean needToConnect) {
- super(injector);
- this.needToConnect = needToConnect;
- }
-
-
- @Override
- public void run() {
-
- if (!isRileyLinkDevice()) {
- return;
- }
-
- RileyLinkPumpDevice pumpDevice = (RileyLinkPumpDevice) activePlugin.getActivePump();
-
- if (needToConnect) {
- pumpDevice.getRileyLinkService().getRileyLinkBLE().connectGatt();
- }
-
- pumpDevice.getRileyLinkService().getRileyLinkBLE().discoverServices();
- }
-}
\ No newline at end of file
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/DiscoverGattServicesTask.kt b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/DiscoverGattServicesTask.kt
new file mode 100644
index 0000000000..e3d5a121b7
--- /dev/null
+++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/DiscoverGattServicesTask.kt
@@ -0,0 +1,15 @@
+package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks
+
+import dagger.android.HasAndroidInjector
+import info.nightscout.shared.logging.AAPSLogger
+import javax.inject.Inject
+
+class DiscoverGattServicesTask(injector: HasAndroidInjector, private val needToConnect: Boolean = false) : ServiceTask(injector) {
+
+ @Inject lateinit var aapsLogger: AAPSLogger
+
+ override fun run() {
+ if (needToConnect) pumpDevice?.rileyLinkService?.rileyLinkBLE?.connectGatt()
+ pumpDevice?.rileyLinkService?.rileyLinkBLE?.discoverServices()
+ }
+}
\ No newline at end of file
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.java
deleted file mode 100644
index 703cd1c211..0000000000
--- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks;
-
-import android.content.Context;
-
-import java.util.Locale;
-
-import javax.inject.Inject;
-
-import dagger.android.HasAndroidInjector;
-import info.nightscout.shared.logging.AAPSLogger;
-import info.nightscout.shared.logging.LTag;
-import info.nightscout.androidaps.plugins.common.ManufacturerType;
-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.RileyLinkUtil;
-import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkTargetFrequency;
-import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
-import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice;
-import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
-import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData;
-import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
-import info.nightscout.androidaps.utils.Round;
-import info.nightscout.shared.sharedPreferences.SP;
-
-/**
- * Created by geoff on 7/9/16.
- *
- * This class is intended to be run by the Service, for the Service. Not intended for clients to run.
- */
-public class InitializePumpManagerTask extends ServiceTask {
-
- @Inject AAPSLogger aapsLogger;
- //@Inject ActivePluginProvider activePlugin;
- @Inject SP sp;
- @Inject RileyLinkServiceData rileyLinkServiceData;
- @Inject RileyLinkUtil rileyLinkUtil;
-
- private final Context context;
-
- public InitializePumpManagerTask(HasAndroidInjector injector, Context context) {
- super(injector);
- this.context = context;
- }
-
- public InitializePumpManagerTask(HasAndroidInjector injector, Context context, ServiceTransport transport) {
- super(injector, transport);
- this.context = context;
- }
-
- @Override
- public void run() {
-
- if (!isRileyLinkDevice()) {
- return;
- }
-
- double lastGoodFrequency;
-
- if (rileyLinkServiceData.lastGoodFrequency == null) {
-
- lastGoodFrequency = sp.getDouble(RileyLinkConst.Prefs.LastGoodDeviceFrequency, 0.0d);
- lastGoodFrequency = Math.round(lastGoodFrequency * 1000d) / 1000d;
-
- rileyLinkServiceData.lastGoodFrequency = lastGoodFrequency;
-
-// if (RileyLinkUtil.getRileyLinkTargetFrequency() == null) {
-// String pumpFrequency = SP.getString(MedtronicConst.Prefs.PumpFrequency, null);
-// }
- } else {
- lastGoodFrequency = rileyLinkServiceData.lastGoodFrequency;
- }
-
- /* FIXME this can apparently crash:
- Fatal Exception: java.lang.ClassCastException
- info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
- cannot be cast to info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice
- */
- RileyLinkCommunicationManager> rileyLinkCommunicationManager = ((RileyLinkPumpDevice) activePlugin.getActivePump()).getRileyLinkService().getDeviceCommunicationManager();
-
- if (activePlugin.getActivePump().manufacturer() == ManufacturerType.Medtronic) {
-
- if ((lastGoodFrequency > 0.0d)
- && rileyLinkCommunicationManager.isValidFrequency(lastGoodFrequency)) {
-
- rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.RileyLinkReady);
-
- aapsLogger.info(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Setting radio frequency to %.3f MHz", lastGoodFrequency));
-
- rileyLinkCommunicationManager.setRadioFrequencyForPump(lastGoodFrequency);
-
- boolean foundThePump = rileyLinkCommunicationManager.tryToConnectToDevice();
-
- if (foundThePump) {
- rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.PumpConnectorReady);
- } else {
- rileyLinkServiceData.setServiceState(RileyLinkServiceState.PumpConnectorError,
- RileyLinkError.NoContactWithDevice);
- rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.IPC.MSG_PUMP_tunePump, context);
- }
-
- } else {
- rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.IPC.MSG_PUMP_tunePump, context);
- }
- } else {
-
- if (!Round.INSTANCE.isSame(lastGoodFrequency,
- RileyLinkTargetFrequency.Omnipod.getScanFrequencies()[0])) {
- lastGoodFrequency = RileyLinkTargetFrequency.Omnipod.getScanFrequencies()[0];
- lastGoodFrequency = Math.round(lastGoodFrequency * 1000d) / 1000d;
-
- rileyLinkServiceData.lastGoodFrequency = lastGoodFrequency;
- }
-
- rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.RileyLinkReady);
- rileyLinkServiceData.rileyLinkTargetFrequency = RileyLinkTargetFrequency.Omnipod; // TODO shouldn't be needed
-
- aapsLogger.info(LTag.PUMPBTCOMM, String.format(Locale.ENGLISH, "Setting radio frequency to %.3f MHz", lastGoodFrequency));
-
- rileyLinkCommunicationManager.setRadioFrequencyForPump(lastGoodFrequency);
-
- rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.PumpConnectorReady);
-
- }
- }
-
-}
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.kt b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.kt
new file mode 100644
index 0000000000..2b43ea0ea3
--- /dev/null
+++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.kt
@@ -0,0 +1,65 @@
+package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks
+
+import android.content.Context
+import dagger.android.HasAndroidInjector
+import info.nightscout.androidaps.plugins.common.ManufacturerType
+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.ble.defs.RileyLinkTargetFrequency
+import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError
+import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState
+import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData
+import info.nightscout.androidaps.utils.Round.isSame
+import info.nightscout.shared.logging.AAPSLogger
+import info.nightscout.shared.logging.LTag
+import info.nightscout.shared.sharedPreferences.SP
+import javax.inject.Inject
+import kotlin.math.roundToLong
+
+/**
+ * This class is intended to be run by the Service, for the Service. Not intended for clients to run.
+ */
+class InitializePumpManagerTask(injector: HasAndroidInjector, private val context: Context) : ServiceTask(injector) {
+
+ @Inject lateinit var aapsLogger: AAPSLogger
+ @Inject lateinit var sp: SP
+ @Inject lateinit var rileyLinkServiceData: RileyLinkServiceData
+ @Inject lateinit var rileyLinkUtil: RileyLinkUtil
+
+ override fun run() {
+ if (!isRileyLinkDevice) return
+
+ var lastGoodFrequency: Double
+ if (rileyLinkServiceData.lastGoodFrequency == null) {
+ lastGoodFrequency = sp.getDouble(RileyLinkConst.Prefs.LastGoodDeviceFrequency, 0.0)
+ lastGoodFrequency = (lastGoodFrequency * 1000.0).roundToLong() / 1000.0
+ rileyLinkServiceData.lastGoodFrequency = lastGoodFrequency
+
+ } else lastGoodFrequency = rileyLinkServiceData.lastGoodFrequency
+
+ val rileyLinkCommunicationManager = pumpDevice?.rileyLinkService?.deviceCommunicationManager
+ if (activePlugin.activePump.manufacturer() === ManufacturerType.Medtronic) {
+ if (lastGoodFrequency > 0.0 && rileyLinkCommunicationManager?.isValidFrequency(lastGoodFrequency) == true) {
+ rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.RileyLinkReady)
+ aapsLogger.info(LTag.PUMPBTCOMM, "Setting radio frequency to $lastGoodFrequency MHz")
+ rileyLinkCommunicationManager.setRadioFrequencyForPump(lastGoodFrequency)
+ if (rileyLinkCommunicationManager.tryToConnectToDevice()) rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.PumpConnectorReady)
+ else {
+ rileyLinkServiceData.setServiceState(RileyLinkServiceState.PumpConnectorError, RileyLinkError.NoContactWithDevice)
+ rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.IPC.MSG_PUMP_tunePump, context)
+ }
+ } else rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.IPC.MSG_PUMP_tunePump, context)
+ } else {
+ if (!isSame(lastGoodFrequency, RileyLinkTargetFrequency.Omnipod.scanFrequencies[0])) {
+ lastGoodFrequency = RileyLinkTargetFrequency.Omnipod.scanFrequencies[0]
+ lastGoodFrequency = (lastGoodFrequency * 1000.0).roundToLong() / 1000.0
+ rileyLinkServiceData.lastGoodFrequency = lastGoodFrequency
+ }
+ rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.RileyLinkReady)
+ rileyLinkServiceData.rileyLinkTargetFrequency = RileyLinkTargetFrequency.Omnipod // TODO shouldn't be needed
+ aapsLogger.info(LTag.PUMPBTCOMM, "Setting radio frequency to $lastGoodFrequency MHz")
+ rileyLinkCommunicationManager?.setRadioFrequencyForPump(lastGoodFrequency)
+ rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.PumpConnectorReady)
+ }
+ }
+}
\ No newline at end of file
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/PumpTask.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/PumpTask.java
deleted file mode 100644
index 66aeb7ae07..0000000000
--- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/PumpTask.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks;
-
-import dagger.android.HasAndroidInjector;
-import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
-
-/**
- * Created by geoff on 7/10/16.
- */
-public class PumpTask extends ServiceTask {
-
- public PumpTask(HasAndroidInjector injector) {
- super(injector);
- }
-
-
- public PumpTask(HasAndroidInjector injector, ServiceTransport transport) {
- super(injector, transport);
- }
-}
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/PumpTask.kt b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/PumpTask.kt
new file mode 100644
index 0000000000..53cca2a306
--- /dev/null
+++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/PumpTask.kt
@@ -0,0 +1,6 @@
+package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks
+
+import dagger.android.HasAndroidInjector
+
+open class PumpTask(injector: HasAndroidInjector) : ServiceTask(injector)
+
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/ResetRileyLinkConfigurationTask.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/ResetRileyLinkConfigurationTask.java
deleted file mode 100644
index 88d1c612f4..0000000000
--- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/ResetRileyLinkConfigurationTask.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks;
-
-import javax.inject.Inject;
-
-import dagger.android.HasAndroidInjector;
-import info.nightscout.androidaps.interfaces.ActivePlugin;
-import info.nightscout.androidaps.plugins.bus.RxBus;
-import info.nightscout.androidaps.plugins.pump.common.events.EventRefreshButtonState;
-import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy;
-import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice;
-
-/**
- * Created by andy on 9/16/18.
- */
-public class ResetRileyLinkConfigurationTask extends PumpTask {
-
- @Inject ActivePlugin activePlugin;
- @Inject RxBus rxBus;
- @Inject RFSpy rfSpy;
-
- public ResetRileyLinkConfigurationTask(HasAndroidInjector injector) {
- super(injector);
- }
-
- @Override
- public void run() {
-
- if (!isRileyLinkDevice()) {
- return;
- }
-
- RileyLinkPumpDevice rileyLinkPumpDevice = (RileyLinkPumpDevice) activePlugin.getActivePump();
-
- rxBus.send(new EventRefreshButtonState(false));
-
- rileyLinkPumpDevice.setBusy(true);
- rfSpy.resetRileyLinkConfiguration();
- rileyLinkPumpDevice.setBusy(false);
-
- rxBus.send(new EventRefreshButtonState(true));
- }
-
-}
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/ResetRileyLinkConfigurationTask.kt b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/ResetRileyLinkConfigurationTask.kt
new file mode 100644
index 0000000000..c0d7e6e136
--- /dev/null
+++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/ResetRileyLinkConfigurationTask.kt
@@ -0,0 +1,22 @@
+package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks
+
+import dagger.android.HasAndroidInjector
+import info.nightscout.androidaps.plugins.bus.RxBus
+import info.nightscout.androidaps.plugins.pump.common.events.EventRefreshButtonState
+import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy
+import javax.inject.Inject
+
+class ResetRileyLinkConfigurationTask(injector: HasAndroidInjector) : PumpTask(injector) {
+
+ @Inject lateinit var rxBus: RxBus
+ @Inject lateinit var rfSpy: RFSpy
+
+ override fun run() {
+ if (!isRileyLinkDevice) return
+ rxBus.send(EventRefreshButtonState(false))
+ pumpDevice?.setBusy(true)
+ rfSpy.resetRileyLinkConfiguration()
+ pumpDevice?.setBusy(false)
+ rxBus.send(EventRefreshButtonState(true))
+ }
+}
\ No newline at end of file
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/ServiceTask.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/ServiceTask.java
deleted file mode 100644
index 498344913b..0000000000
--- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/ServiceTask.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks;
-
-import javax.inject.Inject;
-
-import dagger.android.HasAndroidInjector;
-import info.nightscout.androidaps.interfaces.ActivePlugin;
-import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice;
-import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
-
-/**
- * Created by geoff on 7/9/16.
- */
-public class ServiceTask implements Runnable {
-
- @Inject protected ActivePlugin activePlugin;
-
- public boolean completed = false;
- protected ServiceTransport mTransport;
- protected HasAndroidInjector injector;
-
-
- public ServiceTask(HasAndroidInjector injector) {
- this.injector = injector;
- injector.androidInjector().inject(this);
- init(new ServiceTransport());
- }
-
-
- public ServiceTask(HasAndroidInjector injector, ServiceTransport transport) {
- this.injector = injector;
- injector.androidInjector().inject(this);
- init(transport);
- }
-
-
- public void init(ServiceTransport transport) {
- mTransport = transport;
- }
-
-
- @Override
- public void run() {
- }
-
-
- public void preOp() {
- // This function is called by UI thread before running asynch thread.
- }
-
-
- public void postOp() {
- // This function is called by UI thread after running asynch thread.
- }
-
-
- public ServiceTransport getServiceTransport() {
- return mTransport;
- }
-
- /*
- * protected void sendResponse(ServiceResult result) {
- * RoundtripService.getInstance().sendServiceTransportResponse(mTransport,result);
- * }
- */
-
- public boolean isRileyLinkDevice() {
- return (activePlugin.getActivePump() instanceof RileyLinkPumpDevice);
- }
-
-
-}
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/ServiceTask.kt b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/ServiceTask.kt
new file mode 100644
index 0000000000..34fdf4e050
--- /dev/null
+++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/ServiceTask.kt
@@ -0,0 +1,33 @@
+package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks
+
+import dagger.android.HasAndroidInjector
+import info.nightscout.androidaps.interfaces.ActivePlugin
+import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice
+import javax.inject.Inject
+
+@Suppress("LeakingThis")
+open class ServiceTask constructor(val injector: HasAndroidInjector) : Runnable {
+
+ @Inject lateinit var activePlugin: ActivePlugin
+
+ var completed = false
+
+ init {
+ injector.androidInjector().inject(this)
+ }
+
+ override fun run() {}
+
+ // This function is called by UI thread before running async thread.
+ fun preOp() {}
+
+ // This function is called by UI thread after running async thread.
+ fun postOp() {}
+
+ val isRileyLinkDevice: Boolean
+ get() = activePlugin.activePump is RileyLinkPumpDevice
+
+ val pumpDevice: RileyLinkPumpDevice?
+ get() = if (isRileyLinkDevice) activePlugin.activePump as RileyLinkPumpDevice else null
+
+}
\ No newline at end of file
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/ServiceTaskExecutor.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/ServiceTaskExecutor.java
deleted file mode 100644
index 609b586437..0000000000
--- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/ServiceTaskExecutor.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks;
-
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import info.nightscout.shared.logging.AAPSLogger;
-import info.nightscout.shared.logging.LTag;
-import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
-
-/**
- * Created by geoff on 7/9/16.
- */
-@Singleton
-public class ServiceTaskExecutor extends ThreadPoolExecutor {
-
- @Inject RileyLinkUtil rileyLinkUtil;
- @Inject AAPSLogger aapsLogger;
-
- private static final LinkedBlockingQueue taskQueue = new LinkedBlockingQueue<>();
-
- @Inject
- public ServiceTaskExecutor() {
- super(1, 1, 10000, TimeUnit.MILLISECONDS, taskQueue);
- }
-
- public ServiceTask startTask(ServiceTask task) {
- execute(task); // task will be run on async thread from pool.
- return task;
- }
-
- // FIXME
- @Override protected void beforeExecute(Thread t, Runnable r) {
- // This is run on either caller UI thread or Service UI thread.
- ServiceTask task = (ServiceTask) r;
- aapsLogger.debug(LTag.PUMPBTCOMM, "About to run task " + task.getClass().getSimpleName());
- rileyLinkUtil.setCurrentTask(task);
- task.preOp();
- }
-
-
- // FIXME
- @Override protected void afterExecute(Runnable r, Throwable t) {
- // This is run on either caller UI thread or Service UI thread.
- ServiceTask task = (ServiceTask) r;
- task.postOp();
- aapsLogger.debug(LTag.PUMPBTCOMM, "Finishing task " + task.getClass().getSimpleName());
- rileyLinkUtil.finishCurrentTask(task);
- }
-}
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/ServiceTaskExecutor.kt b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/ServiceTaskExecutor.kt
new file mode 100644
index 0000000000..f0623eaf92
--- /dev/null
+++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/ServiceTaskExecutor.kt
@@ -0,0 +1,39 @@
+package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks
+
+import info.nightscout.shared.logging.AAPSLogger
+import info.nightscout.shared.logging.LTag
+import java.util.concurrent.LinkedBlockingQueue
+import java.util.concurrent.ThreadPoolExecutor
+import java.util.concurrent.TimeUnit
+import javax.inject.Inject
+import javax.inject.Singleton
+
+@Singleton
+class ServiceTaskExecutor @Inject constructor() : ThreadPoolExecutor(1, 1, 10000, TimeUnit.MILLISECONDS, taskQueue) {
+
+ @Inject lateinit var aapsLogger: AAPSLogger
+
+ companion object {
+
+ private val taskQueue = LinkedBlockingQueue()
+ }
+
+ fun startTask(task: ServiceTask): ServiceTask {
+ execute(task) // task will be run on async thread from pool.
+ return task
+ }
+
+ override fun beforeExecute(t: Thread, r: Runnable) {
+ // This is run on either caller UI thread or Service UI thread.
+ val task = r as ServiceTask
+ aapsLogger.debug(LTag.PUMPBTCOMM, "About to run task ${task.javaClass.simpleName}")
+ task.preOp()
+ }
+
+ override fun afterExecute(r: Runnable, t: Throwable?) {
+ // This is run on either caller UI thread or Service UI thread.
+ val task = r as ServiceTask
+ task.postOp()
+ aapsLogger.debug(LTag.PUMPBTCOMM, "Finishing task ${task.javaClass.simpleName}")
+ }
+}
\ No newline at end of file
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/WakeAndTuneTask.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/WakeAndTuneTask.java
deleted file mode 100644
index 67adcd18eb..0000000000
--- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/WakeAndTuneTask.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks;
-
-import javax.inject.Inject;
-
-import dagger.android.HasAndroidInjector;
-import info.nightscout.androidaps.plugins.bus.RxBus;
-import info.nightscout.androidaps.plugins.pump.common.events.EventRefreshButtonState;
-import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice;
-
-/**
- * Created by geoff on 7/16/16.
- */
-public class WakeAndTuneTask extends PumpTask {
-
- //@Inject ActivePluginProvider activePlugin;
- @Inject RxBus rxBus;
-
- private static final String TAG = "WakeAndTuneTask";
-
- public WakeAndTuneTask(HasAndroidInjector injector) {
- super(injector);
- }
-
- @Override
- public void run() {
- if (!isRileyLinkDevice()) {
- return;
- }
-
- RileyLinkPumpDevice pumpDevice = (RileyLinkPumpDevice) activePlugin.getActivePump();
- rxBus.send(new EventRefreshButtonState(false));
- pumpDevice.setBusy(true);
- pumpDevice.getRileyLinkService().doTuneUpDevice();
- pumpDevice.setBusy(false);
- rxBus.send(new EventRefreshButtonState(true));
- }
-}
diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/WakeAndTuneTask.kt b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/WakeAndTuneTask.kt
new file mode 100644
index 0000000000..dfc3bcd91d
--- /dev/null
+++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/WakeAndTuneTask.kt
@@ -0,0 +1,19 @@
+package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks
+
+import dagger.android.HasAndroidInjector
+import info.nightscout.androidaps.plugins.bus.RxBus
+import info.nightscout.androidaps.plugins.pump.common.events.EventRefreshButtonState
+import javax.inject.Inject
+
+class WakeAndTuneTask(injector: HasAndroidInjector) : PumpTask(injector) {
+
+ @Inject lateinit var rxBus: RxBus
+
+ override fun run() {
+ rxBus.send(EventRefreshButtonState(false))
+ pumpDevice?.setBusy(true)
+ pumpDevice?.rileyLinkService?.doTuneUpDevice()
+ pumpDevice?.setBusy(false)
+ rxBus.send(EventRefreshButtonState(true))
+ }
+}
\ No newline at end of file
diff --git a/shared/src/main/java/info/nightscout/shared/weardata/EventData.kt b/shared/src/main/java/info/nightscout/shared/weardata/EventData.kt
index f570743aa6..aca2303c89 100644
--- a/shared/src/main/java/info/nightscout/shared/weardata/EventData.kt
+++ b/shared/src/main/java/info/nightscout/shared/weardata/EventData.kt
@@ -234,4 +234,7 @@ sealed class EventData : Event() {
@Serializable // returnCommand is sent back to Mobile after confirmation
data class ConfirmAction(val title: String, val message: String, val returnCommand: EventData?) : EventData()
-}
\ No newline at end of file
+
+ @Serializable
+ data class SnoozeAlert(val timeStamp: Long) : EventData()
+}
diff --git a/shared/src/main/res/values-af-rZA/strings.xml b/shared/src/main/res/values-af-rZA/strings.xml
new file mode 100644
index 0000000000..875daa124a
--- /dev/null
+++ b/shared/src/main/res/values-af-rZA/strings.xml
@@ -0,0 +1,19 @@
+
+
+
+ h
+ dae
+ ure
+ sekonde
+ minuut
+ uur
+ dag
+ week
+ sekondes
+ minute
+ ure
+ dae
+ weke
+ m
+ d
+
diff --git a/shared/src/main/res/values-bg-rBG/strings.xml b/shared/src/main/res/values-bg-rBG/strings.xml
new file mode 100644
index 0000000000..56da387b4b
--- /dev/null
+++ b/shared/src/main/res/values-bg-rBG/strings.xml
@@ -0,0 +1,21 @@
+
+
+
+ преди %1$d мин
+ преди %1$.1fч
+ ч.
+ дни
+ часа
+ секунда
+ минута
+ час
+ ден
+ седмица
+ секунди
+ минути
+ часове
+ дни
+ седмици
+ мин.
+ д
+
diff --git a/shared/src/main/res/values-ca-rES/strings.xml b/shared/src/main/res/values-ca-rES/strings.xml
new file mode 100644
index 0000000000..9735814c77
--- /dev/null
+++ b/shared/src/main/res/values-ca-rES/strings.xml
@@ -0,0 +1,21 @@
+
+
+
+ Fa %1$d m
+ Fa %1$.1f h
+ h
+ dies
+ hores
+ segon
+ minut
+ hora
+ dia
+ setmana
+ segons
+ minuts
+ hores
+ dies
+ setmanes
+ m
+ d
+
diff --git a/shared/src/main/res/values-cs-rCZ/strings.xml b/shared/src/main/res/values-cs-rCZ/strings.xml
new file mode 100644
index 0000000000..a05fa45757
--- /dev/null
+++ b/shared/src/main/res/values-cs-rCZ/strings.xml
@@ -0,0 +1,30 @@
+
+
+
+ před %1$d min
+ před %1$d minutamí
+ před %1$.1f h
+ Před %1$.1f dny
+ Před %1$.0f dny
+ za %1$.0f dní
+ za %1$.0f dní
+ h
+ dnů
+ hodin
+ sekund
+ minut
+ hodina
+ den
+ týden
+ sekund
+ minut
+ hodin
+ dní
+ týdnů
+ m
+ d
+ Později během dneška
+ Zítra
+ Dnes
+ Včera
+
diff --git a/shared/src/main/res/values-da-rDK/strings.xml b/shared/src/main/res/values-da-rDK/strings.xml
new file mode 100644
index 0000000000..d46c0c97a2
--- /dev/null
+++ b/shared/src/main/res/values-da-rDK/strings.xml
@@ -0,0 +1,30 @@
+
+
+
+ %1$d min. siden
+ %1$d minutter siden
+ %1$.1f t siden
+ %1$.1f dage siden
+ %1$.0f dage siden
+ om %1$.0f dage
+ om %1$.0f dage
+ t
+ dage
+ timer
+ sekund
+ minut
+ time
+ dag
+ uge
+ sekunder
+ minutter
+ timer
+ dage
+ uger
+ min
+ d
+ Senere i dag
+ I morgen
+ I dag
+ I går
+
diff --git a/shared/src/main/res/values-de-rDE/strings.xml b/shared/src/main/res/values-de-rDE/strings.xml
new file mode 100644
index 0000000000..8c95db789a
--- /dev/null
+++ b/shared/src/main/res/values-de-rDE/strings.xml
@@ -0,0 +1,22 @@
+
+
+
+ vor %1$d Min.
+ vor %1$d Minuten
+ vor %1$.1f Stunde
+ Std
+ Tage
+ Stunden
+ Sekunde
+ Minute
+ Stunde
+ Tag
+ Woche
+ Sekunden
+ Minuten
+ Stunden
+ Tage
+ Wochen
+ min
+ d
+
diff --git a/shared/src/main/res/values-el-rGR/strings.xml b/shared/src/main/res/values-el-rGR/strings.xml
new file mode 100644
index 0000000000..960d69de0d
--- /dev/null
+++ b/shared/src/main/res/values-el-rGR/strings.xml
@@ -0,0 +1,18 @@
+
+
+
+ h
+ ημέρες
+ ώρες
+ δευτερόλεπτο
+ λεπτό
+ ώρα
+ ημέρα
+ εβδομάδα
+ δευτερόλεπτα
+ λεπτά
+ ώρες
+ ημέρες
+ εβδομάδες
+ m
+
diff --git a/shared/src/main/res/values-es-rES/strings.xml b/shared/src/main/res/values-es-rES/strings.xml
new file mode 100644
index 0000000000..a0f0767587
--- /dev/null
+++ b/shared/src/main/res/values-es-rES/strings.xml
@@ -0,0 +1,30 @@
+
+
+
+ hace %1$d m
+ Hace %1$d minutos
+ hace %1$.1f h
+ Hace %1$.1f día
+ Hace %1$.0f días
+ en %1$.0f días
+ en %1$.0f días
+ h
+ días
+ horas
+ segundo
+ minuto
+ hora
+ día
+ semana
+ segundos
+ minutos
+ horas
+ días
+ semanas
+ m
+ d
+ Más tarde hoy
+ Mañana
+ Hoy
+ Ayer
+
diff --git a/shared/src/main/res/values-fr-rFR/strings.xml b/shared/src/main/res/values-fr-rFR/strings.xml
new file mode 100644
index 0000000000..67db8a5129
--- /dev/null
+++ b/shared/src/main/res/values-fr-rFR/strings.xml
@@ -0,0 +1,30 @@
+
+
+
+ il y a %1$d m
+ Il y a %1$d minutes
+ il y a %1$.1f h
+ Il y a %1$.1f jours
+ Il y a %1$.0f jours
+ en %1$.0f jours
+ en %1$.0f jours
+ h
+ jours
+ heures
+ seconde
+ minute
+ heure
+ jour
+ semaine
+ secondes
+ minutes
+ heures
+ jours
+ semaines
+ m
+ j
+ Plus tard aujourd\'hui
+ Demain
+ Aujourd’hui
+ Hier
+
diff --git a/shared/src/main/res/values-ga-rIE/strings.xml b/shared/src/main/res/values-ga-rIE/strings.xml
new file mode 100644
index 0000000000..8d4df752e5
--- /dev/null
+++ b/shared/src/main/res/values-ga-rIE/strings.xml
@@ -0,0 +1,21 @@
+
+
+
+ %1$d nóim ó shin
+ %1$.1f u ó shin
+ u
+ lá
+ uair
+ soicind
+ nóiméad
+ uair
+ lá
+ seachtain
+ soicind
+ nóiméad
+ uair
+ lá
+ seachtaine
+ n
+ lá
+
diff --git a/shared/src/main/res/values-hr-rHR/strings.xml b/shared/src/main/res/values-hr-rHR/strings.xml
new file mode 100644
index 0000000000..554d7a16e3
--- /dev/null
+++ b/shared/src/main/res/values-hr-rHR/strings.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/shared/src/main/res/values-hu-rHU/strings.xml b/shared/src/main/res/values-hu-rHU/strings.xml
new file mode 100644
index 0000000000..875ac03d58
--- /dev/null
+++ b/shared/src/main/res/values-hu-rHU/strings.xml
@@ -0,0 +1,6 @@
+
+
+
+ p
+ n
+
diff --git a/shared/src/main/res/values-it-rIT/strings.xml b/shared/src/main/res/values-it-rIT/strings.xml
new file mode 100644
index 0000000000..28f5292504
--- /dev/null
+++ b/shared/src/main/res/values-it-rIT/strings.xml
@@ -0,0 +1,30 @@
+
+
+
+ %1$d m fa
+ %1$d minuti fa
+ %1$.1f h fa
+ %1$.1f giorni fa
+ %1$.0f giorni fa
+ in %1$.0f giorni
+ in %1$.0f giorni
+ h
+ giorni
+ ore
+ secondi
+ minuti
+ ora
+ giorno
+ settimana
+ secondi
+ minuti
+ ore
+ giorni
+ settimane
+ m
+ d
+ Più tardì oggi
+ Domani
+ Oggi
+ Ieri
+
diff --git a/shared/src/main/res/values-iw-rIL/strings.xml b/shared/src/main/res/values-iw-rIL/strings.xml
new file mode 100644
index 0000000000..c1a2923953
--- /dev/null
+++ b/shared/src/main/res/values-iw-rIL/strings.xml
@@ -0,0 +1,30 @@
+
+
+
+ לפני %1$d דקות
+ לפני %1$d דקות
+ לפני %1$.1f שעות
+ לפני %1$.1f ימים
+ לפני %1$.0f ימים
+ בעוד %1$.0f ימים
+ בעוד %1$.0f ימים
+ ש\'
+ ימים
+ שעות
+ שניה
+ דקה
+ שעה
+ יום
+ שבוע
+ שניות
+ דקות
+ שעות
+ ימים
+ שבועות
+ דק\'
+ י\'
+ מאוחר יותר היום
+ מחר
+ היום
+ אתמול
+
diff --git a/shared/src/main/res/values-ko-rKR/strings.xml b/shared/src/main/res/values-ko-rKR/strings.xml
new file mode 100644
index 0000000000..be3ce93a16
--- /dev/null
+++ b/shared/src/main/res/values-ko-rKR/strings.xml
@@ -0,0 +1,21 @@
+
+
+
+ %1$d 분 전
+ %1$.1f 시간 전
+ 시간
+ 일
+ 시간
+ 초
+ 분
+ 시
+ 일
+ 주
+ 초
+ 분
+ 시
+ 일
+ 주
+ 분
+ 일
+
diff --git a/shared/src/main/res/values-lt-rLT/strings.xml b/shared/src/main/res/values-lt-rLT/strings.xml
new file mode 100644
index 0000000000..bb053b1723
--- /dev/null
+++ b/shared/src/main/res/values-lt-rLT/strings.xml
@@ -0,0 +1,21 @@
+
+
+
+ prieš %1$d min
+ Prieš %1$.1f val.
+ val
+ d.
+ val.
+ sek.
+ min.
+ val.
+ d.
+ savaitė
+ sekundės
+ min.
+ val.
+ d.
+ savaičių
+ min.
+ d
+
diff --git a/shared/src/main/res/values-nl-rNL/strings.xml b/shared/src/main/res/values-nl-rNL/strings.xml
new file mode 100644
index 0000000000..b927c43d0b
--- /dev/null
+++ b/shared/src/main/res/values-nl-rNL/strings.xml
@@ -0,0 +1,30 @@
+
+
+
+ %1$d m geleden
+ %1$d minuten geleden
+ %1$.1f uur geleden
+ %1$.1f dagen geleden
+ %1$.0f dagen geleden
+ over %1$.0f dagen
+ over %1$.0f dagen
+ u
+ dagen
+ uren
+ seconde
+ minuut
+ uur
+ dag
+ week
+ seconden
+ minuten
+ uren
+ dagen
+ weken
+ m
+ d
+ Later vandaag
+ Morgen
+ Vandaag
+ Gisteren
+
diff --git a/shared/src/main/res/values-no-rNO/strings.xml b/shared/src/main/res/values-no-rNO/strings.xml
new file mode 100644
index 0000000000..6cdad44084
--- /dev/null
+++ b/shared/src/main/res/values-no-rNO/strings.xml
@@ -0,0 +1,30 @@
+
+
+
+ %1$d min siden
+ %1$d minutter siden
+ %1$.1f timer siden
+ %1$.1f dager siden
+ %1$.0f dager siden
+ om %1$.0f dager
+ om %1$.0f dager
+ t
+ dager
+ timer
+ sekund
+ minutt
+ time
+ dag
+ uke
+ sekunder
+ minutter
+ timer
+ dager
+ uker
+ m
+ d
+ Senere i dag
+ I morgen
+ Idag
+ I går
+
diff --git a/shared/src/main/res/values-pl-rPL/strings.xml b/shared/src/main/res/values-pl-rPL/strings.xml
new file mode 100644
index 0000000000..52ab7af39b
--- /dev/null
+++ b/shared/src/main/res/values-pl-rPL/strings.xml
@@ -0,0 +1,29 @@
+
+
+
+ %1$d min temu
+ %1$.1f godz. temu
+ %1$.1f dni temu
+ %1$.0f dni temu
+ za %1$.0f dni
+ za %1$.0f dni
+ h
+ dni
+ godzin
+ sekunda
+ minuta
+ godzina
+ dzień
+ tydzień
+ sekund
+ minut
+ godzin
+ dni
+ tygodni
+ m
+ d
+ Dzisiaj, później
+ Jutro
+ Dziś
+ Wczoraj
+
diff --git a/shared/src/main/res/values-pt-rBR/strings.xml b/shared/src/main/res/values-pt-rBR/strings.xml
new file mode 100644
index 0000000000..91d8dc0119
--- /dev/null
+++ b/shared/src/main/res/values-pt-rBR/strings.xml
@@ -0,0 +1,22 @@
+
+
+
+ %1$d min atrás
+ %1$d minutos atrás
+ %1$.1fh atrás
+ %1$d dias atrás
+ h
+ dias
+ horas
+ segundo
+ minuto
+ hora
+ dia
+ semana
+ segundos
+ minutos
+ horas
+ dias
+ semanas
+ m
+
diff --git a/shared/src/main/res/values-pt-rPT/strings.xml b/shared/src/main/res/values-pt-rPT/strings.xml
new file mode 100644
index 0000000000..b6194783ad
--- /dev/null
+++ b/shared/src/main/res/values-pt-rPT/strings.xml
@@ -0,0 +1,21 @@
+
+
+
+ %1$d m atrás
+ %1$.1f h atrás
+ h
+ dias
+ horas
+ segundo
+ minuto
+ hora
+ dia
+ semana
+ segundos
+ minutos
+ horas
+ dias
+ semanas
+ m
+ d
+
diff --git a/shared/src/main/res/values-ro-rRO/strings.xml b/shared/src/main/res/values-ro-rRO/strings.xml
new file mode 100644
index 0000000000..025c5d22c6
--- /dev/null
+++ b/shared/src/main/res/values-ro-rRO/strings.xml
@@ -0,0 +1,21 @@
+
+
+
+ %1$d min în urmă
+ %1$.1f ore în urmă
+ h
+ zile
+ ore
+ secundă
+ minut
+ oră
+ zi
+ săptămână
+ secunde
+ minute
+ ore
+ zile
+ săptămâni
+ min
+ z
+
diff --git a/shared/src/main/res/values-ru-rRU/strings.xml b/shared/src/main/res/values-ru-rRU/strings.xml
new file mode 100644
index 0000000000..823285bb86
--- /dev/null
+++ b/shared/src/main/res/values-ru-rRU/strings.xml
@@ -0,0 +1,30 @@
+
+
+
+ %1$d мин. назад
+ %1$d минут назад
+ %1$.1fч. назад
+ %1$s дн назад
+ %1$s дн назад
+ через %1$.0f дн
+ через %1$.0f дн
+ ч
+ дн
+ час
+ сек
+ мин
+ час
+ дн
+ нед
+ сек
+ мин
+ час
+ дн
+ нед
+ мин
+ дн
+ Позднее сегодня
+ Завтра
+ Cегодня
+ Вчера
+
diff --git a/shared/src/main/res/values-sk-rSK/strings.xml b/shared/src/main/res/values-sk-rSK/strings.xml
new file mode 100644
index 0000000000..3371a5e805
--- /dev/null
+++ b/shared/src/main/res/values-sk-rSK/strings.xml
@@ -0,0 +1,30 @@
+
+
+
+ pred %1$d min
+ pred %1$d minútami
+ pred %1$.1f h
+ Pred %1$.1f dňami
+ Pred %1$.0f dňami
+ za %1$.0f dní
+ za %1$.0f dní
+ h
+ dní
+ hodín
+ sekunda
+ minúta
+ hodina
+ deň
+ týždeň
+ sekúnd
+ minút
+ hodín
+ dní
+ týždňov
+ m
+ d
+ Neskôr počas dňa
+ Zajtra
+ Dnes
+ včera
+
diff --git a/shared/src/main/res/values-sv-rSE/strings.xml b/shared/src/main/res/values-sv-rSE/strings.xml
new file mode 100644
index 0000000000..df1d98aae8
--- /dev/null
+++ b/shared/src/main/res/values-sv-rSE/strings.xml
@@ -0,0 +1,22 @@
+
+
+
+ %1$dm sedan
+ %1$d minuter sedan
+ %1$.1f tim sedan
+ h
+ dagar
+ timmar
+ sekund
+ minut
+ timme
+ dag
+ vecka
+ sekunder
+ minuter
+ timmar
+ dagar
+ veckor
+ m
+ d
+
diff --git a/shared/src/main/res/values-tr-rTR/strings.xml b/shared/src/main/res/values-tr-rTR/strings.xml
new file mode 100644
index 0000000000..b457090d83
--- /dev/null
+++ b/shared/src/main/res/values-tr-rTR/strings.xml
@@ -0,0 +1,30 @@
+
+
+
+ %1$d dak önce
+ %1$d dakika önce
+ %1$.1f s önce
+ %1$.1f gün önce
+ %1$.0f gün önce
+ %1$.0f gün içinde
+ %1$.0f gün içinde
+ s
+ gün
+ saat
+ saniye
+ dakika
+ saat
+ gün
+ hafta
+ saniye
+ dakika
+ saat
+ gün
+ hafta
+ dk
+ g
+ Bugünden sonra
+ Yarın
+ Bugün
+ Dün
+
diff --git a/shared/src/main/res/values-zh-rCN/strings.xml b/shared/src/main/res/values-zh-rCN/strings.xml
new file mode 100644
index 0000000000..2619d4b612
--- /dev/null
+++ b/shared/src/main/res/values-zh-rCN/strings.xml
@@ -0,0 +1,30 @@
+
+
+
+ %1$d 分钟前
+ %1$d 分钟前
+ %1$.1f 小时前
+ %1$.1f 天前
+ %1$.0f 天前
+ 在 %1$.0f 天内
+ 在 %1$.0f 天内
+ h
+ 天
+ 小时
+ 秒
+ 分钟
+ 小时
+ 天
+ 周
+ 秒
+ 分钟
+ 小时
+ 天
+ 周
+ m
+ d
+ 今天稍后
+ 明天
+ 今天
+ 昨天
+
diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml
index 88b52fc779..3d10810e37 100644
--- a/wear/src/main/AndroidManifest.xml
+++ b/wear/src/main/AndroidManifest.xml
@@ -629,5 +629,17 @@
+
+
+
+
+
+
+
+
diff --git a/wear/src/main/java/info/nightscout/androidaps/di/WearActivitiesModule.kt b/wear/src/main/java/info/nightscout/androidaps/di/WearActivitiesModule.kt
index 18a63adb66..7055b32be0 100644
--- a/wear/src/main/java/info/nightscout/androidaps/di/WearActivitiesModule.kt
+++ b/wear/src/main/java/info/nightscout/androidaps/di/WearActivitiesModule.kt
@@ -2,6 +2,7 @@ package info.nightscout.androidaps.di
import dagger.Module
import dagger.android.ContributesAndroidInjector
+import info.nightscout.androidaps.interaction.actions.QuickSnoozeActivity
import info.nightscout.androidaps.interaction.ConfigurationActivity
import info.nightscout.androidaps.interaction.TileConfigurationActivity
import info.nightscout.androidaps.interaction.actions.*
@@ -34,4 +35,5 @@ abstract class WearActivitiesModule {
@ContributesAndroidInjector abstract fun contributesFillMenuActivity(): FillMenuActivity
@ContributesAndroidInjector abstract fun contributesMainMenuActivity(): MainMenuActivity
@ContributesAndroidInjector abstract fun contributesStatusMenuActivity(): StatusMenuActivity
-}
\ No newline at end of file
+ @ContributesAndroidInjector abstract fun contributesQuickSnoozeActivity(): QuickSnoozeActivity
+}
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/QuickSnoozeActivity.kt b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/QuickSnoozeActivity.kt
new file mode 100644
index 0000000000..40a8f690e9
--- /dev/null
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/QuickSnoozeActivity.kt
@@ -0,0 +1,52 @@
+package info.nightscout.androidaps.interaction.actions
+
+import android.content.Intent
+import android.content.pm.PackageManager
+import android.os.Bundle
+import android.util.Log
+import android.widget.Toast
+import dagger.android.DaggerActivity
+import info.nightscout.androidaps.R
+import info.nightscout.androidaps.events.EventWearToMobile
+import info.nightscout.androidaps.plugins.bus.RxBus
+import info.nightscout.shared.weardata.EventData
+import javax.inject.Inject
+
+/**
+ * Send a snooze request to silence any alarm. Designed to be bound to a button for fast access
+ */
+
+class QuickSnoozeActivity : DaggerActivity() {
+
+ @Inject lateinit var rxBus: RxBus
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ Toast.makeText(this, R.string.sending_snooze, Toast.LENGTH_LONG).show()
+ rxBus.send(EventWearToMobile(EventData.SnoozeAlert(System.currentTimeMillis())))
+
+ val xDripPackageName = "com.eveningoutpost.dexdrip"
+ if (isPackageExisted(xDripPackageName)) {
+ try {
+ val i = Intent()
+ i.setClassName(xDripPackageName, "$xDripPackageName.QuickSnooze")
+ startActivity(i)
+ } catch (e : Exception) {
+ Log.e("WEAR", "failed to snooze xDrip: ", e)
+ }
+ } else {
+ Log.d("WEAR", "Package $xDripPackageName not available for snooze")
+ }
+
+ finish()
+ }
+
+ private fun isPackageExisted(targetPackage: String): Boolean {
+ try {
+ packageManager.getPackageInfo(targetPackage, PackageManager.GET_META_DATA)
+ } catch (e: PackageManager.NameNotFoundException) {
+ return false
+ }
+ return true
+ }
+}
diff --git a/wear/src/main/res/drawable/ic_icon_snooze.png b/wear/src/main/res/drawable/ic_icon_snooze.png
new file mode 100644
index 0000000000..31b80685be
Binary files /dev/null and b/wear/src/main/res/drawable/ic_icon_snooze.png differ
diff --git a/wear/src/main/res/values-cs-rCZ/strings.xml b/wear/src/main/res/values-cs-rCZ/strings.xml
index 84ebb1a0ae..5c8f9a308d 100644
--- a/wear/src/main/res/values-cs-rCZ/strings.xml
+++ b/wear/src/main/res/values-cs-rCZ/strings.xml
@@ -182,6 +182,8 @@
--- mg/dl
Žádný stav smyčky
000g
- 00,0
+ 00,0
0,00U
+ AAPS Potvrzení výstrahy
+ Odesílání potvrzení do AAPS
diff --git a/wear/src/main/res/values-es-rES/strings.xml b/wear/src/main/res/values-es-rES/strings.xml
index 680c610a92..bf386fac5c 100644
--- a/wear/src/main/res/values-es-rES/strings.xml
+++ b/wear/src/main/res/values-es-rES/strings.xml
@@ -182,6 +182,8 @@
--- mg/dl
Sin estado del lazo
000g
- 00,0
+ 00,0
0,00U
+ Posponer Alertas de AAPS
+ Enviando aplazamientos a AAPS
diff --git a/wear/src/main/res/values-fr-rFR/strings.xml b/wear/src/main/res/values-fr-rFR/strings.xml
index 9073bec2ef..e4bd273b2d 100644
--- a/wear/src/main/res/values-fr-rFR/strings.xml
+++ b/wear/src/main/res/values-fr-rFR/strings.xml
@@ -168,6 +168,8 @@
Aucune configuration disponible
Contrôles Wear désactivés
Aucune donnée disponible
+ augmenter
+ diminuer
H
B
moy
@@ -175,10 +177,11 @@
--g
-.-- U/h
Téléchargement : ---%
+ aucun statut
Il y a -- minutes
--- mg/dl
Aucun statut de la boucle
000 g
- 00,0
+ 00,0
0,00 U
diff --git a/wear/src/main/res/values-it-rIT/strings.xml b/wear/src/main/res/values-it-rIT/strings.xml
index f4a184765a..ccf8bfec97 100644
--- a/wear/src/main/res/values-it-rIT/strings.xml
+++ b/wear/src/main/res/values-it-rIT/strings.xml
@@ -2,6 +2,15 @@
AAPS
AAPS
+ AAPS
+ AAPS(Large)
+ AAPS(BigChart)
+ AAPS(NoChart)
+ AAPS(Circle)
+ AAPS(v2)
+ AAPS(Cockpit)
+ AAPS(Steampunk)
+ AAPS(DigitalStyle)
AAPS(azioni)
AAPS(Temp Target)
AAPS(Quick Wizard)
@@ -55,6 +64,7 @@
Complication Tap Action
Unicode in Complications
Versione:
+ Più impostazioni watchface
Controlla configurazione watchface.
TempT
Calcolatore
@@ -80,6 +90,7 @@
Calcolo richiesto
Riempimento richiesto
CHO richiesti
+ Cambio profilo richiesto
Target
Basso
Alto
@@ -101,6 +112,7 @@
CANCELLA BOLO
Micro
Loop
+ Cambio profilo
TDD
CHO
IOB
@@ -156,4 +168,20 @@
Nessuna configurazione disponibile
Controlli smartwatch disabilitati
Nessun dato disponibile
+ incremento
+ decremento
+ H
+ L
+ media
+ --U
+ --g
+ -.--U/h
+ Caricamento: ---%
+ S: nessuno stato
+ -- Minuti fa
+ --- mg/dl
+ Nessun stato di loop
+ 000g
+ 00,0
+ 0,00U
diff --git a/wear/src/main/res/values-iw-rIL/strings.xml b/wear/src/main/res/values-iw-rIL/strings.xml
index 0fab8bcc3e..05ff9fe014 100644
--- a/wear/src/main/res/values-iw-rIL/strings.xml
+++ b/wear/src/main/res/values-iw-rIL/strings.xml
@@ -2,6 +2,15 @@
AAPS
AAPS
+ AAPS
+ AAPS (גדול)
+ AAPS (תרשים גדול)
+ AAPS (ללא תרשים)
+ AAPS (עיגול)
+ AAPS (v2)
+ AAPS (תא טייס)
+ AAPS (סטימפאנק)
+ AAPS (דיגיטלי)
AAPS (פעולות)
AAPS (מטרה זמנית)
AAPS (אשף מהיר)
@@ -55,6 +64,7 @@
פעולת הקשה על סיבוך
יוניקוד בסיבוכים
גירסה:
+ עוד הגדרות פני שעון
עיינו בהגדרות פני השעון בבקשה.
מטרה זמנית
מחשבון
@@ -80,6 +90,7 @@
התבקש חישוב
התבקש מילוי
נדרשו פחמימות
+ התבקשה החלפת פרופיל
ערך מטרה
נמוך
גבוה
@@ -101,6 +112,7 @@
ביטול בולוס
משאבה
לולאה
+ החלפת פרופיל
סה\"כ מינון אינסולין יומי TDD
פחמימות
כמות אינסולין פעילה
@@ -156,4 +168,20 @@
אין הגדרה
שליטה משעון Wear אינה מאופשרת
אין נתונים זמינים
+ תוספת
+ הפחתה
+ גב\'
+ נמ\'
+ ממוצע
+ -- יח\'
+ -- גר\'
+ -.--יח\' לשעה
+ מעלה: --- %
+ אין סטטוס
+ לפני -- דקות
+ --- mg/dl
+ חסר סטטוס לולאה
+ 000 גר\'
+ 00,0
+ 0,00 יח\'
diff --git a/wear/src/main/res/values-nl-rNL/strings.xml b/wear/src/main/res/values-nl-rNL/strings.xml
index 56deef316c..7dd82b44a5 100644
--- a/wear/src/main/res/values-nl-rNL/strings.xml
+++ b/wear/src/main/res/values-nl-rNL/strings.xml
@@ -2,6 +2,15 @@
AAPS
AAPS
+ AAPS
+ AAPS(Groot)
+ AAPS(GroteGrafiek)
+ AAPS(GeenGrafiek)
+ AAPS(Cirkel)
+ AAPS(v2)
+ AAPS(Cockpit)
+ AAPS(Steampunk)
+ AAPS(DigitaleStijl)
AAPS(Acties)
AAPS(Tijdelijk Streefdoel)
AAPS(Quick Wizard)
@@ -55,6 +64,7 @@
Complicatie tik voor actie
Unicode in complicaties
Versie:
+ Meer Watchface instellingen
Kijk naar de Watchface configuratie, alsjeblieft.
TijdStreefd
Calculator
@@ -80,6 +90,7 @@
Berekening aangevraagd
Vullen aangevraagd
Koolhydraten aangevraagd
+ Profiel wisselen aangevraagd
Doel
Laag
Hoog
@@ -101,6 +112,7 @@
BOLUS ANNULEREN
Pomp
Loop
+ Profiel wissel
TDD
Khd
IOB
@@ -156,4 +168,22 @@
Geen configuratie beschikbaar
Wear OS besturing uitgeschakeld
Geen data beschikbaar
+ verhoog
+ verlaag
+ H
+ L
+ gem
+ --E
+ --g
+ -.--E/uur
+ Uploader: ---%
+ S: geen status
+ -- Minuten geleden
+ --- mg/dl
+ Geen Loop Status
+ 000g
+ 00,0
+ 0,00E
+ AAPS Sluimer Alarm
+ Snooze versturen naar AAPS
diff --git a/wear/src/main/res/values-no-rNO/strings.xml b/wear/src/main/res/values-no-rNO/strings.xml
index 94fe4309d0..ea4deaf2ee 100644
--- a/wear/src/main/res/values-no-rNO/strings.xml
+++ b/wear/src/main/res/values-no-rNO/strings.xml
@@ -61,11 +61,11 @@
Prime i menyen
Enkel måleverdi
Kalkulator prosent
- Komplikasjon trykk handling
- Unicode ikomplikasjoner
+ Handling ved trykk på komplikasjon
+ Unicode i komplikasjoner
Versjon:
- Fler urskive innstillinger
- Vennligst sjekk urskive innstillinger.
+ Flere innstillinger for urskive
+ Vennligst sjekk urskiveinnstillinger.
TempT
Kalkulator
Kalk
@@ -128,7 +128,7 @@
blågrønn
grønn
lysegrønn
- gulgrønn
+ limegrønn
gul
rødbrun
oransje
@@ -139,20 +139,20 @@
hvit
svart
flerfarget
- Forenklet brukergrensesnittet
+ Forenklet brukergrensesnitt
Vis kun tid og BS
Vibrer hver time
Vis ukenummer
Din stil:
ingen stil
- minimal palette
- definert palette
- full palette
- Dine farger:
+ minimalistisk stil
+ form-stil
+ full stil
+ Din farge:
Din fargemetning:
- Din farge gjennomsiktighet:
- AAPS bolus framdrift
- AAPS stille bolus framdrift
+ Din gjennomsiktighet:
+ AAPS bolus-framdrift
+ AAPS stille bolus-framdrift
Bolus framdrift og avbryt
Bolus framdrift og avbryt med mindre vibrasjoner
Av
@@ -182,6 +182,8 @@
--- mg/dl
Ingen loop status
000g
- 00,0
+ 00,0
0,00E
+ AAPS slumre-varsel
+ Sender slumring til AAPS
diff --git a/wear/src/main/res/values-ru-rRU/strings.xml b/wear/src/main/res/values-ru-rRU/strings.xml
index 4f320cac43..034531f610 100644
--- a/wear/src/main/res/values-ru-rRU/strings.xml
+++ b/wear/src/main/res/values-ru-rRU/strings.xml
@@ -182,6 +182,6 @@
--- мг/дл
Нет статуса
000г
- 00,0
+ 00,0
0,00 ед
diff --git a/wear/src/main/res/values-sk-rSK/strings.xml b/wear/src/main/res/values-sk-rSK/strings.xml
index 08dde6af7b..8f2e92e153 100644
--- a/wear/src/main/res/values-sk-rSK/strings.xml
+++ b/wear/src/main/res/values-sk-rSK/strings.xml
@@ -176,11 +176,14 @@
--JI
--g
-.--JI/h
+ Uploader: ---%
S: žiadny stav
Pred -- minútami
--- mg/dl
Žiadny stav uzavretého okruhu
000g
- 00,0
+ 00,0
0,00JI
+ AAPS Potvrdenie výstrahy
+ Odosielanie potvrdení do AAPS
diff --git a/wear/src/main/res/values-tr-rTR/strings.xml b/wear/src/main/res/values-tr-rTR/strings.xml
index 5754310521..f9db54975d 100644
--- a/wear/src/main/res/values-tr-rTR/strings.xml
+++ b/wear/src/main/res/values-tr-rTR/strings.xml
@@ -182,6 +182,8 @@
--- mg/dl
Döngü Durumu Yok
000g
- 00,0
+ 00,0
0,00Ü
+ AAPS Uyarı Erteleme
+ AAPS\'ye Erteleme Gönderme
diff --git a/wear/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml
index d5331aa883..b8391eb22e 100644
--- a/wear/src/main/res/values/strings.xml
+++ b/wear/src/main/res/values/strings.xml
@@ -1,9 +1,7 @@
-
AAPS
AAPS
-
AAPS
AAPS(Large)
AAPS(BigChart)
@@ -13,19 +11,15 @@
AAPS(Cockpit)
AAPS(Steampunk)
AAPS(DigitalStyle)
-
AAPS(Actions)
AAPS(Temp Target)
AAPS(Quick Wizard)
-
No data!
Old data!
Since %1$s
Sync with AAPS!
-
No data received since %1$s! Check if AAPS on the phone sends data to watch
AAPS data is %1$s old! Check your sensor, xDrip+, NS, AAPS config or other!
-
Vibrate on Bolus
Units for Actions
Show Date
@@ -72,7 +66,6 @@
Version:
More Watchface settings
Look into Watchface configuration, please.
-
TempT
Calculator
Calc
@@ -89,7 +82,6 @@
Default
Menu
XL
-
Duration
Temp Target Requested
Quick Wizard Requested
@@ -115,20 +107,16 @@
CONFIRM
timeshift
Bolus
-
Bolus Progress
press to cancel
CANCEL BOLUS
-
Pump
Loop
Profile switch
TDD
-
Carb
IOB
no status
-
red
pink
purple
@@ -153,16 +141,13 @@
multicolor
Simplify UI
Only show time and BG
-
Vibrate hourly
Show Week number
-
Your style:
no style
minimal style
shape style
full style
-
Your color:
Your color saturation:
Your color opacity:
@@ -183,7 +168,6 @@
No config available
Wear controls disabled
No data available
-
QuickWizard
wearcontrol
units_mgdl
@@ -236,7 +220,9 @@
--- mg/dl
No Loop Status
000g
- 00,0
+ 00,0
0,00U
+ AAPS Snooze Alert
+ Sending Snooze to AAPS