summaryrefslogtreecommitdiffstats
path: root/quickstep
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2017-12-13 21:46:19 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-12-13 21:46:19 +0000
commit5f7335741db25ce421512f4ca5773c3a1184a26b (patch)
treeae2207764c393a310b87dba5a05cab3f064f4667 /quickstep
parent30d276cb92f507170311ff11463d8b0bdf949bae (diff)
parentb744a6778556598c96c0566b55d5b61514161481 (diff)
downloadandroid_packages_apps_Trebuchet-5f7335741db25ce421512f4ca5773c3a1184a26b.tar.gz
android_packages_apps_Trebuchet-5f7335741db25ce421512f4ca5773c3a1184a26b.tar.bz2
android_packages_apps_Trebuchet-5f7335741db25ce421512f4ca5773c3a1184a26b.zip
Merge "Swipe from nav bar to enter overview in landscape" into ub-launcher3-master
Diffstat (limited to 'quickstep')
-rw-r--r--quickstep/src/com/android/launcher3/uioverrides/TwoStepSwipeController.java2
-rw-r--r--quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java22
-rw-r--r--quickstep/src/com/android/quickstep/TaskThumbnailView.java21
-rw-r--r--quickstep/src/com/android/quickstep/TouchInteractionService.java34
4 files changed, 57 insertions, 22 deletions
diff --git a/quickstep/src/com/android/launcher3/uioverrides/TwoStepSwipeController.java b/quickstep/src/com/android/launcher3/uioverrides/TwoStepSwipeController.java
index 20cda1cec..435d57e7e 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/TwoStepSwipeController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/TwoStepSwipeController.java
@@ -367,7 +367,7 @@ public class TwoStepSwipeController extends AnimatorListenerAdapter
mCurrentAnimation.setEndAction(() -> {
// TODO: Add logging
clearState();
- mLauncher.getStateManager().goToState(OVERVIEW, false /* animated */);
+ mLauncher.getStateManager().goToState(OVERVIEW, true /* animated */);
});
if (mTwoStateAnimationController != null) {
diff --git a/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java b/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
index 965696fe3..43a01a79c 100644
--- a/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
+++ b/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
@@ -199,9 +199,9 @@ public class NavBarSwipeInteractionHandler extends InternalStateHandler {
private void executeFrameUpdate() {
if (mLauncherReady) {
final float displacement = -mCurrentDisplacement;
- int hotseatHeight = mHotseat.getHeight();
- float translation = Utilities.boundToRange(displacement, 0, hotseatHeight);
- float shift = hotseatHeight == 0 ? 0 : translation / hotseatHeight;
+ int hotseatSize = getHotseatSize();
+ float translation = Utilities.boundToRange(displacement, 0, hotseatSize);
+ float shift = hotseatSize == 0 ? 0 : translation / hotseatSize;
mCurrentShift.updateValue(shift);
}
}
@@ -215,13 +215,14 @@ public class NavBarSwipeInteractionHandler extends InternalStateHandler {
if (mTargetRect.isEmpty()) {
RecentsView.getPageRect(mLauncher, mTargetRect);
DragLayer dl = mLauncher.getDragLayer();
- mSourceRect.set(0, 0, dl.getWidth(), dl.getHeight());
+ mSourceRect.set(0, 0, dl.getWidth() - mStableInsets.left - mStableInsets.right,
+ dl.getHeight() - mStableInsets.top - mStableInsets.bottom);
}
float shift = mCurrentShift.value * mActivityMultiplier.value;
- int hotseatHeight = mHotseat.getHeight();
+ int hotseatSize = getHotseatSize();
- mHotseat.setTranslationY((1 - shift) * hotseatHeight);
+ mHotseat.setTranslationY((1 - shift) * hotseatSize);
mRectEvaluator.evaluate(shift, mSourceRect, mTargetRect);
@@ -230,10 +231,17 @@ public class NavBarSwipeInteractionHandler extends InternalStateHandler {
mDragView.setTranslationY(mCurrentRect.top - mStableInsets.top * scale * shift);
mDragView.setScaleX(scale);
mDragView.setScaleY(scale);
+ // TODO: mDragView.getViewBounds().setClipLeft((int) (mStableInsets.left * shift));
mDragView.getViewBounds().setClipTop((int) (mStableInsets.top * shift));
+ // TODO: mDragView.getViewBounds().setClipRight((int) (mStableInsets.right * shift));
mDragView.getViewBounds().setClipBottom((int) (mStableInsets.bottom * shift));
}
+ private int getHotseatSize() {
+ return mLauncher.getDeviceProfile().isVerticalBarLayout()
+ ? mHotseat.getWidth() : mHotseat.getHeight();
+ }
+
@UiThread
public void setRecentsTaskLoadPlan(RecentsTaskLoadPlan loadPlan) {
mLoadPlan = loadPlan;
@@ -272,7 +280,7 @@ public class NavBarSwipeInteractionHandler extends InternalStateHandler {
endShift = endVelocity < 0 ? 1 : 0;
float minFlingVelocity = res.getDimension(R.dimen.quickstep_fling_min_velocity);
if (Math.abs(endVelocity) > minFlingVelocity && mLauncherReady) {
- float distanceToTravel = (endShift - mCurrentShift.value) * mHotseat.getHeight();
+ float distanceToTravel = (endShift - mCurrentShift.value) * getHotseatSize();
// we want the page's snap velocity to approximately match the velocity at
// which the user flings, so we scale the duration by a value near to the
diff --git a/quickstep/src/com/android/quickstep/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/TaskThumbnailView.java
index 6e8bbeb46..4a9bfead5 100644
--- a/quickstep/src/com/android/quickstep/TaskThumbnailView.java
+++ b/quickstep/src/com/android/quickstep/TaskThumbnailView.java
@@ -25,7 +25,6 @@ import android.graphics.Color;
import android.graphics.LightingColorFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
-import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Shader;
import android.util.AttributeSet;
@@ -154,17 +153,15 @@ public class TaskThumbnailView extends FrameLayout {
final Configuration configuration =
getContext().getApplicationContext().getResources().getConfiguration();
final DeviceProfile profile = Launcher.getLauncher(getContext()).getDeviceProfile();
- if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
- if (mThumbnailData.orientation == Configuration.ORIENTATION_PORTRAIT) {
- // If we are in the same orientation as the screenshot, just scale it to the
- // width of the task view
- mThumbnailScale = (float) getMeasuredWidth() / mThumbnailRect.width();
- } else {
- // Scale the landscape thumbnail up to app size, then scale that to the task
- // view size to match other portrait screenshots
- mThumbnailScale = invThumbnailScale *
- ((float) getMeasuredWidth() / profile.getCurrentWidth());
- }
+ if (configuration.orientation == mThumbnailData.orientation) {
+ // If we are in the same orientation as the screenshot, just scale it to the
+ // width of the task view
+ mThumbnailScale = (float) getMeasuredWidth() / mThumbnailRect.width();
+ } else if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
+ // Scale the landscape thumbnail up to app size, then scale that to the task
+ // view size to match other portrait screenshots
+ mThumbnailScale = invThumbnailScale *
+ ((float) getMeasuredWidth() / profile.getCurrentWidth());
} else {
// Otherwise, scale the screenshot to fit 1:1 in the current orientation
mThumbnailScale = invThumbnailScale;
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index 7b220d8ed..f457a59cb 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -44,6 +44,7 @@ import android.util.Log;
import android.view.Choreographer;
import android.view.Display;
import android.view.MotionEvent;
+import android.view.Surface;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
@@ -61,6 +62,7 @@ import com.android.systemui.shared.recents.model.RecentsTaskLoadPlan.PreloadOpti
import com.android.systemui.shared.recents.model.RecentsTaskLoader;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.BackgroundExecutor;
+import com.android.systemui.shared.system.WindowManagerWrapper;
import java.util.function.Consumer;
@@ -105,6 +107,8 @@ public class TouchInteractionService extends Service {
private int mTouchSlop;
private float mStartDisplacement;
private NavBarSwipeInteractionHandler mInteractionHandler;
+ private int mDisplayRotation;
+ private Rect mStableInsets = new Rect();
private ISystemUiProxy mISystemUiProxy;
private Consumer<MotionEvent> mCurrentConsumer = mNoOpTouchConsumer;
@@ -181,6 +185,10 @@ public class TouchInteractionService extends Service {
mInteractionHandler.endTouch(0);
mInteractionHandler = null;
}
+
+ Display display = getSystemService(WindowManager.class).getDefaultDisplay();
+ mDisplayRotation = display.getRotation();
+ WindowManagerWrapper.getInstance().getStableInsets(mStableInsets);
break;
}
case ACTION_POINTER_UP: {
@@ -206,6 +214,11 @@ public class TouchInteractionService extends Service {
mLastPos.set(ev.getX(pointerIndex), ev.getY(pointerIndex));
float displacement = ev.getY(pointerIndex) - mDownPos.y;
+ if (isNavBarOnRight()) {
+ displacement = ev.getX(pointerIndex) - mDownPos.x;
+ } else if (isNavBarOnLeft()) {
+ displacement = mDownPos.x - ev.getX(pointerIndex);
+ }
if (mInteractionHandler == null) {
if (Math.abs(displacement) >= mTouchSlop) {
mStartDisplacement = Math.signum(displacement) * mTouchSlop;
@@ -229,6 +242,13 @@ public class TouchInteractionService extends Service {
}
}
+ private boolean isNavBarOnRight() {
+ return mDisplayRotation == Surface.ROTATION_90 && mStableInsets.right > 0;
+ }
+
+ private boolean isNavBarOnLeft() {
+ return mDisplayRotation == Surface.ROTATION_270 && mStableInsets.left > 0;
+ }
private void startTouchTracking() {
// Create the shared handler
@@ -272,7 +292,10 @@ public class TouchInteractionService extends Service {
mVelocityTracker.computeCurrentVelocity(1000,
ViewConfiguration.get(this).getScaledMaximumFlingVelocity());
- mInteractionHandler.endTouch(mVelocityTracker.getYVelocity(mActivePointerId));
+ float velocity = isNavBarOnRight() ? mVelocityTracker.getXVelocity(mActivePointerId)
+ : isNavBarOnLeft() ? -mVelocityTracker.getXVelocity(mActivePointerId)
+ : mVelocityTracker.getYVelocity(mActivePointerId);
+ mInteractionHandler.endTouch(velocity);
mInteractionHandler = null;
}
mVelocityTracker.recycle();
@@ -290,9 +313,16 @@ public class TouchInteractionService extends Service {
Point displaySize = new Point();
Display display = getSystemService(WindowManager.class).getDefaultDisplay();
display.getRealSize(displaySize);
+ int rotation = display.getRotation();
+ // The rotation is backwards in landscape, so flip it.
+ if (rotation == Surface.ROTATION_270) {
+ rotation = Surface.ROTATION_90;
+ } else if (rotation == Surface.ROTATION_90) {
+ rotation = Surface.ROTATION_270;
+ }
try {
return mISystemUiProxy.screenshot(new Rect(), displaySize.x, displaySize.y, 0, 100000,
- false, display.getRotation()).toBitmap();
+ false, rotation).toBitmap();
} catch (RemoteException e) {
Log.e(TAG, "Error capturing snapshot", e);
return null;