Merge "Improve TaskMenuView layouts for split pairs" into tm-qpr-dev
This commit is contained in:
commit
b9b7c38d55
6 files changed
+72
-175
No files matched your search
@@ -1,6 +1,5 @@
|
||||
package com.android.quickstep.views;
|
||||
|
||||
import static com.android.launcher3.AbstractFloatingView.getAnyView;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.DEFAULT_SPLIT_RATIO;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT;
|
||||
@@ -14,7 +13,6 @@ import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.AbstractFloatingView;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
@@ -177,21 +175,6 @@ public class GroupedTaskView extends TaskView {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean showTaskMenuWithContainer(IconView iconView) {
|
||||
boolean showedTaskMenu = super.showTaskMenuWithContainer(iconView);
|
||||
if (iconView == mIconView2 && showedTaskMenu && !mActivity.getDeviceProfile().isTablet) {
|
||||
// Adjust the position of the secondary task's menu view (only on phones)
|
||||
TaskMenuView taskMenuView = getAnyView(mActivity, AbstractFloatingView.TYPE_TASK_MENU);
|
||||
DeviceProfile deviceProfile = mActivity.getDeviceProfile();
|
||||
getRecentsView().getPagedOrientationHandler()
|
||||
.setSecondaryTaskMenuPosition(mSplitBoundsConfig, this,
|
||||
deviceProfile, mTaskIdAttributeContainer[0].getThumbnailView(),
|
||||
taskMenuView);
|
||||
}
|
||||
return showedTaskMenu;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public RunnableList launchTaskAnimated() {
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Outline;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.graphics.drawable.shapes.RectShape;
|
||||
@@ -32,7 +31,6 @@ import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.view.ViewTreeObserver.OnScrollChangedListener;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -56,13 +54,12 @@ import com.android.quickstep.views.TaskView.TaskIdAttributeContainer;
|
||||
/**
|
||||
* Contains options for a recent task when long-pressing its icon.
|
||||
*/
|
||||
public class TaskMenuView extends AbstractFloatingView implements OnScrollChangedListener {
|
||||
public class TaskMenuView extends AbstractFloatingView {
|
||||
|
||||
private static final Rect sTempRect = new Rect();
|
||||
|
||||
private static final int REVEAL_OPEN_DURATION = 150;
|
||||
private static final int REVEAL_CLOSE_DURATION = 100;
|
||||
private final float mTaskInsetMargin;
|
||||
|
||||
private BaseDraggingActivity mActivity;
|
||||
private TextView mTaskName;
|
||||
@@ -81,7 +78,6 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange
|
||||
|
||||
mActivity = BaseDraggingActivity.fromContext(context);
|
||||
setClipToOutline(true);
|
||||
mTaskInsetMargin = getResources().getDimension(R.dimen.task_card_margin);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -129,33 +125,6 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange
|
||||
};
|
||||
}
|
||||
|
||||
private void setPosition(float x, float y, int overscrollShift) {
|
||||
PagedOrientationHandler pagedOrientationHandler = mTaskView.getPagedOrientationHandler();
|
||||
// Inset due to margin
|
||||
PointF additionalInset = pagedOrientationHandler
|
||||
.getAdditionalInsetForTaskMenu(mTaskInsetMargin);
|
||||
DeviceProfile deviceProfile = mActivity.getDeviceProfile();
|
||||
int taskTopMargin = deviceProfile.overviewTaskThumbnailTopMarginPx;
|
||||
|
||||
float adjustedY = y + taskTopMargin - additionalInset.y;
|
||||
float adjustedX = x - additionalInset.x;
|
||||
// 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);
|
||||
if (deviceProfile.isTablet) {
|
||||
// In tablet, set pivotY to original position without mThumbnailTopMargin adjustment.
|
||||
setPivotY(-taskTopMargin);
|
||||
} else {
|
||||
setPivotY(0);
|
||||
}
|
||||
setRotation(pagedOrientationHandler.getDegreesRotated());
|
||||
setX(pagedOrientationHandler.getTaskMenuX(adjustedX,
|
||||
mTaskContainer.getThumbnailView(), overscrollShift, deviceProfile));
|
||||
setY(pagedOrientationHandler.getTaskMenuY(
|
||||
adjustedY, mTaskContainer.getThumbnailView(), overscrollShift));
|
||||
}
|
||||
|
||||
public void onRotationChanged() {
|
||||
if (mOpenCloseAnimator != null && mOpenCloseAnimator.isRunning()) {
|
||||
mOpenCloseAnimator.end();
|
||||
@@ -187,17 +156,9 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange
|
||||
return false;
|
||||
}
|
||||
post(this::animateOpen);
|
||||
((RecentsView) mActivity.getOverviewPanel()).addOnScrollChangedListener(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollChanged() {
|
||||
RecentsView rv = mActivity.getOverviewPanel();
|
||||
setPosition(mTaskView.getX() - rv.getScrollX(), mTaskView.getY() - rv.getScrollY(),
|
||||
rv.getOverScrollShift());
|
||||
}
|
||||
|
||||
/** @return true if successfully able to populate task view menu, false otherwise */
|
||||
private boolean populateAndLayoutMenu() {
|
||||
if (mTaskContainer.getTask().icon == null) {
|
||||
@@ -234,18 +195,18 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange
|
||||
RecentsView recentsView = mActivity.getOverviewPanel();
|
||||
PagedOrientationHandler orientationHandler = recentsView.getPagedOrientationHandler();
|
||||
measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
|
||||
orientationHandler.setTaskMenuAroundTaskView(this, mTaskInsetMargin);
|
||||
|
||||
// Get Position
|
||||
DeviceProfile deviceProfile = mActivity.getDeviceProfile();
|
||||
mActivity.getDragLayer().getDescendantRectRelativeToSelf(mTaskView, sTempRect);
|
||||
mActivity.getDragLayer().getDescendantRectRelativeToSelf(taskContainer.getThumbnailView(),
|
||||
sTempRect);
|
||||
Rect insets = mActivity.getDragLayer().getInsets();
|
||||
BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) getLayoutParams();
|
||||
int padding = getResources()
|
||||
.getDimensionPixelSize(R.dimen.task_menu_vertical_padding);
|
||||
params.width = orientationHandler
|
||||
.getTaskMenuWidth(taskContainer.getThumbnailView(),
|
||||
deviceProfile) - (2 * padding);
|
||||
deviceProfile, taskContainer.getStagePosition()) - (2 * padding);
|
||||
// Gravity set to Left instead of Start as sTempRect.left measures Left distance not Start
|
||||
params.gravity = Gravity.LEFT;
|
||||
setLayoutParams(params);
|
||||
@@ -260,7 +221,22 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange
|
||||
|
||||
orientationHandler.setTaskOptionsMenuLayoutOrientation(
|
||||
deviceProfile, mOptionLayout, dividerSpacing, divider);
|
||||
setPosition(sTempRect.left - insets.left, sTempRect.top - insets.top, 0);
|
||||
float thumbnailAlignedX = sTempRect.left - insets.left;
|
||||
float thumbnailAlignedY = sTempRect.top - insets.top;
|
||||
// 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(orientationHandler.getDegreesRotated());
|
||||
|
||||
// Margin that insets the menuView inside the taskView
|
||||
float taskInsetMargin = getResources().getDimension(R.dimen.task_card_margin);
|
||||
setTranslationX(orientationHandler.getTaskMenuX(thumbnailAlignedX,
|
||||
mTaskContainer.getThumbnailView(), deviceProfile, taskInsetMargin));
|
||||
setTranslationY(orientationHandler.getTaskMenuY(
|
||||
thumbnailAlignedY, mTaskContainer.getThumbnailView(),
|
||||
mTaskContainer.getStagePosition(), this, taskInsetMargin));
|
||||
}
|
||||
|
||||
private void animateOpen() {
|
||||
@@ -306,7 +282,6 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange
|
||||
private void closeComplete() {
|
||||
mIsOpen = false;
|
||||
mActivity.getDragLayer().removeView(this);
|
||||
((RecentsView) mActivity.getOverviewPanel()).removeOnScrollChangedListener(this);
|
||||
}
|
||||
|
||||
private RoundedRectRevealOutlineProvider createOpenCloseOutlineProvider() {
|
||||
|
||||
Reference in new issue
Block a user