SMS LOOP commands

This commit is contained in:
Milos Kozak 2016-09-10 15:33:00 +02:00
parent 61134a550f
commit 05831c75a6
5 changed files with 66 additions and 20 deletions

View file

@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View file

@ -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<ResolveInfo> 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<ResolveInfo> 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);
List<ResolveInfo>q = 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;

View file

@ -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" />
<ImageView
android:id="@+id/careportal_newnstreatment_carbs_plus"

View file

@ -302,4 +302,8 @@
<string name="youareonallowedlimit">Dosaženo limitu</string>
<string name="openapsma_target_bg">Cílová hodnota pro výpočty</string>
<string name="bolusdelivering" formatted="false">Aplikováno %.2fU</string>
<string name="smscommunicator_loophasbeendisabled">Smyčka byla zakázána</string>
<string name="smscommunicator_loophasbeenenabled">Smyčka byla povolena</string>
<string name="smscommunicator_loopisdisabled">Smyčka je zakázána</string>
<string name="smscommunicator_loopisenabled">Smyčka je povolena</string>
</resources>

View file

@ -306,5 +306,9 @@
<string name="youareonallowedlimit">You reached allowed limit</string>
<string name="openapsma_target_bg">Target value for calculations</string>
<string name="noprofileselected">No profile selected</string>
<string name="smscommunicator_loophasbeendisabled">Loop has been disabled</string>
<string name="smscommunicator_loophasbeenenabled">Loop has been enabled</string>
<string name="smscommunicator_loopisdisabled">Loop is disabled</string>
<string name="smscommunicator_loopisenabled">Loop is enabled</string>
</resources>