Merge "Rotate Overview Task Action Menu" into ub-launcher3-rvc-dev
This commit is contained in:
@@ -40,6 +40,7 @@ import com.android.launcher3.anim.AnimationSuccessListener;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.anim.RoundedRectRevealOutlineProvider;
|
||||
import com.android.launcher3.popup.SystemShortcut;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
import com.android.quickstep.TaskOverlayFactory;
|
||||
@@ -150,9 +151,26 @@ public class TaskMenuView extends AbstractFloatingView {
|
||||
return (type & TYPE_TASK_MENU) != 0;
|
||||
}
|
||||
|
||||
public void setPosition(float x, float y) {
|
||||
setX(x);
|
||||
setY(y + mThumbnailTopMargin);
|
||||
public void setPosition(float x, float y, PagedOrientationHandler pagedOrientationHandler) {
|
||||
float adjustedY = y + mThumbnailTopMargin;
|
||||
// Changing pivot to make computations easier
|
||||
// NOTE: Changing the pivots means the rotated view gets rotated about the new pivots set,
|
||||
// which would render the X and Y position set here incorrect
|
||||
setPivotX(0);
|
||||
setPivotY(0);
|
||||
setRotation(pagedOrientationHandler.getDegreesRotated());
|
||||
setX(pagedOrientationHandler.getTaskMenuX(x, mTaskView.getThumbnail()));
|
||||
setY(pagedOrientationHandler.getTaskMenuY(adjustedY, mTaskView.getThumbnail()));
|
||||
}
|
||||
|
||||
public void onRotationChanged() {
|
||||
if (mOpenCloseAnimator != null && mOpenCloseAnimator.isRunning()) {
|
||||
mOpenCloseAnimator.end();
|
||||
}
|
||||
if (mIsOpen) {
|
||||
mOptionLayout.removeAllViews();
|
||||
populateAndLayoutMenu();
|
||||
}
|
||||
}
|
||||
|
||||
public static TaskMenuView showForTask(TaskView taskView) {
|
||||
@@ -168,12 +186,16 @@ public class TaskMenuView extends AbstractFloatingView {
|
||||
}
|
||||
mActivity.getDragLayer().addView(this);
|
||||
mTaskView = taskView;
|
||||
addMenuOptions(mTaskView);
|
||||
orientAroundTaskView(mTaskView);
|
||||
populateAndLayoutMenu();
|
||||
post(this::animateOpen);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void populateAndLayoutMenu() {
|
||||
addMenuOptions(mTaskView);
|
||||
orientAroundTaskView(mTaskView);
|
||||
}
|
||||
|
||||
private void addMenuOptions(TaskView taskView) {
|
||||
Drawable icon = taskView.getTask().icon.getConstantState().newDrawable();
|
||||
mTaskIcon.setDrawable(icon);
|
||||
@@ -200,21 +222,26 @@ public class TaskMenuView extends AbstractFloatingView {
|
||||
R.layout.task_view_menu_option, this, false);
|
||||
menuOption.setIconAndLabelFor(
|
||||
menuOptionView.findViewById(R.id.icon), menuOptionView.findViewById(R.id.text));
|
||||
LayoutParams lp = (LayoutParams) menuOptionView.getLayoutParams();
|
||||
mTaskView.getPagedOrientationHandler().setLayoutParamsForTaskMenuOptionItem(lp);
|
||||
menuOptionView.setOnClickListener(menuOption);
|
||||
mOptionLayout.addView(menuOptionView);
|
||||
}
|
||||
|
||||
private void orientAroundTaskView(TaskView taskView) {
|
||||
PagedOrientationHandler orientationHandler = taskView.getPagedOrientationHandler();
|
||||
measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
|
||||
mActivity.getDragLayer().getDescendantRectRelativeToSelf(taskView, sTempRect);
|
||||
Rect insets = mActivity.getDragLayer().getInsets();
|
||||
BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) getLayoutParams();
|
||||
params.width = taskView.getMeasuredWidth();
|
||||
params.width = orientationHandler.getTaskMenuWidth(taskView.getThumbnail());
|
||||
params.gravity = Gravity.START;
|
||||
setLayoutParams(params);
|
||||
setScaleX(taskView.getScaleX());
|
||||
setScaleY(taskView.getScaleY());
|
||||
setPosition(sTempRect.left - insets.left, sTempRect.top - insets.top);
|
||||
mOptionLayout.setOrientation(orientationHandler.getTaskMenuLayoutOrientation());
|
||||
setPosition(sTempRect.left - insets.left, sTempRect.top - insets.top,
|
||||
taskView.getPagedOrientationHandler());
|
||||
}
|
||||
|
||||
private void animateOpen() {
|
||||
|
||||
@@ -473,6 +473,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
int iconRotation = orientationState.getTouchRotation();
|
||||
PagedOrientationHandler orientationHandler = orientationState.getOrientationHandler();
|
||||
boolean isRtl = orientationHandler.getRecentsRtlSetting(getResources());
|
||||
LayoutParams snapshotParams = (LayoutParams) mSnapshotView.getLayoutParams();
|
||||
int thumbnailPadding = (int) getResources().getDimension(R.dimen.task_thumbnail_top_margin);
|
||||
LayoutParams iconParams = (LayoutParams) mIconView.getLayoutParams();
|
||||
int rotation = orientationState.getTouchRotationDegrees();
|
||||
@@ -480,7 +481,8 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
case Surface.ROTATION_90:
|
||||
iconParams.gravity = (isRtl ? END : START) | CENTER_VERTICAL;
|
||||
iconParams.rightMargin = -thumbnailPadding;
|
||||
iconParams.leftMargin = iconParams.topMargin = iconParams.bottomMargin = 0;
|
||||
iconParams.leftMargin = 0;
|
||||
iconParams.topMargin = snapshotParams.topMargin / 2;
|
||||
break;
|
||||
case Surface.ROTATION_180:
|
||||
iconParams.gravity = BOTTOM | CENTER_HORIZONTAL;
|
||||
@@ -490,17 +492,21 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
case Surface.ROTATION_270:
|
||||
iconParams.gravity = (isRtl ? END : START) | CENTER_VERTICAL;
|
||||
iconParams.leftMargin = -thumbnailPadding;
|
||||
iconParams.rightMargin = iconParams.topMargin = iconParams.bottomMargin = 0;
|
||||
iconParams.rightMargin = 0;
|
||||
iconParams.topMargin = snapshotParams.topMargin / 2;
|
||||
break;
|
||||
case Surface.ROTATION_0:
|
||||
default:
|
||||
iconParams.gravity = TOP | CENTER_HORIZONTAL;
|
||||
iconParams.leftMargin = iconParams.topMargin = iconParams.rightMargin =
|
||||
iconParams.bottomMargin = 0;
|
||||
iconParams.leftMargin = iconParams.topMargin = iconParams.rightMargin = 0;
|
||||
break;
|
||||
}
|
||||
mIconView.setLayoutParams(iconParams);
|
||||
mIconView.setRotation(rotation);
|
||||
|
||||
if (mMenuView != null) {
|
||||
mMenuView.onRotationChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void setIconAndDimTransitionProgress(float progress, boolean invert) {
|
||||
@@ -607,7 +613,10 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
}
|
||||
|
||||
if (mMenuView != null) {
|
||||
mMenuView.setPosition(getX() - getRecentsView().getScrollX(), getY());
|
||||
PagedOrientationHandler pagedOrientationHandler = getPagedOrientationHandler();
|
||||
RecentsView recentsView = getRecentsView();
|
||||
mMenuView.setPosition(getX() - recentsView.getScrollX(),
|
||||
getY() - recentsView.getScrollY(), pagedOrientationHandler);
|
||||
mMenuView.setScaleX(getScaleX());
|
||||
mMenuView.setScaleY(getScaleY());
|
||||
}
|
||||
@@ -932,6 +941,10 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
return (RecentsView) getParent();
|
||||
}
|
||||
|
||||
PagedOrientationHandler getPagedOrientationHandler() {
|
||||
return getRecentsView().mOrientationState.getOrientationHandler();
|
||||
}
|
||||
|
||||
public void notifyTaskLaunchFailed(String tag) {
|
||||
String msg = "Failed to launch task";
|
||||
if (mTask != null) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.launcher3.touch;
|
||||
|
||||
import static android.widget.ListPopupWindow.WRAP_CONTENT;
|
||||
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
|
||||
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
|
||||
import static com.android.launcher3.touch.SingleAxisSwipeDetector.HORIZONTAL;
|
||||
@@ -30,6 +31,7 @@ import android.view.Surface;
|
||||
import android.view.VelocityTracker;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.PagedView;
|
||||
@@ -223,6 +225,33 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTaskMenuX(float x, View thumbnailView) {
|
||||
return thumbnailView.getMeasuredWidth() + x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTaskMenuY(float y, View thumbnailView) {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTaskMenuWidth(View view) {
|
||||
return view.getMeasuredHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTaskMenuLayoutOrientation() {
|
||||
return LinearLayout.HORIZONTAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLayoutParamsForTaskMenuOptionItem(LinearLayout.LayoutParams lp) {
|
||||
lp.width = 0;
|
||||
lp.height = WRAP_CONTENT;
|
||||
lp.weight = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChildBounds getChildBounds(View child, int childStart, int pageCenter,
|
||||
boolean layoutChild) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.view.MotionEvent;
|
||||
import android.view.VelocityTracker;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.PagedView;
|
||||
@@ -90,6 +91,11 @@ public interface PagedOrientationHandler {
|
||||
void getCurveProperties(PagedView view, Rect insets, CurveProperties out);
|
||||
boolean isGoingUp(float displacement);
|
||||
boolean isLayoutNaturalToLauncher();
|
||||
float getTaskMenuX(float x, View thumbnailView);
|
||||
float getTaskMenuY(float y, View thumbnailView);
|
||||
int getTaskMenuWidth(View view);
|
||||
int getTaskMenuLayoutOrientation();
|
||||
void setLayoutParamsForTaskMenuOptionItem(LinearLayout.LayoutParams lp);
|
||||
|
||||
/**
|
||||
* Maps the velocity from the coordinate plane of the foreground app to that
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.view.Surface;
|
||||
import android.view.VelocityTracker;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.PagedView;
|
||||
@@ -221,6 +222,31 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTaskMenuX(float x, View thumbnailView) {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTaskMenuY(float y, View thumbnailView) {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTaskMenuWidth(View view) {
|
||||
return view.getMeasuredWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTaskMenuLayoutOrientation() {
|
||||
return LinearLayout.VERTICAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLayoutParamsForTaskMenuOptionItem(LinearLayout.LayoutParams lp) {
|
||||
// no-op, defaults are fine
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChildBounds getChildBounds(View child, int childStart, int pageCenter,
|
||||
boolean layoutChild) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.content.res.Resources;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.RectF;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.launcher3.Utilities;
|
||||
|
||||
@@ -64,4 +65,14 @@ public class SeascapePagedViewHandler extends LandscapePagedViewHandler {
|
||||
float oldY = velocity.y;
|
||||
velocity.set(oldY, -oldX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTaskMenuX(float x, View thumbnailView) {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTaskMenuY(float y, View thumbnailView) {
|
||||
return y + thumbnailView.getMeasuredHeight();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user