ComboFragment: always show refresh button.

To allow force starting a conecting attempt if the pump is still
in disconnected state.
This commit is contained in:
Johannes Mockenhaupt 2017-12-09 22:08:38 +01:00
parent 4a7b2b3da2
commit 26fa63d571
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 33 additions and 28 deletions

View file

@ -10,7 +10,6 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
@ -32,7 +31,10 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
private TextView lastConnectionView; private TextView lastConnectionView;
private TextView lastBolusView; private TextView lastBolusView;
private TextView tempBasalText; private TextView tempBasalText;
private LinearLayout buttonsLayout; private Button refreshButton;
private Button alertsButton;
private Button tddsButton;
private Button fullHistoryButton;
private TextView queueView; private TextView queueView;
@ -48,24 +50,22 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
lastConnectionView = (TextView) view.findViewById(R.id.combo_lastconnection); lastConnectionView = (TextView) view.findViewById(R.id.combo_lastconnection);
//lastBolusView = (TextView) view.findViewById(R.id.combo_last_bolus); //lastBolusView = (TextView) view.findViewById(R.id.combo_last_bolus);
tempBasalText = (TextView) view.findViewById(R.id.combo_temp_basal); tempBasalText = (TextView) view.findViewById(R.id.combo_temp_basal);
buttonsLayout = (LinearLayout) view.findViewById(R.id.combo_buttons_layout);
queueView = (TextView) view.findViewById(R.id.combo_queue); queueView = (TextView) view.findViewById(R.id.combo_queue);
refreshButton = (Button) view.findViewById(R.id.combo_refresh_button);
refreshButton.setOnClickListener(this);
Button refresh = (Button) view.findViewById(R.id.combo_refresh); alertsButton = (Button) view.findViewById(R.id.combo_alerts_button);
refresh.setOnClickListener(this); alertsButton.setOnClickListener(this);
alertsButton.setOnLongClickListener(this);
Button errorHistory = (Button) view.findViewById(R.id.combo_error_history); tddsButton = (Button) view.findViewById(R.id.combo_tdds_button);
errorHistory.setOnClickListener(this); tddsButton.setOnClickListener(this);
errorHistory.setOnLongClickListener(this); tddsButton.setOnLongClickListener(this);
Button tddHistory = (Button) view.findViewById(R.id.combo_tdd_history); fullHistoryButton = (Button) view.findViewById(R.id.combo_full_history_button);
tddHistory.setOnClickListener(this); fullHistoryButton.setOnClickListener(this);
tddHistory.setOnLongClickListener(this); fullHistoryButton.setOnLongClickListener(this);
Button fullHistory = (Button) view.findViewById(R.id.combo_full_history);
fullHistory.setOnClickListener(this);
fullHistory.setOnLongClickListener(this);
updateGUI(); updateGUI();
return view; return view;
@ -74,18 +74,18 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
@Override @Override
public void onClick(View view) { public void onClick(View view) {
switch (view.getId()) { switch (view.getId()) {
case R.id.combo_refresh: case R.id.combo_refresh_button:
ConfigBuilderPlugin.getCommandQueue().readStatus("User request", null); ConfigBuilderPlugin.getCommandQueue().readStatus("User request", null);
break; break;
case R.id.combo_error_history: case R.id.combo_alerts_button:
ComboAlertHistoryDialog ehd = new ComboAlertHistoryDialog(); ComboAlertHistoryDialog ehd = new ComboAlertHistoryDialog();
ehd.show(getFragmentManager(), ComboAlertHistoryDialog.class.getSimpleName()); ehd.show(getFragmentManager(), ComboAlertHistoryDialog.class.getSimpleName());
break; break;
case R.id.combo_tdd_history: case R.id.combo_tdds_button:
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: case R.id.combo_full_history_button:
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(R.string.combo_warning); builder.setTitle(R.string.combo_warning);
builder.setMessage(R.string.combo_read_full_history_warning); builder.setMessage(R.string.combo_read_full_history_warning);
@ -97,13 +97,13 @@ 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_error_history: case R.id.combo_alerts_button:
new Thread(() -> ComboPlugin.getPlugin().readAlertData()).start(); new Thread(() -> ComboPlugin.getPlugin().readAlertData()).start();
return true; return true;
case R.id.combo_tdd_history: case R.id.combo_tdds_button:
new Thread(() -> ComboPlugin.getPlugin().readTddData()).start(); new Thread(() -> ComboPlugin.getPlugin().readTddData()).start();
return true; return true;
case R.id.combo_full_history: case R.id.combo_full_history_button:
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(R.string.combo_warning); builder.setTitle(R.string.combo_warning);
builder.setMessage(R.string.combo_read_full_history_confirmation); builder.setMessage(R.string.combo_read_full_history_confirmation);
@ -151,7 +151,10 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
activityView.setText(activity != null ? activity : ""); activityView.setText(activity != null ? activity : "");
if (plugin.isInitialized()) { if (plugin.isInitialized()) {
buttonsLayout.setVisibility(View.VISIBLE); refreshButton.setVisibility(View.VISIBLE);
alertsButton.setVisibility(View.VISIBLE);
tddsButton.setVisibility(View.VISIBLE);
fullHistoryButton.setVisibility(View.VISIBLE);
// battery // battery
batteryView.setTextSize(20); batteryView.setTextSize(20);

View file

@ -359,11 +359,10 @@
android:id="@+id/combo_buttons_layout" android:id="@+id/combo_buttons_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone"
android:orientation="horizontal"> android:orientation="horizontal">
<Button <Button
android:id="@+id/combo_refresh" android:id="@+id/combo_refresh_button"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -374,7 +373,7 @@
android:text="@string/combo_refresh" /> android:text="@string/combo_refresh" />
<Button <Button
android:id="@+id/combo_error_history" android:id="@+id/combo_alerts_button"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -382,10 +381,11 @@
android:drawableTop="@drawable/icon_cp_announcement" android:drawableTop="@drawable/icon_cp_announcement"
android:paddingLeft="0dp" android:paddingLeft="0dp"
android:paddingRight="0dp" android:paddingRight="0dp"
android:visibility="gone"
android:text="@string/combo_pump_alerts" /> android:text="@string/combo_pump_alerts" />
<Button <Button
android:id="@+id/combo_tdd_history" android:id="@+id/combo_tdds_button"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -393,10 +393,11 @@
android:drawableTop="@drawable/icon_danarstats" android:drawableTop="@drawable/icon_danarstats"
android:paddingLeft="0dp" android:paddingLeft="0dp"
android:paddingRight="0dp" android:paddingRight="0dp"
android:visibility="gone"
android:text="@string/combo_tdds" /> android:text="@string/combo_tdds" />
<Button <Button
android:id="@+id/combo_full_history" android:id="@+id/combo_full_history_button"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -404,6 +405,7 @@
android:drawableTop="@drawable/icon_bolus" android:drawableTop="@drawable/icon_bolus"
android:paddingLeft="0dp" android:paddingLeft="0dp"
android:paddingRight="0dp" android:paddingRight="0dp"
android:visibility="gone"
android:text="@string/combo_history" /> android:text="@string/combo_history" />
</LinearLayout> </LinearLayout>