Skip to content

Commit 6d47e9f

Browse files
Winson ChungAndroid Git Automerger
authored andcommitted
am 48275d2: Adding bouncer animation on PagedView. (Bug 7459660)
* commit '48275d2de99ff2556031929c48f295d3f93447b6': Adding bouncer animation on PagedView. (Bug 7459660)
2 parents d811f27 + 48275d2 commit 6d47e9f

File tree

11 files changed

+103
-16
lines changed

11 files changed

+103
-16
lines changed

core/res/res/layout/keyguard_widget_remove_drop_target.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
android:paddingRight="40dp"
2525
android:drawableLeft="@drawable/kg_widget_delete_drop_target"
2626
android:drawablePadding="4dp"
27+
android:text="@string/kg_reordering_delete_drop_target_text"
2728
android:textColor="#FFF"
2829
android:textSize="13sp"
2930
android:shadowColor="#000"
3031
android:shadowDy="1.0"
3132
android:shadowRadius="1.0"
32-
android:visibility="gone" />
33+
android:visibility="gone" />

core/res/res/values-land/bools.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
<resources>
1818
<bool name="kg_enable_camera_default_widget">false</bool>
19+
<bool name="kg_top_align_page_shrink_on_bouncer_visible">true</bool>
1920
<bool name="kg_share_status_area">false</bool>
2021
<bool name="kg_sim_puk_account_full_screen">false</bool>
2122
</resources>

core/res/res/values-sw600dp/bools.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@
2222
<!-- No camera for you, tablet user -->
2323
<bool name="kg_enable_camera_default_widget">false</bool>
2424
<bool name="kg_center_small_widgets_vertically">true</bool>
25+
<bool name="kg_top_align_page_shrink_on_bouncer_visible">false</bool>
2526
</resources>

core/res/res/values/bools.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<resources>
1818
<bool name="kg_enable_camera_default_widget">true</bool>
1919
<bool name="kg_center_small_widgets_vertically">false</bool>
20+
<bool name="kg_top_align_page_shrink_on_bouncer_visible">true</bool>
2021
<bool name="action_bar_embed_tabs">true</bool>
2122
<bool name="action_bar_embed_tabs_pre_jb">false</bool>
2223
<bool name="split_action_bar_is_narrow">true</bool>

core/res/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3970,6 +3970,8 @@
39703970
<!-- Sequence of characters used to separate message strings in keyguard. Typically just em-dash
39713971
with spaces on either side. [CHAR LIMIT=3] -->
39723972
<string name="kg_text_message_separator" product="default">" \u2014 "</string>
3973+
<!-- The delete-widget drop target button text -->
3974+
<string name="kg_reordering_delete_drop_target_text">Remove</string>
39733975

39743976
<!-- Message shown in dialog when user is attempting to set the music volume above the
39753977
recommended maximum level for headphones -->

