From db4439f1cc475043f164883001dc6e4e816c1c98 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Fri, 6 Apr 2018 11:19:25 +0200 Subject: [PATCH] Combo: remove half-backed alerts dialog. --- .../info/nightscout/androidaps/Config.java | 2 - .../PumpCombo/ComboAlertHistoryDialog.java | 52 ------------------ .../plugins/PumpCombo/ComboFragment.java | 55 +++++-------------- .../plugins/PumpCombo/ComboPlugin.java | 17 ------ .../layout/combo_alert_history_fragment.xml | 53 ------------------ .../main/res/layout/combopump_fragment.xml | 13 ----- 6 files changed, 14 insertions(+), 178 deletions(-) delete mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboAlertHistoryDialog.java delete mode 100644 app/src/main/res/layout/combo_alert_history_fragment.xml diff --git a/app/src/main/java/info/nightscout/androidaps/Config.java b/app/src/main/java/info/nightscout/androidaps/Config.java index bbd96a6c61..ff7b935355 100644 --- a/app/src/main/java/info/nightscout/androidaps/Config.java +++ b/app/src/main/java/info/nightscout/androidaps/Config.java @@ -42,6 +42,4 @@ public class Config { public static final boolean logDanaBTComm = true; public static boolean logDanaMessageDetail = true; public static final boolean logDanaSerialEngine = true; - - public static final boolean enableComboBetaFeatures = false; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboAlertHistoryDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboAlertHistoryDialog.java deleted file mode 100644 index 6f30b3aed9..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboAlertHistoryDialog.java +++ /dev/null @@ -1,52 +0,0 @@ -package info.nightscout.androidaps.plugins.PumpCombo; - -import android.os.Bundle; -import android.support.v4.app.DialogFragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import java.text.DateFormat; -import java.util.List; - -import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpAlert; -import info.nightscout.androidaps.R; - -public class ComboAlertHistoryDialog extends DialogFragment { - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View layout = inflater.inflate(R.layout.combo_alert_history_fragment, container, false); - TextView text = (TextView) layout.findViewById(R.id.combo_error_history_text); - List errors = ComboPlugin.getPlugin().getPump().errorHistory; - if (errors.isEmpty()) { - text.setText(R.string.combo_no_alert_data_note); - } else { - StringBuilder sb = new StringBuilder(); - DateFormat dateTimeFormatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); - boolean first = true; - for (PumpAlert error : errors) { - if (first) { - first = false; - } else { - sb.append("\n"); - } - sb.append(dateTimeFormatter.format(error.timestamp)); - sb.append(" "); - sb.append(error.message); - if (error.warningCode != null) { - sb.append(" (W"); - sb.append(error.warningCode); - sb.append(")"); - } - if (error.errorCode != null) { - sb.append(" (E"); - sb.append(error.errorCode); - sb.append(")"); - } - } - text.setText(sb.toString()); - } - return layout; - } -} 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 7e2b6ae8ad..07f59d727e 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 @@ -6,6 +6,7 @@ import android.app.AlertDialog; import android.graphics.Color; import android.graphics.Typeface; import android.os.Bundle; +import android.support.annotation.NonNull; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -16,7 +17,6 @@ import com.squareup.otto.Subscribe; import org.apache.commons.lang3.StringUtils; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.PumpState; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus; import info.nightscout.androidaps.MainApp; @@ -39,35 +39,30 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis private TextView baseBasalRate; private TextView tempBasalText; private Button refreshButton; - private Button alertsButton; private TextView bolusCount; private TextView tbrCount; private Button fullHistoryButton; @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.combopump_fragment, container, false); - stateView = (TextView) view.findViewById(R.id.combo_state); - activityView = (TextView) view.findViewById(R.id.combo_activity); - batteryView = (TextView) view.findViewById(R.id.combo_pumpstate_battery); - reservoirView = (TextView) view.findViewById(R.id.combo_insulinstate); - lastBolusView = (TextView) view.findViewById(R.id.combo_last_bolus); - lastConnectionView = (TextView) view.findViewById(R.id.combo_lastconnection); - baseBasalRate = (TextView) view.findViewById(R.id.combo_base_basal_rate); - tempBasalText = (TextView) view.findViewById(R.id.combo_temp_basal); - bolusCount = (TextView) view.findViewById(R.id.combo_bolus_count); - tbrCount = (TextView) view.findViewById(R.id.combo_tbr_count); + stateView = view.findViewById(R.id.combo_state); + activityView = view.findViewById(R.id.combo_activity); + batteryView = view.findViewById(R.id.combo_pumpstate_battery); + reservoirView = view.findViewById(R.id.combo_insulinstate); + lastBolusView = view.findViewById(R.id.combo_last_bolus); + lastConnectionView = view.findViewById(R.id.combo_lastconnection); + baseBasalRate = view.findViewById(R.id.combo_base_basal_rate); + tempBasalText = view.findViewById(R.id.combo_temp_basal); + bolusCount = view.findViewById(R.id.combo_bolus_count); + tbrCount = view.findViewById(R.id.combo_tbr_count); - refreshButton = (Button) view.findViewById(R.id.combo_refresh_button); + refreshButton = view.findViewById(R.id.combo_refresh_button); refreshButton.setOnClickListener(this); - alertsButton = (Button) view.findViewById(R.id.combo_alerts_button); - alertsButton.setOnClickListener(this); - alertsButton.setOnLongClickListener(this); - - fullHistoryButton = (Button) view.findViewById(R.id.combo_full_history_button); + fullHistoryButton = view.findViewById(R.id.combo_full_history_button); fullHistoryButton.setOnClickListener(this); fullHistoryButton.setOnLongClickListener(this); @@ -94,10 +89,6 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis } }); break; - case R.id.combo_alerts_button: - ComboAlertHistoryDialog ehd = new ComboAlertHistoryDialog(); - ehd.show(getFragmentManager(), ComboAlertHistoryDialog.class.getSimpleName()); - break; case R.id.combo_full_history_button: AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setMessage(R.string.combo_read_full_history_info); @@ -110,27 +101,12 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis @Override public boolean onLongClick(View view) { switch (view.getId()) { - case R.id.combo_alerts_button: - alertsButton.setEnabled(false); - fullHistoryButton.setEnabled(false); - new Thread(() -> ComboPlugin.getPlugin().readAlertData(new Callback() { - @Override - public void run() { - runOnUiThread(() -> { - alertsButton.setEnabled(true); - fullHistoryButton.setEnabled(true); - }); - } - })).start(); - return true; case R.id.combo_full_history_button: - alertsButton.setEnabled(false); fullHistoryButton.setEnabled(false); new Thread(() -> ComboPlugin.getPlugin().readAllPumpData(new Callback() { @Override public void run() { runOnUiThread(() -> { - alertsButton.setEnabled(true); fullHistoryButton.setEnabled(true); }); } @@ -183,9 +159,6 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis if (plugin.isInitialized()) { refreshButton.setVisibility(View.VISIBLE); - if (Config.enableComboBetaFeatures) { - alertsButton.setVisibility(View.VISIBLE); - } fullHistoryButton.setVisibility(View.VISIBLE); // battery 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 1bafb8642c..e466e3a454 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 @@ -1171,23 +1171,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint return pumpBolus.timestamp + Math.min(secondsFromBolus, 59 * 1000); } - // TODO use queue once ready - void readAlertData(Callback post) { -// ConfigBuilderPlugin.getCommandQueue().custom(new Callback() { -// @Override -// public void run() { - readHistory(new PumpHistoryRequest().pumpErrorHistory(PumpHistoryRequest.FULL)); -// } -// }, post); - if (post != null) { - post.run(); - } - CommandQueue commandQueue = ConfigBuilderPlugin.getCommandQueue(); - if (commandQueue.performing() == null && commandQueue.size() == 0) { - ruffyScripter.disconnect(); - } - } - // TODO use queue once ready void readAllPumpData(Callback post) { // ConfigBuilderPlugin.getCommandQueue().custom(new Callback() { diff --git a/app/src/main/res/layout/combo_alert_history_fragment.xml b/app/src/main/res/layout/combo_alert_history_fragment.xml deleted file mode 100644 index f1faa9bb86..0000000000 --- a/app/src/main/res/layout/combo_alert_history_fragment.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/combopump_fragment.xml b/app/src/main/res/layout/combopump_fragment.xml index 03024eb712..0d665c436b 100644 --- a/app/src/main/res/layout/combopump_fragment.xml +++ b/app/src/main/res/layout/combopump_fragment.xml @@ -500,19 +500,6 @@ android:paddingRight="0dp" android:text="@string/combo_refresh" /> - -