diff options
author | Jorim Jaggi <jjaggi@google.com> | 2014-11-26 12:02:13 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-11-26 12:02:13 +0000 |
commit | 2f47df83343e51214c792dc89874f0bccbeb4593 (patch) | |
tree | 0c188ae04988475c12ec6b1d7005ad69313d711d | |
parent | a7ffed86fce0a0cab8915bd6a727605959f08bb7 (diff) | |
parent | dccd3662da356ed7b0beedc09c8a58103723b463 (diff) | |
download | frameworks_base-2f47df83343e51214c792dc89874f0bccbeb4593.zip frameworks_base-2f47df83343e51214c792dc89874f0bccbeb4593.tar.gz frameworks_base-2f47df83343e51214c792dc89874f0bccbeb4593.tar.bz2 |
am dccd3662: am c1de25d8: Merge "Animate notifs depending on touch when exiting doze mode" into lmp-mr1-dev
* commit 'dccd3662da356ed7b0beedc09c8a58103723b463':
Animate notifs depending on touch when exiting doze mode
5 files changed, 102 insertions, 17 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 477ac74..54eb18c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -53,6 +53,7 @@ import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.PixelFormat; import android.graphics.Point; +import android.graphics.PointF; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; @@ -267,6 +268,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, private UnlockMethodCache mUnlockMethodCache; private DozeServiceHost mDozeServiceHost; private boolean mScreenOnComingFromTouch; + private PointF mScreenOnTouchLocation; int mPixelFormat; Object mQueueLock = new Object(); @@ -3711,7 +3713,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } boolean animate = !mDozing && mDozeScrimController.isPulsing(); mNotificationPanel.setDozing(mDozing, animate); - mStackScroller.setDark(mDozing, animate); + mStackScroller.setDark(mDozing, animate, mScreenOnTouchLocation); mScrimController.setDozing(mDozing); mDozeScrimController.setDozing(mDozing, animate); } @@ -3967,6 +3969,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, public void onScreenTurnedOff() { mScreenOnFromKeyguard = false; mScreenOnComingFromTouch = false; + mScreenOnTouchLocation = null; mStackScroller.setAnimationsEnabled(false); updateVisibleToUser(); } @@ -4089,14 +4092,13 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, return !mNotificationData.getActiveNotifications().isEmpty(); } - public void wakeUpIfDozing(long time, boolean fromTouch) { + public void wakeUpIfDozing(long time, MotionEvent event) { if (mDozing && mDozeScrimController.isPulsing()) { PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); pm.wakeUp(time); - if (fromTouch) { - mScreenOnComingFromTouch = true; - mNotificationPanel.setTouchDisabled(false); - } + mScreenOnComingFromTouch = true; + mScreenOnTouchLocation = new PointF(event.getX(), event.getY()); + mNotificationPanel.setTouchDisabled(false); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java index 47ec08d..a96f4e9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java @@ -173,7 +173,7 @@ public class StatusBarWindowView extends FrameLayout { intercept = mDragDownHelper.onInterceptTouchEvent(ev); // wake up on a touch down event, if dozing if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) { - mService.wakeUpIfDozing(ev.getEventTime(), true); + mService.wakeUpIfDozing(ev.getEventTime(), ev); } } if (!intercept) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/AnimationFilter.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/AnimationFilter.java index 3d4cda6..753a7f7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/AnimationFilter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/AnimationFilter.java @@ -34,6 +34,7 @@ public class AnimationFilter { boolean hasDelays; boolean hasGoToFullShadeEvent; boolean hasDarkEvent; + int darkAnimationOriginIndex; public AnimationFilter animateAlpha() { animateAlpha = true; @@ -94,14 +95,16 @@ public class AnimationFilter { reset(); int size = events.size(); for (int i = 0; i < size; i++) { + NotificationStackScrollLayout.AnimationEvent ev = events.get(i); combineFilter(events.get(i).filter); - if (events.get(i).animationType == + if (ev.animationType == NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_GO_TO_FULL_SHADE) { hasGoToFullShadeEvent = true; } - if (events.get(i).animationType == + if (ev.animationType == NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_DARK) { hasDarkEvent = true; + darkAnimationOriginIndex = ev.darkAnimationOriginIndex; } } } @@ -132,5 +135,7 @@ public class AnimationFilter { hasDelays = false; hasGoToFullShadeEvent = false; hasDarkEvent = false; + darkAnimationOriginIndex = + NotificationStackScrollLayout.AnimationEvent.DARK_ANIMATION_ORIGIN_INDEX_ABOVE; } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index 16ff3dc..2a393bf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -16,10 +16,12 @@ package com.android.systemui.statusbar.stack; +import android.annotation.Nullable; import android.content.Context; import android.content.res.Configuration; import android.graphics.Canvas; import android.graphics.Paint; +import android.graphics.PointF; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; @@ -149,6 +151,7 @@ public class NotificationStackScrollLayout extends ViewGroup private boolean mDimmedNeedsAnimation; private boolean mHideSensitiveNeedsAnimation; private boolean mDarkNeedsAnimation; + private int mDarkAnimationOriginIndex; private boolean mActivateNeedsAnimation; private boolean mGoToFullShadeNeedsAnimation; private boolean mIsExpanded = true; @@ -210,6 +213,7 @@ public class NotificationStackScrollLayout extends ViewGroup } }; private PhoneStatusBar mPhoneStatusBar; + private int[] mTempInt2 = new int[2]; public NotificationStackScrollLayout(Context context) { this(context, null); @@ -587,10 +591,38 @@ public class NotificationStackScrollLayout extends ViewGroup return getChildAtPosition(ev.getX(), ev.getY()); } + public ExpandableView getClosestChildAtRawPosition(float touchX, float touchY) { + getLocationOnScreen(mTempInt2); + float localTouchY = touchY - mTempInt2[1]; + + ExpandableView closestChild = null; + float minDist = Float.MAX_VALUE; + + // find the view closest to the location, accounting for GONE views + final int count = getChildCount(); + for (int childIdx = 0; childIdx < count; childIdx++) { + ExpandableView slidingChild = (ExpandableView) getChildAt(childIdx); + if (slidingChild.getVisibility() == GONE + || slidingChild instanceof StackScrollerDecorView + || slidingChild == mSpeedBumpView) { + continue; + } + float childTop = slidingChild.getTranslationY(); + float top = childTop + slidingChild.getClipTopAmount(); + float bottom = childTop + slidingChild.getActualHeight(); + + float dist = Math.min(Math.abs(top - localTouchY), Math.abs(bottom - localTouchY)); + if (dist < minDist) { + closestChild = slidingChild; + minDist = dist; + } + } + return closestChild; + } + public ExpandableView getChildAtRawPosition(float touchX, float touchY) { - int[] location = new int[2]; - getLocationOnScreen(location); - return getChildAtPosition(touchX - location[0], touchY - location[1]); + getLocationOnScreen(mTempInt2); + return getChildAtPosition(touchX - mTempInt2[0], touchY - mTempInt2[1]); } public ExpandableView getChildAtPosition(float touchX, float touchY) { @@ -1818,8 +1850,9 @@ public class NotificationStackScrollLayout extends ViewGroup private void generateDarkEvent() { if (mDarkNeedsAnimation) { - mAnimationEvents.add( - new AnimationEvent(null, AnimationEvent.ANIMATION_TYPE_DARK)); + AnimationEvent ev = new AnimationEvent(null, AnimationEvent.ANIMATION_TYPE_DARK); + ev.darkAnimationOriginIndex = mDarkAnimationOriginIndex; + mAnimationEvents.add(ev); } mDarkNeedsAnimation = false; } @@ -2151,7 +2184,7 @@ public class NotificationStackScrollLayout extends ViewGroup mEmptyShadeView.setInvisible(); mGoToFullShadeNeedsAnimation = true; mGoToFullShadeDelay = delay; - mNeedsAnimation = true; + mNeedsAnimation = true; requestChildrenUpdate(); } @@ -2182,15 +2215,46 @@ public class NotificationStackScrollLayout extends ViewGroup /** * See {@link AmbientState#setDark}. */ - public void setDark(boolean dark, boolean animate) { + public void setDark(boolean dark, boolean animate, @Nullable PointF touchWakeUpScreenLocation) { mAmbientState.setDark(dark); if (animate && mAnimationsEnabled) { mDarkNeedsAnimation = true; + mDarkAnimationOriginIndex = findDarkAnimationOriginIndex(touchWakeUpScreenLocation); mNeedsAnimation = true; } requestChildrenUpdate(); } + private int findDarkAnimationOriginIndex(@Nullable PointF screenLocation) { + if (screenLocation == null || screenLocation.y < mTopPadding + mTopPaddingOverflow) { + return AnimationEvent.DARK_ANIMATION_ORIGIN_INDEX_ABOVE; + } + if (screenLocation.y > getBottomMostNotificationBottom()) { + return AnimationEvent.DARK_ANIMATION_ORIGIN_INDEX_BELOW; + } + View child = getClosestChildAtRawPosition(screenLocation.x, screenLocation.y); + if (child != null) { + return getNotGoneIndex(child); + } else { + return AnimationEvent.DARK_ANIMATION_ORIGIN_INDEX_ABOVE; + } + } + + private int getNotGoneIndex(View child) { + int count = getChildCount(); + int notGoneIndex = 0; + for (int i = 0; i < count; i++) { + View v = getChildAt(i); + if (child == v) { + return notGoneIndex; + } + if (v.getVisibility() != View.GONE) { + notGoneIndex++; + } + } + return -1; + } + public void setDismissView(DismissView dismissView) { mDismissView = dismissView; addView(mDismissView); @@ -2556,12 +2620,16 @@ public class NotificationStackScrollLayout extends ViewGroup static final int ANIMATION_TYPE_VIEW_RESIZE = 12; static final int ANIMATION_TYPE_EVERYTHING = 13; + static final int DARK_ANIMATION_ORIGIN_INDEX_ABOVE = -1; + static final int DARK_ANIMATION_ORIGIN_INDEX_BELOW = -2; + final long eventStartTime; final View changingView; final int animationType; final AnimationFilter filter; final long length; View viewAfterChangingView; + int darkAnimationOriginIndex; AnimationEvent(View view, int type) { this(view, type, LENGTHS[type]); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java index 05077bf..b027787 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java @@ -315,7 +315,17 @@ public class StackStateAnimator { } private long calculateDelayDark(StackScrollState.ViewState viewState) { - return viewState.notGoneIndex * ANIMATION_DELAY_PER_ELEMENT_DARK; + int referenceIndex; + if (mAnimationFilter.darkAnimationOriginIndex == + NotificationStackScrollLayout.AnimationEvent.DARK_ANIMATION_ORIGIN_INDEX_ABOVE) { + referenceIndex = 0; + } else if (mAnimationFilter.darkAnimationOriginIndex == + NotificationStackScrollLayout.AnimationEvent.DARK_ANIMATION_ORIGIN_INDEX_BELOW) { + referenceIndex = mHostLayout.getNotGoneChildCount() - 1; + } else { + referenceIndex = mAnimationFilter.darkAnimationOriginIndex; + } + return Math.abs(referenceIndex - viewState.notGoneIndex) * ANIMATION_DELAY_PER_ELEMENT_DARK; } private long calculateDelayGoToFullShade(StackScrollState.ViewState viewState) { |