am 40011d6f: am 8daee807: Merge "3D carousel initial stab -- paging outlines / alpha effects pending design" into jb-mr1-lockscreen-dev

* commit '40011d6fef363e4cdc9c90ba3139e9199801c786':
  3D carousel initial stab -- paging outlines / alpha effects pending design
This commit is contained in:
Adam Cohen
2012-10-29 14:23:12 -07:00
committed by Android Git Automerger
11 changed files with 164 additions and 80 deletions

View File

@@ -34,13 +34,13 @@
android:clipChildren="false">
<include layout="@layout/keyguard_widget_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
androidprv:layout_centerWithinArea="0.55"
androidprv:layout_childType="widget"
androidprv:layout_maxWidth="480dp"
androidprv:layout_maxHeight="480dp" />
android:id="@+id/app_widget_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
androidprv:layout_centerWithinArea="0.55"
androidprv:layout_childType="widget"
androidprv:layout_maxWidth="480dp"
androidprv:layout_maxHeight="480dp" />
<include layout="@layout/keyguard_multi_user_selector"/>
<View android:layout_width="match_parent"

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2012, 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.
*/
-->
<!-- This is the selector widget that allows the user to select an action. -->
<com.android.internal.policy.impl.keyguard.KeyguardWidgetCarousel
xmlns:androidprv="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:paddingTop="25dp"
android:paddingBottom="25dp"
android:clipChildren="false"
android:clipToPadding="false"
androidprv:pageSpacing="10dp">
</com.android.internal.policy.impl.keyguard.KeyguardWidgetCarousel>

View File

@@ -39,9 +39,10 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/keyguard_widget_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"/>
android:id="@+id/app_widget_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"/>
</FrameLayout>
<View android:layout_width="match_parent"

View File

@@ -35,12 +35,13 @@
android:orientation="vertical">
<include layout="@layout/keyguard_widget_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
androidprv:layout_centerWithinArea="0.55"
androidprv:layout_childType="widget"
androidprv:layout_maxWidth="480dp"
androidprv:layout_maxHeight="480dp" />
android:id="@+id/app_widget_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
androidprv:layout_centerWithinArea="0.55"
androidprv:layout_childType="widget"
androidprv:layout_maxWidth="480dp"
androidprv:layout_maxHeight="480dp" />
<include layout="@layout/keyguard_multi_user_selector"/>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2012, 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.
*/
-->
<resources>
<integer name="kg_carousel_angle">60</integer>
</resources>

View File

@@ -17,6 +17,7 @@
*/
-->
<resources>
<integer name="kg_carousel_angle">75</integer>
<integer name="kg_security_flip_duration">75</integer>
<integer name="kg_security_fade_duration">75</integer>
</resources>

View File

@@ -1335,6 +1335,7 @@
<java-symbol type="integer" name="config_lidOpenRotation" />
<java-symbol type="integer" name="config_longPressOnHomeBehavior" />
<java-symbol type="integer" name="kg_security_flip_duration" />
<java-symbol type="integer" name="kg_carousel_angle" />
<java-symbol type="layout" name="global_actions_item" />
<java-symbol type="layout" name="global_actions_silent_mode" />
<java-symbol type="layout" name="keyguard_screen_glogin_unlock" />

View File