core/res/res/values/symbols.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,7 @@
12151215
<java-symbol type="bool" name="kg_enable_camera_default_widget" />
12161216
<java-symbol type="bool" name="kg_share_status_area" />
12171217
<java-symbol type="bool" name="kg_sim_puk_account_full_screen" />
1218+
<java-symbol type="bool" name="kg_top_align_page_shrink_on_bouncer_visible" />
12181219
<java-symbol type="bool" name="target_honeycomb_needs_options_menu" />
12191220
<java-symbol type="bool" name="kg_center_small_widgets_vertically" />
12201221
<java-symbol type="color" name="kg_multi_user_text_active" />

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,11 @@ protected void onFinishInflate() {
162162
mAppWidgetContainer.setViewStateManager(mViewStateManager);
163163
mAppWidgetContainer.setLockPatternUtils(mLockPatternUtils);
164164

165+
ChallengeLayout challenge = slider != null ? slider :
166+
(ChallengeLayout) findViewById(R.id.multi_pane_challenge);
167+
challenge.setOnBouncerStateChangedListener(mViewStateManager);
165168
mViewStateManager.setPagedView(mAppWidgetContainer);
166-
mViewStateManager.setChallengeLayout(slider != null ? slider :
167-
(ChallengeLayout) findViewById(R.id.multi_pane_challenge));
169+
mViewStateManager.setChallengeLayout(challenge);
168170
mSecurityViewContainer = (KeyguardSecurityViewFlipper) findViewById(R.id.view_flipper);
169171
mKeyguardSelectorView = (KeyguardSelectorView) findViewById(R.id.keyguard_selector_view);
170172
mViewStateManager.setSecurityViewContainer(mSecurityViewContainer);

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

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import android.os.Looper;
2020
import android.view.View;
2121

22-
public class KeyguardViewStateManager implements SlidingChallengeLayout.OnChallengeScrolledListener {
22+
public class KeyguardViewStateManager implements
23+
SlidingChallengeLayout.OnChallengeScrolledListener,
24+
ChallengeLayout.OnBouncerStateChangedListener {
2325

2426
private KeyguardWidgetPager mKeyguardWidgetPager;
2527
private ChallengeLayout mChallengeLayout;
@@ -196,6 +198,7 @@ private void mapPoint(View fromView, View toView, int pt[]) {
196198
@Override
197199
public void onScrollStateChanged(int scrollState) {
198200
if (mKeyguardWidgetPager == null || mChallengeLayout == null) return;
201+
199202
boolean challengeOverlapping = mChallengeLayout.isChallengeOverlapping();
200203

201204
if (scrollState == SlidingChallengeLayout.SCROLL_STATE_IDLE) {
@@ -226,15 +229,24 @@ public void onScrollStateChanged(int scrollState) {
226229
KeyguardWidgetFrame frame = mKeyguardWidgetPager.getWidgetPageAt(mPageListeningToSlider);
227230
if (frame == null) return;
228231

229-
frame.showFrame(this);
232+
// Skip showing the frame and shrinking the widget if we are
233+
if (!mChallengeLayout.isBouncing()) {
234+
frame.showFrame(this);
230235

231-
// As soon as the security begins sliding, the widget becomes small (if it wasn't
232-
// small to begin with).
233-
if (!frame.isSmall()) {
234-
// We need to fetch the final page, in case the pages are in motion.
235-
mPageListeningToSlider = mKeyguardWidgetPager.getNextPage();
236-
frame.shrinkWidget();
236+
// As soon as the security begins sliding, the widget becomes small (if it wasn't
237+
// small to begin with).
238+
if (!frame.isSmall()) {
239+
// We need to fetch the final page, in case the pages are in motion.
240+
mPageListeningToSlider = mKeyguardWidgetPager.getNextPage();
241+
frame.shrinkWidget();
242+
}
243+
} else {
244+
if (!frame.isSmall()) {
245+
// We need to fetch the final page, in case the pages are in motion.
246+
mPageListeningToSlider = mKeyguardWidgetPager.getNextPage();
247+
}
237248
}
249+
238250
// View is on the move. Pause the security view until it completes.
239251
mKeyguardSecurityContainer.onPause();
240252
}
@@ -279,4 +291,14 @@ public void setTransportState(int state) {
279291
public int getTransportState() {
280292
return mTransportState;
281293
}
294+
295+
// ChallengeLayout.OnBouncerStateChangedListener
296+
@Override
297+
public void onBouncerStateChanged(boolean bouncerActive) {
298+
if (bouncerActive) {
299+
mKeyguardWidgetPager.zoomOutToBouncer();
300+
} else {
301+
mKeyguardWidgetPager.zoomInFromBouncer();
302+
}
303+
}
282304
}

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

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import java.util.ArrayList;
4545

4646
public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwitchListener,
47-
OnLongClickListener {
47+
OnLongClickListener, ChallengeLayout.OnBouncerStateChangedListener {
4848

4949
ZInterpolator mZInterpolator = new ZInterpolator(0.5f);
5050
private static float CAMERA_DISTANCE = 10000;
@@ -73,6 +73,10 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
7373

7474
private int mWidgetToResetAfterFadeOut;
7575

76+
// Bouncer
77+
protected int BOUNCER_ZOOM_IN_OUT_DURATION = 250;
78+
private float BOUNCER_SCALE_FACTOR = 0.67f;
79+
7680
// Background worker thread: used here for persistence, also made available to widget frames
7781
private final HandlerThread mBackgroundWorkerThread;
7882
private final Handler mBackgroundWorkerHandler;
@@ -712,4 +716,46 @@ protected void setPageHoveringOverDeleteDropTarget(int viewIndex, boolean isHove
712716
KeyguardWidgetFrame child = getWidgetPageAt(viewIndex);
713717
child.setIsHoveringOverDeleteDropTarget(isHovering);
714718
}
719+
720+
// ChallengeLayout.OnBouncerStateChangedListener
721+
@Override
722+
public void onBouncerStateChanged(boolean bouncerActive) {
723+
if (bouncerActive) {
724+
zoomOutToBouncer();
725+
} else {
726+
zoomInFromBouncer();
727+
}
728+
}
729+
730+
// Zoom in after the bouncer is dismissed
731+
void zoomInFromBouncer() {
732+
if (mZoomInOutAnim != null && mZoomInOutAnim.isRunning()) {
733+
mZoomInOutAnim.cancel();
734+
}
735+
final View currentPage = getPageAt(getCurrentPage());
736+
if (currentPage.getScaleX() < 1f || currentPage.getScaleY() < 1f) {
737+
mZoomInOutAnim = new AnimatorSet();
738+
mZoomInOutAnim.setDuration(BOUNCER_ZOOM_IN_OUT_DURATION);
739+
mZoomInOutAnim.playTogether(
740+
ObjectAnimator.ofFloat(currentPage, "scaleX", 1f),
741+
ObjectAnimator.ofFloat(currentPage , "scaleY", 1f));
742+
mZoomInOutAnim.start();
743+
}
744+
}
745+
746+
// Zoom out after the bouncer is initiated
747+
void zoomOutToBouncer() {
748+
if (mZoomInOutAnim != null && mZoomInOutAnim.isRunning()) {
749+
mZoomInOutAnim.cancel();
750+
}
751+
View currentPage = getPageAt(getCurrentPage());
752+
if (!(currentPage.getScaleX() < 1f || currentPage.getScaleY() < 1f)) {
753+
mZoomInOutAnim = new AnimatorSet();
754+
mZoomInOutAnim.setDuration(BOUNCER_ZOOM_IN_OUT_DURATION);
755+
mZoomInOutAnim.playTogether(
756+
ObjectAnimator.ofFloat(currentPage, "scaleX", BOUNCER_SCALE_FACTOR),
757+
ObjectAnimator.ofFloat(currentPage, "scaleY", BOUNCER_SCALE_FACTOR));
758+
mZoomInOutAnim.start();
759+
}
760+
}
715761
}

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import android.animation.ValueAnimator;
2525
import android.animation.ValueAnimator.AnimatorUpdateListener;
2626
import android.content.Context;
27+
import android.content.res.Resources;
2728
import android.content.res.TypedArray;
2829
import android.graphics.Canvas;
2930
import android.graphics.Matrix;
@@ -209,7 +210,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
209210
private long REORDERING_DELETE_DROP_TARGET_FADE_DURATION = 150;
210211
private float mMinScale = 1f;
211212
protected View mDragView;
212-
private AnimatorSet mZoomInOutAnim;
213+
protected AnimatorSet mZoomInOutAnim;
213214
private Runnable mSidePageHoverRunnable;
214215
private int mSidePageHoverIndex = -1;
215216
// This variable's scope is only for the duration of startReordering() and endReordering()
@@ -246,6 +247,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
246247
// Drop to delete
247248
private View mDeleteDropTarget;
248249

250+
// Bouncer
251+
private boolean mTopAlignPageWhenShrinkingForBouncer = false;
252+
249253
public interface PageSwitchListener {
250254
void onPageSwitching(View newPage, int newPageIndex);
251255
void onPageSwitched(View newPage, int newPageIndex);
@@ -270,8 +274,10 @@ public PagedView(Context context, AttributeSet attrs, int defStyle) {
270274
a.getDimensionPixelSize(R.styleable.PagedView_scrollIndicatorPaddingRight, 0);
271275
a.recycle();
272276

273-
mEdgeSwipeRegionSize =
274-
getResources().getDimensionPixelSize(R.dimen.kg_edge_swipe_region_size);
277+
Resources r = getResources();
278+
mEdgeSwipeRegionSize = r.getDimensionPixelSize(R.dimen.kg_edge_swipe_region_size);
279+
mTopAlignPageWhenShrinkingForBouncer =
280+
r.getBoolean(R.bool.kg_top_align_page_shrink_on_bouncer_visible);
275281

276282
setHapticFeedbackEnabled(false);
277283
init();
@@ -645,6 +651,10 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
645651
MeasureSpec.makeMeasureSpec(heightSize - verticalPadding, childHeightMode);
646652

647653
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
654+
if (mTopAlignPageWhenShrinkingForBouncer) {
655+
child.setPivotX(child.getWidth() / 2);
656+
child.setPivotY(0f);
657+
}
648658
}
649659
setMeasuredDimension(scaledWidthSize, scaledHeightSize);
650660

0 commit comments

Comments
 (0)