Overhaul Combo tab buttons and dialogs.
This commit is contained in:
parent
063a5ba6b9
commit
27e9cfda6f
5 changed files with 68 additions and 6 deletions
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.PumpCombo;
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
|
@ -15,6 +16,7 @@ import android.widget.TextView;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import de.jotomo.ruffy.spi.PumpState;
|
import de.jotomo.ruffy.spi.PumpState;
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
@ -60,6 +62,10 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
tddHistory.setOnClickListener(this);
|
tddHistory.setOnClickListener(this);
|
||||||
tddHistory.setOnLongClickListener(this);
|
tddHistory.setOnLongClickListener(this);
|
||||||
|
|
||||||
|
Button fullHistory = (Button) view.findViewById(R.id.combo_full_history);
|
||||||
|
fullHistory.setOnClickListener(this);
|
||||||
|
fullHistory.setOnLongClickListener(this);
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -78,6 +84,12 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
ComboTddHistoryDialog thd = new ComboTddHistoryDialog();
|
ComboTddHistoryDialog thd = new ComboTddHistoryDialog();
|
||||||
thd.show(getFragmentManager(), ComboTddHistoryDialog.class.getSimpleName());
|
thd.show(getFragmentManager(), ComboTddHistoryDialog.class.getSimpleName());
|
||||||
break;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +102,15 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
case R.id.combo_tdd_history:
|
case R.id.combo_tdd_history:
|
||||||
new Thread(() -> ComboPlugin.getPlugin().readTddData()).start();
|
new Thread(() -> ComboPlugin.getPlugin().readTddData()).start();
|
||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
private volatile boolean bolusInProgress;
|
private volatile boolean bolusInProgress;
|
||||||
private volatile boolean cancelBolus;
|
private volatile boolean cancelBolus;
|
||||||
private Bolus lastRequestedBolus;
|
private Bolus lastRequestedBolus;
|
||||||
|
private long pumpHistoryLastChecked;
|
||||||
|
|
||||||
public static ComboPlugin getPlugin() {
|
public static ComboPlugin getPlugin() {
|
||||||
if (plugin == null)
|
if (plugin == null)
|
||||||
|
@ -873,8 +874,37 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
void readAlertData() {
|
void readAlertData() {
|
||||||
readHistory(new PumpHistoryRequest()
|
readHistory(new PumpHistoryRequest().pumpErrorHistory(PumpHistoryRequest.FULL));
|
||||||
.pumpErrorHistory(PumpHistoryRequest.FULL));
|
}
|
||||||
|
|
||||||
|
void readAllPumpData() {
|
||||||
|
long lastCheckInitiated = System.currentTimeMillis();
|
||||||
|
|
||||||
|
boolean readHistorySuccess = readHistory(new PumpHistoryRequest()
|
||||||
|
.bolusHistory(pumpHistoryLastChecked)
|
||||||
|
.tbrHistory(pumpHistoryLastChecked)
|
||||||
|
.pumpErrorHistory(PumpHistoryRequest.FULL)
|
||||||
|
.tddHistory(PumpHistoryRequest.FULL));
|
||||||
|
if (!readHistorySuccess) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pumpHistoryLastChecked = lastCheckInitiated;
|
||||||
|
|
||||||
|
/* not displayed in the UI anymore due to pump bug
|
||||||
|
CommandResult reservoirResult = runCommand("Checking reservoir level", 2,
|
||||||
|
ruffyScripter::readReservoirLevelAndLastBolus);
|
||||||
|
if (!reservoirResult.success) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
CommandResult basalResult = runCommand("Reading basal profile", 2, ruffyScripter::readBasalProfile);
|
||||||
|
if (!basalResult.success) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pump.basalProfile = basalResult.basalProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -379,7 +379,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:drawableTop="@drawable/icon_danarhistory"
|
android:drawableTop="@drawable/icon_cp_announcement"
|
||||||
android:paddingLeft="0dp"
|
android:paddingLeft="0dp"
|
||||||
android:paddingRight="0dp"
|
android:paddingRight="0dp"
|
||||||
android:text="@string/combo_pump_alerts" />
|
android:text="@string/combo_pump_alerts" />
|
||||||
|
@ -393,7 +393,18 @@
|
||||||
android:drawableTop="@drawable/icon_danarstats"
|
android:drawableTop="@drawable/icon_danarstats"
|
||||||
android:paddingLeft="0dp"
|
android:paddingLeft="0dp"
|
||||||
android:paddingRight="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>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -691,7 +691,7 @@
|
||||||
<string name="combo_pump_state_suspended_by_user">Durch Benuzter gestoppt</string>
|
<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_suspended_due_to_error">Wegen Fehler gestoppt</string>
|
||||||
<string name="combo_pump_state_running">Normaler Betrieb</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_programming_bolus">Bolusabgabe wird vorbereitet</string>
|
||||||
<string name="combo_pump_action_cancelling_tbr">TBR wird abgebrochen</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>
|
<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="bolusstopped">Bolus delivery stopped</string>
|
||||||
<string name="combo_programming_bolus">Programming pump for bolusing</string>
|
<string name="combo_programming_bolus">Programming pump for bolusing</string>
|
||||||
<string name="combo_refresh">Refresh</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_state_label">State</string>
|
||||||
<string name="combo_pump_activity_label">Activity</string>
|
<string name="combo_pump_activity_label">Activity</string>
|
||||||
<string name="combo_no_pump_connection">No connection for %d min</string>
|
<string name="combo_no_pump_connection">No connection for %d min</string>
|
||||||
|
|
Loading…
Reference in a new issue