Skip to content

Commit 8daee80

Browse files
Adam CohenAndroid (Google) Code Review
authored andcommitted
Merge "3D carousel initial stab -- paging outlines / alpha effects pending design" into jb-mr1-lockscreen-dev
2 parents a15eeac + 9ec871d commit 8daee80

File tree

11 files changed

+164
-80
lines changed

11 files changed

+164
-80
lines changed

core/res/res/layout-land/keyguard_host_view.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434
android:clipChildren="false">
3535

3636
<include layout="@layout/keyguard_widget_pager"
37-
android:layout_width="match_parent"
38-
android:layout_height="match_parent"
39-
androidprv:layout_centerWithinArea="0.55"
40-
androidprv:layout_childType="widget"
41-
androidprv:layout_maxWidth="480dp"
42-
androidprv:layout_maxHeight="480dp" />
43-
37+
android:id="@+id/app_widget_container"
38+
android:layout_width="match_parent"
39+
android:layout_height="match_parent"
40+
androidprv:layout_centerWithinArea="0.55"
41+
androidprv:layout_childType="widget"
42+
androidprv:layout_maxWidth="480dp"
43+
androidprv:layout_maxHeight="480dp" />
4444
<include layout="@layout/keyguard_multi_user_selector"/>
4545

4646
<View android:layout_width="match_parent"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
**
4+
** Copyright 2012, The Android Open Source Project
5+
**
6+
** Licensed under the Apache License, Version 2.0 (the "License")
7+
** you may not use this file except in compliance with the License.
8+
** You may obtain a copy of the License at
9+
**
10+
** http://www.apache.org/licenses/LICENSE-2.0
11+
**
12+
** Unless required by applicable law or agreed to in writing, software
13+
** distributed under the License is distributed on an "AS IS" BASIS,
14+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
** See the License for the specific language governing permissions and
16+
** limitations under the License.
17+
*/
18+
-->
19+
20+
<!-- This is the selector widget that allows the user to select an action. -->
21+
<com.android.internal.policy.impl.keyguard.KeyguardWidgetCarousel
22+
xmlns:androidprv="http://schemas.android.com/apk/res/android"
23+
xmlns:android="http://schemas.android.com/apk/res/android"
24+
android:paddingLeft="25dp"
25+
android:paddingRight="25dp"
26+
android:paddingTop="25dp"
27+
android:paddingBottom="25dp"
28+
android:clipChildren="false"
29+
android:clipToPadding="false"
30+
androidprv:pageSpacing="10dp">
31+
</com.android.internal.policy.impl.keyguard.KeyguardWidgetCarousel>

core/res/res/layout-port/keyguard_host_view.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@
3939
android:layout_width="match_parent"
4040
android:layout_height="match_parent">
4141
<include layout="@layout/keyguard_widget_pager"
42-
android:layout_width="match_parent"
43-
android:layout_height="match_parent"
44-
android:layout_gravity="center"/>
42+
android:id="@+id/app_widget_container"
43+
android:layout_width="match_parent"
44+
android:layout_height="match_parent"
45+
android:layout_gravity="center"/>
4546
</FrameLayout>
4647

4748
<View android:layout_width="match_parent"
File renamed without changes.

core/res/res/layout-sw600dp-port/keyguard_host_view.xml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@
3535
android:orientation="vertical">
3636

3737
<include layout="@layout/keyguard_widget_pager"
38-
android:layout_width="match_parent"
39-
android:layout_height="match_parent"
40-
androidprv:layout_centerWithinArea="0.55"
41-
androidprv:layout_childType="widget"
42-
androidprv:layout_maxWidth="480dp"
43-
androidprv:layout_maxHeight="480dp" />
38+
android:id="@+id/app_widget_container"
39+
android:layout_width="match_parent"
40+
android:layout_height="match_parent"
41+
androidprv:layout_centerWithinArea="0.55"
42+
androidprv:layout_childType="widget"
43+
androidprv:layout_maxWidth="480dp"
44+
androidprv:layout_maxHeight="480dp" />
4445

4546
<include layout="@layout/keyguard_multi_user_selector"/>
4647

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/*
4+
** Copyright 2012, The Android Open Source Project
5+
**
6+
** Licensed under the Apache License, Version 2.0 (the "License");
7+
** you may not use this file except in compliance with the License.
8+
** You may obtain a copy of the License at
9+
**
10+
** http://www.apache.org/licenses/LICENSE-2.0
11+
**
12+
** Unless required by applicable law or agreed to in writing, software
13+
** distributed under the License is distributed on an "AS IS" BASIS,
14+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
** See the License for the specific language governing permissions and
16+
** limitations under the License.
17+
*/
18+
-->
19+
<resources>
20+
<integer name="kg_carousel_angle">60</integer>
21+
</resources>

