Merge branch 'buttons-business' into combo-scripter-v2
* buttons-business: Fix TDDS dialog title. ComboFragment: use queue to refresh state, explicit disconnects for tdd/alert.s Fix ReadHistoryCommand to not ignore TDD requests. Add missing listener registration. Overhaul Combo tab buttons and dialogs. Only read Tdd and Alerts through buttons on Combo tab, not treatment history.
This commit is contained in:
commit
97d13fd14a
|
@ -20,7 +20,7 @@ public class ComboAlertHistoryDialog extends DialogFragment {
|
|||
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_empty_history_note);
|
||||
text.setText(R.string.combo_no_alert_data_note);
|
||||
} else {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
DateFormat dateTimeFormatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.PumpCombo;
|
|||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spanned;
|
||||
|
@ -15,6 +16,7 @@ import android.widget.TextView;
|
|||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import de.jotomo.ruffy.spi.PumpState;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
|
@ -55,11 +57,16 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
|||
|
||||
Button errorHistory = (Button) view.findViewById(R.id.combo_error_history);
|
||||
errorHistory.setOnClickListener(this);
|
||||
errorHistory.setOnLongClickListener(this);
|
||||
|
||||
Button tddHistory = (Button) view.findViewById(R.id.combo_tdd_history);
|
||||
tddHistory.setOnClickListener(this);
|
||||
tddHistory.setOnLongClickListener(this);
|
||||
|
||||
Button fullHistory = (Button) view.findViewById(R.id.combo_full_history);
|
||||
fullHistory.setOnClickListener(this);
|
||||
fullHistory.setOnLongClickListener(this);
|
||||
|
||||
updateGUI();
|
||||
return view;
|
||||
}
|
||||
|
@ -68,7 +75,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
|||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.combo_refresh:
|
||||
new Thread(() -> ComboPlugin.getPlugin().getPumpStatus()).start();
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("User request", null);
|
||||
break;
|
||||
case R.id.combo_error_history:
|
||||
ComboAlertHistoryDialog ehd = new ComboAlertHistoryDialog();
|
||||
|
@ -78,14 +85,32 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
|||
ComboTddHistoryDialog thd = new ComboTddHistoryDialog();
|
||||
thd.show(getFragmentManager(), ComboTddHistoryDialog.class.getSimpleName());
|
||||
break;
|
||||
case R.id.combo_full_history:
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle(R.string.combo_warning);
|
||||
builder.setMessage(R.string.combo_read_full_history_warning);
|
||||
builder.show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.combo_error_history:
|
||||
new Thread(() -> ComboPlugin.getPlugin().readAlertData()).start();
|
||||
return true;
|
||||
case R.id.combo_tdd_history:
|
||||
new Thread(() -> ComboPlugin.getPlugin().readAllPumpData()).start();
|
||||
new Thread(() -> ComboPlugin.getPlugin().readTddData()).start();
|
||||
return true;
|
||||
case R.id.combo_full_history:
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle(R.string.combo_warning);
|
||||
builder.setMessage(R.string.combo_read_full_history_confirmation);
|
||||
builder.setPositiveButton(R.string.ok, (dialog, which) ->
|
||||
new Thread(() -> ComboPlugin.getPlugin().readAllPumpData()).start());
|
||||
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
|
||||
builder.show();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -869,6 +869,19 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
}
|
||||
}
|
||||
|
||||
// TODO queue
|
||||
void readTddData() {
|
||||
readHistory(new PumpHistoryRequest().tddHistory(PumpHistoryRequest.FULL));
|
||||
ruffyScripter.disconnect();
|
||||
}
|
||||
|
||||
// TODO queue
|
||||
void readAlertData() {
|
||||
readHistory(new PumpHistoryRequest().pumpErrorHistory(PumpHistoryRequest.FULL));
|
||||
ruffyScripter.disconnect();
|
||||
}
|
||||
|
||||
// TODO queue
|
||||
void readAllPumpData() {
|
||||
long lastCheckInitiated = System.currentTimeMillis();
|
||||
|
||||
|
@ -897,6 +910,8 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
}
|
||||
|
||||
pump.basalProfile = basalResult.basalProfile;
|
||||
|
||||
ruffyScripter.disconnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,7 +21,7 @@ public class ComboTddHistoryDialog extends DialogFragment {
|
|||
TextView text = (TextView) layout.findViewById(R.id.combo_tdd_history_text);
|
||||
List<Tdd> tdds = ComboPlugin.getPlugin().getPump().tddHistory;
|
||||
if (tdds.isEmpty()) {
|
||||
text.setText(R.string.combo_empty_history_note);
|
||||
text.setText(R.string.combo_no_tdd_data_note);
|
||||
} else {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
DateFormat dateFormatter = DateFormat.getDateInstance();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="TDD"
|
||||
android:text="@string/combo_tdds"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<View
|
||||
|
|
|
@ -379,7 +379,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="@drawable/icon_danarhistory"
|
||||
android:drawableTop="@drawable/icon_cp_announcement"
|
||||
android:paddingLeft="0dp"
|
||||
android:paddingRight="0dp"
|
||||
android:text="@string/combo_pump_alerts" />
|
||||
|
@ -393,7 +393,18 @@
|
|||
android:drawableTop="@drawable/icon_danarstats"
|
||||
android:paddingLeft="0dp"
|
||||
android:paddingRight="0dp"
|
||||
android:text="@string/combo_stats" />
|
||||
android:text="@string/combo_tdds" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/combo_full_history"
|
||||
style="@style/ButtonSmallFontStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="@drawable/icon_bolus"
|
||||
android:paddingLeft="0dp"
|
||||
android:paddingRight="0dp"
|
||||
android:text="@string/combo_history" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -691,7 +691,7 @@
|
|||
<string name="combo_pump_state_suspended_by_user">Durch Benuzter gestoppt</string>
|
||||
<string name="combo_pump_state_suspended_due_to_error">Wegen Fehler gestoppt</string>
|
||||
<string name="combo_pump_state_running">Normaler Betrieb</string>
|
||||
<string name="combo_stats">Statistiken</string>
|
||||
<string name="combo_tdds">TDDS</string>
|
||||
<string name="combo_programming_bolus">Bolusabgabe wird vorbereitet</string>
|
||||
<string name="combo_pump_action_cancelling_tbr">TBR wird abgebrochen</string>
|
||||
<string name="combo_pump_action_setting_tbr">TBR wird gesetzt (%d%% / %d min)</string>
|
||||
|
|
|
@ -790,7 +790,7 @@
|
|||
<string name="bolusstopped">Bolus delivery stopped</string>
|
||||
<string name="combo_programming_bolus">Programming pump for bolusing</string>
|
||||
<string name="combo_refresh">Refresh</string>
|
||||
<string name="combo_stats">TDDS</string>
|
||||
<string name="combo_tdds">TDDS</string>
|
||||
<string name="combo_pump_state_label">State</string>
|
||||
<string name="combo_pump_activity_label">Activity</string>
|
||||
<string name="combo_no_pump_connection">No connection for %d min</string>
|
||||
|
@ -822,7 +822,8 @@
|
|||
<string name="combo_pump_cartridge_low_warrning">Pump cartridge level is low</string>
|
||||
<string name="combo_pump_battery_low_warrning">Pump battery is low</string>
|
||||
<string name="combo_is_in_error_state">Pump is in an error state, please check the pump</string>
|
||||
<string name="combo_empty_history_note">To read all data from the pump, long press the TDDS button. Besides alerts and TDDs, this will read boluses and TBRs from the pump and update the treatments accordingly.\n\nWARNING: this can trigger a bug which causes the pump to reject all connection attempts and requires pressing a button on the pump to recover and should therefore be avoided.</string>
|
||||
<string name="combo_no_alert_data_note">To read the pump\'s error history, long press the ALERTS button\n\nWARNING: this can trigger a bug which causes the pump to reject all connection attempts and requires pressing a button on the pump to recover and should therefore be avoided.</string>
|
||||
<string name="combo_no_tdd_data_note">To read the pump\'s TDD history, long press the TDDS button\n\nWARNING: this can trigger a bug which causes the pump to reject all connection attempts and requires pressing a button on the pump to recover and should therefore be avoided.</string>
|
||||
<string name="key_sync_profile_to_pump">sync_profile_to_pump</string>
|
||||
<string name="combo_tdd_minimum">Minimum: %3.1f U</string>
|
||||
<string name="combo_tdd_average">Average: %3.1f U</string>
|
||||
|
|
|
@ -36,7 +36,8 @@ public class ReadHistoryCommand extends BaseCommand {
|
|||
public void execute() {
|
||||
if (request.bolusHistory != PumpHistoryRequest.SKIP
|
||||
|| request.tbrHistory != PumpHistoryRequest.SKIP
|
||||
|| request.pumpErrorHistory != PumpHistoryRequest.SKIP) {
|
||||
|| request.pumpErrorHistory != PumpHistoryRequest.SKIP
|
||||
|| request.tddHistory != PumpHistoryRequest.SKIP) {
|
||||
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
|
||||
scripter.navigateToMenu(MenuType.MY_DATA_MENU);
|
||||
scripter.verifyMenuIsDisplayed(MenuType.MY_DATA_MENU);
|
||||
|
|
Loading…
Reference in a new issue