diff --git a/app/build.gradle b/app/build.gradle index 858fe354fc..fcd39ee27f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -254,6 +254,8 @@ dependencies { implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.1.1" implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation(name: "android-edittext-validator-v1.3.4-mod", ext: "aar") + implementation(name: "com.atech-software.android.library.wizardpager-1.1.0", ext: "aar") + implementation 'com.madgag.spongycastle:core:1.58.0.0' implementation("com.google.android:flexbox:0.3.0") { diff --git a/app/libs/com.atech-software.android.library.wizardpager-1.1.0.aar b/app/libs/com.atech-software.android.library.wizardpager-1.1.0.aar new file mode 100644 index 0000000000..36f9934047 Binary files /dev/null and b/app/libs/com.atech-software.android.library.wizardpager-1.1.0.aar differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index afd60d4126..c431ea59a9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -308,6 +308,8 @@ + > stepsForWizardStep; @@ -26,13 +28,27 @@ public enum PodInitActionType { } - PodInitActionType() { - + PodInitActionType(int resourceId, PodInitActionType parent) { + this.resourceId = resourceId; + this.parent = parent; } - private PodInitActionType(PodInitActionType... parent) { - this.parent = parent; + PodInitActionType() { + } + + + public List getChildren() { + + List outList = new ArrayList<>(); + + for (PodInitActionType value : values()) { + if (value.parent == this) { + outList.add(value); + } + } + + return outList; } @@ -59,4 +75,8 @@ public enum PodInitActionType { } + public int getResourceId() { + return resourceId; + } + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt index a29d90d5a7..26871e2d31 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt @@ -1,9 +1,16 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dialogs +import android.content.Intent import android.os.Bundle +import com.atech.android.library.wizardpager.WizardPagerActivity +import com.atech.android.library.wizardpager.WizardPagerContext +import com.atech.android.library.wizardpager.data.WizardPagerSettings +import com.atech.android.library.wizardpager.defs.WizardStepsWayType import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.NoSplashActivity +import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitPodCancelAction +import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitPodWizardModel import info.nightscout.androidaps.utils.OKDialog import kotlinx.android.synthetic.main.omnipod_pod_mgmt.* @@ -34,8 +41,32 @@ class PodManagementActivity : NoSplashActivity() { fun initPodAction() { - OKDialog.showConfirmation(this, - MainApp.gs(R.string.omnipod_cmd_init_pod_na), null) + + // TODO check if RL is running + + val pagerSettings = WizardPagerSettings() + + pagerSettings.setWizardStepsWayType(WizardStepsWayType.CancelNext) + pagerSettings.setFinishStringResourceId(R.string.close) + pagerSettings.setFinishButtonBackground(R.drawable.finish_background) + pagerSettings.setNextButtonBackground(R.drawable.selectable_item_background) + pagerSettings.setBackStringResourceId(R.string.cancel) + pagerSettings.setCancelAction(InitPodCancelAction()) + pagerSettings.setTheme(R.style.AppTheme_NoActionBar) + + + WizardPagerContext.getInstance().pagerSettings = pagerSettings + WizardPagerContext.getInstance().wizardModel = InitPodWizardModel(applicationContext) + + val myIntent = Intent(this@PodManagementActivity, WizardPagerActivity::class.java) + this@PodManagementActivity.startActivity(myIntent) + + + + + + //OKDialog.showConfirmation(this, + // MainApp.gs(R.string.omnipod_cmd_init_pod_na), null) } fun removePodAction() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodCancelAction.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodCancelAction.java new file mode 100644 index 0000000000..a6f443a9a2 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodCancelAction.java @@ -0,0 +1,21 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod; + +import com.atech.android.library.wizardpager.defs.action.AbstractCancelAction; + +public class InitPodCancelAction extends AbstractCancelAction { + @Override + public void execute(String cancelReason) { + if (cancelReason != null && cancelReason.trim().length() > 0) { + this.cancelActionText = cancelReason; + } + + if (this.cancelActionText.equals("Cancel")) { + // TODO + // remove pod from SP + + // do refresh of tab + } + + + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodFinishAction.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodFinishAction.java new file mode 100644 index 0000000000..b77fed2042 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodFinishAction.java @@ -0,0 +1,11 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod; + +import com.atech.android.library.wizardpager.defs.action.AbstractFinishAction; + +public class InitPodFinishAction extends AbstractFinishAction { + @Override + public void execute() { + // TODO + // do refresh of tab + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodWizardModel.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodWizardModel.java new file mode 100644 index 0000000000..48a4fa97f8 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodWizardModel.java @@ -0,0 +1,71 @@ +/* + * 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. + */ + +package info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod; + +import android.content.Context; + +import androidx.fragment.app.Fragment; + +import com.atech.android.library.wizardpager.model.DisplayTextPage; + +import com.tech.freak.wizardpager.model.AbstractWizardModel; +import com.tech.freak.wizardpager.model.PageList; + +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType; +import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.InitActionPage; +import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.PodInfoFragment; + +public class InitPodWizardModel extends AbstractWizardModel { + public InitPodWizardModel(Context context) { + super(context); + } + + @Override + protected PageList onNewRootPageList() { + return new PageList( + + new DisplayTextPage(this, + R.string.omnipod_init_pod_wizard_step1_title, + R.string.omnipod_init_pod_wizard_step1_desc, + R.style.WizardPagePodContent).setRequired(true).setCancelReason("None"), + + new InitActionPage(this, + R.string.omnipod_init_pod_wizard_step2_title, + PodInitActionType.PairAndPrimeWizardStep + ).setRequired(true).setCancelReason("Cancel"), + + new DisplayTextPage(this, + R.string.omnipod_init_pod_wizard_step3_title, + R.string.omnipod_init_pod_wizard_step3_desc, + R.style.WizardPagePodContent).setRequired(true).setCancelReason("Cancel"), + + new InitActionPage(this, + R.string.omnipod_init_pod_wizard_step4_title, + PodInitActionType.FillCannulaSetBasalProfileWizardStep + ).setRequired(true).setCancelReason("Cancel") + ); + } + + + public Fragment getReviewFragment() { + PodInfoFragment.isInitPod = true; + return new PodInfoFragment(); + } + + +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitActionFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitActionFragment.java new file mode 100644 index 0000000000..4fd5c3488a --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitActionFragment.java @@ -0,0 +1,202 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages; + +import android.app.Activity; +import android.graphics.Color; +import android.os.AsyncTask; +import android.os.Bundle; +import android.os.SystemClock; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.CheckBox; +import android.widget.LinearLayout; +import android.widget.ProgressBar; +import android.widget.TextView; + +import androidx.fragment.app.Fragment; + +import com.atech.android.library.wizardpager.util.WizardPagesUtil; + +import com.tech.freak.wizardpager.model.Page; +import com.tech.freak.wizardpager.ui.PageFragmentCallbacks; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType; + +/** + * Created by TechFreak on 04/09/2014. + */ +public class InitActionFragment extends Fragment { + private static final String ARG_KEY = "key"; + + private PageFragmentCallbacks mCallbacks; + private String mKey; + private InitActionPage mPage; + + ProgressBar progressBar; + TextView errorView; + + PodInitActionType podInitActionType; + List children; + Map mapCheckBoxes; + + public static InitActionFragment create(String key, PodInitActionType podInitActionType) { + Bundle args = new Bundle(); + args.putString(ARG_KEY, key); + + InitActionFragment fragment = new InitActionFragment(); + fragment.setArguments(args); + fragment.setPodInitActionType(podInitActionType); + return fragment; + } + + public InitActionFragment() { + + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Bundle args = getArguments(); + mKey = args.getString(ARG_KEY); + mPage = (InitActionPage) mCallbacks.onGetPage(mKey); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.omnipod_initpod_init_action, container, false); + WizardPagesUtil.setTitle(mPage, rootView); + + this.progressBar = rootView.findViewById(R.id.initAction_progressBar); + this.errorView = rootView.findViewById(R.id.initAction_textErrorMessage); + + TextView headerView = rootView.findViewById(R.id.initAction_header); + + LinearLayout linearLayout = rootView.findViewById(R.id.initAction_ItemsHolder); + + children = podInitActionType.getChildren(); + mapCheckBoxes = new HashMap<>(); + + for (PodInitActionType child : children) { + + CheckBox checkBox1 = new CheckBox(getContext()); + checkBox1.setText(child.getResourceId()); + checkBox1.setClickable(false); + checkBox1.setTextAppearance(R.style.WizardPagePodListItem); + checkBox1.setHeight(140); + checkBox1.setTextSize(16); + checkBox1.setTextColor(headerView.getTextColors().getDefaultColor()); + + linearLayout.addView(checkBox1); + + mapCheckBoxes.put(child, checkBox1); + } + + return rootView; + } + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + + if (!(activity instanceof PageFragmentCallbacks)) { + throw new ClassCastException("Activity must implement PageFragmentCallbacks"); + } + + mCallbacks = (PageFragmentCallbacks) activity; + } + + @Override + public void onDetach() { + super.onDetach(); + mCallbacks = null; + } + + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + } + + @Override + public void setMenuVisibility(boolean menuVisible) { + super.setMenuVisibility(menuVisible); + + // In a future update to the support library, this should override setUserVisibleHint + // instead of setMenuVisibility. + + } + + public PodInitActionType getPodInitActionType() { + return podInitActionType; + } + + + public void setPodInitActionType(PodInitActionType podInitActionType) { + this.podInitActionType = podInitActionType; + } + + + @Override + public void setUserVisibleHint(boolean isVisibleToUser) { + super.setUserVisibleHint(isVisibleToUser); + 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) { + System.out.println("ACTION: doInBackground Started: "); + SystemClock.sleep(5000); + mPage.setActionCompleted(true); + + System.out.println("ACTION: doInBackground Finished: "); + + + return "Test"; + } + + @Override + protected void onPostExecute(String result) { + super.onPostExecute(result); + + System.out.println("ACTION: onPostExecute: " + result); + + boolean isOk = false; + + for (PodInitActionType actionType : mapCheckBoxes.keySet()) { + mapCheckBoxes.get(actionType).setChecked(true); + mapCheckBoxes.get(actionType).setTextColor(isOk ? Color.rgb(34, 135, 91) : Color.rgb(168, 36, 15)); + } + + progressBar.setVisibility(View.GONE); + + if (!isOk) { + errorView.setVisibility(View.VISIBLE); + errorView.setText("Error containg pod."); + } + + mPage.getData().putString(Page.SIMPLE_DATA_KEY, "ddd"); + mPage.notifyDataChanged(); + } + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + + } else { + System.out.println("ACTION: Not visible"); + } + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitActionPage.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitActionPage.java new file mode 100644 index 0000000000..385febed49 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitActionPage.java @@ -0,0 +1,72 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages; + +import androidx.annotation.StringRes; +import androidx.fragment.app.Fragment; + +import com.tech.freak.wizardpager.model.ModelCallbacks; +import com.tech.freak.wizardpager.model.Page; +import com.tech.freak.wizardpager.model.ReviewItem; + +import java.util.ArrayList; + +import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType; + + +/** + * A page asking for a name and an email. + */ +public class InitActionPage extends Page { + + private PodInitActionType podInitActionType; + + private boolean actionCompleted = false; + private boolean actionSuccess = false; + + public InitActionPage(ModelCallbacks callbacks, String title) { + super(callbacks, title); + } + + public InitActionPage(ModelCallbacks callbacks, @StringRes int titleId, PodInitActionType podInitActionType) { + super(callbacks, titleId); + this.podInitActionType = podInitActionType; + } + + @Override + public Fragment createFragment() { + return InitActionFragment.create(getKey(), this.podInitActionType); + } + + @Override + public void getReviewItems(ArrayList dest) { + } + + @Override + public boolean isCompleted() { + System.out.println("ACTION: Page.isCompleted " + actionCompleted); + return actionCompleted; + } + + public void setActionCompleted(boolean success) { + this.actionCompleted = true; + this.actionSuccess = success; + } + + /** + * This is used just if we want to override default behavior (for example when we enter Page we want prevent any action, until something happens. + * + * @return + */ + public boolean isBackActionPossible() { + return actionCompleted; + } + + /** + * This is used just if we want to override default behavior (for example when we enter Page we want prevent any action, until something happens. + * + * @return + */ + public boolean isNextActionPossible() { + return actionSuccess; + } + +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoFragment.java new file mode 100644 index 0000000000..e4625df76b --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoFragment.java @@ -0,0 +1,200 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages; + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.text.TextUtils; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.BaseAdapter; +import android.widget.ListView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.ListFragment; + +import com.tech.freak.wizardpager.model.ModelCallbacks; +import com.tech.freak.wizardpager.model.Page; +import com.tech.freak.wizardpager.model.ReviewItem; +import com.tech.freak.wizardpager.ui.PageFragmentCallbacks; +import com.tech.freak.wizardpager.ui.ReviewFragment; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.pump.omnipod.defs.FirmwareVersion; +import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState; + + +public class PodInfoFragment extends Fragment { + private static final String ARG_KEY = "key"; + + private PageFragmentCallbacks mCallbacks; + private String mKey; + private PodInfoPage mPage; + public static boolean isInitPod = false; + private ArrayList mCurrentReviewItems; + + public static PodInfoFragment create(String key, boolean initPod) { + Bundle args = new Bundle(); + args.putString(ARG_KEY, key); + isInitPod = initPod; + + PodInfoFragment fragment = new PodInfoFragment(); + fragment.setArguments(args); + return fragment; + } + + public PodInfoFragment() { + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.omnipod_initpod_pod_info, container, false); + + TextView titleView = (TextView) rootView.findViewById(R.id.podInfoTitle); + titleView.setText(R.string.omnipod_init_pod_wizard_pod_info_title); + titleView.setTextColor(getResources().getColor(com.tech.freak.wizardpager.R.color.review_green)); + + TextView headerText = rootView.findViewById(R.id.podInfoText); + headerText.setText(isInitPod ? // + R.string.omnipod_init_pod_wizard_pod_info_init_pod_description : // + R.string.omnipod_init_pod_wizard_pod_info_remove_pod_description); + + + if (isInitPod) { + createDataOfPod(); + + ListView listView = (ListView) rootView.findViewById(R.id.podInfoList); + listView.setAdapter(new PodInfoAdapter(mCurrentReviewItems, getContext())); + listView.setChoiceMode(ListView.CHOICE_MODE_NONE); + } + + + return rootView; + } + + private void createDataOfPod() { + + // TODO + + PodSessionState podSessionState = new PodSessionState(DateTimeZone.UTC, + 483748738, + new DateTime(), + new FirmwareVersion(1,0,0), + new FirmwareVersion(1,0,0), + 574875, + 5487584, + 1, + 1 + ); + + mCurrentReviewItems = new ArrayList<>(); + mCurrentReviewItems.add(new ReviewItem("Pod Address", "" + podSessionState.getAddress(), "33")); + mCurrentReviewItems.add(new ReviewItem("Activated At", podSessionState.getActivatedAt().toString("dd.MM.yyyy HH:mm:ss"), "34")); + mCurrentReviewItems.add(new ReviewItem("Firmware Version", podSessionState.getPiVersion().toString(), "35")); + mCurrentReviewItems.add(new ReviewItem("LOT", "" + podSessionState.getLot(), "36")); + + } + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + + if (!(activity instanceof PageFragmentCallbacks)) { + throw new ClassCastException("Activity must implement PageFragmentCallbacks"); + } + + mCallbacks = (PageFragmentCallbacks) activity; + } + + @Override + public void onDetach() { + super.onDetach(); + mCallbacks = null; + } + + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + } + + + private class PodInfoAdapter extends ArrayAdapter { + + private ArrayList dataSet; + Context mContext; + + // View lookup cache + + + public PodInfoAdapter(ArrayList data, Context context) { + super(context, com.tech.freak.wizardpager.R.layout.list_item_review, data); + this.dataSet = data; + this.mContext=context; + } + + + + private int lastPosition = -1; + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + // Get the data item for this position + ReviewItem dataModel = getItem(position); + // Check if an existing view is being reused, otherwise inflate the view + ViewHolder viewHolder; // view lookup cache stored in tag + + final View result; + + if (convertView == null) { + + viewHolder = new ViewHolder(); + LayoutInflater inflater = LayoutInflater.from(getContext()); + convertView = inflater.inflate(R.layout.omnipod_initpod_pod_info_item, parent, false); + viewHolder.txtName = (TextView) convertView.findViewById(android.R.id.text1); + viewHolder.txtType = (TextView) convertView.findViewById(android.R.id.text2); + + + result=convertView; + + convertView.setTag(viewHolder); + } else { + viewHolder = (ViewHolder) convertView.getTag(); + result=convertView; + } + + + + viewHolder.txtName.setText(dataModel.getTitle()); + viewHolder.txtType.setText(dataModel.getDisplayValue()); + + + // Return the completed view to render on screen + return convertView; + } + + } + + private static class ViewHolder { + TextView txtName; + TextView txtType; + } + + + +} 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 new file mode 100644 index 0000000000..78b0fa07b5 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoPage.java @@ -0,0 +1,36 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages; + +import androidx.fragment.app.Fragment; + +import com.tech.freak.wizardpager.model.ModelCallbacks; +import com.tech.freak.wizardpager.model.Page; +import com.tech.freak.wizardpager.model.ReviewItem; + +import java.util.ArrayList; + + +/** + * A page asking for a name and an email. + */ +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); + } + + @Override + public Fragment createFragment() { + return PodInfoFragment.create(getKey(), true); + } + + @Override + public void getReviewItems(ArrayList dest) { + } + + @Override + public boolean isCompleted() { + return true; + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemovePodWizardModel.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemovePodWizardModel.java new file mode 100644 index 0000000000..12052a4c0b --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemovePodWizardModel.java @@ -0,0 +1,75 @@ +/* + * 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. + */ + +package info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.removepod; + +import android.content.Context; + +import androidx.fragment.app.Fragment; + +import com.atech.android.library.wizardpager.model.DisplayTextPage; +import com.atech.android.library.wizardpager.ui.DisplayTextFragment; + +import com.tech.freak.wizardpager.model.AbstractWizardModel; +import com.tech.freak.wizardpager.model.PageList; + +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType; +import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.InitActionPage; +import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.PodInfoFragment; + +public class RemovePodWizardModel extends AbstractWizardModel { + public RemovePodWizardModel(Context context) { + super(context); + } + + @Override + protected PageList onNewRootPageList() { + // TODO + return new PageList( + + new DisplayTextPage(this, + R.string.omnipod_init_pod_wizard_step1_title, + R.string.omnipod_init_pod_wizard_step1_desc, + R.style.WizardPagePodContent).setRequired(true).setCancelReason("None"), + + new InitActionPage(this, + R.string.omnipod_init_pod_wizard_step2_title, + PodInitActionType.PairAndPrimeWizardStep + ).setRequired(true).setCancelReason("Cancel"), + + new DisplayTextPage(this, + R.string.omnipod_init_pod_wizard_step3_title, + R.string.omnipod_init_pod_wizard_step3_desc, + R.style.WizardPagePodContent).setRequired(true).setCancelReason("Cancel"), + + new InitActionPage(this, + R.string.omnipod_init_pod_wizard_step4_title, + PodInitActionType.FillCannulaSetBasalProfileWizardStep).setRequired(true).setCancelReason("Cancel") + + //new PodInfoPage(this, "Pod Info").setRequired(true) + ); + } + + + public Fragment getReviewFragment() { + // TODO + PodInfoFragment.isInitPod = false; + return DisplayTextFragment.create(null, 0, 0); + } + + +} diff --git a/app/src/main/res/layout/omnipod_initpod_init_action.xml b/app/src/main/res/layout/omnipod_initpod_init_action.xml new file mode 100644 index 0000000000..b465f178e2 --- /dev/null +++ b/app/src/main/res/layout/omnipod_initpod_init_action.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/omnipod_initpod_pod_info.xml b/app/src/main/res/layout/omnipod_initpod_pod_info.xml new file mode 100644 index 0000000000..e10ce18f7d --- /dev/null +++ b/app/src/main/res/layout/omnipod_initpod_pod_info.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/omnipod_initpod_pod_info_item.xml b/app/src/main/res/layout/omnipod_initpod_pod_info_item.xml new file mode 100644 index 0000000000..1d03aabeac --- /dev/null +++ b/app/src/main/res/layout/omnipod_initpod_pod_info_item.xml @@ -0,0 +1,45 @@ + + + + + + + + + diff --git a/app/src/main/res/layout/omnipod_pod_mgmt.xml b/app/src/main/res/layout/omnipod_pod_mgmt.xml index e203e72540..13862757eb 100644 --- a/app/src/main/res/layout/omnipod_pod_mgmt.xml +++ b/app/src/main/res/layout/omnipod_pod_mgmt.xml @@ -104,7 +104,7 @@ android:layout_marginBottom="3dp" android:textAllCaps="false" android:layout_weight="0.5" - android:drawableTop="@drawable/icon_cp_pump_canula" + android:drawableTop="@drawable/icon_danarhistory" android:text="@string/omnipod_cmd_pod_history" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 706b9b29d5..3c5fde662f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1661,6 +1661,23 @@ Omnipod + Fill the Pod + \nFill new Pod with Insulin.\n\n\nAfter filling Pod, listen for 2 beeps, then press "Next".\n\n\nNote: Do not remove needle cap at this time. + Pair and Prime the Pod + 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. + Attach the Pod + \nPrepare infusion site. Remove Pods needle cap.\n\nIf cannula sticks out press Cancel (Pod will need to be discarded).\n\nPress Next to insert cannula and begin Basal Delivery. + Fill Cannula and Start Basal delivery + Pod Info + Pod is now active.\n\nBasal has been programmed.\n\nCheck infusion site and cannula. If cannula seems incorrectly inserted, please replace the Pod. + Pod Info + + Pair Pod + Prime Pod + Fill Cannula + Set Basal Profile + + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index d2cacff3b7..e31396a640 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -49,4 +49,37 @@ + + + + +