diff options
author | cretin45 <cretin45@gmail.com> | 2015-01-23 14:04:04 -0800 |
---|---|---|
committer | cretin45 <cretin45@gmail.com> | 2015-01-23 14:04:04 -0800 |
commit | 1fcde3985e9d62eb22eff0b8eacf1d4832234867 (patch) | |
tree | a7b3076149cf0709a0c6df8b0555de8bfbda7e7a /src/com/cyanogenmod/setupwizard/setup | |
parent | 501a25032dc1783c57a094485f0b7b94c26c9421 (diff) | |
download | packages_apps_SetupWizard-1fcde3985e9d62eb22eff0b8eacf1d4832234867.zip packages_apps_SetupWizard-1fcde3985e9d62eb22eff0b8eacf1d4832234867.tar.gz packages_apps_SetupWizard-1fcde3985e9d62eb22eff0b8eacf1d4832234867.tar.bz2 |
SetupWizard: Add loading fragment if launching into another activity
Also always show the Wi-Fi page
Change-Id: I3be39f793403131ea07d071c3d107b1800771e65
Diffstat (limited to 'src/com/cyanogenmod/setupwizard/setup')
3 files changed, 71 insertions, 8 deletions
diff --git a/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java b/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java index 3e45ed4..8b808dc 100644 --- a/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java @@ -22,6 +22,8 @@ import android.accounts.AccountManagerFuture; import android.accounts.AuthenticatorException; import android.accounts.OperationCanceledException; import android.app.Activity; +import android.app.Fragment; +import android.app.FragmentManager; import android.content.Context; import android.content.Intent; import android.os.Bundle; @@ -41,13 +43,26 @@ public class GmsAccountPage extends SetupPage { } @Override + public Fragment getFragment(FragmentManager fragmentManager, int action) { + Fragment fragment = fragmentManager.findFragmentByTag(getKey()); + if (fragment == null) { + Bundle args = new Bundle(); + args.putString(Page.KEY_PAGE_ARGUMENT, getKey()); + args.putInt(Page.KEY_PAGE_ACTION, action); + fragment = new LoadingFragment(); + fragment.setArguments(args); + } + return fragment; + } + + @Override public String getKey() { return TAG; } @Override public int getTitleResId() { - return R.string.setup_gms_account; + return R.string.loading; } @Override @@ -60,6 +75,7 @@ public class GmsAccountPage extends SetupPage { if (action == Page.ACTION_PREVIOUS) { getCallbacks().onPreviousPage(); } else { + super.doLoadAction(context, action); launchGmsAccountSetup(context); } } diff --git a/src/com/cyanogenmod/setupwizard/setup/LoadingFragment.java b/src/com/cyanogenmod/setupwizard/setup/LoadingFragment.java new file mode 100644 index 0000000..1983806 --- /dev/null +++ b/src/com/cyanogenmod/setupwizard/setup/LoadingFragment.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2015 The CyanogenMod Project + * + * 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 com.cyanogenmod.setupwizard.setup; + +import com.cyanogenmod.setupwizard.R; +import com.cyanogenmod.setupwizard.ui.SetupPageFragment; + +public class LoadingFragment extends SetupPageFragment { + @Override + protected void initializePage() {} + + @Override + protected int getLayoutResource() { + return R.layout.setup_loading_page; + } +} diff --git a/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java b/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java index 705b932..2d764d6 100644 --- a/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java @@ -17,8 +17,11 @@ package com.cyanogenmod.setupwizard.setup; import android.app.Activity; +import android.app.Fragment; +import android.app.FragmentManager; import android.content.Context; import android.content.Intent; +import android.os.Bundle; import com.cyanogenmod.setupwizard.R; import com.cyanogenmod.setupwizard.SetupWizardApp; @@ -33,6 +36,19 @@ public class WifiSetupPage extends SetupPage { } @Override + public Fragment getFragment(FragmentManager fragmentManager, int action) { + Fragment fragment = fragmentManager.findFragmentByTag(getKey()); + if (fragment == null) { + Bundle args = new Bundle(); + args.putString(Page.KEY_PAGE_ARGUMENT, getKey()); + args.putInt(Page.KEY_PAGE_ACTION, action); + fragment = new LoadingFragment(); + fragment.setArguments(args); + } + return fragment; + } + + @Override public int getNextButtonTitleResId() { return R.string.skip; } @@ -44,22 +60,23 @@ public class WifiSetupPage extends SetupPage { @Override public int getTitleResId() { - return R.string.existing; + return R.string.setup_wifi; } @Override public void doLoadAction(Activity context, int action) { - if (action == Page.ACTION_PREVIOUS) { - getCallbacks().onPreviousPage(); - } else { - SetupWizardUtils.launchWifiSetup(context); - } + super.doLoadAction(context, action); + SetupWizardUtils.launchWifiSetup(context); } @Override public boolean onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode != SetupWizardApp.REQUEST_CODE_SETUP_WIFI) return false; - getCallbacks().onNextPage(); + if (resultCode == Activity.RESULT_OK || resultCode == Activity.RESULT_FIRST_USER) { + getCallbacks().onNextPage(); + } else if (resultCode == Activity.RESULT_CANCELED) { + getCallbacks().onPreviousPage(); + } return true; } } |