From 272262b115b491f46900f7de9841ff5921a73b62 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 13 Jul 2016 13:54:40 +0200 Subject: [PATCH] SMSCommunicator plugin --- .idea/misc.xml | 2 +- app/src/main/AndroidManifest.xml | 4 + .../info/nightscout/androidaps/Config.java | 1 + .../nightscout/androidaps/MainActivity.java | 2 + .../SmsCommunicatorFragment.java | 83 +++++++++++++++++++ .../res/layout/smscommunicator_fragment.xml | 7 ++ app/src/main/res/values/strings.xml | 1 + 7 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorFragment.java create mode 100644 app/src/main/res/layout/smscommunicator_fragment.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index fbb68289f4..5d19981032 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f3e369f670..941085f08c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,6 +9,10 @@ + + + + diff --git a/app/src/main/java/info/nightscout/androidaps/Config.java b/app/src/main/java/info/nightscout/androidaps/Config.java index c0bb7e8d06..dfbb826412 100644 --- a/app/src/main/java/info/nightscout/androidaps/Config.java +++ b/app/src/main/java/info/nightscout/androidaps/Config.java @@ -13,6 +13,7 @@ public class Config { public static final boolean OBJECTIVESENABLED = APS && true; public static final boolean CAREPORTALENABLED = true; + public static final boolean SMSCOMMUNICATORENABLED = true; public static final boolean DANAR = true; diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 0176443b46..5b5dc5d007 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -39,6 +39,7 @@ import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAFragment; import info.nightscout.androidaps.plugins.Overview.OverviewFragment; import info.nightscout.androidaps.plugins.SafetyFragment.SafetyFragment; import info.nightscout.androidaps.plugins.SimpleProfile.SimpleProfileFragment; +import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorFragment; import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientFragment; import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripFragment; import info.nightscout.androidaps.plugins.TempBasals.TempBasalsFragment; @@ -100,6 +101,7 @@ public class MainActivity extends AppCompatActivity { if (Config.OBJECTIVESENABLED) pluginsList.add(ObjectivesFragment.newInstance()); pluginsList.add(SourceXdripFragment.newInstance()); pluginsList.add(SourceNSClientFragment.newInstance()); + if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorFragment.newInstance()); pluginsList.add(configBuilderFragment = ConfigBuilderFragment.newInstance()); registerBus(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorFragment.java new file mode 100644 index 0000000000..177f892587 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorFragment.java @@ -0,0 +1,83 @@ +package info.nightscout.androidaps.plugins.SmsCommunicator; + + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.interfaces.PluginBase; + +/** + * A simple {@link Fragment} subclass. + */ +public class SmsCommunicatorFragment extends Fragment implements PluginBase { + + boolean fragmentEnabled = false; + boolean fragmentVisible = true; + + public SmsCommunicatorFragment() { + super(); + registerBus(); + } + + public static SmsCommunicatorFragment newInstance() { + SmsCommunicatorFragment fragment = new SmsCommunicatorFragment(); + return fragment; + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.smscommunicator_fragment, container, false); + } + + private void registerBus() { + try { + MainApp.bus().unregister(this); + } catch (RuntimeException x) { + // Ignore + } + MainApp.bus().register(this); + } + + @Override + public int getType() { + return PluginBase.GENERAL; + } + + @Override + public String getName() { + return MainApp.sResources.getString(R.string.smscommunicator); + } + + @Override + public boolean isEnabled(int type) { + return fragmentEnabled; + } + + @Override + public boolean isVisibleInTabs(int type) { + return fragmentVisible; + } + + @Override + public boolean canBeHidden(int type) { + return true; + } + + @Override + public void setFragmentEnabled(int type, boolean fragmentEnabled) { + this.fragmentEnabled = fragmentEnabled; + } + + @Override + public void setFragmentVisible(int type, boolean fragmentVisible) { + this.fragmentVisible = fragmentVisible; + } +} diff --git a/app/src/main/res/layout/smscommunicator_fragment.xml b/app/src/main/res/layout/smscommunicator_fragment.xml new file mode 100644 index 0000000000..b744120e14 --- /dev/null +++ b/app/src/main/res/layout/smscommunicator_fragment.xml @@ -0,0 +1,7 @@ + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 15cd5770c9..3ff09334c4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -242,5 +242,6 @@ Percent Absolute Cancel temp basal + Sms Communicator