BolusProgressDialog: persist/resurrect state message across restarts.

Intents to solve #1909.
This commit is contained in:
Johannes Mockenhaupt 2019-07-31 18:44:52 +02:00
parent afe29a1e67
commit 056125ffb3
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -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