Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 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 | |
| 17 | package com.android.systemui.statusbar.phone; |
| 18 | |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 19 | import android.animation.Animator; |
| 20 | import android.animation.AnimatorListenerAdapter; |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 21 | import android.animation.ObjectAnimator; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 22 | import android.animation.ValueAnimator; |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 23 | import android.content.Context; |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 24 | import android.content.res.Configuration; |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 25 | import android.util.AttributeSet; |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 26 | import android.view.MotionEvent; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 27 | import android.view.VelocityTracker; |
Daniel Sandler | 13522a2 | 2012-09-27 14:46:58 -0400 | [diff] [blame] | 28 | import android.view.View; |
Jorim Jaggi | 0d74eeb | 2014-05-09 22:05:24 +0200 | [diff] [blame] | 29 | import android.view.ViewGroup; |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 30 | import android.view.ViewTreeObserver; |
Casey Burkhardt | 23b0a4e | 2013-04-29 12:18:32 -0700 | [diff] [blame] | 31 | import android.view.accessibility.AccessibilityEvent; |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 32 | import android.view.animation.AnimationUtils; |
| 33 | import android.view.animation.Interpolator; |
Jorim Jaggi | 0d74eeb | 2014-05-09 22:05:24 +0200 | [diff] [blame] | 34 | import android.widget.LinearLayout; |
Daniel Sandler | 13522a2 | 2012-09-27 14:46:58 -0400 | [diff] [blame] | 35 | |
Chet Haase | 4d179dc | 2012-08-22 07:14:42 -0700 | [diff] [blame] | 36 | import com.android.systemui.R; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 37 | import com.android.systemui.statusbar.ExpandableView; |
Jorim Jaggi | 87cd5e7 | 2014-05-12 23:29:10 +0200 | [diff] [blame] | 38 | import com.android.systemui.statusbar.FlingAnimationUtils; |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 39 | import com.android.systemui.statusbar.GestureRecorder; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 40 | import com.android.systemui.statusbar.StatusBarState; |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 41 | import com.android.systemui.statusbar.stack.NotificationStackScrollLayout; |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 42 | import com.android.systemui.statusbar.stack.StackStateAnimator; |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 43 | |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 44 | import java.util.ArrayList; |
| 45 | |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 46 | public class NotificationPanelView extends PanelView implements |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 47 | ExpandableView.OnHeightChangedListener, ObservableScrollView.Listener, |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 48 | View.OnClickListener, NotificationStackScrollLayout.OnOverscrollTopChangedListener, |
| 49 | KeyguardPageSwipeHelper.Callback { |
Chet Haase | 4d179dc | 2012-08-22 07:14:42 -0700 | [diff] [blame] | 50 | |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 51 | private static final float LOCK_ICON_ACTIVE_SCALE = 1.2f; |
Selim Cinek | a02fe52 | 2014-05-30 17:01:21 +0200 | [diff] [blame] | 52 | |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 53 | private KeyguardPageSwipeHelper mPageSwiper; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 54 | private StatusBarHeaderView mHeader; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 55 | private View mQsContainer; |
John Spurlock | 3e04cc8 | 2014-05-30 12:34:03 -0400 | [diff] [blame] | 56 | private View mQsPanel; |
John Spurlock | 73203eb | 2014-04-15 16:14:46 -0400 | [diff] [blame] | 57 | private View mKeyguardStatusView; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 58 | private ObservableScrollView mScrollView; |
| 59 | private View mStackScrollerContainer; |
John Spurlock | 73203eb | 2014-04-15 16:14:46 -0400 | [diff] [blame] | 60 | |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 61 | private NotificationStackScrollLayout mNotificationStackScroller; |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 62 | private int mNotificationTopPadding; |
Jorim Jaggi | 98fb09c | 2014-05-01 22:40:56 +0200 | [diff] [blame] | 63 | private boolean mAnimateNextTopPaddingChange; |
Chet Haase | 4d179dc | 2012-08-22 07:14:42 -0700 | [diff] [blame] | 64 | |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 65 | private int mTrackingPointer; |
| 66 | private VelocityTracker mVelocityTracker; |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 67 | private boolean mQsTracking; |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 68 | |
| 69 | /** |
| 70 | * Whether we are currently handling a motion gesture in #onInterceptTouchEvent, but haven't |
| 71 | * intercepted yet. |
| 72 | */ |
| 73 | private boolean mIntercepting; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 74 | private boolean mQsExpanded; |
John Spurlock | bc3a5e9 | 2014-05-30 16:20:05 -0400 | [diff] [blame] | 75 | private boolean mQsFullyExpanded; |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 76 | private boolean mKeyguardShowing; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 77 | private float mInitialHeightOnTouch; |
| 78 | private float mInitialTouchX; |
| 79 | private float mInitialTouchY; |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 80 | private float mLastTouchX; |
| 81 | private float mLastTouchY; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 82 | private float mQsExpansionHeight; |
| 83 | private int mQsMinExpansionHeight; |
| 84 | private int mQsMaxExpansionHeight; |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 85 | private int mQsPeekHeight; |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 86 | private boolean mStackScrollerOverscrolling; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 87 | private boolean mQsExpansionEnabled = true; |
| 88 | private ValueAnimator mQsExpansionAnimator; |
Jorim Jaggi | 87cd5e7 | 2014-05-12 23:29:10 +0200 | [diff] [blame] | 89 | private FlingAnimationUtils mFlingAnimationUtils; |
Selim Cinek | 9dbbca8 | 2014-05-15 15:23:37 +0200 | [diff] [blame] | 90 | private int mStatusBarMinHeight; |
Jorim Jaggi | 457cc35 | 2014-06-02 22:47:42 +0200 | [diff] [blame] | 91 | private boolean mHeaderHidden; |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 92 | private boolean mUnlockIconActive; |
Jorim Jaggi | 457cc35 | 2014-06-02 22:47:42 +0200 | [diff] [blame] | 93 | private int mNotificationsHeaderCollideDistance; |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 94 | private int mUnlockMoveDistance; |
John Spurlock | 3e04cc8 | 2014-05-30 12:34:03 -0400 | [diff] [blame] | 95 | |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 96 | private Interpolator mFastOutSlowInInterpolator; |
Jorim Jaggi | 457cc35 | 2014-06-02 22:47:42 +0200 | [diff] [blame] | 97 | private Interpolator mFastOutLinearInterpolator; |
| 98 | private Interpolator mLinearOutSlowInInterpolator; |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 99 | private ObjectAnimator mClockAnimator; |
| 100 | private int mClockAnimationTarget = -1; |
Jorim Jaggi | 7d16bb1 | 2014-05-22 04:24:50 +0200 | [diff] [blame] | 101 | private int mTopPaddingAdjustment; |
| 102 | private KeyguardClockPositionAlgorithm mClockPositionAlgorithm = |
| 103 | new KeyguardClockPositionAlgorithm(); |
| 104 | private KeyguardClockPositionAlgorithm.Result mClockPositionResult = |
| 105 | new KeyguardClockPositionAlgorithm.Result(); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 106 | private boolean mIsSwipedHorizontally; |
| 107 | private boolean mIsExpanding; |
| 108 | private KeyguardBottomAreaView mKeyguardBottomArea; |
| 109 | private boolean mBlockTouches; |
| 110 | private ArrayList<View> mSwipeTranslationViews = new ArrayList<>(); |
Jorim Jaggi | 069cd03 | 2014-05-15 03:09:01 +0200 | [diff] [blame] | 111 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 112 | public NotificationPanelView(Context context, AttributeSet attrs) { |
| 113 | super(context, attrs); |
Daniel Sandler | 13522a2 | 2012-09-27 14:46:58 -0400 | [diff] [blame] | 114 | } |
Chet Haase | 4d179dc | 2012-08-22 07:14:42 -0700 | [diff] [blame] | 115 | |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 116 | public void setStatusBar(PhoneStatusBar bar) { |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 117 | if (mStatusBar != null) { |
| 118 | mStatusBar.setOnFlipRunnable(null); |
| 119 | } |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 120 | mStatusBar = bar; |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 121 | if (bar != null) { |
| 122 | mStatusBar.setOnFlipRunnable(new Runnable() { |
| 123 | @Override |
| 124 | public void run() { |
| 125 | requestPanelHeightUpdate(); |
| 126 | } |
| 127 | }); |
| 128 | } |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 129 | } |
| 130 | |
Daniel Sandler | 13522a2 | 2012-09-27 14:46:58 -0400 | [diff] [blame] | 131 | @Override |
| 132 | protected void onFinishInflate() { |
| 133 | super.onFinishInflate(); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 134 | mHeader = (StatusBarHeaderView) findViewById(R.id.header); |
| 135 | mHeader.getBackgroundView().setOnClickListener(this); |
Jorim Jaggi | 3d878be | 2014-05-10 03:22:32 +0200 | [diff] [blame] | 136 | mHeader.setOverlayParent(this); |
John Spurlock | 73203eb | 2014-04-15 16:14:46 -0400 | [diff] [blame] | 137 | mKeyguardStatusView = findViewById(R.id.keyguard_status_view); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 138 | mStackScrollerContainer = findViewById(R.id.notification_container_parent); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 139 | mQsContainer = findViewById(R.id.quick_settings_container); |
John Spurlock | 3e04cc8 | 2014-05-30 12:34:03 -0400 | [diff] [blame] | 140 | mQsPanel = findViewById(R.id.quick_settings_panel); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 141 | mScrollView = (ObservableScrollView) findViewById(R.id.scroll_view); |
| 142 | mScrollView.setListener(this); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 143 | mNotificationStackScroller = (NotificationStackScrollLayout) |
| 144 | findViewById(R.id.notification_stack_scroller); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 145 | mNotificationStackScroller.setOnHeightChangedListener(this); |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 146 | mNotificationStackScroller.setOverscrollTopChangedListener(this); |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 147 | mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(getContext(), |
| 148 | android.R.interpolator.fast_out_slow_in); |
Jorim Jaggi | 457cc35 | 2014-06-02 22:47:42 +0200 | [diff] [blame] | 149 | mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(getContext(), |
| 150 | android.R.interpolator.linear_out_slow_in); |
| 151 | mFastOutLinearInterpolator = AnimationUtils.loadInterpolator(getContext(), |
| 152 | android.R.interpolator.fast_out_linear_in); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 153 | mKeyguardBottomArea = (KeyguardBottomAreaView) findViewById(R.id.keyguard_bottom_area); |
| 154 | mSwipeTranslationViews.add(mNotificationStackScroller); |
Jorim Jaggi | a27b004 | 2014-06-14 03:58:56 +0000 | [diff] [blame] | 155 | mSwipeTranslationViews.add(mKeyguardStatusView); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 156 | mPageSwiper = new KeyguardPageSwipeHelper(this, getContext()); |
Jorim Jaggi | 069cd03 | 2014-05-15 03:09:01 +0200 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | @Override |
| 160 | protected void loadDimens() { |
| 161 | super.loadDimens(); |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 162 | mNotificationTopPadding = getResources().getDimensionPixelSize( |
| 163 | R.dimen.notifications_top_padding); |
Jorim Jaggi | 1d48069 | 2014-05-20 19:41:58 +0200 | [diff] [blame] | 164 | mFlingAnimationUtils = new FlingAnimationUtils(getContext(), 0.4f); |
Selim Cinek | 9dbbca8 | 2014-05-15 15:23:37 +0200 | [diff] [blame] | 165 | mStatusBarMinHeight = getResources().getDimensionPixelSize( |
| 166 | com.android.internal.R.dimen.status_bar_height); |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 167 | mQsPeekHeight = getResources().getDimensionPixelSize(R.dimen.qs_peek_height); |
Jorim Jaggi | 457cc35 | 2014-06-02 22:47:42 +0200 | [diff] [blame] | 168 | mNotificationsHeaderCollideDistance = |
| 169 | getResources().getDimensionPixelSize(R.dimen.header_notifications_collide_distance); |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 170 | mUnlockMoveDistance = getResources().getDimensionPixelOffset(R.dimen.unlock_move_distance); |
Jorim Jaggi | 7d16bb1 | 2014-05-22 04:24:50 +0200 | [diff] [blame] | 171 | mClockPositionAlgorithm.loadDimens(getResources()); |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | @Override |
| 175 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { |
| 176 | super.onLayout(changed, left, top, right, bottom); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 177 | |
| 178 | // Calculate quick setting heights. |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 179 | mQsMinExpansionHeight = mHeader.getCollapsedHeight() + mQsPeekHeight; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 180 | mQsMaxExpansionHeight = mHeader.getExpandedHeight() + mQsContainer.getHeight(); |
John Spurlock | 2684d5e | 2014-05-28 20:27:44 -0400 | [diff] [blame] | 181 | if (mQsExpanded) { |
John Spurlock | bc3a5e9 | 2014-05-30 16:20:05 -0400 | [diff] [blame] | 182 | if (mQsFullyExpanded) { |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 183 | mQsExpansionHeight = mQsMaxExpansionHeight; |
| 184 | requestScrollerTopPaddingUpdate(false /* animate */); |
John Spurlock | bc3a5e9 | 2014-05-30 16:20:05 -0400 | [diff] [blame] | 185 | } |
John Spurlock | 2684d5e | 2014-05-28 20:27:44 -0400 | [diff] [blame] | 186 | } else { |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 187 | if (!mStackScrollerOverscrolling) { |
| 188 | setQsExpansion(mQsMinExpansionHeight); |
| 189 | } |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 190 | positionClockAndNotifications(); |
| 191 | mNotificationStackScroller.setStackHeight(getExpandedHeight()); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 192 | } |
Jorim Jaggi | 98fb09c | 2014-05-01 22:40:56 +0200 | [diff] [blame] | 193 | } |
| 194 | |
Jorim Jaggi | 069cd03 | 2014-05-15 03:09:01 +0200 | [diff] [blame] | 195 | /** |
| 196 | * Positions the clock and notifications dynamically depending on how many notifications are |
| 197 | * showing. |
| 198 | */ |
| 199 | private void positionClockAndNotifications() { |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 200 | boolean animateClock = mNotificationStackScroller.isAddOrRemoveAnimationPending(); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 201 | int stackScrollerPadding; |
Jorim Jaggi | 069cd03 | 2014-05-15 03:09:01 +0200 | [diff] [blame] | 202 | if (mStatusBar.getBarState() != StatusBarState.KEYGUARD) { |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 203 | int bottom = mStackScrollerOverscrolling |
| 204 | ? mHeader.getCollapsedHeight() |
| 205 | : mHeader.getBottom(); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 206 | stackScrollerPadding = bottom + mQsPeekHeight |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 207 | + mNotificationTopPadding; |
Jorim Jaggi | 7d16bb1 | 2014-05-22 04:24:50 +0200 | [diff] [blame] | 208 | mTopPaddingAdjustment = 0; |
Jorim Jaggi | 069cd03 | 2014-05-15 03:09:01 +0200 | [diff] [blame] | 209 | } else { |
Jorim Jaggi | 7d16bb1 | 2014-05-22 04:24:50 +0200 | [diff] [blame] | 210 | mClockPositionAlgorithm.setup( |
| 211 | mStatusBar.getMaxKeyguardNotifications(), |
| 212 | getMaxPanelHeight(), |
| 213 | getExpandedHeight(), |
| 214 | mNotificationStackScroller.getNotGoneChildCount(), |
| 215 | getHeight(), |
| 216 | mKeyguardStatusView.getHeight()); |
| 217 | mClockPositionAlgorithm.run(mClockPositionResult); |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 218 | if (animateClock || mClockAnimator != null) { |
Jorim Jaggi | 7d16bb1 | 2014-05-22 04:24:50 +0200 | [diff] [blame] | 219 | startClockAnimation(mClockPositionResult.clockY); |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 220 | } else { |
Jorim Jaggi | 7d16bb1 | 2014-05-22 04:24:50 +0200 | [diff] [blame] | 221 | mKeyguardStatusView.setY(mClockPositionResult.clockY); |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 222 | } |
Jorim Jaggi | 7d16bb1 | 2014-05-22 04:24:50 +0200 | [diff] [blame] | 223 | applyClockAlpha(mClockPositionResult.clockAlpha); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 224 | stackScrollerPadding = mClockPositionResult.stackScrollerPadding; |
Jorim Jaggi | 7d16bb1 | 2014-05-22 04:24:50 +0200 | [diff] [blame] | 225 | mTopPaddingAdjustment = mClockPositionResult.stackScrollerPaddingAdjustment; |
Jorim Jaggi | 069cd03 | 2014-05-15 03:09:01 +0200 | [diff] [blame] | 226 | } |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 227 | mNotificationStackScroller.setIntrinsicPadding(stackScrollerPadding); |
| 228 | requestScrollerTopPaddingUpdate(animateClock); |
Jorim Jaggi | 069cd03 | 2014-05-15 03:09:01 +0200 | [diff] [blame] | 229 | } |
| 230 | |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 231 | private void startClockAnimation(int y) { |
| 232 | if (mClockAnimationTarget == y) { |
| 233 | return; |
| 234 | } |
| 235 | mClockAnimationTarget = y; |
| 236 | getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { |
| 237 | @Override |
| 238 | public boolean onPreDraw() { |
| 239 | getViewTreeObserver().removeOnPreDrawListener(this); |
| 240 | if (mClockAnimator != null) { |
| 241 | mClockAnimator.removeAllListeners(); |
| 242 | mClockAnimator.cancel(); |
| 243 | } |
Jorim Jaggi | a1b1c7a | 2014-06-03 16:29:05 +0200 | [diff] [blame] | 244 | mClockAnimator = ObjectAnimator |
| 245 | .ofFloat(mKeyguardStatusView, View.Y, mClockAnimationTarget); |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 246 | mClockAnimator.setInterpolator(mFastOutSlowInInterpolator); |
| 247 | mClockAnimator.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD); |
| 248 | mClockAnimator.addListener(new AnimatorListenerAdapter() { |
| 249 | @Override |
| 250 | public void onAnimationEnd(Animator animation) { |
| 251 | mClockAnimator = null; |
| 252 | mClockAnimationTarget = -1; |
| 253 | } |
| 254 | }); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 255 | mClockAnimator.start(); |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 256 | return true; |
| 257 | } |
| 258 | }); |
| 259 | } |
| 260 | |
Jorim Jaggi | 7d16bb1 | 2014-05-22 04:24:50 +0200 | [diff] [blame] | 261 | private void applyClockAlpha(float alpha) { |
| 262 | if (alpha != 1.0f) { |
| 263 | mKeyguardStatusView.setLayerType(LAYER_TYPE_HARDWARE, null); |
| 264 | } else { |
| 265 | mKeyguardStatusView.setLayerType(LAYER_TYPE_NONE, null); |
| 266 | } |
| 267 | mKeyguardStatusView.setAlpha(alpha); |
Jorim Jaggi | 069cd03 | 2014-05-15 03:09:01 +0200 | [diff] [blame] | 268 | } |
| 269 | |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 270 | public void animateToFullShade() { |
Jorim Jaggi | 98fb09c | 2014-05-01 22:40:56 +0200 | [diff] [blame] | 271 | mAnimateNextTopPaddingChange = true; |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 272 | mNotificationStackScroller.goToFullShade(); |
Jorim Jaggi | 98fb09c | 2014-05-01 22:40:56 +0200 | [diff] [blame] | 273 | requestLayout(); |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 274 | } |
| 275 | |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 276 | /** |
| 277 | * @return Whether Quick Settings are currently expanded. |
| 278 | */ |
| 279 | public boolean isQsExpanded() { |
| 280 | return mQsExpanded; |
| 281 | } |
| 282 | |
| 283 | public void setQsExpansionEnabled(boolean qsExpansionEnabled) { |
| 284 | mQsExpansionEnabled = qsExpansionEnabled; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 285 | } |
| 286 | |
Selim Cinek | 3c4635c | 2014-05-29 02:12:47 +0200 | [diff] [blame] | 287 | @Override |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 288 | public void resetViews() { |
| 289 | mBlockTouches = false; |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 290 | mUnlockIconActive = false; |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 291 | mPageSwiper.reset(); |
| 292 | closeQs(); |
| 293 | } |
| 294 | |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 295 | public void closeQs() { |
| 296 | cancelAnimation(); |
| 297 | setQsExpansion(mQsMinExpansionHeight); |
| 298 | } |
| 299 | |
| 300 | public void openQs() { |
| 301 | cancelAnimation(); |
| 302 | if (mQsExpansionEnabled) { |
| 303 | setQsExpansion(mQsMaxExpansionHeight); |
| 304 | } |
| 305 | } |
| 306 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 307 | @Override |
| 308 | public void fling(float vel, boolean always) { |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 309 | GestureRecorder gr = ((PhoneStatusBarView) mBar).mBar.getGestureRecorder(); |
| 310 | if (gr != null) { |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 311 | gr.tag("fling " + ((vel > 0) ? "open" : "closed"), "notifications,v=" + vel); |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 312 | } |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 313 | super.fling(vel, always); |
| 314 | } |
Chet Haase | 4d179dc | 2012-08-22 07:14:42 -0700 | [diff] [blame] | 315 | |
Casey Burkhardt | 23b0a4e | 2013-04-29 12:18:32 -0700 | [diff] [blame] | 316 | @Override |
| 317 | public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { |
| 318 | if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { |
| 319 | event.getText() |
| 320 | .add(getContext().getString(R.string.accessibility_desc_notification_shade)); |
| 321 | return true; |
| 322 | } |
| 323 | |
| 324 | return super.dispatchPopulateAccessibilityEvent(event); |
| 325 | } |
| 326 | |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 327 | @Override |
John Spurlock | 73203eb | 2014-04-15 16:14:46 -0400 | [diff] [blame] | 328 | public boolean onInterceptTouchEvent(MotionEvent event) { |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 329 | if (mBlockTouches) { |
| 330 | return false; |
| 331 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 332 | int pointerIndex = event.findPointerIndex(mTrackingPointer); |
| 333 | if (pointerIndex < 0) { |
| 334 | pointerIndex = 0; |
| 335 | mTrackingPointer = event.getPointerId(pointerIndex); |
John Spurlock | 73203eb | 2014-04-15 16:14:46 -0400 | [diff] [blame] | 336 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 337 | final float x = event.getX(pointerIndex); |
| 338 | final float y = event.getY(pointerIndex); |
| 339 | |
| 340 | switch (event.getActionMasked()) { |
| 341 | case MotionEvent.ACTION_DOWN: |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 342 | mIntercepting = true; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 343 | mInitialTouchY = y; |
| 344 | mInitialTouchX = x; |
| 345 | initVelocityTracker(); |
| 346 | trackMovement(event); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 347 | if (shouldQuickSettingsIntercept(mInitialTouchX, mInitialTouchY, 0)) { |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 348 | getParent().requestDisallowInterceptTouchEvent(true); |
| 349 | } |
| 350 | break; |
| 351 | case MotionEvent.ACTION_POINTER_UP: |
| 352 | final int upPointer = event.getPointerId(event.getActionIndex()); |
| 353 | if (mTrackingPointer == upPointer) { |
| 354 | // gesture is ongoing, find a new pointer to track |
| 355 | final int newIndex = event.getPointerId(0) != upPointer ? 0 : 1; |
| 356 | mTrackingPointer = event.getPointerId(newIndex); |
| 357 | mInitialTouchX = event.getX(newIndex); |
| 358 | mInitialTouchY = event.getY(newIndex); |
| 359 | } |
| 360 | break; |
| 361 | |
| 362 | case MotionEvent.ACTION_MOVE: |
| 363 | final float h = y - mInitialTouchY; |
| 364 | trackMovement(event); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 365 | if (mQsTracking) { |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 366 | |
| 367 | // Already tracking because onOverscrolled was called. We need to update here |
| 368 | // so we don't stop for a frame until the next touch event gets handled in |
| 369 | // onTouchEvent. |
| 370 | setQsExpansion(h + mInitialHeightOnTouch); |
| 371 | trackMovement(event); |
| 372 | mIntercepting = false; |
| 373 | return true; |
| 374 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 375 | if (Math.abs(h) > mTouchSlop && Math.abs(h) > Math.abs(x - mInitialTouchX) |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 376 | && shouldQuickSettingsIntercept(mInitialTouchX, mInitialTouchY, h)) { |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 377 | onQsExpansionStarted(); |
| 378 | mInitialHeightOnTouch = mQsExpansionHeight; |
| 379 | mInitialTouchY = y; |
| 380 | mInitialTouchX = x; |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 381 | mQsTracking = true; |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 382 | mIntercepting = false; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 383 | mNotificationStackScroller.removeLongPressCallback(); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 384 | return true; |
| 385 | } |
| 386 | break; |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 387 | |
| 388 | case MotionEvent.ACTION_CANCEL: |
| 389 | case MotionEvent.ACTION_UP: |
Jorim Jaggi | c9a52ab | 2014-05-12 23:46:19 +0200 | [diff] [blame] | 390 | trackMovement(event); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 391 | if (mQsTracking) { |
| 392 | flingQsWithCurrentVelocity(); |
| 393 | mQsTracking = false; |
Jorim Jaggi | c9a52ab | 2014-05-12 23:46:19 +0200 | [diff] [blame] | 394 | } |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 395 | mIntercepting = false; |
| 396 | break; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 397 | } |
| 398 | return !mQsExpanded && super.onInterceptTouchEvent(event); |
John Spurlock | 73203eb | 2014-04-15 16:14:46 -0400 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | @Override |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 402 | public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) { |
| 403 | |
Jorim Jaggi | ce50b81 | 2014-05-24 16:29:57 +0200 | [diff] [blame] | 404 | // Block request when interacting with the scroll view so we can still intercept the |
| 405 | // scrolling when QS is expanded. |
| 406 | if (mScrollView.isDispatchingTouchEvent()) { |
| 407 | return; |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 408 | } |
Jorim Jaggi | ce50b81 | 2014-05-24 16:29:57 +0200 | [diff] [blame] | 409 | super.requestDisallowInterceptTouchEvent(disallowIntercept); |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 410 | } |
| 411 | |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 412 | private void flingQsWithCurrentVelocity() { |
Jorim Jaggi | c9a52ab | 2014-05-12 23:46:19 +0200 | [diff] [blame] | 413 | float vel = getCurrentVelocity(); |
| 414 | |
| 415 | // TODO: Better logic whether we should expand or not. |
| 416 | flingSettings(vel, vel > 0); |
| 417 | } |
| 418 | |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 419 | @Override |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 420 | public boolean onTouchEvent(MotionEvent event) { |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 421 | if (mBlockTouches) { |
| 422 | return false; |
| 423 | } |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 424 | // TODO: Handle doublefinger swipe to notifications again. Look at history for a reference |
| 425 | // implementation. |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 426 | if ((!mIsExpanding || mHintAnimationRunning) |
| 427 | && !mQsExpanded |
| 428 | && mStatusBar.getBarState() != StatusBarState.SHADE) { |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 429 | mPageSwiper.onTouchEvent(event); |
| 430 | if (mPageSwiper.isSwipingInProgress()) { |
| 431 | return true; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 432 | } |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 433 | } |
| 434 | if (mQsTracking || mQsExpanded) { |
| 435 | return onQsTouch(event); |
John Spurlock | 73203eb | 2014-04-15 16:14:46 -0400 | [diff] [blame] | 436 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 437 | |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 438 | super.onTouchEvent(event); |
| 439 | return true; |
| 440 | } |
| 441 | |
| 442 | @Override |
| 443 | protected boolean hasConflictingGestures() { |
| 444 | return mStatusBar.getBarState() != StatusBarState.SHADE; |
| 445 | } |
| 446 | |
| 447 | private boolean onQsTouch(MotionEvent event) { |
| 448 | int pointerIndex = event.findPointerIndex(mTrackingPointer); |
| 449 | if (pointerIndex < 0) { |
| 450 | pointerIndex = 0; |
| 451 | mTrackingPointer = event.getPointerId(pointerIndex); |
| 452 | } |
| 453 | final float y = event.getY(pointerIndex); |
| 454 | final float x = event.getX(pointerIndex); |
| 455 | |
| 456 | switch (event.getActionMasked()) { |
| 457 | case MotionEvent.ACTION_DOWN: |
| 458 | mQsTracking = true; |
| 459 | mInitialTouchY = y; |
| 460 | mInitialTouchX = x; |
| 461 | onQsExpansionStarted(); |
| 462 | mInitialHeightOnTouch = mQsExpansionHeight; |
| 463 | initVelocityTracker(); |
| 464 | trackMovement(event); |
| 465 | break; |
| 466 | |
| 467 | case MotionEvent.ACTION_POINTER_UP: |
| 468 | final int upPointer = event.getPointerId(event.getActionIndex()); |
| 469 | if (mTrackingPointer == upPointer) { |
| 470 | // gesture is ongoing, find a new pointer to track |
| 471 | final int newIndex = event.getPointerId(0) != upPointer ? 0 : 1; |
| 472 | final float newY = event.getY(newIndex); |
| 473 | final float newX = event.getX(newIndex); |
| 474 | mTrackingPointer = event.getPointerId(newIndex); |
| 475 | mInitialHeightOnTouch = mQsExpansionHeight; |
| 476 | mInitialTouchY = newY; |
| 477 | mInitialTouchX = newX; |
| 478 | } |
| 479 | break; |
| 480 | |
| 481 | case MotionEvent.ACTION_MOVE: |
| 482 | final float h = y - mInitialTouchY; |
| 483 | setQsExpansion(h + mInitialHeightOnTouch); |
| 484 | trackMovement(event); |
| 485 | break; |
| 486 | |
| 487 | case MotionEvent.ACTION_UP: |
| 488 | case MotionEvent.ACTION_CANCEL: |
| 489 | mQsTracking = false; |
| 490 | mTrackingPointer = -1; |
| 491 | trackMovement(event); |
| 492 | flingQsWithCurrentVelocity(); |
| 493 | if (mVelocityTracker != null) { |
| 494 | mVelocityTracker.recycle(); |
| 495 | mVelocityTracker = null; |
| 496 | } |
| 497 | break; |
| 498 | } |
| 499 | return true; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 500 | } |
| 501 | |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 502 | @Override |
| 503 | public void onOverscrolled(int amount) { |
| 504 | if (mIntercepting) { |
| 505 | onQsExpansionStarted(amount); |
| 506 | mInitialHeightOnTouch = mQsExpansionHeight; |
| 507 | mInitialTouchY = mLastTouchY; |
| 508 | mInitialTouchX = mLastTouchX; |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 509 | mQsTracking = true; |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 510 | } |
| 511 | } |
| 512 | |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 513 | |
| 514 | @Override |
| 515 | public void onOverscrollTopChanged(float amount) { |
| 516 | cancelAnimation(); |
| 517 | float rounded = amount >= 1f ? amount : 0f; |
| 518 | mStackScrollerOverscrolling = rounded != 0f; |
| 519 | setQsExpansion(mQsMinExpansionHeight + rounded); |
| 520 | updateQsState(); |
| 521 | } |
| 522 | |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 523 | @Override |
| 524 | public void flingTopOverscroll(float velocity, boolean open) { |
| 525 | mStackScrollerOverscrolling = false; |
| 526 | setQsExpansion(mQsExpansionHeight); |
| 527 | flingSettings(velocity, open); |
| 528 | } |
| 529 | |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 530 | private void onQsExpansionStarted() { |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 531 | onQsExpansionStarted(0); |
| 532 | } |
| 533 | |
| 534 | private void onQsExpansionStarted(int overscrollAmount) { |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 535 | cancelAnimation(); |
| 536 | |
| 537 | // Reset scroll position and apply that position to the expanded height. |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 538 | float height = mQsExpansionHeight - mScrollView.getScrollY() - overscrollAmount; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 539 | mScrollView.scrollTo(0, 0); |
| 540 | setQsExpansion(height); |
| 541 | } |
| 542 | |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 543 | private void setQsExpanded(boolean expanded) { |
| 544 | boolean changed = mQsExpanded != expanded; |
| 545 | if (changed) { |
| 546 | mQsExpanded = expanded; |
| 547 | updateQsState(); |
| 548 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 549 | } |
| 550 | |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 551 | public void setKeyguardShowing(boolean keyguardShowing) { |
| 552 | mKeyguardShowing = keyguardShowing; |
| 553 | updateQsState(); |
| 554 | } |
| 555 | |
| 556 | private void updateQsState() { |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 557 | boolean expandVisually = mQsExpanded || mStackScrollerOverscrolling; |
| 558 | mHeader.setExpanded(expandVisually, mStackScrollerOverscrolling); |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 559 | mNotificationStackScroller.setEnabled(!mQsExpanded); |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 560 | mQsPanel.setVisibility(expandVisually ? View.VISIBLE : View.INVISIBLE); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 561 | mQsContainer.setVisibility(mKeyguardShowing && !expandVisually |
| 562 | ? View.INVISIBLE |
| 563 | : View.VISIBLE); |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 564 | mScrollView.setTouchEnabled(mQsExpanded); |
Selim Cinek | 5158d82 | 2014-06-04 13:20:41 +0200 | [diff] [blame] | 565 | mNotificationStackScroller.setTouchEnabled(!mQsExpanded); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | private void setQsExpansion(float height) { |
| 569 | height = Math.min(Math.max(height, mQsMinExpansionHeight), mQsMaxExpansionHeight); |
John Spurlock | bc3a5e9 | 2014-05-30 16:20:05 -0400 | [diff] [blame] | 570 | mQsFullyExpanded = height == mQsMaxExpansionHeight; |
Jorim Jaggi | 290600a | 2014-05-30 17:02:20 +0200 | [diff] [blame] | 571 | if (height > mQsMinExpansionHeight && !mQsExpanded && !mStackScrollerOverscrolling) { |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 572 | setQsExpanded(true); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 573 | } else if (height <= mQsMinExpansionHeight && mQsExpanded) { |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 574 | setQsExpanded(false); |
John Spurlock | 73203eb | 2014-04-15 16:14:46 -0400 | [diff] [blame] | 575 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 576 | mQsExpansionHeight = height; |
Jorim Jaggi | f62f2bb | 2014-05-25 22:28:41 +0200 | [diff] [blame] | 577 | mHeader.setExpansion(height - mQsPeekHeight); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 578 | setQsTranslation(height); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 579 | requestScrollerTopPaddingUpdate(false /* animate */); |
John Spurlock | d08f91f | 2014-05-23 11:00:34 -0400 | [diff] [blame] | 580 | mStatusBar.userActivity(); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | private void setQsTranslation(float height) { |
| 584 | mQsContainer.setY(height - mQsContainer.getHeight()); |
| 585 | } |
| 586 | |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 587 | |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 588 | private void requestScrollerTopPaddingUpdate(boolean animate) { |
| 589 | mNotificationStackScroller.updateTopPadding(mQsExpansionHeight, |
| 590 | mScrollView.getScrollY(), |
| 591 | mAnimateNextTopPaddingChange || animate); |
Selim Cinek | 758afb1 | 2014-06-04 18:46:12 +0200 | [diff] [blame] | 592 | mAnimateNextTopPaddingChange = false; |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | private void trackMovement(MotionEvent event) { |
| 596 | if (mVelocityTracker != null) mVelocityTracker.addMovement(event); |
Jorim Jaggi | fc1a824 | 2014-05-12 19:30:05 +0200 | [diff] [blame] | 597 | mLastTouchX = event.getX(); |
| 598 | mLastTouchY = event.getY(); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | private void initVelocityTracker() { |
| 602 | if (mVelocityTracker != null) { |
| 603 | mVelocityTracker.recycle(); |
| 604 | } |
| 605 | mVelocityTracker = VelocityTracker.obtain(); |
| 606 | } |
| 607 | |
| 608 | private float getCurrentVelocity() { |
| 609 | if (mVelocityTracker == null) { |
| 610 | return 0; |
| 611 | } |
| 612 | mVelocityTracker.computeCurrentVelocity(1000); |
| 613 | return mVelocityTracker.getYVelocity(); |
| 614 | } |
| 615 | |
| 616 | private void cancelAnimation() { |
| 617 | if (mQsExpansionAnimator != null) { |
| 618 | mQsExpansionAnimator.cancel(); |
| 619 | } |
| 620 | } |
| 621 | private void flingSettings(float vel, boolean expand) { |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 622 | float target = expand ? mQsMaxExpansionHeight : mQsMinExpansionHeight; |
Jorim Jaggi | 9cd731a | 2014-05-22 14:26:06 +0200 | [diff] [blame] | 623 | if (target == mQsExpansionHeight) { |
| 624 | return; |
| 625 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 626 | ValueAnimator animator = ValueAnimator.ofFloat(mQsExpansionHeight, target); |
Jorim Jaggi | 87cd5e7 | 2014-05-12 23:29:10 +0200 | [diff] [blame] | 627 | mFlingAnimationUtils.apply(animator, mQsExpansionHeight, target, vel); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 628 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { |
| 629 | @Override |
| 630 | public void onAnimationUpdate(ValueAnimator animation) { |
| 631 | setQsExpansion((Float) animation.getAnimatedValue()); |
| 632 | } |
| 633 | }); |
| 634 | animator.addListener(new AnimatorListenerAdapter() { |
| 635 | @Override |
| 636 | public void onAnimationEnd(Animator animation) { |
| 637 | mQsExpansionAnimator = null; |
| 638 | } |
| 639 | }); |
| 640 | animator.start(); |
| 641 | mQsExpansionAnimator = animator; |
| 642 | } |
| 643 | |
| 644 | /** |
| 645 | * @return Whether we should intercept a gesture to open Quick Settings. |
| 646 | */ |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 647 | private boolean shouldQuickSettingsIntercept(float x, float y, float yDiff) { |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 648 | if (!mQsExpansionEnabled) { |
| 649 | return false; |
| 650 | } |
Jorim Jaggi | bc5f496 | 2014-05-12 00:00:52 +0200 | [diff] [blame] | 651 | boolean onHeader = x >= mHeader.getLeft() && x <= mHeader.getRight() |
John Spurlock | 3e04cc8 | 2014-05-30 12:34:03 -0400 | [diff] [blame] | 652 | && y >= mHeader.getTop() && y <= mHeader.getBottom(); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 653 | if (mQsExpanded) { |
John Spurlock | 3e04cc8 | 2014-05-30 12:34:03 -0400 | [diff] [blame] | 654 | return onHeader || (mScrollView.isScrolledToBottom() && yDiff < 0); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 655 | } else { |
| 656 | return onHeader; |
| 657 | } |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 658 | } |
| 659 | |
| 660 | @Override |
Jorim Jaggi | 0d74eeb | 2014-05-09 22:05:24 +0200 | [diff] [blame] | 661 | public void setVisibility(int visibility) { |
| 662 | int oldVisibility = getVisibility(); |
| 663 | super.setVisibility(visibility); |
| 664 | if (visibility != oldVisibility) { |
| 665 | reparentStatusIcons(visibility == VISIBLE); |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | /** |
| 670 | * When the notification panel gets expanded, we need to move the status icons in the header |
| 671 | * card. |
| 672 | */ |
| 673 | private void reparentStatusIcons(boolean toHeader) { |
| 674 | if (mStatusBar == null) { |
| 675 | return; |
| 676 | } |
| 677 | LinearLayout systemIcons = mStatusBar.getSystemIcons(); |
| 678 | if (systemIcons.getParent() != null) { |
| 679 | ((ViewGroup) systemIcons.getParent()).removeView(systemIcons); |
| 680 | } |
| 681 | if (toHeader) { |
| 682 | mHeader.attachSystemIcons(systemIcons); |
| 683 | } else { |
Jorim Jaggi | 13c1b1f | 2014-05-11 21:55:00 +0200 | [diff] [blame] | 684 | mHeader.onSystemIconsDetached(); |
Jorim Jaggi | 0d74eeb | 2014-05-09 22:05:24 +0200 | [diff] [blame] | 685 | mStatusBar.reattachSystemIcons(); |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | @Override |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 690 | protected boolean isScrolledToBottom() { |
Selim Cinek | b688bf7 | 2014-06-16 16:36:51 -0700 | [diff] [blame^] | 691 | if (mStatusBar.getBarState() == StatusBarState.KEYGUARD) { |
| 692 | return true; |
| 693 | } |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 694 | if (!isInSettings()) { |
| 695 | return mNotificationStackScroller.isScrolledToBottom(); |
Chris Wren | 64161cc | 2012-12-17 16:49:30 -0500 | [diff] [blame] | 696 | } |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 697 | return super.isScrolledToBottom(); |
| 698 | } |
| 699 | |
| 700 | @Override |
| 701 | protected int getMaxPanelHeight() { |
Jorim Jaggi | 1d48069 | 2014-05-20 19:41:58 +0200 | [diff] [blame] | 702 | // TODO: Figure out transition for collapsing when QS is open, adjust height here. |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 703 | int emptyBottomMargin = mNotificationStackScroller.getEmptyBottomMargin(); |
Selim Cinek | aa402d5 | 2014-06-04 22:41:04 +0200 | [diff] [blame] | 704 | int maxHeight = mNotificationStackScroller.getHeight() - emptyBottomMargin |
| 705 | - mTopPaddingAdjustment; |
Jorim Jaggi | 1d48069 | 2014-05-20 19:41:58 +0200 | [diff] [blame] | 706 | maxHeight = Math.max(maxHeight, mStatusBarMinHeight); |
| 707 | return maxHeight; |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 708 | } |
| 709 | |
| 710 | private boolean isInSettings() { |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 711 | return mQsExpanded; |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 712 | } |
| 713 | |
| 714 | @Override |
| 715 | protected void onHeightUpdated(float expandedHeight) { |
Jorim Jaggi | 7d16bb1 | 2014-05-22 04:24:50 +0200 | [diff] [blame] | 716 | if (!mQsExpanded) { |
| 717 | positionClockAndNotifications(); |
| 718 | } |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 719 | mNotificationStackScroller.setStackHeight(expandedHeight); |
Jorim Jaggi | 457cc35 | 2014-06-02 22:47:42 +0200 | [diff] [blame] | 720 | updateKeyguardHeaderVisibility(); |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 721 | updateUnlockIcon(); |
| 722 | } |
| 723 | |
Jorim Jaggi | 47c85a3 | 2014-06-05 17:25:40 +0200 | [diff] [blame] | 724 | @Override |
| 725 | protected float getOverExpansionAmount() { |
| 726 | return mNotificationStackScroller.getCurrentOverScrollAmount(true /* top */); |
| 727 | } |
| 728 | |
| 729 | @Override |
| 730 | protected float getOverExpansionPixels() { |
| 731 | return mNotificationStackScroller.getCurrentOverScrolledPixels(true /* top */); |
| 732 | } |
| 733 | |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 734 | private void updateUnlockIcon() { |
| 735 | if (mStatusBar.getBarState() == StatusBarState.KEYGUARD |
| 736 | || mStatusBar.getBarState() == StatusBarState.SHADE_LOCKED) { |
| 737 | boolean active = getMaxPanelHeight() - getExpandedHeight() > mUnlockMoveDistance; |
| 738 | if (active && !mUnlockIconActive && mTracking) { |
| 739 | mKeyguardBottomArea.getLockIcon().animate() |
| 740 | .alpha(1f) |
| 741 | .scaleY(LOCK_ICON_ACTIVE_SCALE) |
| 742 | .scaleX(LOCK_ICON_ACTIVE_SCALE) |
| 743 | .setInterpolator(mFastOutLinearInterpolator) |
| 744 | .setDuration(150); |
| 745 | } else if (!active && mUnlockIconActive && mTracking) { |
| 746 | mKeyguardBottomArea.getLockIcon().animate() |
| 747 | .alpha(KeyguardPageSwipeHelper.SWIPE_RESTING_ALPHA_AMOUNT) |
| 748 | .scaleY(1f) |
| 749 | .scaleX(1f) |
| 750 | .setInterpolator(mFastOutLinearInterpolator) |
| 751 | .setDuration(150); |
| 752 | } |
| 753 | mUnlockIconActive = active; |
| 754 | } |
Jorim Jaggi | 457cc35 | 2014-06-02 22:47:42 +0200 | [diff] [blame] | 755 | } |
| 756 | |
| 757 | /** |
| 758 | * Hides the header when notifications are colliding with it. |
| 759 | */ |
| 760 | private void updateKeyguardHeaderVisibility() { |
| 761 | if (mStatusBar.getBarState() == StatusBarState.KEYGUARD |
| 762 | || mStatusBar.getBarState() == StatusBarState.SHADE_LOCKED) { |
Jorim Jaggi | a1b1c7a | 2014-06-03 16:29:05 +0200 | [diff] [blame] | 763 | boolean hidden; |
| 764 | if (mStatusBar.getBarState() == StatusBarState.KEYGUARD) { |
| 765 | |
| 766 | // When on Keyguard, we hide the header as soon as the top card of the notification |
| 767 | // stack scroller is close enough (collision distance) to the bottom of the header. |
| 768 | hidden = mNotificationStackScroller.getNotificationsTopY() |
| 769 | <= mHeader.getBottom() + mNotificationsHeaderCollideDistance; |
| 770 | } else { |
| 771 | |
| 772 | // In SHADE_LOCKED, the top card is already really close to the header. Hide it as |
| 773 | // soon as we start translating the stack. |
| 774 | hidden = mNotificationStackScroller.getTranslationY() < 0; |
| 775 | } |
| 776 | |
Jorim Jaggi | 457cc35 | 2014-06-02 22:47:42 +0200 | [diff] [blame] | 777 | if (hidden && !mHeaderHidden) { |
| 778 | mHeader.animate() |
| 779 | .alpha(0f) |
| 780 | .withLayer() |
| 781 | .translationY(-mHeader.getHeight()/2) |
| 782 | .setInterpolator(mFastOutLinearInterpolator) |
| 783 | .setDuration(200); |
| 784 | } else if (!hidden && mHeaderHidden) { |
| 785 | mHeader.animate() |
| 786 | .alpha(1f) |
| 787 | .withLayer() |
| 788 | .translationY(0) |
| 789 | .setInterpolator(mLinearOutSlowInInterpolator) |
| 790 | .setDuration(200); |
| 791 | } |
| 792 | mHeaderHidden = hidden; |
| 793 | } else { |
| 794 | mHeader.animate().cancel(); |
| 795 | mHeader.setAlpha(1f); |
| 796 | mHeader.setTranslationY(0f); |
| 797 | if (mHeader.getLayerType() != LAYER_TYPE_NONE) { |
| 798 | mHeader.setLayerType(LAYER_TYPE_NONE, null); |
| 799 | } |
| 800 | mHeaderHidden = false; |
| 801 | } |
| 802 | |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 803 | } |
| 804 | |
| 805 | @Override |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 806 | protected void onExpandingStarted() { |
| 807 | super.onExpandingStarted(); |
| 808 | mNotificationStackScroller.onExpansionStarted(); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 809 | mIsExpanding = true; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 810 | } |
| 811 | |
| 812 | @Override |
| 813 | protected void onExpandingFinished() { |
| 814 | super.onExpandingFinished(); |
| 815 | mNotificationStackScroller.onExpansionStopped(); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 816 | mIsExpanding = false; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 817 | } |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 818 | |
| 819 | @Override |
Jorim Jaggi | 47c85a3 | 2014-06-05 17:25:40 +0200 | [diff] [blame] | 820 | protected void setOverExpansion(float overExpansion, boolean isPixels) { |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 821 | if (mStatusBar.getBarState() != StatusBarState.KEYGUARD) { |
Jorim Jaggi | 47c85a3 | 2014-06-05 17:25:40 +0200 | [diff] [blame] | 822 | mNotificationStackScroller.setOnHeightChangedListener(null); |
| 823 | if (isPixels) { |
| 824 | mNotificationStackScroller.setOverScrolledPixels( |
| 825 | overExpansion, true /* onTop */, false /* animate */); |
| 826 | } else { |
| 827 | mNotificationStackScroller.setOverScrollAmount( |
| 828 | overExpansion, true /* onTop */, false /* animate */); |
| 829 | } |
| 830 | mNotificationStackScroller.setOnHeightChangedListener(this); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 831 | } |
Selim Cinek | 24120a5 | 2014-05-26 10:05:42 +0200 | [diff] [blame] | 832 | } |
| 833 | |
| 834 | @Override |
Jorim Jaggi | 282a615 | 2014-06-02 23:37:53 +0200 | [diff] [blame] | 835 | protected void onTrackingStarted() { |
| 836 | super.onTrackingStarted(); |
| 837 | if (mStatusBar.getBarState() == StatusBarState.KEYGUARD |
| 838 | || mStatusBar.getBarState() == StatusBarState.SHADE_LOCKED) { |
| 839 | mPageSwiper.animateHideLeftRightIcon(); |
| 840 | } |
| 841 | } |
| 842 | |
| 843 | @Override |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 844 | protected void onTrackingStopped(boolean expand) { |
| 845 | super.onTrackingStopped(expand); |
Jorim Jaggi | 47c85a3 | 2014-06-05 17:25:40 +0200 | [diff] [blame] | 846 | if (expand) { |
| 847 | mNotificationStackScroller.setOverScrolledPixels( |
| 848 | 0.0f, true /* onTop */, true /* animate */); |
| 849 | } |
Jorim Jaggi | 282a615 | 2014-06-02 23:37:53 +0200 | [diff] [blame] | 850 | if (expand && (mStatusBar.getBarState() == StatusBarState.KEYGUARD |
| 851 | || mStatusBar.getBarState() == StatusBarState.SHADE_LOCKED)) { |
| 852 | mPageSwiper.showAllIcons(true); |
| 853 | } |
Jorim Jaggi | 8dd95e0 | 2014-06-03 16:19:33 +0200 | [diff] [blame] | 854 | if (!expand && (mStatusBar.getBarState() == StatusBarState.KEYGUARD |
| 855 | || mStatusBar.getBarState() == StatusBarState.SHADE_LOCKED)) { |
| 856 | mKeyguardBottomArea.getLockIcon().animate() |
| 857 | .alpha(0f) |
| 858 | .scaleX(2f) |
| 859 | .scaleY(2f) |
| 860 | .setInterpolator(mFastOutLinearInterpolator) |
| 861 | .setDuration(100); |
| 862 | } |
Selim Cinek | 24120a5 | 2014-05-26 10:05:42 +0200 | [diff] [blame] | 863 | } |
| 864 | |
Selim Cinek | 24120a5 | 2014-05-26 10:05:42 +0200 | [diff] [blame] | 865 | @Override |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 866 | public void onHeightChanged(ExpandableView view) { |
| 867 | requestPanelHeightUpdate(); |
| 868 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 869 | |
| 870 | @Override |
| 871 | public void onScrollChanged() { |
| 872 | if (mQsExpanded) { |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 873 | requestScrollerTopPaddingUpdate(false /* animate */); |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 874 | } |
| 875 | } |
| 876 | |
| 877 | @Override |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 878 | protected void onConfigurationChanged(Configuration newConfig) { |
| 879 | super.onConfigurationChanged(newConfig); |
| 880 | mPageSwiper.onConfigurationChanged(); |
| 881 | } |
| 882 | |
| 883 | @Override |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 884 | public void onClick(View v) { |
| 885 | if (v == mHeader.getBackgroundView()) { |
| 886 | onQsExpansionStarted(); |
| 887 | if (mQsExpanded) { |
| 888 | flingSettings(0 /* vel */, false /* expand */); |
| 889 | } else if (mQsExpansionEnabled) { |
| 890 | flingSettings(0 /* vel */, true /* expand */); |
| 891 | } |
| 892 | } |
| 893 | } |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 894 | |
| 895 | @Override |
| 896 | public void onAnimationToSideStarted(boolean rightPage) { |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 897 | boolean start = getLayoutDirection() == LAYOUT_DIRECTION_RTL ? rightPage : !rightPage; |
| 898 | if (start) { |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 899 | mKeyguardBottomArea.launchPhone(); |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 900 | } else { |
| 901 | mKeyguardBottomArea.launchCamera(); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 902 | } |
| 903 | mBlockTouches = true; |
| 904 | } |
| 905 | |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 906 | @Override |
| 907 | protected void onEdgeClicked(boolean right) { |
| 908 | if ((right && getRightIcon().getVisibility() != View.VISIBLE) |
| 909 | || (!right && getLeftIcon().getVisibility() != View.VISIBLE)) { |
| 910 | return; |
| 911 | } |
| 912 | mHintAnimationRunning = true; |
| 913 | mPageSwiper.startHintAnimation(right, new Runnable() { |
| 914 | @Override |
| 915 | public void run() { |
| 916 | mHintAnimationRunning = false; |
| 917 | mStatusBar.onHintFinished(); |
| 918 | } |
| 919 | }); |
Jorim Jaggi | 93a2bb2 | 2014-06-02 19:57:28 +0200 | [diff] [blame] | 920 | startHighlightIconAnimation(right ? getRightIcon() : getLeftIcon()); |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 921 | boolean start = getLayoutDirection() == LAYOUT_DIRECTION_RTL ? right : !right; |
| 922 | if (start) { |
| 923 | mStatusBar.onPhoneHintStarted(); |
| 924 | } else { |
| 925 | mStatusBar.onCameraHintStarted(); |
| 926 | } |
| 927 | } |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 928 | |
| 929 | @Override |
Jorim Jaggi | 93a2bb2 | 2014-06-02 19:57:28 +0200 | [diff] [blame] | 930 | protected void startUnlockHintAnimation() { |
| 931 | super.startUnlockHintAnimation(); |
| 932 | startHighlightIconAnimation(getCenterIcon()); |
| 933 | } |
| 934 | |
| 935 | /** |
| 936 | * Starts the highlight (making it fully opaque) animation on an icon. |
| 937 | */ |
| 938 | private void startHighlightIconAnimation(final View icon) { |
| 939 | icon.animate() |
| 940 | .alpha(1.0f) |
| 941 | .setDuration(KeyguardPageSwipeHelper.HINT_PHASE1_DURATION) |
| 942 | .setInterpolator(mFastOutSlowInInterpolator) |
| 943 | .withEndAction(new Runnable() { |
| 944 | @Override |
| 945 | public void run() { |
| 946 | icon.animate().alpha(KeyguardPageSwipeHelper.SWIPE_RESTING_ALPHA_AMOUNT) |
| 947 | .setDuration(KeyguardPageSwipeHelper.HINT_PHASE1_DURATION) |
| 948 | .setInterpolator(mFastOutSlowInInterpolator); |
| 949 | } |
| 950 | }); |
| 951 | } |
| 952 | |
| 953 | @Override |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 954 | public float getPageWidth() { |
| 955 | return getWidth(); |
| 956 | } |
| 957 | |
| 958 | @Override |
| 959 | public ArrayList<View> getTranslationViews() { |
| 960 | return mSwipeTranslationViews; |
| 961 | } |
| 962 | |
| 963 | @Override |
| 964 | public View getLeftIcon() { |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 965 | return getLayoutDirection() == LAYOUT_DIRECTION_RTL |
| 966 | ? mKeyguardBottomArea.getCameraImageView() |
| 967 | : mKeyguardBottomArea.getPhoneImageView(); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 968 | } |
| 969 | |
| 970 | @Override |
| 971 | public View getCenterIcon() { |
| 972 | return mKeyguardBottomArea.getLockIcon(); |
| 973 | } |
| 974 | |
| 975 | @Override |
| 976 | public View getRightIcon() { |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 977 | return getLayoutDirection() == LAYOUT_DIRECTION_RTL |
| 978 | ? mKeyguardBottomArea.getPhoneImageView() |
| 979 | : mKeyguardBottomArea.getCameraImageView(); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 980 | } |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 981 | } |