From 05831c75a684ddd69c0e345e99ea5790e2e5faa5 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 10 Sep 2016 15:33:00 +0200 Subject: [PATCH] SMS LOOP commands --- .idea/misc.xml | 2 +- .../SmsCommunicatorPlugin.java | 73 ++++++++++++++----- .../careportal_newnstreatment_dialog.xml | 3 +- app/src/main/res/values-cs/strings.xml | 4 + app/src/main/res/values/strings.xml | 4 + 5 files changed, 66 insertions(+), 20 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 5d19981032..fbb68289f4 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java index 4f18516349..e7512db331 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java @@ -24,8 +24,8 @@ import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PumpInterface; -import info.nightscout.androidaps.plugins.DanaR.DanaRFragment; import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin; +import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS; import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui; import info.nightscout.utils.SafeParse; @@ -153,24 +153,64 @@ public class SmsCommunicatorPlugin implements PluginBase { if (splited.length > 0) { switch (splited[0].toUpperCase()) { - case "RT": - Intent restartNSClient = new Intent(Intents.ACTION_RESTART); - MainApp.getDbHelper().resetTreatments(); - MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient); - List q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(restartNSClient, 0); - reply = "RT " + q.size() + " receivers"; - receivedSms.processed = true; + case "LOOP": + switch (splited[1].toUpperCase()) { + case "STOP": + LoopPlugin loopPlugin = (LoopPlugin) MainApp.getSpecificPlugin(LoopPlugin.class); + if (loopPlugin != null && loopPlugin.isEnabled(PluginBase.LOOP)) { + loopPlugin.setFragmentEnabled(PluginBase.LOOP, false); + reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeendisabled); + } + receivedSms.processed = true; + break; + case "START": + loopPlugin = (LoopPlugin) MainApp.getSpecificPlugin(LoopPlugin.class); + if (loopPlugin != null && !loopPlugin.isEnabled(PluginBase.LOOP)) { + loopPlugin.setFragmentEnabled(PluginBase.LOOP, true); + reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeenenabled); + } + receivedSms.processed = true; + break; + case "STATUS": + loopPlugin = (LoopPlugin) MainApp.getSpecificPlugin(LoopPlugin.class); + if (loopPlugin != null) { + if (loopPlugin.isEnabled(PluginBase.LOOP)) { + reply = MainApp.sResources.getString(R.string.smscommunicator_loopisenabled); + } else { + reply = MainApp.sResources.getString(R.string.smscommunicator_loopisdisabled); + } + } + receivedSms.processed = true; + break; + } break; - case "RNSC": - restartNSClient = new Intent(Intents.ACTION_RESTART); - MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient); - q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(restartNSClient, 0); - reply = "RNSC " + q.size() + " receivers"; - receivedSms.processed = true; + case "TREATMENTS": + switch (splited[1].toUpperCase()) { + case "REFRESH": + Intent restartNSClient = new Intent(Intents.ACTION_RESTART); + MainApp.getDbHelper().resetTreatments(); + MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient); + List q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(restartNSClient, 0); + reply = "TERATMENTS REFRESH " + q.size() + " receivers"; + receivedSms.processed = true; + break; + } + break; + case "NSCLIENT": + switch (splited[1].toUpperCase()) { + case "RESTART": + Intent restartNSClient = new Intent(Intents.ACTION_RESTART); + MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient); + Listq = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(restartNSClient, 0); + reply = "NSCLIENT RESTART " + q.size() + " receivers"; + receivedSms.processed = true; + break; + } break; case "DANAR": DanaRPlugin danaRPlugin = (DanaRPlugin) MainApp.getSpecificPlugin(DanaRPlugin.class); - if (danaRPlugin != null) reply = danaRPlugin.shortStatus(); + if (danaRPlugin != null && danaRPlugin.isEnabled(PluginBase.PUMP)) + reply = danaRPlugin.shortStatus(); receivedSms.processed = true; break; case "BOLUS": @@ -233,8 +273,7 @@ public class SmsCommunicatorPlugin implements PluginBase { MainApp.bus().post(new EventSmsCommunicatorUpdateGui()); } - public static String stripAccents(String s) - { + public static String stripAccents(String s) { s = Normalizer.normalize(s, Normalizer.Form.NFD); s = s.replaceAll("[\\p{InCombiningDiacriticalMarks}]", ""); return s; diff --git a/app/src/main/res/layout/careportal_newnstreatment_dialog.xml b/app/src/main/res/layout/careportal_newnstreatment_dialog.xml index de755d535e..a7815c727b 100644 --- a/app/src/main/res/layout/careportal_newnstreatment_dialog.xml +++ b/app/src/main/res/layout/careportal_newnstreatment_dialog.xml @@ -148,8 +148,7 @@ android:gravity="center_horizontal" android:inputType="numberDecimal" android:padding="10dp" - android:textAppearance="?android:attr/textAppearanceLarge" - android:visibility="gone" /> + android:textAppearance="?android:attr/textAppearanceLarge" /> Dosaženo limitu Cílová hodnota pro výpočty Aplikováno %.2fU + Smyčka byla zakázána + Smyčka byla povolena + Smyčka je zakázána + Smyčka je povolena \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 685bdf8898..125a93b7ad 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -306,5 +306,9 @@ You reached allowed limit Target value for calculations No profile selected + Loop has been disabled + Loop has been enabled + Loop is disabled + Loop is enabled