SetupWizard: Reveal the default wallpaper on oobe finish

Change-Id: I68a256853f256af3464da7eba57a307a810d80cd
This commit is contained in:
cretin45 2015-02-16 11:46:30 -08:00
parent aaec6f7e3e
commit 9d72db9dbe
23 changed files with 240 additions and 74 deletions

View File

@ -77,6 +77,7 @@
android:label="@string/product_name"
android:launchMode="singleInstance"
android:excludeFromRecents="true"
android:uiOptions="none"
android:immersive="true">
<intent-filter android:priority="9">

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="1000"/>
</set>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="1.0" android:toAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="1000"/>
</set>

View File

@ -20,6 +20,7 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingTop="@dimen/header_logo_margin_top"
android:background="@color/primary"
style="@style/Header">
<ImageView

View File

@ -17,7 +17,8 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/button_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:background="@color/button_bar_background">
<Button
style="@style/ButtonBar.Left"

View File

@ -18,6 +18,7 @@
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="@dimen/header_height"
android:background="@color/header_bg"
style="@style/Header">
<TextView

View File

@ -17,7 +17,8 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="@dimen/page_title_height"
android:layout_height="@dimen/header_condensed_height"
android:background="@color/header_condensed_bg"
style="@style/Header">
<TextView

View File

@ -18,6 +18,7 @@
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="@dimen/logo_header_height"
android:background="@color/primary"
style="@style/Header">
<ImageView

View File

@ -14,12 +14,16 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true">
<com.cyanogenmod.setupwizard.ui.widget.ScrimInsetsFrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:fitsSystemWindows="true"
app:insetForeground="@android:color/transparent">
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
@ -31,7 +35,7 @@
android:layout_weight="1"
style="@style/PageContainer"/>
<include layout="@layout/button_bar" />
<include layout="@layout/button_bar"/>
</LinearLayout>
@ -41,5 +45,5 @@
android:background="@drawable/reveal"
android:visibility="invisible"/>
</FrameLayout>
</com.cyanogenmod.setupwizard.ui.widget.ScrimInsetsFrameLayout>

View File

@ -15,5 +15,5 @@
limitations under the License.
-->
<resources>
<color name="status_bar">@color/primary_dark</color>
<color name="header_bg">@color/header_condensed_bg</color>
</resources>

View File

@ -15,5 +15,5 @@
limitations under the License.
-->
<resources>
<dimen name="header_height">@dimen/page_title_height</dimen>
<dimen name="header_height">@dimen/header_condensed_height</dimen>
</resources>

20
res/values/attrs.xml Normal file
View File

@ -0,0 +1,20 @@
<!--
Copyright 2014 Google Inc. All rights reserved.
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.
-->
<resources>
<declare-styleable name="ScrimInsetsView">
<attr name="insetForeground" format="reference|color" />
</declare-styleable>
</resources>

View File

@ -17,7 +17,6 @@
<resources>
<color name="black">#000000</color>
<color name="white">#ffffff</color>
<color name="window_background">#e4e7e8</color>
<color name="page_background">#efefef</color>
<color name="primary">#00B1E5</color>
@ -26,5 +25,7 @@
<color name="primary_text">#8a000000</color>
<color name="secondary_text">#727272</color>
<color name="divider">#40000000</color>
<color name="status_bar">@color/primary</color>
<color name="header_bg">@color/primary</color>
<color name="header_condensed_bg">@color/primary_dark</color>
<color name="button_bar_background">#e4e7e8</color>
</resources>

View File

@ -15,8 +15,9 @@
limitations under the License.
-->
<resources>
<dimen name="logo_header_height">220dp</dimen>
<dimen name="header_height">220dp</dimen>
<dimen name="logo_header_height">244dp</dimen>
<dimen name="header_height">244dp</dimen>
<dimen name="header_condensed_height">88dp</dimen>
<dimen name="page_title_height">64dp</dimen>
<dimen name="header_title_margin_left">26dp</dimen>
<dimen name="header_logo_margin_left">25dp</dimen>

View File

@ -18,16 +18,16 @@
<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/window_background</item>
<item name="android:windowBackground">@color/page_background</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>
</style>
<style name="Header">
<item name="android:elevation">4dp</item>
<item name="android:background">@color/primary</item>
</style>
<style name="PageContainer">

View File

@ -20,7 +20,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;
import com.android.internal.telephony.TelephonyIntents;

View File

@ -16,13 +16,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.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
import android.preference.PreferenceManager;
import android.provider.Settings;
@ -210,13 +208,6 @@ public class CyanogenSettingsPage extends SetupPage {
}
};
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final Activity activity = getActivity();
activity.getWindow().setStatusBarColor(getResources().getColor(R.color.primary_dark));
}
@Override
protected void initializePage() {
String privacy_policy = getString(R.string.services_privacy_policy);

View File

@ -70,12 +70,6 @@ public class FinishPage extends SetupPage {
public static class FinishFragment extends SetupPageFragment {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.primary));
}
@Override
protected void initializePage() {}

