diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java index 0c331b8eb7..5469e8e0b8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java @@ -33,7 +33,7 @@ public class ComboFragment extends Fragment implements View.OnClickListener { } private Button refresh; - private Button testButton; + private TextView updateCapabilities; private TextView statusText; @@ -46,13 +46,15 @@ public class ComboFragment extends Fragment implements View.OnClickListener { private TextView lastCmdTimeText; private TextView lastCmdResultText; + private TextView tbrCapabilityText; + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.combopump_fragment, container, false); refresh = (Button) view.findViewById(R.id.combo_refresh); - testButton = (Button) view.findViewById(R.id.combo_testaction); + updateCapabilities = (TextView) view.findViewById(R.id.combo_update_capabilities); statusText = (TextView) view.findViewById(R.id.combo_status); @@ -64,9 +66,10 @@ public class ComboFragment extends Fragment implements View.OnClickListener { lastCmdText = (TextView) view.findViewById(R.id.combo_last_command); lastCmdTimeText = (TextView) view.findViewById(R.id.combo_last_command_time); lastCmdResultText = (TextView) view.findViewById(R.id.combo_last_command_result); + tbrCapabilityText = (TextView) view.findViewById(R.id.combo_tbr_capability); refresh.setOnClickListener(this); - testButton.setOnClickListener(this); + updateCapabilities.setOnClickListener(this); updateGUI(); return view; @@ -102,11 +105,29 @@ public class ComboFragment extends Fragment implements View.OnClickListener { }); thread.start(); break; - case R.id.combo_testaction: + case R.id.combo_update_capabilities: (new Thread(new Runnable() { @Override public void run() { - getPlugin().doTestAction(); + Activity activity = getActivity(); + if (activity != null) + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + updateCapabilities.setText("{fa-bluetooth}"); + } + }); + + getPlugin().updateCapabilities(); + + if (activity != null) + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + updateCapabilities.setText("{fa-bluetooth-b}"); + } + }); + } })).start(); break; @@ -151,7 +172,9 @@ public class ComboFragment extends Fragment implements View.OnClickListener { } else { lastCmdResultText.setText(""); } + } + tbrCapabilityText.setText(getPlugin().getPumpDescription().maxTempPercent + "%"); } }); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index ce76f7df8a..d14abd580f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -621,19 +621,23 @@ public class ComboPlugin implements PluginBase, PumpInterface { } - public void doTestAction() { - ToastUtils.showToastInUiThread(MainApp.instance(), "TestAction called"); + public void updateCapabilities() { // if Android is sluggish this might get called before ruffy is bound if (ruffyScripter == null) { log.warn("Rejecting call to RefreshDataFromPump: ruffy service not bound (yet)"); - ToastUtils.showToastInUiThread(MainApp.instance(), "Rejecting call to RefreshDataFromPump: ruffy service not bound (yet)"); - + ToastUtils.showToastInUiThread(MainApp.instance(), "Ruffy not initialized."); + return; + } + if (isBusy()){ + ToastUtils.showToastInUiThread(MainApp.instance(), "Pump busy!"); return; } CommandResult result = runCommand(new DetermineCapabilitiesCommand()); if (result.success){ - ToastUtils.showToastInUiThread(MainApp.instance(), "max%: " + result.capabilities.maxTempPercent); + //TODO: write to settings result.capabilities.maxTempPercent + pumpDescription.maxTempPercent = (int) result.capabilities.maxTempPercent; + MainApp.bus().post(new EventComboPumpUpdateGUI()); } else { ToastUtils.showToastInUiThread(MainApp.instance(), "No success with test Command."); } diff --git a/app/src/main/res/layout/combopump_fragment.xml b/app/src/main/res/layout/combopump_fragment.xml index d076925740..5e7a352127 100644 --- a/app/src/main/res/layout/combopump_fragment.xml +++ b/app/src/main/res/layout/combopump_fragment.xml @@ -20,13 +20,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Refresh" /> -