From 056125ffb3e2fa30a99f363b91c124cd65aec6d6 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Wed, 31 Jul 2019 18:44:52 +0200 Subject: [PATCH] BolusProgressDialog: persist/resurrect state message across restarts. Intents to solve #1909. --- .../overview/dialogs/BolusProgressDialog.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/BolusProgressDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/BolusProgressDialog.java index 1b41ea0c44..3876250308 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/BolusProgressDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/BolusProgressDialog.java @@ -4,6 +4,7 @@ package info.nightscout.androidaps.plugins.general.overview.dialogs; import android.app.Activity; import android.os.Bundle; import android.os.SystemClock; +import androidx.annotation.NonNull; import androidx.fragment.app.DialogFragment; import android.view.LayoutInflater; import android.view.View; @@ -38,6 +39,9 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL public static boolean running = true; public static boolean stopPressed = false; + private String state; + private final static String DEFAULT_STATE = MainApp.gs(R.string.waitingforpump); + public BolusProgressDialog() { super(); } @@ -62,7 +66,8 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL progressBar = view.findViewById(R.id.overview_bolusprogress_progressbar); stopButton.setOnClickListener(this); progressBar.setMax(100); - statusView.setText(MainApp.gs(R.string.waitingforpump)); + state = savedInstanceState != null ? savedInstanceState.getString("state", DEFAULT_STATE) : DEFAULT_STATE; + statusView.setText(state); setCancelable(false); stopPressed = false; return view; @@ -114,6 +119,13 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL log.debug("onPause"); } + @Override + public void onSaveInstanceState(@NonNull Bundle outState) { + outState.putString("state", state); + log.debug("storing state: " + state); + super.onSaveInstanceState(outState); + } + @Override public void onClick(View view) { switch (view.getId()) { @@ -143,6 +155,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL } }); } + state = ev.status; } @Subscribe