View File

@ -49,7 +49,8 @@ public class OtherSettingsPage extends SetupPage {
private static final String TAG = "OtherSettingsPage";
private static final String PRIVACY_POLICY_URI = "https://www.google.com/intl/en/policies/privacy/?fg=1";
private static final String PRIVACY_POLICY_URI =
"https://www.google.com/intl/en/policies/privacy/?fg=1";
public OtherSettingsPage(Context context, SetupDataCallbacks callbacks) {
super(context, callbacks);
@ -140,7 +141,6 @@ public class OtherSettingsPage extends SetupPage {
mContentResolver = getActivity().getContentResolver();
mBackupManager = IBackupManager.Stub.asInterface(
ServiceManager.getService(Context.BACKUP_SERVICE));
getActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.primary_dark));
}
@Override
@ -157,7 +157,8 @@ public class OtherSettingsPage extends SetupPage {
public void onClick(View textView) {
WebViewDialogFragment.newInstance()
.setUri(PRIVACY_POLICY_URI)
.show(getActivity().getFragmentManager(), WebViewDialogFragment.TAG);
.show(getActivity().getFragmentManager(),
WebViewDialogFragment.TAG);
}
};
ss.setSpan(clickableSpan,
@ -219,11 +220,13 @@ public class OtherSettingsPage extends SetupPage {
public void onStart() {
super.onStart();
// listen for Location Manager settings changes
Cursor settingsCursor = getActivity().getContentResolver().query(Settings.Secure.CONTENT_URI, null,
Cursor settingsCursor = getActivity().getContentResolver()
.query(Settings.Secure.CONTENT_URI, null,
"(" + Settings.System.NAME + "=?)",
new String[]{Settings.Secure.LOCATION_PROVIDERS_ALLOWED},
null);
mContentQueryMap = new ContentQueryMap(settingsCursor, Settings.System.NAME, true, null);
mContentQueryMap =
new ContentQueryMap(settingsCursor, Settings.System.NAME, true, null);
}
@Override

View File

@ -105,12 +105,6 @@ public class WelcomePage extends SetupPage {
}
};
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.primary));
}
@Override
protected void initializePage() {
mLanguagePicker = (LocalePicker) mRootView.findViewById(R.id.locale_list);

View File

@ -66,7 +66,6 @@ public abstract class SetupPageFragment extends Fragment {
}
initializePage();
mCallbacks.onPageLoaded(mPage);
getActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.status_bar));
}
@Override

View File

@ -19,9 +19,11 @@ package com.cyanogenmod.setupwizard.ui;
import android.animation.Animator;
import android.app.Activity;
import android.app.AppGlobals;
import android.app.WallpaperManager;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.UserHandle;
@ -45,6 +47,7 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
private static final String TAG = SetupWizardActivity.class.getSimpleName();
private View mRootView;
private View mButtonBar;
private Button mNextButton;
private Button mPrevButton;
private View mReveal;
@ -59,9 +62,12 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
setContentView(R.layout.setup_main);
getWindow().setWindowAnimations(android.R.anim.fade_in);
mRootView = findViewById(R.id.root);
mButtonBar = findViewById(R.id.button_bar);
((SetupWizardApp)getApplicationContext()).disableStatusBar();
mSetupData = (CMSetupWizardData)getLastNonConfigurationInstance();
if (mSetupData == null) {
@ -70,16 +76,19 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
mNextButton = (Button) findViewById(R.id.next_button);
mPrevButton = (Button) findViewById(R.id.prev_button);
mReveal = findViewById(R.id.reveal);
setupRevealImage();
mSetupData.registerListener(this);
mNextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
enableButtonBar(false);
mSetupData.onNextPage();
}
});
mPrevButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
enableButtonBar(false);
mSetupData.onPreviousPage();
}
});
@ -120,8 +129,8 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
@Override
protected void onResume() {
super.onResume();
updateSystemUI();
onPageTreeChanged();
enableButtonBar(true);
}
@Override
@ -168,8 +177,8 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
@Override
public void onPageLoaded(Page page) {
updateSystemUI();
updateButtonBar();
enableButtonBar(true);
}
@Override
@ -177,16 +186,9 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
updateButtonBar();
}
private void updateSystemUI() {
if (getResources().getConfiguration().orientation
== Configuration.ORIENTATION_LANDSCAPE &&
mSetupData.isFirstPage()) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE
| View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
} else {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}
private void enableButtonBar(boolean enabled) {
mNextButton.setEnabled(enabled);
mPrevButton.setEnabled(enabled);
}
private void updateButtonBar() {
@ -208,7 +210,7 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
}
final Resources resources = getResources();
if (mSetupData.isLastPage()) {
mRootView.setBackgroundColor(resources.getColor(R.color.primary));
mButtonBar.setBackgroundResource(R.color.primary);
mNextButton.setCompoundDrawablesWithIntrinsicBounds(null, null,
getDrawable(R.drawable.ic_chevron_right_wht), null);
mNextButton.setTextColor(resources.getColor(R.color.white));
@ -217,7 +219,7 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
null, null);
mPrevButton.setTextColor(resources.getColor(R.color.white));
} else {
mRootView.setBackgroundColor(resources.getColor(R.color.window_background));
mButtonBar.setBackgroundResource(R.color.button_bar_background);
mNextButton.setCompoundDrawablesWithIntrinsicBounds(null, null,
getDrawable(R.drawable.ic_chevron_right_dark), null);
mNextButton.setTextColor(resources.getColor(R.color.primary_text));
@ -246,13 +248,35 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
}
private void setupRevealImage() {
Thread t = new Thread() {
@Override
public void run() {
Point p = new Point();
getWindowManager().getDefaultDisplay().getRealSize(p);
final Drawable drawable = WallpaperManager.getInstance(SetupWizardActivity.this)
.getBuiltInDrawable(
p.x, p.y, false, 0, 0);
if (drawable != null) {
mHandler.post(new Runnable() {
@Override
public void run() {
mReveal.setBackground(drawable);
}
});
}
}
};
t.start();
}
private void animateOut() {
int cx = (mReveal.getLeft() + mReveal.getRight()) / 2;
int cy = (mReveal.getTop() + mReveal.getBottom()) / 2;
int finalRadius = Math.max(mReveal.getWidth(), mReveal.getHeight());
Animator anim =
ViewAnimationUtils.createCircularReveal(mReveal, cx, cy, 0, finalRadius);
anim.setDuration(800);
anim.setDuration(900);
anim.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {

View File

@ -0,0 +1,142 @@
/*
* Copyright 2014 Google Inc.
*
* 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.ui.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import com.cyanogenmod.setupwizard.R;
/**
* A layout that draws something in the insets passed to {@link #fitSystemWindows(android.graphics.Rect)}, i.e. the area above UI chrome
* (status and navigation bars, overlay action bars).
*/
public class ScrimInsetsFrameLayout extends FrameLayout {
private Drawable mInsetForeground;
private Rect mInsets;
private Rect mTempRect = new Rect();
private OnInsetsCallback mOnInsetsCallback;
public ScrimInsetsFrameLayout(Context context) {
super(context);
init(context, null, 0);
}
public ScrimInsetsFrameLayout(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs, 0);
}
public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context, attrs, defStyle);
}
private void init(Context context, AttributeSet attrs, int defStyle) {
final TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.ScrimInsetsView, defStyle, 0);
if (a == null) {
return;
}
mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insetForeground);
a.recycle();
setWillNotDraw(true);
}
@Override
protected boolean fitSystemWindows(Rect insets) {
mInsets = new Rect(insets);
setWillNotDraw(mInsetForeground == null);
ViewCompat.postInvalidateOnAnimation(this);
if (mOnInsetsCallback != null) {
mOnInsetsCallback.onInsetsChanged(insets);
}
return true; // consume insets
}
@Override
public void draw(Canvas canvas) {
super.draw(canvas);
int width = getWidth();
int height = getHeight();
if (mInsets != null && mInsetForeground != null) {
int sc = canvas.save();
canvas.translate(getScrollX(), getScrollY());
// Top
mTempRect.set(0, 0, width, mInsets.top);
mInsetForeground.setBounds(mTempRect);
mInsetForeground.draw(canvas);
// Bottom
mTempRect.set(0, height - mInsets.bottom, width, height);
mInsetForeground.setBounds(mTempRect);
mInsetForeground.draw(canvas);
// Left
mTempRect.set(0, mInsets.top, mInsets.left, height - mInsets.bottom);
mInsetForeground.setBounds(mTempRect);
mInsetForeground.draw(canvas);
// Right
mTempRect.set(width - mInsets.right, mInsets.top, width, height - mInsets.bottom);
mInsetForeground.setBounds(mTempRect);
mInsetForeground.draw(canvas);
canvas.restoreToCount(sc);
}
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (mInsetForeground != null) {
mInsetForeground.setCallback(this);
}
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
if (mInsetForeground != null) {
mInsetForeground.setCallback(null);
}
}
/**
* Allows the calling container to specify a callback for custom processing when insets change (i.e. when
* {@link #fitSystemWindows(android.graphics.Rect)} is called. This is useful for setting padding on UI elements based on
* UI chrome insets (e.g. a Google Map or a ListView). When using with ListView or GridView, remember to set
* clipToPadding to false.
*/
public void setOnInsetsCallback(OnInsetsCallback onInsetsCallback) {
mOnInsetsCallback = onInsetsCallback;
}
public static interface OnInsetsCallback {
public void onInsetsChanged(Rect insets);
}
}