@@ -0,0 +1,82 @@
/*
* Copyright (C) 2012 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.
*/
package com.android.internal.policy.impl.keyguard;
import android.content.Context;
import android.util.AttributeSet;
import com.android.internal.R;
public class KeyguardWidgetCarousel extends KeyguardWidgetPager {
private float mAdjacentPagesAngle;
private static float CAMERA_DISTANCE = 10000;
public KeyguardWidgetCarousel(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public KeyguardWidgetCarousel(Context context) {
this(context, null, 0);
}
public KeyguardWidgetCarousel(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mAdjacentPagesAngle = context.getResources().getInteger(R.integer.kg_carousel_angle);
}
protected float getMaxScrollProgress() {
return 1.5f;
}
private void updatePageAlphaValues(int screenCenter) {
boolean isInOverscroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;
if (!isInOverscroll) {
for (int i = 0; i < getChildCount(); i++) {
KeyguardWidgetFrame child = getWidgetPageAt(i);
if (child != null) {
float scrollProgress = getScrollProgress(screenCenter, child, i);
if (!isReordering(false)) {
child.setBackgroundAlphaMultiplier(
backgroundAlphaInterpolator(Math.abs(scrollProgress)));
} else {
child.setBackgroundAlphaMultiplier(1f);
}
}
}
}
}
@Override
protected void screenScrolled(int screenCenter) {
updatePageAlphaValues(screenCenter);
for (int i = 0; i < getChildCount(); i++) {
KeyguardWidgetFrame v = getWidgetPageAt(i);
if (v == mDragView) continue;
if (v != null) {
float scrollProgress = getScrollProgress(screenCenter, v, i);
int width = v.getMeasuredWidth();
float pivotX = (width / 2f) + scrollProgress * (width / 2f);
float pivotY = v.getMeasuredHeight() / 2;
float rotationY = - mAdjacentPagesAngle * scrollProgress;
v.setCameraDistance(CAMERA_DISTANCE);
v.setPivotX(pivotX);
v.setPivotY(pivotY);
v.setRotationY(rotationY);
}
}
}
}

View File

@@ -37,12 +37,9 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
ZInterpolator mZInterpolator = new ZInterpolator(0.5f);
private static float CAMERA_DISTANCE = 10000;
private static float TRANSITION_SCALE_FACTOR = 0.74f;
private static float TRANSITION_PIVOT = 0.65f;
private static float TRANSITION_MAX_ROTATION = 30;
private static final boolean PERFORM_OVERSCROLL_ROTATION = true;
private AccelerateInterpolator mAlphaInterpolator = new AccelerateInterpolator(0.9f);
private DecelerateInterpolator mLeftScreenAlphaInterpolator = new DecelerateInterpolator(4);
private KeyguardViewStateManager mViewStateManager;
private LockPatternUtils mLockPatternUtils;
@@ -56,7 +53,6 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
private float mSidePagesAlpha = 1f;
private static final long CUSTOM_WIDGET_USER_ACTIVITY_TIMEOUT = 30000;
private static final boolean CAFETERIA_TRAY = false;
private int mPage = 0;
private Callbacks mCallbacks;
@@ -317,7 +313,7 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
}
float backgroundAlphaInterpolator(float r) {
return r;
return Math.min(1f, r);
}
private void updatePageAlphaValues(int screenCenter) {
@@ -327,7 +323,6 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
KeyguardWidgetFrame child = getWidgetPageAt(i);
if (child != null) {
float scrollProgress = getScrollProgress(screenCenter, child, i);
// TODO: Set content alpha
if (!isReordering(false)) {
child.setBackgroundAlphaMultiplier(
backgroundAlphaInterpolator(Math.abs(scrollProgress)));
@@ -339,73 +334,37 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
}
}
// In apps customize, we have a scrolling effect which emulates pulling cards off of a stack.
@Override
protected void screenScrolled(int screenCenter) {
super.screenScrolled(screenCenter);
updatePageAlphaValues(screenCenter);
for (int i = 0; i < getChildCount(); i++) {
KeyguardWidgetFrame v = getWidgetPageAt(i);
if (v == mDragView) continue;
if (v != null) {
float scrollProgress = getScrollProgress(screenCenter, v, i);
float interpolatedProgress =
mZInterpolator.getInterpolation(Math.abs(Math.min(scrollProgress, 0)));
float scale = 1.0f;
float translationX = 0;
float alpha = 1.0f;
if (CAFETERIA_TRAY) {
scale = (1 - interpolatedProgress) +
interpolatedProgress * TRANSITION_SCALE_FACTOR;
translationX = Math.min(0, scrollProgress) * v.getMeasuredWidth();
if (scrollProgress < 0) {
alpha = scrollProgress < 0 ? mAlphaInterpolator.getInterpolation(
1 - Math.abs(scrollProgress)) : 1.0f;
} else {
// On large screens we need to fade the page as it nears its leftmost position
alpha = mLeftScreenAlphaInterpolator.getInterpolation(1 - scrollProgress);
}
}
v.setCameraDistance(mDensity * CAMERA_DISTANCE);
int pageWidth = v.getMeasuredWidth();
int pageHeight = v.getMeasuredHeight();
if (PERFORM_OVERSCROLL_ROTATION) {
if (i == 0 && scrollProgress < 0) {
// Overscroll to the left
v.setPivotX(TRANSITION_PIVOT * pageWidth);
// Over scroll to the left
v.setRotationY(-TRANSITION_MAX_ROTATION * scrollProgress);
v.setOverScrollAmount(Math.abs(scrollProgress), true);
scale = 1.0f;
alpha = 1.0f;
// On the first page, we don't want the page to have any lateral motion
translationX = 0;
} else if (i == getChildCount() - 1 && scrollProgress > 0) {
// Overscroll to the right
v.setPivotX((1 - TRANSITION_PIVOT) * pageWidth);
// Over scroll to the right
v.setRotationY(-TRANSITION_MAX_ROTATION * scrollProgress);
scale = 1.0f;
alpha = 1.0f;
v.setOverScrollAmount(Math.abs(scrollProgress), false);
// On the last page, we don't want the page to have any lateral motion.
translationX = 0;
} else {
v.setPivotY(pageHeight / 2.0f);
v.setPivotX(pageWidth / 2.0f);
v.setRotationY(0f);
v.setOverScrollAmount(0, false);
}
}
if (CAFETERIA_TRAY) {
v.setTranslationX(translationX);
v.setScaleX(scale);
v.setScaleY(scale);
}
v.setAlpha(alpha);
// If the view has 0 alpha, we set it to be invisible so as to prevent
@@ -418,7 +377,6 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
}
}
}
@Override
protected void onStartReordering() {
super.onStartReordering();

View File

@@ -696,22 +696,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
protected void screenScrolled(int screenCenter) {
if (isScrollingIndicatorEnabled()) {
updateScrollingIndicator();
}
boolean isInOverscroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;
if (mFadeInAdjacentScreens && !isInOverscroll) {
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
if (child != null && child != mDragView) {
float scrollProgress = getScrollProgress(screenCenter, child, i);
float alpha = 1 - Math.abs(scrollProgress);
child.setAlpha(alpha);
}
}
invalidate();
}
}
@Override
@@ -1164,6 +1148,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
}
protected float getMaxScrollProgress() {
return 1.0f;
}
protected float getScrollProgress(int screenCenter, View v, int page) {
final int halfScreenSize = getMinScaledMeasuredWidth() / 2;
@@ -1172,8 +1160,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
getRelativeChildOffset(page) + halfScreenSize);
float scrollProgress = delta / (totalDistance * 1.0f);
scrollProgress = Math.min(scrollProgress, 1.0f);
scrollProgress = Math.max(scrollProgress, -1.0f);
scrollProgress = Math.min(scrollProgress, getMaxScrollProgress());
scrollProgress = Math.max(scrollProgress, - getMaxScrollProgress());
return scrollProgress;
}