summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java1
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java9
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/FinishPage.java6
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/OtherSettingsPage.java13
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/WelcomePage.java6
-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
8 files changed, 190 insertions, 44 deletions
diff --git a/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java b/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java
index 3c8b5ad..3061c36 100644
--- a/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java
+++ b/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java
@@ -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;
diff --git a/src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java
index c8eb304..9dab3c0 100644
--- a/src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java
@@ -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;
@@ -211,13 +209,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);
String policySummary = getString(R.string.services_explanation, privacy_policy);
diff --git a/src/com/cyanogenmod/setupwizard/setup/FinishPage.java b/src/com/cyanogenmod/setupwizard/setup/FinishPage.java
index 5d33b8a..fa25bd1 100644
--- a/src/com/cyanogenmod/setupwizard/setup/FinishPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/FinishPage.java
@@ -71,12 +71,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() {}
@Override
diff --git a/src/com/cyanogenmod/setupwizard/setup/OtherSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/OtherSettingsPage.java
index ab5bce8..d6293e9 100644
--- a/src/com/cyanogenmod/setupwizard/setup/OtherSettingsPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/OtherSettingsPage.java
@@ -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
diff --git a/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java b/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java
index 66bff4d..e919267 100644
--- a/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java
@@ -106,12 +106,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);
loadLanguages();
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