core/res/res/values/integers.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
-->
1919
<resources>
20+
<integer name="kg_carousel_angle">75</integer>
2021
<integer name="kg_security_flip_duration">75</integer>
2122
<integer name="kg_security_fade_duration">75</integer>
2223
</resources>

core/res/res/values/symbols.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,7 @@
13351335
<java-symbol type="integer" name="config_lidOpenRotation" />
13361336
<java-symbol type="integer" name="config_longPressOnHomeBehavior" />
13371337
<java-symbol type="integer" name="kg_security_flip_duration" />
1338+
<java-symbol type="integer" name="kg_carousel_angle" />
13381339
<java-symbol type="layout" name="global_actions_item" />
13391340
<java-symbol type="layout" name="global_actions_silent_mode" />
13401341
<java-symbol type="layout" name="keyguard_screen_glogin_unlock" />
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Copyright (C) 2012 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.android.internal.policy.impl.keyguard;
17+
18+
import android.content.Context;
19+
import android.util.AttributeSet;
20+
21+
import com.android.internal.R;
22+
23+
public class KeyguardWidgetCarousel extends KeyguardWidgetPager {
24+
25+
private float mAdjacentPagesAngle;
26+
private static float CAMERA_DISTANCE = 10000;
27+
28+
public KeyguardWidgetCarousel(Context context, AttributeSet attrs) {
29+
this(context, attrs, 0);
30+
}
31+
32+
public KeyguardWidgetCarousel(Context context) {
33+
this(context, null, 0);
34+
}
35+
36+
public KeyguardWidgetCarousel(Context context, AttributeSet attrs, int defStyle) {
37+
super(context, attrs, defStyle);
38+
mAdjacentPagesAngle = context.getResources().getInteger(R.integer.kg_carousel_angle);
39+
}
40+
41+
protected float getMaxScrollProgress() {
42+
return 1.5f;
43+
}
44+
45+
private void updatePageAlphaValues(int screenCenter) {
46+
boolean isInOverscroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;
47+
if (!isInOverscroll) {
48+
for (int i = 0; i < getChildCount(); i++) {
49+
KeyguardWidgetFrame child = getWidgetPageAt(i);
50+
if (child != null) {
51+
float scrollProgress = getScrollProgress(screenCenter, child, i);
52+
if (!isReordering(false)) {
53+
child.setBackgroundAlphaMultiplier(
54+
backgroundAlphaInterpolator(Math.abs(scrollProgress)));
55+
} else {
56+
child.setBackgroundAlphaMultiplier(1f);
57+
}
58+
}
59+
}
60+
}
61+
}
62+
63+
@Override
64+
protected void screenScrolled(int screenCenter) {
65+
updatePageAlphaValues(screenCenter);
66+
for (int i = 0; i < getChildCount(); i++) {
67+
KeyguardWidgetFrame v = getWidgetPageAt(i);
68+
if (v == mDragView) continue;
69+
if (v != null) {
70+
float scrollProgress = getScrollProgress(screenCenter, v, i);
71+
int width = v.getMeasuredWidth();
72+
float pivotX = (width / 2f) + scrollProgress * (width / 2f);
73+
float pivotY = v.getMeasuredHeight() / 2;
74+
float rotationY = - mAdjacentPagesAngle * scrollProgress;
75+
v.setCameraDistance(CAMERA_DISTANCE);
76+
v.setPivotX(pivotX);
77+
v.setPivotY(pivotY);
78+
v.setRotationY(rotationY);
79+
}
80+
}
81+
}
82+
}

policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,9 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
3737

3838
ZInterpolator mZInterpolator = new ZInterpolator(0.5f);
3939
private static float CAMERA_DISTANCE = 10000;
40-
private static float TRANSITION_SCALE_FACTOR = 0.74f;
41-
private static float TRANSITION_PIVOT = 0.65f;
4240
private static float TRANSITION_MAX_ROTATION = 30;
4341
private static final boolean PERFORM_OVERSCROLL_ROTATION = true;
44-
private AccelerateInterpolator mAlphaInterpolator = new AccelerateInterpolator(0.9f);
45-
private DecelerateInterpolator mLeftScreenAlphaInterpolator = new DecelerateInterpolator(4);
42+
4643
private KeyguardViewStateManager mViewStateManager;
4744
private LockPatternUtils mLockPatternUtils;
4845

@@ -56,7 +53,6 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
5653
private float mSidePagesAlpha = 1f;
5754

5855
private static final long CUSTOM_WIDGET_USER_ACTIVITY_TIMEOUT = 30000;
59-
private static final boolean CAFETERIA_TRAY = false;
6056

