SetupWizard: Refactor for better transitions out of OOBE

Change-Id: If91da3f44dbc5383236b54da529953d48a475250
This commit is contained in:
cretin45 2015-03-09 14:49:31 -07:00
parent 7732b7485d
commit 0d31b31aac
9 changed files with 92 additions and 28 deletions

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2009, The Android Open Source 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.
*/
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/decelerate_quad">
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="@android:integer/config_shortAnimTime"/>
</set>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2009, The Android Open Source 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.
*/
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/accelerate_quad">
<alpha android:fromAlpha="1.0" android:toAlpha="0"
android:duration="@android:integer/config_shortAnimTime"/>
</set>

View File

@ -18,12 +18,25 @@
<style name="Theme.Setup" parent="@android:style/Theme.Material.Light">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@color/page_background</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorPrimary">@color/primary</item>
<item name="android:colorPrimaryDark">@color/primary</item>
<item name="android:colorAccent">@color/accent</item>
<item name="android:textColorLink">@color/accent</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowAnimationStyle">@style/ActivityAnimations</item>
</style>
<style name="ActivityAnimations" parent="@android:style/Animation.Activity">
<item name="android:activityOpenEnterAnimation">@anim/translucent_enter</item>
<item name="android:activityOpenExitAnimation">@anim/translucent_exit</item>
<item name="android:activityCloseEnterAnimation">@anim/translucent_enter</item>
<item name="android:activityCloseExitAnimation">@anim/translucent_exit</item>
<item name="android:taskToFrontEnterAnimation">@anim/translucent_enter</item>
<item name="android:taskToFrontExitAnimation">@anim/translucent_exit</item>
<item name="android:taskToBackEnterAnimation">@anim/translucent_enter</item>
<item name="android:taskToBackExitAnimation">@anim/translucent_exit</item>
</style>
<style name="Header">
@ -32,6 +45,7 @@
<style name="PageContainer">
<item name="android:textColor">@color/primary_text</item>
<item name="android:background">@color/page_background</item>
</style>
<style name="PageContent">

View File

@ -22,6 +22,8 @@ import android.app.StatusBarManager;
import android.content.Context;
import android.provider.Settings;
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
public class SetupWizardApp extends Application {
public static final String TAG = SetupWizardApp.class.getSimpleName();
@ -55,8 +57,22 @@ public class SetupWizardApp extends Application {
@Override
public void onCreate() {
super.onCreate();
disableCaptivePortalDetection();
mStatusBarManager = (StatusBarManager)getSystemService(Context.STATUS_BAR_SERVICE);
try {
// Since this is a new component, we need to disable here if the user
// has already been through setup on a previous version.
if (SetupWizardUtils.isGuestUser(this)
|| Settings.Secure.getInt(getContentResolver(),
Settings.Secure.USER_SETUP_COMPLETE) == 1) {
SetupWizardUtils.disableSetupWizard(this);
} else {
disableCaptivePortalDetection();
}
} catch (Settings.SettingNotFoundException e) {
// Continue with setup
disableCaptivePortalDetection();
}
}
public void disableStatusBar() {

View File

@ -86,7 +86,9 @@ public class CMSetupWizardData extends AbstractSetupData {
}
showHideMobileDataPage();
} else if (intent.getAction()
.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
.equals(ConnectivityManager.CONNECTIVITY_ACTION) ||
intent.getAction()
.equals(ConnectivityManager.CONNECTIVITY_ACTION_IMMEDIATE)) {
showHideAccountPages();
} else if (intent.getAction()
.equals(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
@ -139,6 +141,7 @@ public class CMSetupWizardData extends AbstractSetupData {
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
filter.addAction(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
}
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION_IMMEDIATE);
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
filter.addAction(Intent.ACTION_TIME_CHANGED);

View File

@ -69,8 +69,6 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
private final Handler mHandler = new Handler();
private boolean mIsGuestUser = false;
private volatile boolean mIsFinishing = false;
private static long sLaunchTime = 0;
@ -83,7 +81,6 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
SetupStats.addEvent(SetupStats.Categories.APP_LAUNCH, TAG);
sLaunchTime = System.nanoTime();
}
getWindow().setWindowAnimations(android.R.anim.fade_in);
setContentView(R.layout.setup_main);
mRootView = findViewById(R.id.root);
mReveal = (ImageView)mRootView.findViewById(R.id.reveal);
@ -126,20 +123,6 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
return mEnableAccessibilityController.onInterceptTouchEvent(event);
}
});
// Since this is a new component, we need to disable here if the user
// has already been through setup on a previous version.
try {
if (Settings.Secure.getInt(getContentResolver(),
Settings.Secure.USER_SETUP_COMPLETE) == 1) {
finalizeSetup();
}
} catch (Settings.SettingNotFoundException e) {
// Continue with setup
}
mIsGuestUser = SetupWizardUtils.isGuestUser(this);
if (mIsGuestUser) {
finalizeSetup();
}
registerReceiver(mSetupData, mSetupData.getIntentFilter());
}
@ -325,7 +308,7 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
@Override
public void finish() {
super.finish();
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
overridePendingTransition(R.anim.translucent_enter, R.anim.translucent_exit);
}
private void setupRevealImage() {

View File

@ -43,11 +43,6 @@ public class SetupWizardUtils {
private SetupWizardUtils(){}
public static boolean isStatsCollectionEnabled(Context context) {
return Settings.Secure.getInt(context.getContentResolver(),
Settings.Secure.STATS_COLLECTION, 1) != 0;
}
public static void tryEnablingWifi(Context context) {
WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
if (!wifiManager.isWifiEnabled()) {
@ -160,7 +155,7 @@ public class SetupWizardUtils {
disableComponentArray(context, packageInfo.services);
disableComponentArray(context, packageInfo.receivers);
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Enable to disable GMS");
Log.e(TAG, "Unable to disable GMS");
}
}

View File

@ -30,6 +30,7 @@
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" />
<uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<application android:icon="@drawable/icon">
<uses-library android:name="android.test.runner" />

View File

@ -18,6 +18,7 @@ package com.cyanogenmod.setupwizard.tests;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@ -66,6 +67,8 @@ public class ManualTestActivity extends Activity {
pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
pm.clearApplicationUserData("com.cyanogenmod.setupwizard", null);
ActivityManager am = (ActivityManager) getSystemService(Activity.ACTIVITY_SERVICE);
am.killBackgroundProcesses("com.cyanogenmod.setupwizard");
try {
PackageInfo packageInfo = getPackageManager()
.getPackageInfo("com.google.android.setupwizard",
@ -110,7 +113,6 @@ public class ManualTestActivity extends Activity {
private void setSetupComplete() {
Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1);
Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0);
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.HOME");
final PackageManager pm = getPackageManager();
@ -118,6 +120,8 @@ public class ManualTestActivity extends Activity {
"com.cyanogenmod.setupwizard.ui.SetupWizardActivity");
pm.setComponentEnabledSetting(componentName,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
ActivityManager am = (ActivityManager) getSystemService(Activity.ACTIVITY_SERVICE);
am.killBackgroundProcesses("com.cyanogenmod.setupwizard");
try {
PackageInfo packageInfo = this.getPackageManager()
.getPackageInfo("com.google.android.setupwizard",