diff --git a/app/src/main/java/info/nightscout/androidaps/Config.java b/app/src/main/java/info/nightscout/androidaps/Config.java
index dfbb826412..1f2fdf846a 100644
--- a/app/src/main/java/info/nightscout/androidaps/Config.java
+++ b/app/src/main/java/info/nightscout/androidaps/Config.java
@@ -17,6 +17,8 @@ public class Config {
public static final boolean DANAR = true;
+ public static final boolean MM640G = true;
+
public static final boolean detailedLog = true;
public static final boolean logFunctionCalls = true;
public static final boolean logIncommingBG = true;
diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java
index 5b5dc5d007..01cf8272fa 100644
--- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java
@@ -34,6 +34,7 @@ import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.DanaR.DanaRFragment;
import info.nightscout.androidaps.plugins.Loop.LoopFragment;
import info.nightscout.androidaps.plugins.LowSuspend.LowSuspendFragment;
+import info.nightscout.androidaps.plugins.MM640g.MM640gFragment;
import info.nightscout.androidaps.plugins.NSProfileViewer.NSProfileViewerFragment;
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAFragment;
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
@@ -88,6 +89,7 @@ public class MainActivity extends AppCompatActivity {
// Register all tabs in app here
pluginsList.add(OverviewFragment.newInstance());
if (Config.DANAR) pluginsList.add(DanaRFragment.newInstance());
+ if (Config.MM640G) pluginsList.add(MM640gFragment.newInstance());
pluginsList.add(VirtualPumpFragment.newInstance());
if (Config.CAREPORTALENABLED) pluginsList.add(CareportalFragment.newInstance());
if (Config.LOOPENABLED) pluginsList.add(LoopFragment.newInstance());
diff --git a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java
index 4e4214e91f..d7bd740ef0 100644
--- a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java
@@ -85,6 +85,8 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
addPreferencesFromResource(R.xml.pref_nightscout);
if (Config.DANAR)
addPreferencesFromResource(R.xml.pref_danar);
+ if (Config.MM640G)
+ addPreferencesFromResource(R.xml.pref_mm640g);
if (Config.CAREPORTALENABLED)
addPreferencesFromResource(R.xml.pref_careportal);
initSummary(getPreferenceScreen());
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java
index cf37373a69..fb8680908f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java
@@ -150,7 +150,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
}
void setViews() {
- bgsourceDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.BGSOURCE), PluginBase.BGSOURCE);
+ bgsourceDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsListByInterface(BgSourceInterface.class), PluginBase.BGSOURCE);
bgsourceListView.setAdapter(bgsourceDataAdapter);
setListViewHeightBasedOnChildren(bgsourceListView);
pumpDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.PUMP), PluginBase.PUMP);
@@ -455,9 +455,10 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
CheckBox cb = (CheckBox) v;
PluginBase plugin = (PluginBase) cb.getTag();
plugin.setFragmentEnabled(type, cb.isChecked());
- if (cb.isChecked()) plugin.setFragmentVisible(type, true);
+ plugin.setFragmentVisible(type, cb.isChecked());
onEnabledCategoryChanged(plugin, type);
storeSettings();
+ MainApp.bus().post(new EventRefreshGui());
}
});
@@ -569,12 +570,13 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
// this is new selected
} else {
p.setFragmentEnabled(type, false);
- setViews();
+ p.setFragmentVisible(type, false);
}
}
} else { // enable first plugin in list
pluginsInCategory.get(0).setFragmentEnabled(type, true);
}
+ setViews();
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/MM640g/MM640gFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/MM640g/MM640gFragment.java
new file mode 100644
index 0000000000..90b6708040
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/MM640g/MM640gFragment.java
@@ -0,0 +1,205 @@
+package info.nightscout.androidaps.plugins.MM640g;
+
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.squareup.otto.Subscribe;
+
+import org.json.JSONObject;
+
+import java.util.Date;
+
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.data.PumpEnactResult;
+import info.nightscout.androidaps.db.TempBasal;
+import info.nightscout.androidaps.events.EventPreferenceChange;
+import info.nightscout.androidaps.interfaces.BgSourceInterface;
+import info.nightscout.androidaps.interfaces.PluginBase;
+import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.client.data.NSProfile;
+
+public class MM640gFragment extends Fragment implements PluginBase, PumpInterface, BgSourceInterface {
+
+
+ boolean fragmentPumpEnabled = false;
+ boolean fragmentProfileEnabled = false;
+ boolean fragmentBgSourceEnabled = false;
+ boolean fragmentPumpVisible = true;
+
+
+ public MM640gFragment() {
+ registerBus();
+ }
+
+ public static MM640gFragment newInstance() {
+ MM640gFragment fragment = new MM640gFragment();
+ return fragment;
+ }
+
+ private void registerBus() {
+ try {
+ MainApp.bus().unregister(this);
+ } catch (RuntimeException x) {
+ // Ignore
+ }
+ MainApp.bus().register(this);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.mm640g_fragment, container, false);
+ return view;
+ }
+
+ /**
+ * Plugin base interface
+ */
+
+ @Override
+ public int getType() {
+ return PluginBase.PUMP;
+ }
+
+ @Override
+ public String getName() {
+ return MainApp.instance().getString(R.string.mm640g);
+ }
+
+ @Override
+ public boolean isEnabled(int type) {
+ if (type == PluginBase.PROFILE) return fragmentProfileEnabled;
+ else if (type == PluginBase.BGSOURCE) return fragmentBgSourceEnabled;
+ else if (type == PluginBase.PUMP) return fragmentPumpEnabled;
+ else if (type == PluginBase.CONSTRAINTS) return fragmentPumpEnabled;
+ return false;
+ }
+
+ @Override
+ public boolean isVisibleInTabs(int type) {
+ if (type == PluginBase.PROFILE || type == PluginBase.CONSTRAINTS) return false;
+ else if (type == PluginBase.PUMP) return fragmentPumpVisible;
+ return false;
+ }
+
+ @Override
+ public boolean canBeHidden(int type) {
+ return true;
+ }
+
+ @Override
+ public void setFragmentEnabled(int type, boolean fragmentEnabled) {
+ if (type == PluginBase.PROFILE) this.fragmentProfileEnabled = fragmentEnabled;
+ if (type == PluginBase.BGSOURCE) this.fragmentBgSourceEnabled = fragmentEnabled;
+ else if (type == PluginBase.PUMP) this.fragmentPumpEnabled = fragmentEnabled;
+ }
+
+ @Override
+ public void setFragmentVisible(int type, boolean fragmentVisible) {
+ if (type == PluginBase.PUMP)
+ this.fragmentPumpVisible = fragmentVisible;
+ }
+
+ /**
+ * Plugin communications
+ */
+
+ @Subscribe
+ public void onStatusEvent(final EventPreferenceChange s) {
+
+ }
+
+ /**
+ * Pump Interface
+ */
+
+ @Override
+ public boolean isTempBasalInProgress() {
+ return false;
+ }
+
+ @Override
+ public boolean isExtendedBoluslInProgress() {
+ return false;
+ }
+
+ @Override
+ public void setNewBasalProfile(NSProfile profile) {
+
+ }
+
+ @Override
+ public double getBaseBasalRate() {
+ return 0;
+ }
+
+ @Override
+ public double getTempBasalAbsoluteRate() {
+ return 0;
+ }
+
+ @Override
+ public double getTempBasalRemainingMinutes() {
+ return 0;
+ }
+
+ @Override
+ public TempBasal getTempBasal(Date time) {
+ return null;
+ }
+
+ @Override
+ public TempBasal getTempBasal() {
+ return null;
+ }
+
+ @Override
+ public TempBasal getExtendedBolus() {
+ return null;
+ }
+
+ @Override
+ public PumpEnactResult deliverTreatment(Double insulin, Integer carbs) {
+ return new PumpEnactResult();
+ }
+
+ @Override
+ public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) {
+ return new PumpEnactResult();
+ }
+
+ @Override
+ public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
+ return new PumpEnactResult();
+ }
+
+ @Override
+ public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
+ return new PumpEnactResult();
+ }
+
+ @Override
+ public PumpEnactResult cancelTempBasal() {
+ return new PumpEnactResult();
+ }
+
+ @Override
+ public PumpEnactResult cancelExtendedBolus() {
+ return new PumpEnactResult();
+ }
+
+ @Override
+ public JSONObject getJSONStatus() {
+ return new JSONObject();
+ }
+
+ @Override
+ public String deviceID() {
+ return "MM640G"; // TODO: probably serial goes here
+ }
+}
diff --git a/app/src/main/res/layout/mm640g_fragment.xml b/app/src/main/res/layout/mm640g_fragment.xml
new file mode 100644
index 0000000000..cf0c892dd0
--- /dev/null
+++ b/app/src/main/res/layout/mm640g_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 3ff09334c4..5e8135d4a1 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -243,5 +243,6 @@
Absolute
Cancel temp basal
Sms Communicator
+ MM 640g
diff --git a/app/src/main/res/xml/pref_mm640g.xml b/app/src/main/res/xml/pref_mm640g.xml
new file mode 100644
index 0000000000..60b7eaf24f
--- /dev/null
+++ b/app/src/main/res/xml/pref_mm640g.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
\ No newline at end of file