Combo: remove half-backed alerts dialog.
This commit is contained in:
parent
e937a777ba
commit
db4439f1cc
6 changed files with 14 additions and 178 deletions
|
@ -42,6 +42,4 @@ public class Config {
|
||||||
public static final boolean logDanaBTComm = true;
|
public static final boolean logDanaBTComm = true;
|
||||||
public static boolean logDanaMessageDetail = true;
|
public static boolean logDanaMessageDetail = true;
|
||||||
public static final boolean logDanaSerialEngine = true;
|
public static final boolean logDanaSerialEngine = true;
|
||||||
|
|
||||||
public static final boolean enableComboBetaFeatures = false;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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<PumpAlert> 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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,6 +6,7 @@ import android.app.AlertDialog;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -16,7 +17,6 @@ import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
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.PumpState;
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus;
|
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
@ -39,35 +39,30 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
private TextView baseBasalRate;
|
private TextView baseBasalRate;
|
||||||
private TextView tempBasalText;
|
private TextView tempBasalText;
|
||||||
private Button refreshButton;
|
private Button refreshButton;
|
||||||
private Button alertsButton;
|
|
||||||
private TextView bolusCount;
|
private TextView bolusCount;
|
||||||
private TextView tbrCount;
|
private TextView tbrCount;
|
||||||
private Button fullHistoryButton;
|
private Button fullHistoryButton;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.combopump_fragment, container, false);
|
View view = inflater.inflate(R.layout.combopump_fragment, container, false);
|
||||||
|
|
||||||
stateView = (TextView) view.findViewById(R.id.combo_state);
|
stateView = view.findViewById(R.id.combo_state);
|
||||||
activityView = (TextView) view.findViewById(R.id.combo_activity);
|
activityView = view.findViewById(R.id.combo_activity);
|
||||||
batteryView = (TextView) view.findViewById(R.id.combo_pumpstate_battery);
|
batteryView = view.findViewById(R.id.combo_pumpstate_battery);
|
||||||
reservoirView = (TextView) view.findViewById(R.id.combo_insulinstate);
|
reservoirView = view.findViewById(R.id.combo_insulinstate);
|
||||||
lastBolusView = (TextView) view.findViewById(R.id.combo_last_bolus);
|
lastBolusView = view.findViewById(R.id.combo_last_bolus);
|
||||||
lastConnectionView = (TextView) view.findViewById(R.id.combo_lastconnection);
|
lastConnectionView = view.findViewById(R.id.combo_lastconnection);
|
||||||
baseBasalRate = (TextView) view.findViewById(R.id.combo_base_basal_rate);
|
baseBasalRate = view.findViewById(R.id.combo_base_basal_rate);
|
||||||
tempBasalText = (TextView) view.findViewById(R.id.combo_temp_basal);
|
tempBasalText = view.findViewById(R.id.combo_temp_basal);
|
||||||
bolusCount = (TextView) view.findViewById(R.id.combo_bolus_count);
|
bolusCount = view.findViewById(R.id.combo_bolus_count);
|
||||||
tbrCount = (TextView) view.findViewById(R.id.combo_tbr_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);
|
refreshButton.setOnClickListener(this);
|
||||||
|
|
||||||
alertsButton = (Button) view.findViewById(R.id.combo_alerts_button);
|
fullHistoryButton = view.findViewById(R.id.combo_full_history_button);
|
||||||
alertsButton.setOnClickListener(this);
|
|
||||||
alertsButton.setOnLongClickListener(this);
|
|
||||||
|
|
||||||
fullHistoryButton = (Button) view.findViewById(R.id.combo_full_history_button);
|
|
||||||
fullHistoryButton.setOnClickListener(this);
|
fullHistoryButton.setOnClickListener(this);
|
||||||
fullHistoryButton.setOnLongClickListener(this);
|
fullHistoryButton.setOnLongClickListener(this);
|
||||||
|
|
||||||
|
@ -94,10 +89,6 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
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:
|
case R.id.combo_full_history_button:
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
builder.setMessage(R.string.combo_read_full_history_info);
|
builder.setMessage(R.string.combo_read_full_history_info);
|
||||||
|
@ -110,27 +101,12 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View view) {
|
public boolean onLongClick(View view) {
|
||||||
switch (view.getId()) {
|
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:
|
case R.id.combo_full_history_button:
|
||||||
alertsButton.setEnabled(false);
|
|
||||||
fullHistoryButton.setEnabled(false);
|
fullHistoryButton.setEnabled(false);
|
||||||
new Thread(() -> ComboPlugin.getPlugin().readAllPumpData(new Callback() {
|
new Thread(() -> ComboPlugin.getPlugin().readAllPumpData(new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
alertsButton.setEnabled(true);
|
|
||||||
fullHistoryButton.setEnabled(true);
|
fullHistoryButton.setEnabled(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -183,9 +159,6 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
|
|
||||||
if (plugin.isInitialized()) {
|
if (plugin.isInitialized()) {
|
||||||
refreshButton.setVisibility(View.VISIBLE);
|
refreshButton.setVisibility(View.VISIBLE);
|
||||||
if (Config.enableComboBetaFeatures) {
|
|
||||||
alertsButton.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
fullHistoryButton.setVisibility(View.VISIBLE);
|
fullHistoryButton.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
// battery
|
// battery
|
||||||
|
|
|
@ -1171,23 +1171,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
return pumpBolus.timestamp + Math.min(secondsFromBolus, 59 * 1000);
|
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
|
// TODO use queue once ready
|
||||||
void readAllPumpData(Callback post) {
|
void readAllPumpData(Callback post) {
|
||||||
// ConfigBuilderPlugin.getCommandQueue().custom(new Callback() {
|
// ConfigBuilderPlugin.getCommandQueue().custom(new Callback() {
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:context=".plugins.PumpCombo.ComboFragment">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView3"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:text="Alerts"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/profileview_datedelimiter"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="2dip"
|
|
||||||
android:layout_marginLeft="20dp"
|
|
||||||
android:layout_marginRight="20dp"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:background="@color/listdelimiter" />
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/combo_error_history_text"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAlignment="textStart"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:gravity="start"/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
|
@ -500,19 +500,6 @@
|
||||||
android:paddingRight="0dp"
|
android:paddingRight="0dp"
|
||||||
android:text="@string/combo_refresh" />
|
android:text="@string/combo_refresh" />
|
||||||
|
|
||||||
<info.nightscout.utils.SingleClickButton
|
|
||||||
android:id="@+id/combo_alerts_button"
|
|
||||||
style="@style/ButtonSmallFontStyle"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.5"
|
|
||||||
android:layout_marginRight="-4dp"
|
|
||||||
android:drawableTop="@drawable/icon_cp_announcement"
|
|
||||||
android:paddingLeft="0dp"
|
|
||||||
android:paddingRight="0dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:text="@string/combo_pump_alerts" />
|
|
||||||
|
|
||||||
<info.nightscout.utils.SingleClickButton
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/combo_full_history_button"
|
android:id="@+id/combo_full_history_button"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
|
|
Loading…
Reference in a new issue