2121
2222public class KeyguardViewStateManager implements SlidingChallengeLayout .OnChallengeScrolledListener {
2323
24- private KeyguardWidgetPager mPagedView ;
24+ private KeyguardWidgetPager mKeyguardWidgetPager ;
2525 private ChallengeLayout mChallengeLayout ;
2626 private int [] mTmpPoint = new int [2 ];
2727 private int [] mTmpLoc = new int [2 ];
@@ -50,11 +50,23 @@ public KeyguardViewStateManager() {
5050 }
5151
5252 public void setPagedView (KeyguardWidgetPager pagedView ) {
53- mPagedView = pagedView ;
53+ mKeyguardWidgetPager = pagedView ;
54+ updateEdgeSwiping ();
5455 }
5556
5657 public void setChallengeLayout (ChallengeLayout layout ) {
5758 mChallengeLayout = layout ;
59+ updateEdgeSwiping ();
60+ }
61+
62+ private void updateEdgeSwiping () {
63+ if (mChallengeLayout != null && mKeyguardWidgetPager != null ) {
64+ if (mChallengeLayout .isChallengeOverlapping ()) {
65+ mKeyguardWidgetPager .setOnlyAllowEdgeSwipes (true );
66+ } else {
67+ mKeyguardWidgetPager .setOnlyAllowEdgeSwipes (false );
68+ }
69+ }
5870 }
5971
6072 public boolean isChallengeShowing () {
@@ -103,7 +115,7 @@ public void fadeInSecurity(int duration) {
103115 }
104116
105117 public void onPageSwitching (View newPage , int newPageIndex ) {
106- if (mPagedView != null && mChallengeLayout instanceof SlidingChallengeLayout ) {
118+ if (mKeyguardWidgetPager != null && mChallengeLayout instanceof SlidingChallengeLayout ) {
107119 boolean isCameraPage = newPage instanceof CameraWidgetFrame ;
108120 ((SlidingChallengeLayout ) mChallengeLayout ).setChallengeInteractive (!isCameraPage );
109121 }
@@ -117,13 +129,13 @@ public void onPageSwitched(View newPage, int newPageIndex) {
117129 // If the page hasn't switched, don't bother with any of this
118130 if (mCurrentPage == newPageIndex ) return ;
119131
120- if (mPagedView != null && mChallengeLayout != null ) {
121- KeyguardWidgetFrame prevPage = mPagedView .getWidgetPageAt (mCurrentPage );
132+ if (mKeyguardWidgetPager != null && mChallengeLayout != null ) {
133+ KeyguardWidgetFrame prevPage = mKeyguardWidgetPager .getWidgetPageAt (mCurrentPage );
122134 if (prevPage != null && mCurrentPage != mPageListeningToSlider ) {
123135 prevPage .resetSize ();
124136 }
125137
126- KeyguardWidgetFrame newCurPage = mPagedView .getWidgetPageAt (newPageIndex );
138+ KeyguardWidgetFrame newCurPage = mKeyguardWidgetPager .getWidgetPageAt (newPageIndex );
127139 boolean challengeOverlapping = mChallengeLayout .isChallengeOverlapping ();
128140 if (challengeOverlapping && !newCurPage .isSmall ()
129141 && mPageListeningToSlider != newPageIndex ) {
@@ -164,27 +176,22 @@ private void mapPoint(View fromView, View toView, int pt[]) {
164176
165177 @ Override
166178 public void onScrollStateChanged (int scrollState ) {
167- if (mPagedView == null || mChallengeLayout == null ) return ;
179+ if (mKeyguardWidgetPager == null || mChallengeLayout == null ) return ;
168180 boolean challengeOverlapping = mChallengeLayout .isChallengeOverlapping ();
169181
170182 if (scrollState == SlidingChallengeLayout .SCROLL_STATE_IDLE ) {
171- KeyguardWidgetFrame frame = mPagedView .getWidgetPageAt (mPageListeningToSlider );
183+ KeyguardWidgetFrame frame = mKeyguardWidgetPager .getWidgetPageAt (mPageListeningToSlider );
172184 if (frame == null ) return ;
173185
174186 if (!challengeOverlapping ) {
175- if (!mPagedView .isPageMoving ()) {
187+ if (!mKeyguardWidgetPager .isPageMoving ()) {
176188 frame .resetSize ();
177189 } else {
178- mPagedView .resetWidgetSizeOnPagesFaded (frame );
190+ mKeyguardWidgetPager .resetWidgetSizeOnPagesFaded (frame );
179191 }
180192 }
181193 frame .hideFrame (this );
182-
183- if (challengeOverlapping ) {
184- mPagedView .setOnlyAllowEdgeSwipes (true );
185- } else {
186- mPagedView .setOnlyAllowEdgeSwipes (false );
187- }
194+ updateEdgeSwiping ();
188195
189196 if (mChallengeLayout .isChallengeShowing ()) {
190197 mKeyguardSecurityContainer .onResume ();
@@ -196,8 +203,8 @@ public void onScrollStateChanged(int scrollState) {
196203 // Whether dragging or settling, if the last state was idle, we use this signal
197204 // to update the current page who will receive events from the sliding challenge.
198205 // We resize the frame as appropriate.
199- mPageListeningToSlider = mPagedView .getNextPage ();
200- KeyguardWidgetFrame frame = mPagedView .getWidgetPageAt (mPageListeningToSlider );
206+ mPageListeningToSlider = mKeyguardWidgetPager .getNextPage ();
207+ KeyguardWidgetFrame frame = mKeyguardWidgetPager .getWidgetPageAt (mPageListeningToSlider );
201208 if (frame == null ) return ;
202209
203210 frame .showFrame (this );
@@ -206,7 +213,7 @@ public void onScrollStateChanged(int scrollState) {
206213 // small to begin with).
207214 if (!frame .isSmall ()) {
208215 // We need to fetch the final page, in case the pages are in motion.
209- mPageListeningToSlider = mPagedView .getNextPage ();
216+ mPageListeningToSlider = mKeyguardWidgetPager .getNextPage ();
210217 frame .shrinkWidget ();
211218 }
212219 // View is on the move. Pause the security view until it completes.
@@ -218,17 +225,17 @@ public void onScrollStateChanged(int scrollState) {
218225 @ Override
219226 public void onScrollPositionChanged (float scrollPosition , int challengeTop ) {
220227 mChallengeTop = challengeTop ;
221- KeyguardWidgetFrame frame = mPagedView .getWidgetPageAt (mPageListeningToSlider );
222- if (frame != null && !mPagedView .isPageMoving ()) {
228+ KeyguardWidgetFrame frame = mKeyguardWidgetPager .getWidgetPageAt (mPageListeningToSlider );
229+ if (frame != null && !mKeyguardWidgetPager .isPageMoving ()) {
223230 frame .adjustFrame (getChallengeTopRelativeToFrame (frame , mChallengeTop ));
224231 }
225232 }
226233
227234 private Runnable mHideHintsRunnable = new Runnable () {
228235 @ Override
229236 public void run () {
230- if (mPagedView != null ) {
231- mPagedView .hideOutlinesAndSidePages ();
237+ if (mKeyguardWidgetPager != null ) {
238+ mKeyguardWidgetPager .hideOutlinesAndSidePages ();
232239 }
233240 }
234241 };
@@ -240,7 +247,7 @@ public void run() {
240247 mKeyguardSecurityContainer .showUsabilityHint ();
241248 }
242249 } , SCREEN_ON_RING_HINT_DELAY );
243- mPagedView .showInitialPageHints ();
250+ mKeyguardWidgetPager .showInitialPageHints ();
244251 if (mHideHintsRunnable != null ) {
245252 mMainQueue .postDelayed (mHideHintsRunnable , SCREEN_ON_HINT_DURATION );
246253 }
0 commit comments