Jim Miller | b5f3b70 | 2012-10-21 19:09:23 -0700 | [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 | */ |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 16 | package com.android.keyguard; |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 17 | |
Adam Cohen | 6fb841f | 2012-10-24 13:15:38 -0700 | [diff] [blame] | 18 | import android.os.Handler; |
| 19 | import android.os.Looper; |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 20 | import android.view.View; |
| 21 | |
Winson Chung | 48275d2 | 2012-11-05 10:56:31 -0800 | [diff] [blame] | 22 | public class KeyguardViewStateManager implements |
| 23 | SlidingChallengeLayout.OnChallengeScrolledListener, |
| 24 | ChallengeLayout.OnBouncerStateChangedListener { |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 25 | |
Adam Cohen | 7f6bb6e | 2012-11-04 14:00:05 -0800 | [diff] [blame] | 26 | private KeyguardWidgetPager mKeyguardWidgetPager; |
Jim Miller | 19a5267 | 2012-10-23 19:52:04 -0700 | [diff] [blame] | 27 | private ChallengeLayout mChallengeLayout; |
Adam Cohen | d6f8960 | 2012-11-06 11:46:25 -0800 | [diff] [blame] | 28 | private KeyguardHostView mKeyguardHostView; |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 29 | private int[] mTmpPoint = new int[2]; |
Adam Cohen | 8a7785c | 2012-10-29 22:01:33 -0700 | [diff] [blame] | 30 | private int[] mTmpLoc = new int[2]; |
| 31 | |
| 32 | private KeyguardSecurityView mKeyguardSecurityContainer; |
Adam Cohen | 6fb841f | 2012-10-24 13:15:38 -0700 | [diff] [blame] | 33 | private static final int SCREEN_ON_HINT_DURATION = 1000; |
Adam Cohen | 47c6cfa | 2012-10-27 18:29:52 -0700 | [diff] [blame] | 34 | private static final int SCREEN_ON_RING_HINT_DELAY = 300; |
Adam Cohen | 6fb841f | 2012-10-24 13:15:38 -0700 | [diff] [blame] | 35 | Handler mMainQueue = new Handler(Looper.myLooper()); |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 36 | |
Adam Cohen | e364313 | 2012-10-28 18:29:17 -0700 | [diff] [blame] | 37 | int mLastScrollState = SlidingChallengeLayout.SCROLL_STATE_IDLE; |
| 38 | |
| 39 | // Paged view state |
| 40 | private int mPageListeningToSlider = -1; |
| 41 | private int mCurrentPage = -1; |
Adam Cohen | 8caabad | 2012-11-04 17:23:25 -0800 | [diff] [blame] | 42 | private int mPageIndexOnPageBeginMoving = -1; |
Adam Cohen | e364313 | 2012-10-28 18:29:17 -0700 | [diff] [blame] | 43 | |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 44 | int mChallengeTop = 0; |
| 45 | |
Adam Cohen | d6f8960 | 2012-11-06 11:46:25 -0800 | [diff] [blame] | 46 | public KeyguardViewStateManager(KeyguardHostView hostView) { |
| 47 | mKeyguardHostView = hostView; |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | public void setPagedView(KeyguardWidgetPager pagedView) { |
Adam Cohen | 7f6bb6e | 2012-11-04 14:00:05 -0800 | [diff] [blame] | 51 | mKeyguardWidgetPager = pagedView; |
| 52 | updateEdgeSwiping(); |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Jim Miller | 19a5267 | 2012-10-23 19:52:04 -0700 | [diff] [blame] | 55 | public void setChallengeLayout(ChallengeLayout layout) { |
| 56 | mChallengeLayout = layout; |
Adam Cohen | 7f6bb6e | 2012-11-04 14:00:05 -0800 | [diff] [blame] | 57 | updateEdgeSwiping(); |
| 58 | } |
| 59 | |
| 60 | private void updateEdgeSwiping() { |
| 61 | if (mChallengeLayout != null && mKeyguardWidgetPager != null) { |
| 62 | if (mChallengeLayout.isChallengeOverlapping()) { |
| 63 | mKeyguardWidgetPager.setOnlyAllowEdgeSwipes(true); |
| 64 | } else { |
| 65 | mKeyguardWidgetPager.setOnlyAllowEdgeSwipes(false); |
| 66 | } |
| 67 | } |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Winson Chung | 9dc9923 | 2012-10-29 17:43:18 -0700 | [diff] [blame] | 70 | public boolean isChallengeShowing() { |
| 71 | if (mChallengeLayout != null) { |
| 72 | return mChallengeLayout.isChallengeShowing(); |
| 73 | } |
| 74 | return false; |
| 75 | } |
| 76 | |
Winson Chung | 70aa528 | 2012-10-30 10:56:37 -0700 | [diff] [blame] | 77 | public boolean isChallengeOverlapping() { |
| 78 | if (mChallengeLayout != null) { |
| 79 | return mChallengeLayout.isChallengeOverlapping(); |
| 80 | } |
| 81 | return false; |
| 82 | } |
| 83 | |
Adam Cohen | 6fb841f | 2012-10-24 13:15:38 -0700 | [diff] [blame] | 84 | public void setSecurityViewContainer(KeyguardSecurityView container) { |
| 85 | mKeyguardSecurityContainer = container; |
| 86 | } |
| 87 | |
Jim Miller | b5f3b70 | 2012-10-21 19:09:23 -0700 | [diff] [blame] | 88 | public void showBouncer(boolean show) { |
Jim Miller | 19a5267 | 2012-10-23 19:52:04 -0700 | [diff] [blame] | 89 | mChallengeLayout.showBouncer(); |
Jim Miller | b5f3b70 | 2012-10-21 19:09:23 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Chris Wren | c0ae9e6 | 2012-11-05 13:16:31 -0500 | [diff] [blame] | 92 | public boolean isBouncing() { |
| 93 | return mChallengeLayout.isBouncing(); |
| 94 | } |
| 95 | |
Adam Cohen | 70009e4 | 2012-10-30 16:48:22 -0700 | [diff] [blame] | 96 | public void fadeOutSecurity(int duration) { |
| 97 | ((View) mKeyguardSecurityContainer).animate().alpha(0).setDuration(duration); |
| 98 | } |
| 99 | |
| 100 | public void fadeInSecurity(int duration) { |
| 101 | ((View) mKeyguardSecurityContainer).animate().alpha(1f).setDuration(duration); |
| 102 | } |
| 103 | |
Adam Cohen | 8caabad | 2012-11-04 17:23:25 -0800 | [diff] [blame] | 104 | public void onPageBeginMoving() { |
| 105 | if (mChallengeLayout.isChallengeOverlapping() && |
| 106 | mChallengeLayout instanceof SlidingChallengeLayout) { |
| 107 | SlidingChallengeLayout scl = (SlidingChallengeLayout) mChallengeLayout; |
| 108 | scl.fadeOutChallenge(); |
| 109 | mPageIndexOnPageBeginMoving = mKeyguardWidgetPager.getCurrentPage(); |
| 110 | } |
Michael Jurka | 1413889 | 2012-11-07 13:45:53 -0800 | [diff] [blame] | 111 | // We use mAppWidgetToShow to show a particular widget after you add it-- |
| 112 | // once the user swipes a page we clear that behavior |
| 113 | if (mKeyguardHostView != null) { |
| 114 | mKeyguardHostView.clearAppWidgetToShow(); |
Jim Miller | 4eeb4f6 | 2012-11-08 00:04:29 -0800 | [diff] [blame] | 115 | mKeyguardHostView.setOnDismissAction(null); |
Michael Jurka | 1413889 | 2012-11-07 13:45:53 -0800 | [diff] [blame] | 116 | } |
Adam Cohen | 8caabad | 2012-11-04 17:23:25 -0800 | [diff] [blame] | 117 | if (mHideHintsRunnable != null) { |
| 118 | mMainQueue.removeCallbacks(mHideHintsRunnable); |
| 119 | mHideHintsRunnable = null; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | public void onPageEndMoving() { |
| 124 | mPageIndexOnPageBeginMoving = -1; |
| 125 | } |
| 126 | |
John Spurlock | bb5c941 | 2012-10-31 09:46:15 -0400 | [diff] [blame] | 127 | public void onPageSwitching(View newPage, int newPageIndex) { |
Adam Cohen | 7f6bb6e | 2012-11-04 14:00:05 -0800 | [diff] [blame] | 128 | if (mKeyguardWidgetPager != null && mChallengeLayout instanceof SlidingChallengeLayout) { |
John Spurlock | bb5c941 | 2012-10-31 09:46:15 -0400 | [diff] [blame] | 129 | boolean isCameraPage = newPage instanceof CameraWidgetFrame; |
| 130 | ((SlidingChallengeLayout) mChallengeLayout).setChallengeInteractive(!isCameraPage); |
| 131 | } |
Adam Cohen | 8caabad | 2012-11-04 17:23:25 -0800 | [diff] [blame] | 132 | |
| 133 | // If the page we're settling to is the same as we started on, and the action of |
| 134 | // moving the page hid the security, we restore it immediately. |
| 135 | if (mPageIndexOnPageBeginMoving == mKeyguardWidgetPager.getNextPage() && |
| 136 | mChallengeLayout instanceof SlidingChallengeLayout) { |
| 137 | SlidingChallengeLayout scl = (SlidingChallengeLayout) mChallengeLayout; |
| 138 | scl.fadeInChallenge(); |
| 139 | mKeyguardWidgetPager.setWidgetToResetOnPageFadeOut(-1); |
| 140 | } |
| 141 | mPageIndexOnPageBeginMoving = -1; |
John Spurlock | bb5c941 | 2012-10-31 09:46:15 -0400 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | public void onPageSwitched(View newPage, int newPageIndex) { |
Adam Cohen | e364313 | 2012-10-28 18:29:17 -0700 | [diff] [blame] | 145 | // Reset the previous page size and ensure the current page is sized appropriately. |
| 146 | // We only modify the page state if it is not currently under control by the slider. |
| 147 | // This prevents conflicts. |
Adam Cohen | 4ddcd57 | 2012-11-01 17:36:32 -0700 | [diff] [blame] | 148 | |
| 149 | // If the page hasn't switched, don't bother with any of this |
Adam Cohen | 2522880 | 2012-11-04 13:20:26 -0800 | [diff] [blame] | 150 | if (mCurrentPage == newPageIndex) return; |
Adam Cohen | 4ddcd57 | 2012-11-01 17:36:32 -0700 | [diff] [blame] | 151 | |
Adam Cohen | 7f6bb6e | 2012-11-04 14:00:05 -0800 | [diff] [blame] | 152 | if (mKeyguardWidgetPager != null && mChallengeLayout != null) { |
| 153 | KeyguardWidgetFrame prevPage = mKeyguardWidgetPager.getWidgetPageAt(mCurrentPage); |
Adam Cohen | 8caabad | 2012-11-04 17:23:25 -0800 | [diff] [blame] | 154 | if (prevPage != null && mCurrentPage != mPageListeningToSlider && mCurrentPage |
| 155 | != mKeyguardWidgetPager.getWidgetToResetOnPageFadeOut()) { |
Adam Cohen | e364313 | 2012-10-28 18:29:17 -0700 | [diff] [blame] | 156 | prevPage.resetSize(); |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 157 | } |
| 158 | |
Adam Cohen | 7f6bb6e | 2012-11-04 14:00:05 -0800 | [diff] [blame] | 159 | KeyguardWidgetFrame newCurPage = mKeyguardWidgetPager.getWidgetPageAt(newPageIndex); |
Adam Cohen | e364313 | 2012-10-28 18:29:17 -0700 | [diff] [blame] | 160 | boolean challengeOverlapping = mChallengeLayout.isChallengeOverlapping(); |
| 161 | if (challengeOverlapping && !newCurPage.isSmall() |
| 162 | && mPageListeningToSlider != newPageIndex) { |
Adam Cohen | 8a7785c | 2012-10-29 22:01:33 -0700 | [diff] [blame] | 163 | newCurPage.shrinkWidget(); |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 164 | } |
| 165 | } |
Adam Cohen | 8caabad | 2012-11-04 17:23:25 -0800 | [diff] [blame] | 166 | |
Adam Cohen | e364313 | 2012-10-28 18:29:17 -0700 | [diff] [blame] | 167 | mCurrentPage = newPageIndex; |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 168 | } |
| 169 | |
Adam Cohen | e364313 | 2012-10-28 18:29:17 -0700 | [diff] [blame] | 170 | private int getChallengeTopRelativeToFrame(KeyguardWidgetFrame frame, int top) { |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 171 | mTmpPoint[0] = 0; |
Adam Cohen | e364313 | 2012-10-28 18:29:17 -0700 | [diff] [blame] | 172 | mTmpPoint[1] = top; |
Jim Miller | 19a5267 | 2012-10-23 19:52:04 -0700 | [diff] [blame] | 173 | mapPoint((View) mChallengeLayout, frame, mTmpPoint); |
Adam Cohen | e364313 | 2012-10-28 18:29:17 -0700 | [diff] [blame] | 174 | return mTmpPoint[1]; |
| 175 | } |
| 176 | |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 177 | /** |
| 178 | * Simple method to map a point from one view's coordinates to another's. Note: this method |
| 179 | * doesn't account for transforms, so if the views will be transformed, this should not be used. |
| 180 | * |
| 181 | * @param fromView The view to which the point is relative |
| 182 | * @param toView The view into which the point should be mapped |
| 183 | * @param pt The point |
| 184 | */ |
Adam Cohen | 8a7785c | 2012-10-29 22:01:33 -0700 | [diff] [blame] | 185 | private void mapPoint(View fromView, View toView, int pt[]) { |
| 186 | fromView.getLocationInWindow(mTmpLoc); |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 187 | |
Adam Cohen | 8a7785c | 2012-10-29 22:01:33 -0700 | [diff] [blame] | 188 | int x = mTmpLoc[0]; |
| 189 | int y = mTmpLoc[1]; |
| 190 | |
| 191 | toView.getLocationInWindow(mTmpLoc); |
| 192 | int vX = mTmpLoc[0]; |
| 193 | int vY = mTmpLoc[1]; |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 194 | |
| 195 | pt[0] += x - vX; |
| 196 | pt[1] += y - vY; |
| 197 | } |
| 198 | |
Adam Cohen | 08c83ef | 2012-11-08 00:25:47 -0800 | [diff] [blame] | 199 | private void userActivity() { |
| 200 | if (mKeyguardHostView != null) { |
| 201 | mKeyguardHostView.onUserActivityTimeoutChanged(); |
| 202 | mKeyguardHostView.userActivity(); |
| 203 | } |
| 204 | } |
| 205 | |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 206 | @Override |
| 207 | public void onScrollStateChanged(int scrollState) { |
Adam Cohen | 7f6bb6e | 2012-11-04 14:00:05 -0800 | [diff] [blame] | 208 | if (mKeyguardWidgetPager == null || mChallengeLayout == null) return; |
Winson Chung | 48275d2 | 2012-11-05 10:56:31 -0800 | [diff] [blame] | 209 | |
Adam Cohen | e364313 | 2012-10-28 18:29:17 -0700 | [diff] [blame] | 210 | boolean challengeOverlapping = mChallengeLayout.isChallengeOverlapping(); |
| 211 | |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 212 | if (scrollState == SlidingChallengeLayout.SCROLL_STATE_IDLE) { |
Adam Cohen | 7f6bb6e | 2012-11-04 14:00:05 -0800 | [diff] [blame] | 213 | KeyguardWidgetFrame frame = mKeyguardWidgetPager.getWidgetPageAt(mPageListeningToSlider); |
Adam Cohen | e364313 | 2012-10-28 18:29:17 -0700 | [diff] [blame] | 214 | if (frame == null) return; |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 215 | |
Adam Cohen | e364313 | 2012-10-28 18:29:17 -0700 | [diff] [blame] | 216 | if (!challengeOverlapping) { |
Adam Cohen | 7f6bb6e | 2012-11-04 14:00:05 -0800 | [diff] [blame] | 217 | if (!mKeyguardWidgetPager.isPageMoving()) { |
Adam Cohen | db1c5d5 | 2012-11-03 17:10:07 -0700 | [diff] [blame] | 218 | frame.resetSize(); |
Adam Cohen | 08c83ef | 2012-11-08 00:25:47 -0800 | [diff] [blame] | 219 | userActivity(); |
Adam Cohen | db1c5d5 | 2012-11-03 17:10:07 -0700 | [diff] [blame] | 220 | } else { |
Adam Cohen | 8caabad | 2012-11-04 17:23:25 -0800 | [diff] [blame] | 221 | mKeyguardWidgetPager.setWidgetToResetOnPageFadeOut(mPageListeningToSlider); |
Adam Cohen | db1c5d5 | 2012-11-03 17:10:07 -0700 | [diff] [blame] | 222 | } |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 223 | } |
Adam Cohen | 44dc141 | 2012-11-07 20:50:39 -0800 | [diff] [blame] | 224 | if (frame.isSmall()) { |
| 225 | // This is to make sure that if the scroller animation gets cut off midway |
| 226 | // that the frame doesn't stay in a partial down position. |
| 227 | frame.setFrameHeight(frame.getSmallFrameHeight()); |
| 228 | } |
Adam Cohen | d51700b3 | 2012-11-07 16:26:46 -0800 | [diff] [blame] | 229 | if (scrollState != SlidingChallengeLayout.SCROLL_STATE_FADING) { |
| 230 | frame.hideFrame(this); |
| 231 | } |
Adam Cohen | 7f6bb6e | 2012-11-04 14:00:05 -0800 | [diff] [blame] | 232 | updateEdgeSwiping(); |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 233 | |
Jim Miller | bbba68a | 2012-10-24 22:21:40 -0700 | [diff] [blame] | 234 | if (mChallengeLayout.isChallengeShowing()) { |
Chris Wren | a042ac9 | 2012-11-07 11:37:06 -0500 | [diff] [blame] | 235 | mKeyguardSecurityContainer.onResume(KeyguardSecurityView.VIEW_REVEALED); |
Jim Miller | bbba68a | 2012-10-24 22:21:40 -0700 | [diff] [blame] | 236 | } else { |
| 237 | mKeyguardSecurityContainer.onPause(); |
| 238 | } |
Adam Cohen | e364313 | 2012-10-28 18:29:17 -0700 | [diff] [blame] | 239 | mPageListeningToSlider = -1; |
| 240 | } else if (mLastScrollState == SlidingChallengeLayout.SCROLL_STATE_IDLE) { |
| 241 | // Whether dragging or settling, if the last state was idle, we use this signal |
| 242 | // to update the current page who will receive events from the sliding challenge. |
| 243 | // We resize the frame as appropriate. |
Adam Cohen | 7f6bb6e | 2012-11-04 14:00:05 -0800 | [diff] [blame] | 244 | mPageListeningToSlider = mKeyguardWidgetPager.getNextPage(); |
| 245 | KeyguardWidgetFrame frame = mKeyguardWidgetPager.getWidgetPageAt(mPageListeningToSlider); |
Adam Cohen | e364313 | 2012-10-28 18:29:17 -0700 | [diff] [blame] | 246 | if (frame == null) return; |
| 247 | |
Winson Chung | 48275d2 | 2012-11-05 10:56:31 -0800 | [diff] [blame] | 248 | // Skip showing the frame and shrinking the widget if we are |
| 249 | if (!mChallengeLayout.isBouncing()) { |
Adam Cohen | d51700b3 | 2012-11-07 16:26:46 -0800 | [diff] [blame] | 250 | if (scrollState != SlidingChallengeLayout.SCROLL_STATE_FADING) { |
| 251 | frame.showFrame(this); |
| 252 | } |
Adam Cohen | e364313 | 2012-10-28 18:29:17 -0700 | [diff] [blame] | 253 | |
Winson Chung | 48275d2 | 2012-11-05 10:56:31 -0800 | [diff] [blame] | 254 | // As soon as the security begins sliding, the widget becomes small (if it wasn't |
| 255 | // small to begin with). |
| 256 | if (!frame.isSmall()) { |
| 257 | // We need to fetch the final page, in case the pages are in motion. |
| 258 | mPageListeningToSlider = mKeyguardWidgetPager.getNextPage(); |
Adam Cohen | 44dc141 | 2012-11-07 20:50:39 -0800 | [diff] [blame] | 259 | frame.shrinkWidget(false); |
Winson Chung | 48275d2 | 2012-11-05 10:56:31 -0800 | [diff] [blame] | 260 | } |
| 261 | } else { |
| 262 | if (!frame.isSmall()) { |
| 263 | // We need to fetch the final page, in case the pages are in motion. |
| 264 | mPageListeningToSlider = mKeyguardWidgetPager.getNextPage(); |
| 265 | } |
Adam Cohen | e364313 | 2012-10-28 18:29:17 -0700 | [diff] [blame] | 266 | } |
Winson Chung | 48275d2 | 2012-11-05 10:56:31 -0800 | [diff] [blame] | 267 | |
Jim Miller | bbba68a | 2012-10-24 22:21:40 -0700 | [diff] [blame] | 268 | // View is on the move. Pause the security view until it completes. |
| 269 | mKeyguardSecurityContainer.onPause(); |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 270 | } |
Adam Cohen | e364313 | 2012-10-28 18:29:17 -0700 | [diff] [blame] | 271 | mLastScrollState = scrollState; |
| 272 | } |
| 273 | |
| 274 | @Override |
| 275 | public void onScrollPositionChanged(float scrollPosition, int challengeTop) { |
| 276 | mChallengeTop = challengeTop; |
Adam Cohen | 7f6bb6e | 2012-11-04 14:00:05 -0800 | [diff] [blame] | 277 | KeyguardWidgetFrame frame = mKeyguardWidgetPager.getWidgetPageAt(mPageListeningToSlider); |
Adam Cohen | 44dc141 | 2012-11-07 20:50:39 -0800 | [diff] [blame] | 278 | if (frame != null && mLastScrollState != SlidingChallengeLayout.SCROLL_STATE_FADING) { |
Adam Cohen | e364313 | 2012-10-28 18:29:17 -0700 | [diff] [blame] | 279 | frame.adjustFrame(getChallengeTopRelativeToFrame(frame, mChallengeTop)); |
| 280 | } |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 281 | } |
| 282 | |
Adam Cohen | 196cde9 | 2012-11-02 15:25:32 -0700 | [diff] [blame] | 283 | private Runnable mHideHintsRunnable = new Runnable() { |
| 284 | @Override |
| 285 | public void run() { |
Adam Cohen | 7f6bb6e | 2012-11-04 14:00:05 -0800 | [diff] [blame] | 286 | if (mKeyguardWidgetPager != null) { |
| 287 | mKeyguardWidgetPager.hideOutlinesAndSidePages(); |
Adam Cohen | 196cde9 | 2012-11-02 15:25:32 -0700 | [diff] [blame] | 288 | } |
| 289 | } |
| 290 | }; |
| 291 | |
Adam Cohen | 6fb841f | 2012-10-24 13:15:38 -0700 | [diff] [blame] | 292 | public void showUsabilityHints() { |
Adam Cohen | 47c6cfa | 2012-10-27 18:29:52 -0700 | [diff] [blame] | 293 | mMainQueue.postDelayed( new Runnable() { |
| 294 | @Override |
| 295 | public void run() { |
| 296 | mKeyguardSecurityContainer.showUsabilityHint(); |
| 297 | } |
| 298 | } , SCREEN_ON_RING_HINT_DELAY); |
Adam Cohen | 7f6bb6e | 2012-11-04 14:00:05 -0800 | [diff] [blame] | 299 | mKeyguardWidgetPager.showInitialPageHints(); |
Adam Cohen | 196cde9 | 2012-11-02 15:25:32 -0700 | [diff] [blame] | 300 | if (mHideHintsRunnable != null) { |
| 301 | mMainQueue.postDelayed(mHideHintsRunnable, SCREEN_ON_HINT_DURATION); |
| 302 | } |
Adam Cohen | 6fb841f | 2012-10-24 13:15:38 -0700 | [diff] [blame] | 303 | } |
Jim Miller | e0566da | 2012-10-30 14:57:29 -0700 | [diff] [blame] | 304 | |
Winson Chung | 48275d2 | 2012-11-05 10:56:31 -0800 | [diff] [blame] | 305 | // ChallengeLayout.OnBouncerStateChangedListener |
| 306 | @Override |
| 307 | public void onBouncerStateChanged(boolean bouncerActive) { |
| 308 | if (bouncerActive) { |
| 309 | mKeyguardWidgetPager.zoomOutToBouncer(); |
| 310 | } else { |
| 311 | mKeyguardWidgetPager.zoomInFromBouncer(); |
Jim Miller | 4eeb4f6 | 2012-11-08 00:04:29 -0800 | [diff] [blame] | 312 | if (mKeyguardHostView != null) { |
| 313 | mKeyguardHostView.setOnDismissAction(null); |
| 314 | } |
Winson Chung | 48275d2 | 2012-11-05 10:56:31 -0800 | [diff] [blame] | 315 | } |
| 316 | } |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 317 | } |