diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java index 9a6b7e9650..c93f06a1c0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java @@ -7,6 +7,7 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; import android.widget.CheckBox; import android.widget.LinearLayout; import android.widget.ProgressBar; @@ -42,6 +43,7 @@ public class InitActionFragment extends Fragment implements PodInitReceiver { protected ProgressBar progressBar; protected TextView errorView; + protected Button retryButton; protected PodInitActionType podInitActionType; protected List children; @@ -109,6 +111,11 @@ public class InitActionFragment extends Fragment implements PodInitReceiver { headerView.setText(R.string.omnipod_remove_pod_wizard_step2_action_header); } + this.retryButton = rootView.findViewById(R.id.initAction_RetryButton); + + this.retryButton.setOnClickListener(view -> + new InitPodTask(instance).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR)); + return rootView; } @@ -146,41 +153,7 @@ public class InitActionFragment extends Fragment implements PodInitReceiver { //System.out.println("ACTION: setUserVisibleHint="+ isVisibleToUser); if (isVisibleToUser) { //System.out.println("ACTION: Visible"); - - new AsyncTask() { - - protected void onPreExecute() { - progressBar.setVisibility(View.VISIBLE); - } - - @Override - protected String doInBackground(Void... params) { - if (podInitActionType == PodInitActionType.PairAndPrimeWizardStep) { - callResult = AapsOmnipodManager.getInstance().initPod( - podInitActionType, - instance, - null - ); - } else if (podInitActionType == PodInitActionType.FillCannulaSetBasalProfileWizardStep) { - callResult = AapsOmnipodManager.getInstance().initPod( - podInitActionType, - instance, - ProfileFunctions.getInstance().getProfile() - ); - } else if (podInitActionType == PodInitActionType.DeactivatePodWizardStep) { - callResult = AapsOmnipodManager.getInstance().deactivatePod(instance); - } - - return "OK"; - } - - @Override - protected void onPostExecute(String result) { - super.onPostExecute(result); - - actionOnReceiveResponse(result); - } - }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + new InitPodTask(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { System.out.println("ACTION: Not visible"); @@ -230,6 +203,8 @@ public class InitActionFragment extends Fragment implements PodInitReceiver { if (!isOk) { errorView.setVisibility(View.VISIBLE); errorView.setText(errorMessage); + + retryButton.setVisibility(View.VISIBLE); } mPage.setActionCompleted(isOk); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodTask.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodTask.java new file mode 100644 index 0000000000..3dcf957c06 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodTask.java @@ -0,0 +1,59 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod; + +import android.os.AsyncTask; +import android.os.SystemClock; +import android.view.View; + +import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions; +import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager; + +/** + * Created by andy on 11/12/2019 + */ +public class InitPodTask extends AsyncTask { + + private InitActionFragment initActionFragment; + + public InitPodTask(InitActionFragment initActionFragment) { + + this.initActionFragment = initActionFragment; + } + + protected void onPreExecute() { + initActionFragment.progressBar.setVisibility(View.VISIBLE); + initActionFragment.errorView.setVisibility(View.GONE); + initActionFragment.retryButton.setVisibility(View.GONE); + } + + @Override + protected String doInBackground(Void... params) { + + if (initActionFragment.podInitActionType == PodInitActionType.PairAndPrimeWizardStep) { + initActionFragment.callResult = AapsOmnipodManager.getInstance().initPod( + initActionFragment.podInitActionType, + initActionFragment.instance, + null + ); + } else if (initActionFragment.podInitActionType == PodInitActionType.FillCannulaSetBasalProfileWizardStep) { + initActionFragment.callResult = AapsOmnipodManager.getInstance().initPod( + initActionFragment.podInitActionType, + initActionFragment.instance, + ProfileFunctions.getInstance().getProfile() + ); + } else if (initActionFragment.podInitActionType == PodInitActionType.DeactivatePodWizardStep) { + initActionFragment.callResult = AapsOmnipodManager.getInstance().deactivatePod(initActionFragment.instance); + } + + return "OK"; + } + + @Override + protected void onPostExecute(String result) { + super.onPostExecute(result); + + initActionFragment.actionOnReceiveResponse(result); + } + + +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoPage.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoPage.java index cb0a84eedb..04ca08a0f3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoPage.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoPage.java @@ -13,8 +13,6 @@ import java.util.ArrayList; * Created by andy on 12/11/2019 */ public class PodInfoPage extends Page { - public static final String NAME_DATA_KEY = "name"; - public static final String EMAIL_DATA_KEY = "email"; public PodInfoPage(ModelCallbacks callbacks, String title) { super(callbacks, title); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemoveActionFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemoveActionFragment.java index 33ab8de5e8..480e90319c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemoveActionFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemoveActionFragment.java @@ -44,6 +44,8 @@ public class RemoveActionFragment extends InitActionFragment implements PodInitR if (!isOk) { errorView.setVisibility(View.VISIBLE); errorView.setText(callResult.comment); + + retryButton.setVisibility(View.VISIBLE); } mPage.setActionCompleted(isOk); diff --git a/app/src/main/res/layout/omnipod_initpod_init_action.xml b/app/src/main/res/layout/omnipod_initpod_init_action.xml index b465f178e2..e25b667565 100644 --- a/app/src/main/res/layout/omnipod_initpod_init_action.xml +++ b/app/src/main/res/layout/omnipod_initpod_init_action.xml @@ -1,19 +1,3 @@ - - @@ -47,15 +31,34 @@ - - + android:orientation="horizontal" + android:weightSum="1"> + + + +