Add workaround for anti pattern in wizard pager model
This commit is contained in:
parent
b1e358e8b0
commit
403551406b
|
@ -12,7 +12,8 @@ import info.nightscout.androidaps.activities.NoSplashActivity
|
|||
import info.nightscout.androidaps.events.EventRefreshOverview
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitPodWizardModel
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.FullInitPodWizardModel
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.ShortInitPodWizardModel
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.InitPodRefreshAction
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.removepod.RemovePodWizardModel
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager
|
||||
|
@ -86,7 +87,11 @@ class PodManagementActivity : NoSplashActivity() {
|
|||
wizardPagerContext.pagerSettings = pagerSettings
|
||||
val podSessionState = OmnipodUtil.getPodSessionState()
|
||||
val isFullInit = podSessionState == null || podSessionState.setupProgress.isBefore(SetupProgress.PRIMING_FINISHED)
|
||||
wizardPagerContext.wizardModel = InitPodWizardModel(applicationContext, isFullInit)
|
||||
if(isFullInit) {
|
||||
wizardPagerContext.wizardModel = FullInitPodWizardModel(applicationContext)
|
||||
} else {
|
||||
wizardPagerContext.wizardModel = ShortInitPodWizardModel(applicationContext)
|
||||
}
|
||||
|
||||
val myIntent = Intent(this@PodManagementActivity, WizardPagerActivity::class.java)
|
||||
this@PodManagementActivity.startActivity(myIntent)
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.PodInfoFragment;
|
||||
|
||||
/**
|
||||
* Created by andy on 12/11/2019
|
||||
*/
|
||||
// Full init pod wizard model
|
||||
// Cannot be merged with ShortInitPodWizardModel, because we can't set any instance variables
|
||||
// before the onNewRootPageList method is called (which happens in the super constructor)
|
||||
public class FullInitPodWizardModel extends InitPodWizardModel {
|
||||
|
||||
public FullInitPodWizardModel(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")
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,96 +1,21 @@
|
|||
/*
|
||||
* 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.PodInfoFragment;
|
||||
|
||||
/**
|
||||
* Created by andy on 12/11/2019
|
||||
*/
|
||||
public class InitPodWizardModel extends AbstractWizardModel {
|
||||
|
||||
boolean isFullInit;
|
||||
|
||||
public InitPodWizardModel(Context context, boolean isFullInit) {
|
||||
public abstract class InitPodWizardModel extends AbstractWizardModel {
|
||||
public InitPodWizardModel(Context context) {
|
||||
super(context);
|
||||
this.isFullInit = isFullInit;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PageList onNewRootPageList() {
|
||||
|
||||
if (isFullInit) {
|
||||
|
||||
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")
|
||||
);
|
||||
} else {
|
||||
|
||||
return new PageList(
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* 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.PodInfoFragment;
|
||||
|
||||
/**
|
||||
* Created by andy on 12/11/2019
|
||||
*/
|
||||
// Init pod wizard model without the pair and prime step
|
||||
// Cannot be merged with FullInitPodWizardModel, because we can't set any instance variables
|
||||
// before the onNewRootPageList method is called (which happens in the super constructor)
|
||||
public class ShortInitPodWizardModel extends InitPodWizardModel {
|
||||
|
||||
public ShortInitPodWizardModel(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PageList onNewRootPageList() {
|
||||
return new PageList(
|
||||
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")
|
||||
);
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue