summaryrefslogtreecommitdiffstats
path: root/src/com/cyanogenmod/setupwizard/ui
diff options
context:
space:
mode:
authorcretin45 <cretin45@gmail.com>2015-02-16 11:46:30 -0800
committercretin45 <cretin45@gmail.com>2015-02-16 16:52:06 -0800
commit9d72db9dbeae863c39253688b79525ac75f1306b (patch)
tree084bb6cd15347e90176ed0aff3479a74556a16cf /src/com/cyanogenmod/setupwizard/ui
parentaaec6f7e3e46081f256465fe549a56cde6332b78 (diff)
downloadpackages_apps_SetupWizard-9d72db9dbeae863c39253688b79525ac75f1306b.zip
packages_apps_SetupWizard-9d72db9dbeae863c39253688b79525ac75f1306b.tar.gz
packages_apps_SetupWizard-9d72db9dbeae863c39253688b79525ac75f1306b.tar.bz2
SetupWizard: Reveal the default wallpaper on oobe finish
Change-Id: I68a256853f256af3464da7eba57a307a810d80cd
Diffstat (limited to 'src/com/cyanogenmod/setupwizard/ui')
-rw-r--r--src/com/cyanogenmod/setupwizard/ui/SetupPageFragment.java1
-rw-r--r--src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java56
-rw-r--r--src/com/cyanogenmod/setupwizard/ui/widget/ScrimInsetsFrameLayout.java142
3 files changed, 182 insertions, 17 deletions
diff --git a/src/com/cyanogenmod/setupwizard/ui/SetupPageFragment.java b/src/com/cyanogenmod/setupwizard/ui/SetupPageFragment.java
index 61f1318..bffa377 100644
--- a/src/com/cyanogenmod/setupwizard/ui/SetupPageFragment.java
+++ b/src/com/cyanogenmod/setupwizard/ui/SetupPageFragment.java
@@ -66,7 +66,6 @@ public abstract class SetupPageFragment extends Fragment {
}
initializePage();
mCallbacks.onPageLoaded(mPage);
- getActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.status_bar));
}
@Override
diff --git a/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java b/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java
index f0ebc75..5fe15c2 100644
--- a/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java
+++ b/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java
@@ -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) {
diff --git a/src/com/cyanogenmod/setupwizard/ui/widget/ScrimInsetsFrameLayout.java b/src/com/cyanogenmod/setupwizard/ui/widget/ScrimInsetsFrameLayout.java
new file mode 100644
index 0000000..ea1e52b
--- /dev/null
+++ b/src/com/cyanogenmod/setupwizard/ui/widget/ScrimInsetsFrameLayout.java
@@ -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);
+ }
+} \ No newline at end of file