SetupWizard: Add loading fragment if launching into another activity

Also always show the Wi-Fi page

Change-Id: I3be39f793403131ea07d071c3d107b1800771e65
This commit is contained in:
cretin45 2015-01-23 14:04:04 -08:00
parent 501a25032d
commit 1fcde3985e
11 changed files with 121 additions and 10 deletions

BIN
res/drawable-hdpi/timer.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
res/drawable-mdpi/timer.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 967 B

BIN
res/drawable-xhdpi/timer.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
res/drawable-xxhdpi/timer.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
res/drawable-xxxhdpi/timer.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/header" />
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminateOnly="true"
android:layout_width="match_parent"
android:layout_height="8dp" />
<FrameLayout android:id="@+id/page"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
style="@style/PageContent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/timer"/>
</FrameLayout>
</LinearLayout>

View File

@ -33,10 +33,11 @@
<string name="new_account">New</string>
<string name="skip_anyway">Skip anyway</string>
<string name="dont_skip">Don\'t skip</string>
<string name="loading">Loading...</string>
<string name="setup_complete">Setup is complete</string>
<string name="setup_welcome">Welcome</string>
<string name="setup_wifi">Connect to Wi-Fi</string>
<string name="setup_wifi">Select Wi-Fi</string>
<string name="setup_sim_missing">SIM Card Missing</string>
<string name="setup_gms_account">GMS account</string>
<string name="setup_choose_data_sim">Choose a SIM for Data</string>

View File

@ -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;
@ -40,6 +42,19 @@ public class GmsAccountPage extends SetupPage {
super(context, callbacks);
}
@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;
@ -47,7 +62,7 @@ public class GmsAccountPage extends SetupPage {
@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);
}
}

View File

@ -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;
}
}

View File

@ -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;
@ -32,6 +35,19 @@ public class WifiSetupPage extends SetupPage {
super(context, callbacks);
}
@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;
}
}

View File

@ -57,7 +57,7 @@ public class SetupWizardUtils {
intent.putExtra(SetupWizardApp.EXTRA_FIRST_RUN, true);
intent.putExtra(SetupWizardApp.EXTRA_ALLOW_SKIP, true);
intent.putExtra("theme", "material_light");
intent.putExtra(SetupWizardApp.EXTRA_AUTO_FINISH, true);
intent.putExtra(SetupWizardApp.EXTRA_AUTO_FINISH, false);
context.startActivityForResult(intent, SetupWizardApp.REQUEST_CODE_SETUP_WIFI);
}