Merge pull request #1923 from jotomo/rotating-bolus-progress-dialog

BolusProgressDialog: persist/resurrect state message across restarts.
This commit is contained in:
Milos Kozak 2019-07-31 19:15:01 +02:00 committed by GitHub
commit 32ff72b620
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,7 @@ package info.nightscout.androidaps.plugins.general.overview.dialogs;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.os.SystemClock; import android.os.SystemClock;
import androidx.annotation.NonNull;
import androidx.fragment.app.DialogFragment; import androidx.fragment.app.DialogFragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -38,6 +39,9 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
public static boolean running = true; public static boolean running = true;
public static boolean stopPressed = false; public static boolean stopPressed = false;
private String state;
private final static String DEFAULT_STATE = MainApp.gs(R.string.waitingforpump);
public BolusProgressDialog() { public BolusProgressDialog() {
super(); super();
} }
@ -62,7 +66,8 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
progressBar = view.findViewById(R.id.overview_bolusprogress_progressbar); progressBar = view.findViewById(R.id.overview_bolusprogress_progressbar);
stopButton.setOnClickListener(this); stopButton.setOnClickListener(this);
progressBar.setMax(100); 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); setCancelable(false);
stopPressed = false; stopPressed = false;
return view; return view;
@ -114,6 +119,13 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
log.debug("onPause"); log.debug("onPause");
} }
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
outState.putString("state", state);
log.debug("storing state: " + state);
super.onSaveInstanceState(outState);
}
@Override @Override
public void onClick(View view) { public void onClick(View view) {
switch (view.getId()) { switch (view.getId()) {
@ -143,6 +155,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
} }
}); });
} }
state = ev.status;
} }
@Subscribe @Subscribe