Loading policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java +13 −22 Original line number Diff line number Diff line Loading @@ -843,7 +843,7 @@ public class KeyguardHostView extends KeyguardViewBase { @Override public void onCameraLaunchedSuccessfully() { if (isCameraPage(mAppWidgetContainer.getCurrentPage())) { if (mAppWidgetContainer.isCameraPage(mAppWidgetContainer.getCurrentPage())) { mAppWidgetContainer.scrollLeft(); } setSliderHandleAlpha(1); Loading Loading @@ -932,7 +932,8 @@ public class KeyguardHostView extends KeyguardViewBase { int lastWidget = mAppWidgetContainer.getChildCount() - 1; int position = 0; // handle no widget case if (lastWidget >= 0) { position = isCameraPage(lastWidget) ? lastWidget : lastWidget + 1; position = mAppWidgetContainer.isCameraPage(lastWidget) ? lastWidget : lastWidget + 1; } mAppWidgetContainer.addWidget(mTransportControl, position); mTransportControl.setVisibility(View.VISIBLE); Loading Loading @@ -1146,7 +1147,7 @@ public class KeyguardHostView extends KeyguardViewBase { private CameraWidgetFrame findCameraPage() { for (int i = mAppWidgetContainer.getChildCount() - 1; i >= 0; i--) { if (isCameraPage(i)) { if (mAppWidgetContainer.isCameraPage(i)) { return (CameraWidgetFrame) mAppWidgetContainer.getChildAt(i); } } Loading @@ -1162,20 +1163,6 @@ public class KeyguardHostView extends KeyguardViewBase { return false; } private boolean isCameraPage(int pageIndex) { View v = mAppWidgetContainer.getChildAt(pageIndex); return v != null && v instanceof CameraWidgetFrame; } private boolean isAddPage(int pageIndex) { View v = mAppWidgetContainer.getChildAt(pageIndex); return v != null && v.getId() == R.id.keyguard_add_widget; } private boolean isMusicPage(int pageIndex) { return pageIndex >= 0 && pageIndex == getWidgetPosition(R.id.keyguard_transport_control); } private int getStickyWidget() { // The first time we query the persistent state. From that point, we use a locally updated // notion of the sticky widget page. Loading @@ -1190,10 +1177,10 @@ public class KeyguardHostView extends KeyguardViewBase { if (index < 0 || index >= mAppWidgetContainer.getChildCount()) { return; } if (isAddPage(index)) { if (mAppWidgetContainer.isAddPage(index)) { return; } if (isCameraPage(index)) { if (mAppWidgetContainer.isCameraPage(index)) { return; } if (isMusicPage(index)) { Loading @@ -1203,6 +1190,10 @@ public class KeyguardHostView extends KeyguardViewBase { mLocalStickyWidget = index; } boolean isMusicPage(int pageIndex) { return pageIndex >= 0 && pageIndex == getWidgetPosition(R.id.keyguard_transport_control); } private int getAppropriateWidgetPage(boolean isMusicPlaying) { // assumes at least one widget (besides camera + add) Loading @@ -1216,15 +1207,15 @@ public class KeyguardHostView extends KeyguardViewBase { int stickyWidgetIndex = getStickyWidget(); if (stickyWidgetIndex > -1 && stickyWidgetIndex < mAppWidgetContainer.getChildCount() && !isAddPage(stickyWidgetIndex) && !isCameraPage(stickyWidgetIndex)) { && !mAppWidgetContainer.isAddPage(stickyWidgetIndex) && !mAppWidgetContainer.isCameraPage(stickyWidgetIndex)) { if (DEBUG) Log.d(TAG, "Valid sticky widget found, show page " + stickyWidgetIndex); return stickyWidgetIndex; } // else show the right-most widget (except for camera) int rightMost = mAppWidgetContainer.getChildCount() - 1; if (isCameraPage(rightMost)) { if (mAppWidgetContainer.isCameraPage(rightMost)) { rightMost--; } if (DEBUG) Log.d(TAG, "Show right-most page " + rightMost); Loading policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java +15 −0 Original line number Diff line number Diff line Loading @@ -782,4 +782,19 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit mZoomInOutAnim.start(); } } boolean isAddPage(int pageIndex) { View v = getChildAt(pageIndex); return v != null && v.getId() == R.id.keyguard_add_widget; } boolean isCameraPage(int pageIndex) { View v = getChildAt(pageIndex); return v != null && v instanceof CameraWidgetFrame; } @Override protected boolean shouldSetTopAlignedPivotForWidget(int childIndex) { return !isCameraPage(childIndex) && super.shouldSetTopAlignedPivotForWidget(childIndex); } } policy/src/com/android/internal/policy/impl/keyguard/PagedView.java +37 −16 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.util.Log; import android.view.InputDevice; import android.view.KeyEvent; Loading Loading @@ -577,6 +578,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc computeScrollHelper(); } protected boolean shouldSetTopAlignedPivotForWidget(int childIndex) { return mTopAlignPageWhenShrinkingForBouncer; } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (!mIsDataReady || getChildCount() == 0) { Loading @@ -593,8 +598,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc int heightSize = MeasureSpec.getSize(heightMeasureSpec); // NOTE: We multiply by 1.5f to account for the fact that depending on the offset of the // viewport, we can be at most one and a half screens offset once we scale down int parentWidthSize = (int) (1.5f * parent.getMeasuredWidth()); int parentHeightSize = parent.getMeasuredHeight(); DisplayMetrics dm = getResources().getDisplayMetrics(); int maxSize = Math.max(dm.widthPixels, dm.heightPixels); int parentWidthSize = (int) (1.5f * maxSize); int parentHeightSize = maxSize; int scaledWidthSize = (int) (parentWidthSize / mMinScale); int scaledHeightSize = (int) (parentHeightSize / mMinScale); mViewport.set(0, 0, widthSize, heightSize); Loading Loading @@ -651,7 +658,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc MeasureSpec.makeMeasureSpec(heightSize - verticalPadding, childHeightMode); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); if (mTopAlignPageWhenShrinkingForBouncer) { if (shouldSetTopAlignedPivotForWidget(i)) { child.setPivotX(child.getWidth() / 2); child.setPivotY(0f); } Loading Loading @@ -1015,6 +1022,17 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc return (x > (getViewportOffsetX() + getViewportWidth() - getRelativeChildOffset(mCurrentPage) + mPageSpacing)); } /** Returns whether x and y originated within the buffered/unbuffered viewport */ private boolean isTouchPointInViewport(int x, int y, boolean buffer) { if (buffer) { mTmpRect.set(mViewport.left - mViewport.width() / 2, mViewport.top, mViewport.right + mViewport.width() / 2, mViewport.bottom); return mTmpRect.contains(x, y); } else { return mViewport.contains(x, y); } } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (DISABLE_TOUCH_INTERACTION) { Loading Loading @@ -1093,7 +1111,11 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc mTouchState = TOUCH_STATE_REST; mScroller.abortAnimation(); } else { if (isTouchPointInViewport((int) mDownMotionX, (int) mDownMotionY, true)) { mTouchState = TOUCH_STATE_SCROLLING; } else { mTouchState = TOUCH_STATE_REST; } } // check if this can be the beginning of a tap on the side of the pages Loading @@ -1115,6 +1137,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: resetTouchState(); // Just intercept the touch event on up if we tap outside the strict viewport if (!isTouchPointInViewport((int) mLastMotionX, (int) mLastMotionY, false)) { return true; } break; case MotionEvent.ACTION_POINTER_UP: Loading @@ -1139,24 +1165,19 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc * user moves their touch point too far. */ protected void determineScrollingStart(MotionEvent ev, float touchSlopScale) { /* * Locally do absolute value. mLastMotionX is set to the y value * of the down event. */ // Disallow scrolling if we don't have a valid pointer index final int pointerIndex = ev.findPointerIndex(mActivePointerId); if (pointerIndex == -1) return; if (pointerIndex == -1) { return; } // Disallow scrolling if we started the gesture from outside the viewport final float x = ev.getX(pointerIndex); final float y = ev.getY(pointerIndex); if (!isTouchPointInViewport((int) x, (int) y, true)) return; // If we're only allowing edge swipes, we break out early if the down event wasn't // at the edge. if (mOnlyAllowEdgeSwipes && !mDownEventOnEdge) { return; } if (mOnlyAllowEdgeSwipes && !mDownEventOnEdge) return; final float x = ev.getX(pointerIndex); final float y = ev.getY(pointerIndex); final int xDiff = (int) Math.abs(x - mLastMotionX); final int yDiff = (int) Math.abs(y - mLastMotionY); Loading policy/src/com/android/internal/policy/impl/keyguard/SlidingChallengeLayout.java +1 −1 Original line number Diff line number Diff line Loading @@ -469,8 +469,8 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout public void showBouncer() { if (mIsBouncing) return; mWasChallengeShowing = mChallengeShowing; showChallenge(true); mIsBouncing = true; showChallenge(true); if (mScrimView != null) { mScrimView.setVisibility(VISIBLE); } Loading Loading
policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java +13 −22 Original line number Diff line number Diff line Loading @@ -843,7 +843,7 @@ public class KeyguardHostView extends KeyguardViewBase { @Override public void onCameraLaunchedSuccessfully() { if (isCameraPage(mAppWidgetContainer.getCurrentPage())) { if (mAppWidgetContainer.isCameraPage(mAppWidgetContainer.getCurrentPage())) { mAppWidgetContainer.scrollLeft(); } setSliderHandleAlpha(1); Loading Loading @@ -932,7 +932,8 @@ public class KeyguardHostView extends KeyguardViewBase { int lastWidget = mAppWidgetContainer.getChildCount() - 1; int position = 0; // handle no widget case if (lastWidget >= 0) { position = isCameraPage(lastWidget) ? lastWidget : lastWidget + 1; position = mAppWidgetContainer.isCameraPage(lastWidget) ? lastWidget : lastWidget + 1; } mAppWidgetContainer.addWidget(mTransportControl, position); mTransportControl.setVisibility(View.VISIBLE); Loading Loading @@ -1146,7 +1147,7 @@ public class KeyguardHostView extends KeyguardViewBase { private CameraWidgetFrame findCameraPage() { for (int i = mAppWidgetContainer.getChildCount() - 1; i >= 0; i--) { if (isCameraPage(i)) { if (mAppWidgetContainer.isCameraPage(i)) { return (CameraWidgetFrame) mAppWidgetContainer.getChildAt(i); } } Loading @@ -1162,20 +1163,6 @@ public class KeyguardHostView extends KeyguardViewBase { return false; } private boolean isCameraPage(int pageIndex) { View v = mAppWidgetContainer.getChildAt(pageIndex); return v != null && v instanceof CameraWidgetFrame; } private boolean isAddPage(int pageIndex) { View v = mAppWidgetContainer.getChildAt(pageIndex); return v != null && v.getId() == R.id.keyguard_add_widget; } private boolean isMusicPage(int pageIndex) { return pageIndex >= 0 && pageIndex == getWidgetPosition(R.id.keyguard_transport_control); } private int getStickyWidget() { // The first time we query the persistent state. From that point, we use a locally updated // notion of the sticky widget page. Loading @@ -1190,10 +1177,10 @@ public class KeyguardHostView extends KeyguardViewBase { if (index < 0 || index >= mAppWidgetContainer.getChildCount()) { return; } if (isAddPage(index)) { if (mAppWidgetContainer.isAddPage(index)) { return; } if (isCameraPage(index)) { if (mAppWidgetContainer.isCameraPage(index)) { return; } if (isMusicPage(index)) { Loading @@ -1203,6 +1190,10 @@ public class KeyguardHostView extends KeyguardViewBase { mLocalStickyWidget = index; } boolean isMusicPage(int pageIndex) { return pageIndex >= 0 && pageIndex == getWidgetPosition(R.id.keyguard_transport_control); } private int getAppropriateWidgetPage(boolean isMusicPlaying) { // assumes at least one widget (besides camera + add) Loading @@ -1216,15 +1207,15 @@ public class KeyguardHostView extends KeyguardViewBase { int stickyWidgetIndex = getStickyWidget(); if (stickyWidgetIndex > -1 && stickyWidgetIndex < mAppWidgetContainer.getChildCount() && !isAddPage(stickyWidgetIndex) && !isCameraPage(stickyWidgetIndex)) { && !mAppWidgetContainer.isAddPage(stickyWidgetIndex) && !mAppWidgetContainer.isCameraPage(stickyWidgetIndex)) { if (DEBUG) Log.d(TAG, "Valid sticky widget found, show page " + stickyWidgetIndex); return stickyWidgetIndex; } // else show the right-most widget (except for camera) int rightMost = mAppWidgetContainer.getChildCount() - 1; if (isCameraPage(rightMost)) { if (mAppWidgetContainer.isCameraPage(rightMost)) { rightMost--; } if (DEBUG) Log.d(TAG, "Show right-most page " + rightMost); Loading
policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java +15 −0 Original line number Diff line number Diff line Loading @@ -782,4 +782,19 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit mZoomInOutAnim.start(); } } boolean isAddPage(int pageIndex) { View v = getChildAt(pageIndex); return v != null && v.getId() == R.id.keyguard_add_widget; } boolean isCameraPage(int pageIndex) { View v = getChildAt(pageIndex); return v != null && v instanceof CameraWidgetFrame; } @Override protected boolean shouldSetTopAlignedPivotForWidget(int childIndex) { return !isCameraPage(childIndex) && super.shouldSetTopAlignedPivotForWidget(childIndex); } }
policy/src/com/android/internal/policy/impl/keyguard/PagedView.java +37 −16 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.util.Log; import android.view.InputDevice; import android.view.KeyEvent; Loading Loading @@ -577,6 +578,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc computeScrollHelper(); } protected boolean shouldSetTopAlignedPivotForWidget(int childIndex) { return mTopAlignPageWhenShrinkingForBouncer; } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (!mIsDataReady || getChildCount() == 0) { Loading @@ -593,8 +598,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc int heightSize = MeasureSpec.getSize(heightMeasureSpec); // NOTE: We multiply by 1.5f to account for the fact that depending on the offset of the // viewport, we can be at most one and a half screens offset once we scale down int parentWidthSize = (int) (1.5f * parent.getMeasuredWidth()); int parentHeightSize = parent.getMeasuredHeight(); DisplayMetrics dm = getResources().getDisplayMetrics(); int maxSize = Math.max(dm.widthPixels, dm.heightPixels); int parentWidthSize = (int) (1.5f * maxSize); int parentHeightSize = maxSize; int scaledWidthSize = (int) (parentWidthSize / mMinScale); int scaledHeightSize = (int) (parentHeightSize / mMinScale); mViewport.set(0, 0, widthSize, heightSize); Loading Loading @@ -651,7 +658,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc MeasureSpec.makeMeasureSpec(heightSize - verticalPadding, childHeightMode); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); if (mTopAlignPageWhenShrinkingForBouncer) { if (shouldSetTopAlignedPivotForWidget(i)) { child.setPivotX(child.getWidth() / 2); child.setPivotY(0f); } Loading Loading @@ -1015,6 +1022,17 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc return (x > (getViewportOffsetX() + getViewportWidth() - getRelativeChildOffset(mCurrentPage) + mPageSpacing)); } /** Returns whether x and y originated within the buffered/unbuffered viewport */ private boolean isTouchPointInViewport(int x, int y, boolean buffer) { if (buffer) { mTmpRect.set(mViewport.left - mViewport.width() / 2, mViewport.top, mViewport.right + mViewport.width() / 2, mViewport.bottom); return mTmpRect.contains(x, y); } else { return mViewport.contains(x, y); } } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (DISABLE_TOUCH_INTERACTION) { Loading Loading @@ -1093,7 +1111,11 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc mTouchState = TOUCH_STATE_REST; mScroller.abortAnimation(); } else { if (isTouchPointInViewport((int) mDownMotionX, (int) mDownMotionY, true)) { mTouchState = TOUCH_STATE_SCROLLING; } else { mTouchState = TOUCH_STATE_REST; } } // check if this can be the beginning of a tap on the side of the pages Loading @@ -1115,6 +1137,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: resetTouchState(); // Just intercept the touch event on up if we tap outside the strict viewport if (!isTouchPointInViewport((int) mLastMotionX, (int) mLastMotionY, false)) { return true; } break; case MotionEvent.ACTION_POINTER_UP: Loading @@ -1139,24 +1165,19 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc * user moves their touch point too far. */ protected void determineScrollingStart(MotionEvent ev, float touchSlopScale) { /* * Locally do absolute value. mLastMotionX is set to the y value * of the down event. */ // Disallow scrolling if we don't have a valid pointer index final int pointerIndex = ev.findPointerIndex(mActivePointerId); if (pointerIndex == -1) return; if (pointerIndex == -1) { return; } // Disallow scrolling if we started the gesture from outside the viewport final float x = ev.getX(pointerIndex); final float y = ev.getY(pointerIndex); if (!isTouchPointInViewport((int) x, (int) y, true)) return; // If we're only allowing edge swipes, we break out early if the down event wasn't // at the edge. if (mOnlyAllowEdgeSwipes && !mDownEventOnEdge) { return; } if (mOnlyAllowEdgeSwipes && !mDownEventOnEdge) return; final float x = ev.getX(pointerIndex); final float y = ev.getY(pointerIndex); final int xDiff = (int) Math.abs(x - mLastMotionX); final int yDiff = (int) Math.abs(y - mLastMotionY); Loading
policy/src/com/android/internal/policy/impl/keyguard/SlidingChallengeLayout.java +1 −1 Original line number Diff line number Diff line Loading @@ -469,8 +469,8 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout public void showBouncer() { if (mIsBouncing) return; mWasChallengeShowing = mChallengeShowing; showChallenge(true); mIsBouncing = true; showChallenge(true); if (mScrimView != null) { mScrimView.setVisibility(VISIBLE); } Loading