Overview: make checkbox labels toggle state as well.

This commit is contained in:
Johannes Mockenhaupt 2018-01-24 13:50:12 +01:00
parent b6f3fae487
commit 3a02f01374
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 93 additions and 52 deletions

View file

@ -148,12 +148,18 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
TextView sage; TextView sage;
TextView pbage; TextView pbage;
CheckBox showPredictionView; TextView showPredictionLabel;
CheckBox showBasalsView; CheckBox showPredictionCheckbox;
CheckBox showIobView; TextView showBasalsLabel;
CheckBox showCobView; CheckBox showBasalsCheckbox;
CheckBox showDeviationsView; TextView showIobLabel;
CheckBox showRatiosView; CheckBox showIobCheckbox;
TextView showCobLabel;
CheckBox showCobCheckbox;
TextView showDeviationsLabel;
CheckBox showDeviationsCheckbox;
TextView showRatiosLabel;
CheckBox showRatiosCheckbox;
RecyclerView notificationsView; RecyclerView notificationsView;
LinearLayoutManager llm; LinearLayoutManager llm;
@ -265,24 +271,37 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout); acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout);
showPredictionView = (CheckBox) view.findViewById(R.id.overview_showprediction); showPredictionCheckbox = (CheckBox) view.findViewById(R.id.overview_showprediction);
showBasalsView = (CheckBox) view.findViewById(R.id.overview_showbasals); showBasalsCheckbox = (CheckBox) view.findViewById(R.id.overview_showbasals);
showIobView = (CheckBox) view.findViewById(R.id.overview_showiob); showIobCheckbox = (CheckBox) view.findViewById(R.id.overview_showiob);
showCobView = (CheckBox) view.findViewById(R.id.overview_showcob); showCobCheckbox = (CheckBox) view.findViewById(R.id.overview_showcob);
showDeviationsView = (CheckBox) view.findViewById(R.id.overview_showdeviations); showDeviationsCheckbox = (CheckBox) view.findViewById(R.id.overview_showdeviations);
showRatiosView = (CheckBox) view.findViewById(R.id.overview_showratios); showRatiosCheckbox = (CheckBox) view.findViewById(R.id.overview_showratios);
showPredictionView.setChecked(SP.getBoolean("showprediction", false)); showPredictionCheckbox.setChecked(SP.getBoolean("showprediction", false));
showBasalsView.setChecked(SP.getBoolean("showbasals", true)); showBasalsCheckbox.setChecked(SP.getBoolean("showbasals", true));
showIobView.setChecked(SP.getBoolean("showiob", false)); showIobCheckbox.setChecked(SP.getBoolean("showiob", false));
showCobView.setChecked(SP.getBoolean("showcob", false)); showCobCheckbox.setChecked(SP.getBoolean("showcob", false));
showDeviationsView.setChecked(SP.getBoolean("showdeviations", false)); showDeviationsCheckbox.setChecked(SP.getBoolean("showdeviations", false));
showRatiosView.setChecked(SP.getBoolean("showratios", false)); showRatiosCheckbox.setChecked(SP.getBoolean("showratios", false));
showPredictionView.setOnCheckedChangeListener(this); showPredictionCheckbox.setOnCheckedChangeListener(this);
showBasalsView.setOnCheckedChangeListener(this); showBasalsCheckbox.setOnCheckedChangeListener(this);
showIobView.setOnCheckedChangeListener(this); showIobCheckbox.setOnCheckedChangeListener(this);
showCobView.setOnCheckedChangeListener(this); showCobCheckbox.setOnCheckedChangeListener(this);
showDeviationsView.setOnCheckedChangeListener(this); showDeviationsCheckbox.setOnCheckedChangeListener(this);
showRatiosView.setOnCheckedChangeListener(this); showRatiosCheckbox.setOnCheckedChangeListener(this);
showPredictionLabel = (TextView) view.findViewById(R.id.overview_showprediction_label);
showPredictionLabel.setOnClickListener(this);
showBasalsLabel = (TextView) view.findViewById(R.id.overview_showbasals_label);
showBasalsLabel.setOnClickListener(this);
showIobLabel = (TextView) view.findViewById(R.id.overview_showiob_label);
showIobLabel.setOnClickListener(this);
showCobLabel = (TextView) view.findViewById(R.id.overview_showcob_label);
showCobLabel.setOnClickListener(this);
showDeviationsLabel = (TextView) view.findViewById(R.id.overview_showdeviations_label);
showDeviationsLabel.setOnClickListener(this);
showRatiosLabel = (TextView) view.findViewById(R.id.overview_showratios_label);
showRatiosLabel.setOnClickListener(this);
notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications); notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications);
notificationsView.setHasFixedSize(true); notificationsView.setHasFixedSize(true);
@ -375,24 +394,24 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
case R.id.overview_showiob: case R.id.overview_showiob:
break; break;
case R.id.overview_showcob: case R.id.overview_showcob:
showDeviationsView.setOnCheckedChangeListener(null); showDeviationsCheckbox.setOnCheckedChangeListener(null);
showDeviationsView.setChecked(false); showDeviationsCheckbox.setChecked(false);
showDeviationsView.setOnCheckedChangeListener(this); showDeviationsCheckbox.setOnCheckedChangeListener(this);
break; break;
case R.id.overview_showdeviations: case R.id.overview_showdeviations:
showCobView.setOnCheckedChangeListener(null); showCobCheckbox.setOnCheckedChangeListener(null);
showCobView.setChecked(false); showCobCheckbox.setChecked(false);
showCobView.setOnCheckedChangeListener(this); showCobCheckbox.setOnCheckedChangeListener(this);
break; break;
case R.id.overview_showratios: case R.id.overview_showratios:
break; break;
} }
SP.putBoolean("showiob", showIobView.isChecked()); SP.putBoolean("showiob", showIobCheckbox.isChecked());
SP.putBoolean("showprediction", showPredictionView.isChecked()); SP.putBoolean("showprediction", showPredictionCheckbox.isChecked());
SP.putBoolean("showbasals", showBasalsView.isChecked()); SP.putBoolean("showbasals", showBasalsCheckbox.isChecked());
SP.putBoolean("showcob", showCobView.isChecked()); SP.putBoolean("showcob", showCobCheckbox.isChecked());
SP.putBoolean("showdeviations", showDeviationsView.isChecked()); SP.putBoolean("showdeviations", showDeviationsCheckbox.isChecked());
SP.putBoolean("showratios", showRatiosView.isChecked()); SP.putBoolean("showratios", showRatiosCheckbox.isChecked());
scheduleUpdateGUI("onGraphCheckboxesCheckedChanged"); scheduleUpdateGUI("onGraphCheckboxesCheckedChanged");
} }
@ -619,6 +638,24 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
if (ConfigBuilderPlugin.getActivePump().isSuspended() || !ConfigBuilderPlugin.getActivePump().isInitialized()) if (ConfigBuilderPlugin.getActivePump().isSuspended() || !ConfigBuilderPlugin.getActivePump().isInitialized())
ConfigBuilderPlugin.getCommandQueue().readStatus("RefreshClicked", null); ConfigBuilderPlugin.getCommandQueue().readStatus("RefreshClicked", null);
break; break;
case R.id.overview_showprediction_label:
showPredictionCheckbox.toggle();
break;
case R.id.overview_showbasals_label:
showBasalsCheckbox.toggle();
break;
case R.id.overview_showiob_label:
showIobCheckbox.toggle();
break;
case R.id.overview_showcob_label:
showCobCheckbox.toggle();
break;
case R.id.overview_showdeviations_label:
showDeviationsCheckbox.toggle();
break;
case R.id.overview_showratios_label:
showRatiosCheckbox.toggle();
break;
} }
} }
@ -1247,13 +1284,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
cobView.setText(cobText); cobView.setText(cobText);
} }
final boolean showPrediction = showPredictionView.isChecked() && finalLastRun != null && finalLastRun.constraintsProcessed.getClass().equals(DetermineBasalResultAMA.class); final boolean showPrediction = showPredictionCheckbox.isChecked() && finalLastRun != null && finalLastRun.constraintsProcessed.getClass().equals(DetermineBasalResultAMA.class);
if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class) != null && MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS)) { if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class) != null && MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS)) {
showPredictionView.setVisibility(View.VISIBLE); showPredictionCheckbox.setVisibility(View.VISIBLE);
getActivity().findViewById(R.id.overview_showprediction_label).setVisibility(View.VISIBLE); showPredictionLabel.setVisibility(View.VISIBLE);
} else { } else {
showPredictionView.setVisibility(View.GONE); showPredictionCheckbox.setVisibility(View.GONE);
getActivity().findViewById(R.id.overview_showprediction_label).setVisibility(View.GONE); showPredictionLabel.setVisibility(View.GONE);
} }
// pump status from ns // pump status from ns
@ -1345,7 +1382,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
graphData.addTreatments(fromTime, endTime); graphData.addTreatments(fromTime, endTime);
// add basal data // add basal data
if (pump.getPumpDescription().isTempBasalCapable && showBasalsView.isChecked()) { if (pump.getPumpDescription().isTempBasalCapable && showBasalsCheckbox.isChecked()) {
graphData.addBasals(fromTime, now, lowLine / graphData.maxY / 1.2d); graphData.addBasals(fromTime, now, lowLine / graphData.maxY / 1.2d);
} }
@ -1362,23 +1399,23 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
boolean useDevForScale = false; boolean useDevForScale = false;
boolean useRatioForScale = false; boolean useRatioForScale = false;
if (showIobView.isChecked()) { if (showIobCheckbox.isChecked()) {
useIobForScale = true; useIobForScale = true;
} else if (showCobView.isChecked()) { } else if (showCobCheckbox.isChecked()) {
useCobForScale = true; useCobForScale = true;
} else if (showDeviationsView.isChecked()) { } else if (showDeviationsCheckbox.isChecked()) {
useDevForScale = true; useDevForScale = true;
} else if (showRatiosView.isChecked()) { } else if (showRatiosCheckbox.isChecked()) {
useRatioForScale = true; useRatioForScale = true;
} }
if (showIobView.isChecked()) if (showIobCheckbox.isChecked())
secondGraphData.addIob(fromTime, now, useIobForScale, 1d); secondGraphData.addIob(fromTime, now, useIobForScale, 1d);
if (showCobView.isChecked()) if (showCobCheckbox.isChecked())
secondGraphData.addCob(fromTime, now, useCobForScale, useCobForScale ? 1d : 0.5d); secondGraphData.addCob(fromTime, now, useCobForScale, useCobForScale ? 1d : 0.5d);
if (showDeviationsView.isChecked()) if (showDeviationsCheckbox.isChecked())
secondGraphData.addDeviations(fromTime, now, useDevForScale, 1d); secondGraphData.addDeviations(fromTime, now, useDevForScale, 1d);
if (showRatiosView.isChecked()) if (showRatiosCheckbox.isChecked())
secondGraphData.addRatio(fromTime, now, useRatioForScale, 1d); secondGraphData.addRatio(fromTime, now, useRatioForScale, 1d);
// **** NOW line **** // **** NOW line ****
@ -1392,7 +1429,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (showIobView.isChecked() || showCobView.isChecked() || showDeviationsView.isChecked() || showRatiosView.isChecked()) { if (showIobCheckbox.isChecked() || showCobCheckbox.isChecked() || showDeviationsCheckbox.isChecked() || showRatiosCheckbox.isChecked()) {
iobGraph.setVisibility(View.VISIBLE); iobGraph.setVisibility(View.VISIBLE);
} else { } else {
iobGraph.setVisibility(View.GONE); iobGraph.setVisibility(View.GONE);

View file

@ -270,6 +270,7 @@
app:buttonTint="@color/basal" /> app:buttonTint="@color/basal" />
<TextView <TextView
android:id="@+id/overview_showbasals_label"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
@ -286,6 +287,7 @@
app:buttonTint="@color/iob" /> app:buttonTint="@color/iob" />
<TextView <TextView
android:id="@+id/overview_showiob_label"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
@ -294,7 +296,6 @@
android:textColor="@color/iob" android:textColor="@color/iob"
android:textStyle="bold" /> android:textStyle="bold" />
<CheckBox <CheckBox
android:id="@+id/overview_showcob" android:id="@+id/overview_showcob"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -303,6 +304,7 @@
app:buttonTint="@color/cob" /> app:buttonTint="@color/cob" />
<TextView <TextView
android:id="@+id/overview_showcob_label"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
@ -319,6 +321,7 @@
app:buttonTint="@color/deviations" /> app:buttonTint="@color/deviations" />
<TextView <TextView
android:id="@+id/overview_showdeviations_label"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
@ -334,6 +337,7 @@
android:layout_gravity="center" /> android:layout_gravity="center" />
<TextView <TextView
android:id="@+id/overview_showratios_label"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"