Merge "Sysui: Align projection permission dialog checkbox." into lmp-mr1-dev
diff --git a/packages/SystemUI/res/layout/qs_detail_item.xml b/packages/SystemUI/res/layout/qs_detail_item.xml
index 55139fb..ea2e1e1 100644
--- a/packages/SystemUI/res/layout/qs_detail_item.xml
+++ b/packages/SystemUI/res/layout/qs_detail_item.xml
@@ -31,7 +31,7 @@
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
- android:layout_marginStart="20dp"
+ android:layout_marginStart="12dp"
android:layout_weight="1"
android:orientation="vertical" >
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 5caa866..841bef5 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -321,7 +321,7 @@
<dimen name="heads_up_window_height">250dp</dimen>
<!-- The minimum amount the user needs to swipe to go to the camera / phone. -->
- <dimen name="keyguard_min_swipe_amount">90dp</dimen>
+ <dimen name="keyguard_min_swipe_amount">110dp</dimen>
<!-- The minimum background radius when swiping to a side for the camera / phone affordances. -->
<dimen name="keyguard_affordance_min_background_radius">30dp</dimen>
diff --git a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
index 4857adc..0516768 100644
--- a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
+++ b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
@@ -174,7 +174,7 @@
public void trimMemory(int level) {
if (level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW &&
- mBackground != null && mIsHwAccelerated) {
+ mBackground != null) {
if (DEBUG) {
Log.d(TAG, "trimMemory");
}
@@ -212,6 +212,7 @@
unregisterReceiver(mReceiver);
}
mBackground = null;
+ mWallpaperManager.forgetLoadedWallpaper();
}
void updateSurfaceSize(SurfaceHolder surfaceHolder) {
@@ -337,111 +338,116 @@
}
void drawFrame() {
- int newRotation = ((WindowManager) getSystemService(WINDOW_SERVICE)).
- getDefaultDisplay().getRotation();
+ try {
+ int newRotation = ((WindowManager) getSystemService(WINDOW_SERVICE)).
+ getDefaultDisplay().getRotation();
- // Sometimes a wallpaper is not large enough to cover the screen in one dimension.
- // Call updateSurfaceSize -- it will only actually do the update if the dimensions
- // should change
- if (newRotation != mLastRotation) {
- // Update surface size (if necessary)
- updateSurfaceSize(getSurfaceHolder());
- }
- SurfaceHolder sh = getSurfaceHolder();
- final Rect frame = sh.getSurfaceFrame();
- final int dw = frame.width();
- final int dh = frame.height();
- boolean surfaceDimensionsChanged = dw != mLastSurfaceWidth || dh != mLastSurfaceHeight;
-
- boolean redrawNeeded = surfaceDimensionsChanged || newRotation != mLastRotation;
- if (!redrawNeeded && !mOffsetsChanged) {
- if (DEBUG) {
- Log.d(TAG, "Suppressed drawFrame since redraw is not needed "
- + "and offsets have not changed.");
+ // Sometimes a wallpaper is not large enough to cover the screen in one dimension.
+ // Call updateSurfaceSize -- it will only actually do the update if the dimensions
+ // should change
+ if (newRotation != mLastRotation) {
+ // Update surface size (if necessary)
+ updateSurfaceSize(getSurfaceHolder());
}
- return;
- }
- mLastRotation = newRotation;
+ SurfaceHolder sh = getSurfaceHolder();
+ final Rect frame = sh.getSurfaceFrame();
+ final int dw = frame.width();
+ final int dh = frame.height();
+ boolean surfaceDimensionsChanged = dw != mLastSurfaceWidth
+ || dh != mLastSurfaceHeight;
- // Load bitmap if it is not yet loaded or if it was loaded at a different size
- if (mBackground == null || surfaceDimensionsChanged) {
- if (DEBUG) {
- Log.d(TAG, "Reloading bitmap: mBackground, bgw, bgh, dw, dh = " +
- mBackground + ", " +
- ((mBackground == null) ? 0 : mBackground.getWidth()) + ", " +
- ((mBackground == null) ? 0 : mBackground.getHeight()) + ", " +
- dw + ", " + dh);
- }
- mWallpaperManager.forgetLoadedWallpaper();
- updateWallpaperLocked();
- if (mBackground == null) {
+ boolean redrawNeeded = surfaceDimensionsChanged || newRotation != mLastRotation;
+ if (!redrawNeeded && !mOffsetsChanged) {
if (DEBUG) {
- Log.d(TAG, "Unable to load bitmap");
+ Log.d(TAG, "Suppressed drawFrame since redraw is not needed "
+ + "and offsets have not changed.");
}
return;
}
- if (DEBUG) {
- if (dw != mBackground.getWidth() || dh != mBackground.getHeight()) {
- Log.d(TAG, "Surface != bitmap dimensions: surface w/h, bitmap w/h: " +
- dw + ", " + dh + ", " + mBackground.getWidth() + ", " +
- mBackground.getHeight());
+ mLastRotation = newRotation;
+
+ // Load bitmap if it is not yet loaded or if it was loaded at a different size
+ if (mBackground == null || surfaceDimensionsChanged) {
+ if (DEBUG) {
+ Log.d(TAG, "Reloading bitmap: mBackground, bgw, bgh, dw, dh = " +
+ mBackground + ", " +
+ ((mBackground == null) ? 0 : mBackground.getWidth()) + ", " +
+ ((mBackground == null) ? 0 : mBackground.getHeight()) + ", " +
+ dw + ", " + dh);
+ }
+ mWallpaperManager.forgetLoadedWallpaper();
+ updateWallpaperLocked();
+ if (mBackground == null) {
+ if (DEBUG) {
+ Log.d(TAG, "Unable to load bitmap");
+ }
+ return;
+ }
+ if (DEBUG) {
+ if (dw != mBackground.getWidth() || dh != mBackground.getHeight()) {
+ Log.d(TAG, "Surface != bitmap dimensions: surface w/h, bitmap w/h: " +
+ dw + ", " + dh + ", " + mBackground.getWidth() + ", " +
+ mBackground.getHeight());
+ }
}
}
- }
- // Center the scaled image
- mScale = Math.max(1f, Math.max(dw / (float) mBackground.getWidth(),
- dh / (float) mBackground.getHeight()));
- final int availw = dw - (int) (mBackground.getWidth() * mScale);
- final int availh = dh - (int) (mBackground.getHeight() * mScale);
- int xPixels = availw / 2;
- int yPixels = availh / 2;
+ // Center the scaled image
+ mScale = Math.max(1f, Math.max(dw / (float) mBackground.getWidth(),
+ dh / (float) mBackground.getHeight()));
+ final int availw = dw - (int) (mBackground.getWidth() * mScale);
+ final int availh = dh - (int) (mBackground.getHeight() * mScale);
+ int xPixels = availw / 2;
+ int yPixels = availh / 2;
- // Adjust the image for xOffset/yOffset values. If window manager is handling offsets,
- // mXOffset and mYOffset are set to 0.5f by default and therefore xPixels and yPixels
- // will remain unchanged
- final int availwUnscaled = dw - mBackground.getWidth();
- final int availhUnscaled = dh - mBackground.getHeight();
- if (availwUnscaled < 0) xPixels += (int)(availwUnscaled * (mXOffset - .5f) + .5f);
- if (availhUnscaled < 0) yPixels += (int)(availhUnscaled * (mYOffset - .5f) + .5f);
+ // Adjust the image for xOffset/yOffset values. If window manager is handling offsets,
+ // mXOffset and mYOffset are set to 0.5f by default and therefore xPixels and yPixels
+ // will remain unchanged
+ final int availwUnscaled = dw - mBackground.getWidth();
+ final int availhUnscaled = dh - mBackground.getHeight();
+ if (availwUnscaled < 0)
+ xPixels += (int) (availwUnscaled * (mXOffset - .5f) + .5f);
+ if (availhUnscaled < 0)
+ yPixels += (int) (availhUnscaled * (mYOffset - .5f) + .5f);
- mOffsetsChanged = false;
- mRedrawNeeded = false;
- if (surfaceDimensionsChanged) {
- mLastSurfaceWidth = dw;
- mLastSurfaceHeight = dh;
- }
- if (!redrawNeeded && xPixels == mLastXTranslation && yPixels == mLastYTranslation) {
- if (DEBUG) {
- Log.d(TAG, "Suppressed drawFrame since the image has not "
- + "actually moved an integral number of pixels.");
+ mOffsetsChanged = false;
+ mRedrawNeeded = false;
+ if (surfaceDimensionsChanged) {
+ mLastSurfaceWidth = dw;
+ mLastSurfaceHeight = dh;
}
- return;
- }
- mLastXTranslation = xPixels;
- mLastYTranslation = yPixels;
+ if (!redrawNeeded && xPixels == mLastXTranslation && yPixels == mLastYTranslation) {
+ if (DEBUG) {
+ Log.d(TAG, "Suppressed drawFrame since the image has not "
+ + "actually moved an integral number of pixels.");
+ }
+ return;
+ }
+ mLastXTranslation = xPixels;
+ mLastYTranslation = yPixels;
- if (DEBUG) {
- Log.d(TAG, "Redrawing wallpaper");
- }
+ if (DEBUG) {
+ Log.d(TAG, "Redrawing wallpaper");
+ }
- if (mIsHwAccelerated) {
- if (!drawWallpaperWithOpenGL(sh, availw, availh, xPixels, yPixels)) {
+ if (mIsHwAccelerated) {
+ if (!drawWallpaperWithOpenGL(sh, availw, availh, xPixels, yPixels)) {
+ drawWallpaperWithCanvas(sh, availw, availh, xPixels, yPixels);
+ }
+ } else {
drawWallpaperWithCanvas(sh, availw, availh, xPixels, yPixels);
}
- } else {
- drawWallpaperWithCanvas(sh, availw, availh, xPixels, yPixels);
- if (FIXED_SIZED_SURFACE) {
+ } finally {
+ if (FIXED_SIZED_SURFACE && !mIsHwAccelerated) {
// If the surface is fixed-size, we should only need to
// draw it once and then we'll let the window manager
// position it appropriately. As such, we no longer needed
// the loaded bitmap. Yay!
- // hw-accelerated path retains bitmap for faster rotation
+ // hw-accelerated renderer retains bitmap for faster rotation
mBackground = null;
mWallpaperManager.forgetLoadedWallpaper();
}
}
-
}
private void updateWallpaperLocked() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java
index 4667d56..58a2d41 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java
@@ -46,7 +46,6 @@
private FlingAnimationUtils mFlingAnimationUtils;
private Callback mCallback;
- private int mTrackingPointer;
private VelocityTracker mVelocityTracker;
private boolean mSwipingInProgress;
private float mInitialTouchX;
@@ -65,6 +64,7 @@
private Animator mSwipeAnimator;
private int mMinBackgroundRadius;
private boolean mMotionPerformedByUser;
+ private boolean mMotionCancelled;
private AnimatorListenerAdapter mFlingEndListener = new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
@@ -117,13 +117,11 @@
}
public boolean onTouchEvent(MotionEvent event) {
- int pointerIndex = event.findPointerIndex(mTrackingPointer);
- if (pointerIndex < 0) {
- pointerIndex = 0;
- mTrackingPointer = event.getPointerId(pointerIndex);
+ if (mMotionCancelled && event.getActionMasked() != MotionEvent.ACTION_DOWN) {
+ return false;
}
- final float y = event.getY(pointerIndex);
- final float x = event.getX(pointerIndex);
+ final float y = event.getY();
+ final float x = event.getX();
boolean isUp = false;
switch (event.getActionMasked()) {
@@ -137,22 +135,12 @@
initVelocityTracker();
trackMovement(event);
mMotionPerformedByUser = false;
+ mMotionCancelled = false;
break;
-
- case MotionEvent.ACTION_POINTER_UP:
- final int upPointer = event.getPointerId(event.getActionIndex());
- if (mTrackingPointer == upPointer) {
- // gesture is ongoing, find a new pointer to track
- final int newIndex = event.getPointerId(0) != upPointer ? 0 : 1;
- final float newY = event.getY(newIndex);
- final float newX = event.getX(newIndex);
- mTrackingPointer = event.getPointerId(newIndex);
- mInitialTouchY = newY;
- mInitialTouchX = newX;
- mTranslationOnDown = mTranslation;
- }
+ case MotionEvent.ACTION_POINTER_DOWN:
+ mMotionCancelled = true;
+ endMotion(event, true /* forceSnapBack */);
break;
-
case MotionEvent.ACTION_MOVE:
final float w = x - mInitialTouchX;
trackMovement(event);
@@ -174,20 +162,23 @@
case MotionEvent.ACTION_UP:
isUp = true;
case MotionEvent.ACTION_CANCEL:
- mTrackingPointer = -1;
trackMovement(event);
- if (mSwipingInProgress) {
- flingWithCurrentVelocity(!isUp);
- }
- if (mVelocityTracker != null) {
- mVelocityTracker.recycle();
- mVelocityTracker = null;
- }
+ endMotion(event, !isUp);
break;
}
return true;
}
+ private void endMotion(MotionEvent event, boolean forceSnapBack) {
+ if (mSwipingInProgress) {
+ flingWithCurrentVelocity(forceSnapBack);
+ }
+ if (mVelocityTracker != null) {
+ mVelocityTracker.recycle();
+ mVelocityTracker = null;
+ }
+ }
+
private void setSwipingInProgress(boolean inProgress) {
mSwipingInProgress = inProgress;
if (inProgress) {