private final Callbacks mCallbacks;
private final WindowManager mWindowManager;
private final Point mRenderedSize = new Point();
+ private final int[] mScreenLocation = new int[2];
private View mWidgetView;
private long mLaunchCameraStart;
private boolean mActive;
- private boolean mChallengeActive;
private boolean mTransitioning;
private boolean mDown;
+ private boolean mWindowFocused;
private final Runnable mLaunchCameraRunnable = new Runnable() {
@Override
}
private void transitionToCamera() {
- if (mTransitioning || mChallengeActive || mDown) return;
+ if (mTransitioning || mDown) return;
mTransitioning = true;
public void onClick(View v) {
if (DEBUG) Log.d(TAG, "clicked");
if (mTransitioning) return;
- if (mActive && !mChallengeActive) {
+ if (mActive) {
cancelTransitionToCamera();
transitionToCamera();
}
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
super.onWindowFocusChanged(hasWindowFocus);
+ mWindowFocused = hasWindowFocus;
if (DEBUG) Log.d(TAG, "onWindowFocusChanged: " + hasWindowFocus);
if (!hasWindowFocus) {
mTransitioning = false;
}
@Override
- public boolean onUserInteraction(int action) {
- if (mTransitioning) return true;
- if (DEBUG) Log.d(TAG, "onUserInteraction " + action);
+ public boolean onUserInteraction(MotionEvent event) {
+ if (!mWindowFocused) {
+ if (DEBUG) Log.d(TAG, "onUserInteraction eaten: !mWindowFocused");
+ return true;
+ }
+ if (mTransitioning) {
+ if (DEBUG) Log.d(TAG, "onUserInteraction eaten: mTransitioning");
+ return true;
+ }
+
+ getLocationOnScreen(mScreenLocation);
+ int rawBottom = mScreenLocation[1] + getHeight();
+ if (event.getRawY() > rawBottom) {
+ if (DEBUG) Log.d(TAG, "onUserInteraction eaten: below widget");
+ return true;
+ }
+
+ int action = event.getAction();
mDown = action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE;
- if (mActive && !mChallengeActive) {
+ if (mActive) {
rescheduleTransitionToCamera();
}
+ if (DEBUG) Log.d(TAG, "onUserInteraction observed, not eaten");
return false;
}
super.onFocusLost();
}
- @Override
- public void onChallengeActive(boolean challengeActive) {
- if (DEBUG) Log.d(TAG, "onChallengeActive: " + challengeActive);
- mChallengeActive = challengeActive;
- if (mTransitioning) return;
- if (mActive) {
- if (mChallengeActive) {
- cancelTransitionToCamera();
- } else {
- rescheduleTransitionToCamera();
- }
- }
- }
-
public void onScreenTurnedOff() {
if (DEBUG) Log.d(TAG, "onScreenTurnedOff");
reset();
if (DEBUG) Log.d(TAG, "reset");
mLaunchCameraStart = 0;
mTransitioning = false;
- mChallengeActive = false;
mDown = false;
cancelTransitionToCamera();
animate().cancel();
WindowManager.LayoutParams wlp = (WindowManager.LayoutParams) lp;
int newWindowAnimations = isEnabled ? com.android.internal.R.style.Animation_LockScreen : 0;
if (newWindowAnimations != wlp.windowAnimations) {
+ if (DEBUG) Log.d(TAG, "setting windowAnimations to: " + newWindowAnimations);
wlp.windowAnimations = newWindowAnimations;
mWindowManager.updateViewLayout(root, wlp);
}
if (isCameraPage(mAppWidgetContainer.getCurrentPage())) {
mAppWidgetContainer.scrollLeft();
}
+ SlidingChallengeLayout slider = locateSlider();
+ if (slider != null) {
+ slider.setHandleAlpha(1);
+ }
mShowSecurityWhenReturn = true;
}
((View) mKeyguardSecurityContainer).animate().alpha(1f).setDuration(duration);
}
- public void onPageSwitch(View newPage, int newPageIndex) {
+ public void onPageSwitching(View newPage, int newPageIndex) {
+ if (mPagedView != null && mChallengeLayout instanceof SlidingChallengeLayout) {
+ boolean isCameraPage = newPage instanceof CameraWidgetFrame;
+ ((SlidingChallengeLayout) mChallengeLayout).setChallengeInteractive(!isCameraPage);
+ }
+ }
+
+ public void onPageSwitched(View newPage, int newPageIndex) {
// Reset the previous page size and ensure the current page is sized appropriately.
// We only modify the page state if it is not currently under control by the slider.
// This prevents conflicts.
if (!challengeOverlapping) {
frame.resetSize();
}
- frame.onChallengeActive(mChallengeLayout.isChallengeShowing());
frame.hideFrame(this);
if (challengeOverlapping) {
}
// View is on the move. Pause the security view until it completes.
mKeyguardSecurityContainer.onPause();
-
- frame.onChallengeActive(true);
}
mLastScrollState = scrollState;
}
// hook for subclasses
}
- public boolean onUserInteraction(int action) {
+ public boolean onUserInteraction(MotionEvent event) {
// hook for subclasses
return false;
}
-
- public void onChallengeActive(boolean challengeActive) {
- // hook for subclasses
- }
}
}
@Override
- public void onPageSwitch(View newPage, int newPageIndex) {
+ public void onPageSwitching(View newPage, int newPageIndex) {
+ if (mViewStateManager != null) {
+ mViewStateManager.onPageSwitching(newPage, newPageIndex);
+ }
+ }
+
+ @Override
+ public void onPageSwitched(View newPage, int newPageIndex) {
boolean showingStatusWidget = false;
if (newPage instanceof ViewGroup) {
ViewGroup vg = (ViewGroup) newPage;
}
}
if (mViewStateManager != null) {
- mViewStateManager.onPageSwitch(newPage, newPageIndex);
+ mViewStateManager.onPageSwitched(newPage, newPageIndex);
}
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
KeyguardWidgetFrame currentWidgetPage = getWidgetPageAt(getCurrentPage());
- if (currentWidgetPage != null && currentWidgetPage.onUserInteraction(ev.getAction())) {
+ if (currentWidgetPage != null && currentWidgetPage.onUserInteraction(ev)) {
return true;
}
return super.onTouchEvent(ev);
private boolean mIsFlingingToDelete = false;
public interface PageSwitchListener {
- void onPageSwitch(View newPage, int newPageIndex);
+ void onPageSwitching(View newPage, int newPageIndex);
+ void onPageSwitched(View newPage, int newPageIndex);
}
public PagedView(Context context) {
public void setPageSwitchListener(PageSwitchListener pageSwitchListener) {
mPageSwitchListener = pageSwitchListener;
if (mPageSwitchListener != null) {
- mPageSwitchListener.onPageSwitch(getPageAt(mCurrentPage), mCurrentPage);
+ mPageSwitchListener.onPageSwitched(getPageAt(mCurrentPage), mCurrentPage);
}
}
* Sets the current page.
*/
void setCurrentPage(int currentPage) {
+ notifyPageSwitching(currentPage);
if (!mScroller.isFinished()) {
mScroller.abortAnimation();
}
mCurrentPage = Math.max(0, Math.min(currentPage, getPageCount() - 1));
updateCurrentPageScroll();
updateScrollingIndicator();
- notifyPageSwitchListener();
+ notifyPageSwitched();
invalidate();
}
mOnlyAllowEdgeSwipes = enable;
}
- protected void notifyPageSwitchListener() {
+ protected void notifyPageSwitching(int whichPage) {
if (mPageSwitchListener != null) {
- mPageSwitchListener.onPageSwitch(getPageAt(mCurrentPage), mCurrentPage);
+ mPageSwitchListener.onPageSwitching(getPageAt(whichPage), whichPage);
+ }
+ }
+
+ protected void notifyPageSwitched() {
+ if (mPageSwitchListener != null) {
+ mPageSwitchListener.onPageSwitched(getPageAt(mCurrentPage), mCurrentPage);
}
}
} else if (mNextPage != INVALID_PAGE) {
mCurrentPage = Math.max(0, Math.min(mNextPage, getPageCount() - 1));
mNextPage = INVALID_PAGE;
- notifyPageSwitchListener();
+ notifyPageSwitched();
// We don't want to trigger a page end moving unless the page has settled
// and the user has stopped scrolling
}
protected void snapToPage(int whichPage, int delta, int duration, boolean immediate) {
mNextPage = whichPage;
-
+ notifyPageSwitching(whichPage);
View focusedChild = getFocusedChild();
if (focusedChild != null && whichPage != mCurrentPage &&
focusedChild == getPageAt(mCurrentPage)) {
if (!mScroller.isFinished()) mScroller.abortAnimation();
mScroller.startScroll(mUnboundedScrollX, 0, delta, 0, duration);
- notifyPageSwitchListener();
+ notifyPageSwitched();
// Trigger a compute() to finish switching pages if necessary
if (immediate) {
private final Rect mTempRect = new Rect();
private boolean mHasGlowpad;
+ private boolean mChallengeInteractive = true;
static final Property<SlidingChallengeLayout, Float> HANDLE_ALPHA =
new FloatProperty<SlidingChallengeLayout>("handleAlpha") {
private final OnClickListener mExpandChallengeClickListener = new OnClickListener() {
@Override
public void onClick(View v) {
- if (!isChallengeShowing()) {
+ if (!isChallengeShowing() && mChallengeInteractive) {
showChallenge(true);
}
}
}
}
+ public void setChallengeInteractive(boolean interactive) {
+ mChallengeInteractive = interactive;
+ }
+
void animateHandle(boolean visible) {
if (mHandleAnimation != null) {
mHandleAnimation.cancel();
for (int i = 0; i < count; i++) {
final float x = ev.getX(i);
final float y = ev.getY(i);
- if (!mIsBouncing && mActivePointerId == INVALID_POINTER
+ if (!mIsBouncing && mChallengeInteractive && mActivePointerId == INVALID_POINTER
&& (crossedDragHandle(x, y, mGestureStartY)
|| (isInChallengeView(x, y) &&
mScrollState == SCROLL_STATE_SETTLING))) {
break;
case MotionEvent.ACTION_CANCEL:
- if (mDragging) {
+ if (mDragging && mChallengeInteractive) {
showChallenge(0);
}
resetTouch();
break;
}
case MotionEvent.ACTION_UP:
- if (mDragging) {
+ if (mDragging && mChallengeInteractive) {
mVelocityTracker.computeCurrentVelocity(1000, mMaxVelocity);
showChallenge((int) mVelocityTracker.getYVelocity(mActivePointerId));
}
if ((isInDragHandle(x, y) || crossedDragHandle(x, y, mGestureStartY) ||
(isInChallengeView(x, y) && mScrollState == SCROLL_STATE_SETTLING))
- && mActivePointerId == INVALID_POINTER) {
+ && mActivePointerId == INVALID_POINTER
+ && mChallengeInteractive) {
mGestureStartX = x;
mGestureStartY = y;
mActivePointerId = ev.getPointerId(i);