- changed initpod_init_action dialog: added Retry button
- extracted InitPodTask into separate class, since it needs to be called several times
This commit is contained in:
parent
7e8e57dad9
commit
2133d347f0
|
@ -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<PodInitActionType> 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<Void, Void, String>() {
|
||||
|
||||
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);
|
||||
|
|
|
@ -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<Void, Void, String> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,19 +1,3 @@
|
|||
<!--
|
||||
Copyright 2012 Roman Nurik
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="@style/WizardPageContainer"
|
||||
android:orientation="vertical">
|
||||
|
@ -47,15 +31,34 @@
|
|||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/initAction_textErrorMessage"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:layout_marginLeft="25dp"
|
||||
android:layout_marginRight="25dp"
|
||||
style="@style/WizardPagePodContent"
|
||||
android:visibility="gone" />
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="1">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/initAction_textErrorMessage"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_weight="0.3"
|
||||
style="@style/WizardPagePodContent"
|
||||
android:visibility="gone" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/initAction_RetryButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.7"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:drawableTop="@drawable/icon_actions_refill"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<ProgressBar
|
||||
|
|
|
@ -1707,7 +1707,7 @@
|
|||
<string name="omnipod_init_pod_wizard_step1_title">Fill the Pod</string>
|
||||
<string name="omnipod_init_pod_wizard_step1_desc">\nFill new Pod with Insulin.\n\n\nAfter filling Pod, listen for 2 beeps, then press "Next".\n\n\n<b>Note:</b> Do not remove needle cap at this time.</string>
|
||||
<string name="omnipod_init_pod_wizard_step2_title">Pair and Prime the Pod</string>
|
||||
<string name="omnipod_init_pod_wizard_step2_action_header">We are trying to communicate with Pod.\n\nWhen all items are checked, you can press Next. If you decide to Cancel, you will have to discard the Pod.</string>
|
||||
<string name="omnipod_init_pod_wizard_step2_action_header">We are trying to communicate with Pod.\n\nWhen all items are checked, you can press Next. If you decide to Cancel, you will have to discard the Pod. If there is an error you will get option to retry.</string>
|
||||
<string name="omnipod_init_pod_wizard_step3_title">Attach the Pod</string>
|
||||
<string name="omnipod_init_pod_wizard_step3_desc">\nPrepare infusion site. Remove Pods needle cap.\n\nIf cannula sticks out press <b>Cancel</b> (Pod will need to be discarded).\n\nPress <b>Next</b> to insert cannula and begin Basal Delivery.</string>
|
||||
<string name="omnipod_init_pod_wizard_step4_title">Fill Cannula and Start Basal delivery</string>
|
||||
|
|
Loading…
Reference in a new issue