6157
private int mPage = 0;
6258
private Callbacks mCallbacks;
@@ -317,7 +313,7 @@ protected void overScroll(float amount) {
317313
}
318314

319315
float backgroundAlphaInterpolator(float r) {
320-
return r;
316+
return Math.min(1f, r);
321317
}
322318

323319
private void updatePageAlphaValues(int screenCenter) {
@@ -327,7 +323,6 @@ private void updatePageAlphaValues(int screenCenter) {
327323
KeyguardWidgetFrame child = getWidgetPageAt(i);
328324
if (child != null) {
329325
float scrollProgress = getScrollProgress(screenCenter, child, i);
330-
// TODO: Set content alpha
331326
if (!isReordering(false)) {
332327
child.setBackgroundAlphaMultiplier(
333328
backgroundAlphaInterpolator(Math.abs(scrollProgress)));
@@ -339,73 +334,37 @@ private void updatePageAlphaValues(int screenCenter) {
339334
}
340335
}
341336

342-
// In apps customize, we have a scrolling effect which emulates pulling cards off of a stack.
343337
@Override
344338
protected void screenScrolled(int screenCenter) {
345-
super.screenScrolled(screenCenter);
346339
updatePageAlphaValues(screenCenter);
347340
for (int i = 0; i < getChildCount(); i++) {
348341
KeyguardWidgetFrame v = getWidgetPageAt(i);
349342
if (v == mDragView) continue;
350343
if (v != null) {
351344
float scrollProgress = getScrollProgress(screenCenter, v, i);
352-
float interpolatedProgress =
353-
mZInterpolator.getInterpolation(Math.abs(Math.min(scrollProgress, 0)));
354345

355-
float scale = 1.0f;
356-
float translationX = 0;
357346
float alpha = 1.0f;
358347

359-
if (CAFETERIA_TRAY) {
360-
scale = (1 - interpolatedProgress) +
361-
interpolatedProgress * TRANSITION_SCALE_FACTOR;
362-
translationX = Math.min(0, scrollProgress) * v.getMeasuredWidth();
363-
364-
if (scrollProgress < 0) {
365-
alpha = scrollProgress < 0 ? mAlphaInterpolator.getInterpolation(
366-
1 - Math.abs(scrollProgress)) : 1.0f;
367-
} else {
368-
// On large screens we need to fade the page as it nears its leftmost position
369-
alpha = mLeftScreenAlphaInterpolator.getInterpolation(1 - scrollProgress);
370-
}
371-
}
372-
373348
v.setCameraDistance(mDensity * CAMERA_DISTANCE);
374-
int pageWidth = v.getMeasuredWidth();
375-
int pageHeight = v.getMeasuredHeight();
376349

377350
if (PERFORM_OVERSCROLL_ROTATION) {
378351
if (i == 0 && scrollProgress < 0) {
379-
// Overscroll to the left
380-
v.setPivotX(TRANSITION_PIVOT * pageWidth);
352+
// Over scroll to the left
381353
v.setRotationY(-TRANSITION_MAX_ROTATION * scrollProgress);
382354
v.setOverScrollAmount(Math.abs(scrollProgress), true);
383-
scale = 1.0f;
384355
alpha = 1.0f;
385356
// On the first page, we don't want the page to have any lateral motion
386-
translationX = 0;
387357
} else if (i == getChildCount() - 1 && scrollProgress > 0) {
388-
// Overscroll to the right
389-
v.setPivotX((1 - TRANSITION_PIVOT) * pageWidth);
358+
// Over scroll to the right
390359
v.setRotationY(-TRANSITION_MAX_ROTATION * scrollProgress);
391-
scale = 1.0f;
392360
alpha = 1.0f;
393361
v.setOverScrollAmount(Math.abs(scrollProgress), false);
394362
// On the last page, we don't want the page to have any lateral motion.
395-
translationX = 0;
396363
} else {
397-
v.setPivotY(pageHeight / 2.0f);
398-
v.setPivotX(pageWidth / 2.0f);
399364
v.setRotationY(0f);
400365
v.setOverScrollAmount(0, false);
401366
}
402367
}
403-
404-
if (CAFETERIA_TRAY) {
405-
v.setTranslationX(translationX);
406-
v.setScaleX(scale);
407-
v.setScaleY(scale);
408-
}
409368
v.setAlpha(alpha);
410369

411370
// If the view has 0 alpha, we set it to be invisible so as to prevent
@@ -418,7 +377,6 @@ protected void screenScrolled(int screenCenter) {
418377
}
419378
}
420379
}
421-
422380
@Override
423381
protected void onStartReordering() {
424382
super.onStartReordering();

0 commit comments

Comments
 (0)