Merge "Refactoring PagedOrientationHandler to extract functions from to quickstep" into main
This commit is contained in:
@@ -45,7 +45,7 @@ import com.android.launcher3.anim.AnimatorListeners;
|
||||
import com.android.launcher3.anim.PendingAnimation;
|
||||
import com.android.launcher3.anim.PropertySetter;
|
||||
import com.android.launcher3.states.StateAnimationConfig;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
import com.android.quickstep.util.AnimUtils;
|
||||
import com.android.quickstep.util.SplitAnimationTimings;
|
||||
import com.android.quickstep.views.ClearAllButton;
|
||||
@@ -130,7 +130,7 @@ public final class RecentsViewStateController extends
|
||||
}
|
||||
|
||||
// Create transition animations to split select
|
||||
PagedOrientationHandler orientationHandler =
|
||||
RecentsPagedOrientationHandler orientationHandler =
|
||||
((RecentsView) mLauncher.getOverviewPanel()).getPagedOrientationHandler();
|
||||
Pair<FloatProperty, FloatProperty> taskViewsFloat =
|
||||
orientationHandler.getSplitSelectTaskOffset(
|
||||
|
||||
+9
-5
@@ -36,13 +36,13 @@ import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
import com.android.launcher3.anim.PendingAnimation;
|
||||
import com.android.launcher3.touch.BaseSwipeDetector;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.touch.SingleAxisSwipeDetector;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.FlingBlockCheck;
|
||||
import com.android.launcher3.util.TouchController;
|
||||
import com.android.launcher3.util.VibratorWrapper;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
import com.android.quickstep.util.VibrationConstants;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
import com.android.quickstep.views.TaskView;
|
||||
@@ -225,7 +225,8 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
|
||||
mCurrentAnimation.dispatchOnCancel();
|
||||
}
|
||||
|
||||
PagedOrientationHandler orientationHandler = mRecentsView.getPagedOrientationHandler();
|
||||
RecentsPagedOrientationHandler orientationHandler =
|
||||
mRecentsView.getPagedOrientationHandler();
|
||||
mCurrentAnimationIsGoingUp = goingUp;
|
||||
BaseDragLayer dl = mActivity.getDragLayer();
|
||||
final int secondaryLayerDimension = orientationHandler.getSecondaryDimension(dl);
|
||||
@@ -269,7 +270,8 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
|
||||
|
||||
@Override
|
||||
public void onDragStart(boolean start, float startDisplacement) {
|
||||
PagedOrientationHandler orientationHandler = mRecentsView.getPagedOrientationHandler();
|
||||
RecentsPagedOrientationHandler orientationHandler =
|
||||
mRecentsView.getPagedOrientationHandler();
|
||||
if (mCurrentAnimation == null) {
|
||||
reInitAnimationController(orientationHandler.isGoingUp(startDisplacement, mIsRtl));
|
||||
mDisplacementShift = 0;
|
||||
@@ -283,7 +285,8 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
|
||||
|
||||
@Override
|
||||
public boolean onDrag(float displacement) {
|
||||
PagedOrientationHandler orientationHandler = mRecentsView.getPagedOrientationHandler();
|
||||
RecentsPagedOrientationHandler orientationHandler =
|
||||
mRecentsView.getPagedOrientationHandler();
|
||||
float totalDisplacement = displacement + mDisplacementShift;
|
||||
boolean isGoingUp = totalDisplacement == 0 ? mCurrentAnimationIsGoingUp :
|
||||
orientationHandler.isGoingUp(totalDisplacement, mIsRtl);
|
||||
@@ -346,7 +349,8 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
|
||||
if (blockedFling) {
|
||||
fling = false;
|
||||
}
|
||||
PagedOrientationHandler orientationHandler = mRecentsView.getPagedOrientationHandler();
|
||||
RecentsPagedOrientationHandler orientationHandler =
|
||||
mRecentsView.getPagedOrientationHandler();
|
||||
boolean goingUp = orientationHandler.isGoingUp(velocity, mIsRtl);
|
||||
float progress = mCurrentAnimation.getProgressFraction();
|
||||
float interpolatedProgress = mCurrentAnimation.getInterpolatedProgress();
|
||||
|
||||
@@ -62,6 +62,7 @@ import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.launcher3.views.ScrimView;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
import com.android.quickstep.util.ActivityInitListener;
|
||||
import com.android.quickstep.util.AnimatorControllerWithResistance;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
@@ -128,7 +129,7 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
|
||||
|
||||
public abstract int getSwipeUpDestinationAndLength(
|
||||
DeviceProfile dp, Context context, Rect outRect,
|
||||
PagedOrientationHandler orientationHandler);
|
||||
RecentsPagedOrientationHandler orientationHandler);
|
||||
|
||||
/** Called when the animation to home has fully settled. */
|
||||
public void onSwipeUpToHomeComplete(RecentsAnimationDeviceState deviceState) {}
|
||||
|
||||
@@ -32,10 +32,10 @@ import androidx.annotation.Nullable;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.statemanager.StateManager;
|
||||
import com.android.launcher3.taskbar.FallbackTaskbarUIController;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.quickstep.GestureState.GestureEndTarget;
|
||||
import com.android.quickstep.fallback.RecentsState;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
import com.android.quickstep.util.ActivityInitListener;
|
||||
import com.android.quickstep.util.AnimatorControllerWithResistance;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
@@ -60,7 +60,7 @@ public final class FallbackActivityInterface extends
|
||||
/** 2 */
|
||||
@Override
|
||||
public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect,
|
||||
PagedOrientationHandler orientationHandler) {
|
||||
RecentsPagedOrientationHandler orientationHandler) {
|
||||
calculateTaskSize(context, dp, outRect, orientationHandler);
|
||||
if (dp.isVerticalBarLayout() && DisplayController.getNavigationMode(context) != NO_BUTTON) {
|
||||
return dp.isSeascape() ? outRect.left : (dp.widthPx - outRect.right);
|
||||
|
||||
@@ -46,11 +46,11 @@ import com.android.launcher3.statehandlers.DepthController;
|
||||
import com.android.launcher3.statehandlers.DesktopVisibilityController;
|
||||
import com.android.launcher3.statemanager.StateManager;
|
||||
import com.android.launcher3.taskbar.LauncherTaskbarUIController;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.uioverrides.QuickstepLauncher;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.quickstep.GestureState.GestureEndTarget;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
import com.android.quickstep.util.ActivityInitListener;
|
||||
import com.android.quickstep.util.AnimatorControllerWithResistance;
|
||||
import com.android.quickstep.util.LayoutUtils;
|
||||
@@ -74,7 +74,7 @@ public final class LauncherActivityInterface extends
|
||||
|
||||
@Override
|
||||
public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect,
|
||||
PagedOrientationHandler orientationHandler) {
|
||||
RecentsPagedOrientationHandler orientationHandler) {
|
||||
calculateTaskSize(context, dp, outRect, orientationHandler);
|
||||
if (dp.isVerticalBarLayout()
|
||||
&& DisplayController.getNavigationMode(context) != NavigationMode.NO_BUTTON) {
|
||||
|
||||
@@ -14,8 +14,8 @@ import androidx.annotation.Nullable;
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext;
|
||||
import com.android.launcher3.testing.TestInformationHandler;
|
||||
import com.android.launcher3.testing.shared.TestProtocol;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
import com.android.quickstep.util.LayoutUtils;
|
||||
import com.android.quickstep.util.TISBindHelper;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
@@ -56,7 +56,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
|
||||
}
|
||||
Rect focusedTaskRect = new Rect();
|
||||
LauncherActivityInterface.INSTANCE.calculateTaskSize(mContext, mDeviceProfile,
|
||||
focusedTaskRect, PagedOrientationHandler.PORTRAIT);
|
||||
focusedTaskRect, RecentsPagedOrientationHandler.PORTRAIT);
|
||||
response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, focusedTaskRect.height());
|
||||
return response;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
|
||||
}
|
||||
Rect gridTaskRect = new Rect();
|
||||
LauncherActivityInterface.INSTANCE.calculateGridTaskSize(mContext, mDeviceProfile,
|
||||
gridTaskRect, PagedOrientationHandler.PORTRAIT);
|
||||
gridTaskRect, RecentsPagedOrientationHandler.PORTRAIT);
|
||||
response.putParcelable(TestProtocol.TEST_INFO_RESPONSE_FIELD, gridTaskRect);
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
import com.android.launcher3.anim.PendingAnimation;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
import com.android.quickstep.util.AnimatorControllerWithResistance;
|
||||
import com.android.quickstep.util.RectFSpringAnim;
|
||||
import com.android.quickstep.util.RectFSpringAnim.DefaultSpringConfig;
|
||||
@@ -151,7 +152,7 @@ public abstract class SwipeUpAnimationLogic implements
|
||||
@UiThread
|
||||
public abstract void onCurrentShiftUpdated();
|
||||
|
||||
protected PagedOrientationHandler getOrientationHandler() {
|
||||
protected RecentsPagedOrientationHandler getOrientationHandler() {
|
||||
// OrientationHandler should be independent of remote target, can directly take one
|
||||
return mRemoteTargetHandles[0].getTaskViewSimulator()
|
||||
.getOrientationState().getOrientationHandler();
|
||||
|
||||
@@ -47,9 +47,9 @@ import com.android.launcher3.logging.StatsLogManager.LauncherEvent;
|
||||
import com.android.launcher3.model.WellbeingModel;
|
||||
import com.android.launcher3.popup.SystemShortcut;
|
||||
import com.android.launcher3.popup.SystemShortcut.AppInfo;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.util.InstantAppResolver;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
import com.android.quickstep.views.GroupedTaskView;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
import com.android.quickstep.views.TaskThumbnailView;
|
||||
@@ -281,7 +281,7 @@ public interface TaskShortcutFactory {
|
||||
final int intentFlags = task.key.baseIntent.getFlags();
|
||||
final TaskView taskView = taskContainer.getTaskView();
|
||||
final RecentsView recentsView = taskView.getRecentsView();
|
||||
final PagedOrientationHandler orientationHandler =
|
||||
final RecentsPagedOrientationHandler orientationHandler =
|
||||
recentsView.getPagedOrientationHandler();
|
||||
|
||||
boolean notEnoughTasksToSplit =
|
||||
|
||||
@@ -0,0 +1,683 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.quickstep.orientation;
|
||||
|
||||
import static android.view.Gravity.BOTTOM;
|
||||
import static android.view.Gravity.CENTER_VERTICAL;
|
||||
import static android.view.Gravity.END;
|
||||
import static android.view.Gravity.LEFT;
|
||||
import static android.view.Gravity.START;
|
||||
import static android.view.Gravity.TOP;
|
||||
import static android.view.View.LAYOUT_DIRECTION_RTL;
|
||||
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
|
||||
import static com.android.launcher3.Flags.enableOverviewIconMenu;
|
||||
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;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_UNDEFINED;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_TYPE_MAIN;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.util.FloatProperty;
|
||||
import android.util.Pair;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.Surface;
|
||||
import android.view.VelocityTracker;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.touch.SingleAxisSwipeDetector;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.SplitBounds;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.StagePosition;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
import com.android.quickstep.views.IconAppChipView;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class LandscapePagedViewHandler implements RecentsPagedOrientationHandler {
|
||||
|
||||
@Override
|
||||
public <T> T getPrimaryValue(T x, T y) {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getSecondaryValue(T x, T y) {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrimaryValue(int x, int y) {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSecondaryValue(int x, int y) {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPrimaryValue(float x, float y) {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSecondaryValue(float x, float y) {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLayoutNaturalToLauncher() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustFloatingIconStartVelocity(PointF velocity) {
|
||||
float oldX = velocity.x;
|
||||
float oldY = velocity.y;
|
||||
velocity.set(-oldY, oldX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fixBoundsForHomeAnimStartRect(RectF outStartRect, DeviceProfile deviceProfile) {
|
||||
// We don't need to check the "top" value here because the startRect is in the orientation
|
||||
// of the app, not of the fixed portrait launcher.
|
||||
if (outStartRect.left > deviceProfile.heightPx) {
|
||||
outStartRect.offsetTo(0, outStartRect.top);
|
||||
} else if (outStartRect.left < -deviceProfile.heightPx) {
|
||||
outStartRect.offsetTo(0, outStartRect.top);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void setPrimary(T target, Int2DAction<T> action, int param) {
|
||||
action.call(target, 0, param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void setPrimary(T target, Float2DAction<T> action, float param) {
|
||||
action.call(target, 0, param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void setSecondary(T target, Float2DAction<T> action, float param) {
|
||||
action.call(target, param, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void set(T target, Int2DAction<T> action, int primaryParam,
|
||||
int secondaryParam) {
|
||||
action.call(target, secondaryParam, primaryParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPrimaryDirection(MotionEvent event, int pointerIndex) {
|
||||
return event.getY(pointerIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPrimaryVelocity(VelocityTracker velocityTracker, int pointerId) {
|
||||
return velocityTracker.getYVelocity(pointerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMeasuredSize(View view) {
|
||||
return view.getMeasuredHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrimarySize(View view) {
|
||||
return view.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPrimarySize(RectF rect) {
|
||||
return rect.height();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStart(RectF rect) {
|
||||
return rect.top;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEnd(RectF rect) {
|
||||
return rect.bottom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getClearAllSidePadding(View view, boolean isRtl) {
|
||||
return (isRtl ? view.getPaddingBottom() : - view.getPaddingTop()) / 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSecondaryDimension(View view) {
|
||||
return view.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloatProperty<View> getPrimaryViewTranslate() {
|
||||
return VIEW_TRANSLATE_Y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloatProperty<View> getSecondaryViewTranslate() {
|
||||
return VIEW_TRANSLATE_X;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrimaryScroll(View view) {
|
||||
return view.getScrollY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPrimaryScale(View view) {
|
||||
return view.getScaleY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxScroll(AccessibilityEvent event, int maxScroll) {
|
||||
event.setMaxScrollY(maxScroll);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getRecentsRtlSetting(Resources resources) {
|
||||
return !Utilities.isRtl(resources);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDegreesRotated() {
|
||||
return 90;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRotation() {
|
||||
return Surface.ROTATION_90;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrimaryScale(View view, float scale) {
|
||||
view.setScaleY(scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecondaryScale(View view, float scale) {
|
||||
view.setScaleX(scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChildStart(View view) {
|
||||
return view.getTop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCenterForPage(View view, Rect insets) {
|
||||
return (view.getPaddingLeft() + view.getMeasuredWidth() + insets.left
|
||||
- insets.right - view.getPaddingRight()) / 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScrollOffsetStart(View view, Rect insets) {
|
||||
return insets.top + view.getPaddingTop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScrollOffsetEnd(View view, Rect insets) {
|
||||
return view.getHeight() - view.getPaddingBottom() - insets.bottom;
|
||||
}
|
||||
|
||||
public int getSecondaryTranslationDirectionFactor() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSplitTranslationDirectionFactor(int stagePosition, DeviceProfile deviceProfile) {
|
||||
if (stagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTaskMenuX(float x, View thumbnailView,
|
||||
DeviceProfile deviceProfile, float taskInsetMargin, View taskViewIcon) {
|
||||
if (enableOverviewIconMenu()) {
|
||||
return x + (taskInsetMargin / 2f);
|
||||
}
|
||||
return thumbnailView.getMeasuredWidth() + x - taskInsetMargin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTaskMenuY(float y, View thumbnailView, int stagePosition,
|
||||
View taskMenuView, float taskInsetMargin, View taskViewIcon) {
|
||||
if (enableOverviewIconMenu()) {
|
||||
return y - (thumbnailView.getLayoutDirection() == LAYOUT_DIRECTION_RTL
|
||||
? taskMenuView.getMeasuredHeight() * 2 - (taskInsetMargin / 2f)
|
||||
: taskMenuView.getMeasuredHeight());
|
||||
|
||||
}
|
||||
BaseDragLayer.LayoutParams lp = (BaseDragLayer.LayoutParams) taskMenuView.getLayoutParams();
|
||||
int taskMenuWidth = lp.width;
|
||||
if (stagePosition == STAGE_POSITION_UNDEFINED) {
|
||||
return y + taskInsetMargin
|
||||
+ (thumbnailView.getMeasuredHeight() - taskMenuWidth) / 2f;
|
||||
} else {
|
||||
return y + taskInsetMargin;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTaskMenuWidth(View thumbnailView, DeviceProfile deviceProfile,
|
||||
@StagePosition int stagePosition) {
|
||||
if (enableOverviewIconMenu()) {
|
||||
return thumbnailView.getResources().getDimensionPixelSize(
|
||||
R.dimen.task_thumbnail_icon_menu_max_width);
|
||||
}
|
||||
if (stagePosition == SplitConfigurationOptions.STAGE_POSITION_UNDEFINED) {
|
||||
return thumbnailView.getMeasuredWidth();
|
||||
} else {
|
||||
return thumbnailView.getMeasuredHeight();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTaskOptionsMenuLayoutOrientation(DeviceProfile deviceProfile,
|
||||
LinearLayout taskMenuLayout, int dividerSpacing,
|
||||
ShapeDrawable dividerDrawable) {
|
||||
taskMenuLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
dividerDrawable.setIntrinsicHeight(dividerSpacing);
|
||||
taskMenuLayout.setDividerDrawable(dividerDrawable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLayoutParamsForTaskMenuOptionItem(LinearLayout.LayoutParams lp,
|
||||
LinearLayout viewGroup, DeviceProfile deviceProfile) {
|
||||
// Phone fake landscape
|
||||
viewGroup.setOrientation(LinearLayout.HORIZONTAL);
|
||||
lp.width = MATCH_PARENT;
|
||||
lp.height = WRAP_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Float, Float> getDwbLayoutTranslations(int taskViewWidth,
|
||||
int taskViewHeight, SplitBounds splitBounds, DeviceProfile deviceProfile,
|
||||
View[] thumbnailViews, int desiredTaskId, View banner) {
|
||||
boolean isRtl = banner.getLayoutDirection() == LAYOUT_DIRECTION_RTL;
|
||||
float translationX = 0;
|
||||
float translationY = 0;
|
||||
FrameLayout.LayoutParams bannerParams = (FrameLayout.LayoutParams) banner.getLayoutParams();
|
||||
banner.setPivotX(0);
|
||||
banner.setPivotY(0);
|
||||
banner.setRotation(getDegreesRotated());
|
||||
translationX = banner.getHeight();
|
||||
FrameLayout.LayoutParams snapshotParams =
|
||||
(FrameLayout.LayoutParams) thumbnailViews[0]
|
||||
.getLayoutParams();
|
||||
bannerParams.gravity = TOP | (isRtl ? END : START);
|
||||
if (splitBounds == null) {
|
||||
// Single, fullscreen case
|
||||
bannerParams.width = taskViewHeight - snapshotParams.topMargin;
|
||||
return new Pair<>(translationX, Integer.valueOf(snapshotParams.topMargin).floatValue());
|
||||
}
|
||||
|
||||
// Set correct width
|
||||
if (desiredTaskId == splitBounds.leftTopTaskId) {
|
||||
bannerParams.width = thumbnailViews[0].getMeasuredHeight();
|
||||
} else {
|
||||
bannerParams.width = thumbnailViews[1].getMeasuredHeight();
|
||||
}
|
||||
|
||||
// Set translations
|
||||
if (desiredTaskId == splitBounds.rightBottomTaskId) {
|
||||
float topLeftTaskPlusDividerPercent = splitBounds.appsStackedVertically
|
||||
? (splitBounds.topTaskPercent + splitBounds.dividerHeightPercent)
|
||||
: (splitBounds.leftTaskPercent + splitBounds.dividerWidthPercent);
|
||||
translationY = snapshotParams.topMargin
|
||||
+ ((taskViewHeight - snapshotParams.topMargin) * topLeftTaskPlusDividerPercent);
|
||||
}
|
||||
if (desiredTaskId == splitBounds.leftTopTaskId) {
|
||||
translationY = snapshotParams.topMargin;
|
||||
}
|
||||
return new Pair<>(translationX, translationY);
|
||||
}
|
||||
|
||||
/* ---------- The following are only used by TaskViewTouchHandler. ---------- */
|
||||
|
||||
@Override
|
||||
public SingleAxisSwipeDetector.Direction getUpDownSwipeDirection() {
|
||||
return HORIZONTAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUpDirection(boolean isRtl) {
|
||||
return isRtl ? SingleAxisSwipeDetector.DIRECTION_NEGATIVE
|
||||
: SingleAxisSwipeDetector.DIRECTION_POSITIVE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGoingUp(float displacement, boolean isRtl) {
|
||||
return isRtl ? displacement < 0 : displacement > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTaskDragDisplacementFactor(boolean isRtl) {
|
||||
return isRtl ? 1 : -1;
|
||||
}
|
||||
|
||||
/* -------------------- */
|
||||
|
||||
@Override
|
||||
public ChildBounds getChildBounds(View child, int childStart, int pageCenter,
|
||||
boolean layoutChild) {
|
||||
final int childHeight = child.getMeasuredHeight();
|
||||
final int childBottom = childStart + childHeight;
|
||||
final int childWidth = child.getMeasuredWidth();
|
||||
final int childLeft = pageCenter - childWidth/ 2;
|
||||
if (layoutChild) {
|
||||
child.layout(childLeft, childStart, childLeft + childWidth, childBottom);
|
||||
}
|
||||
return new ChildBounds(childHeight, childWidth, childBottom, childLeft);
|
||||
}
|
||||
|
||||
@SuppressWarnings("SuspiciousNameCombination")
|
||||
@Override
|
||||
public int getDistanceToBottomOfRect(DeviceProfile dp, Rect rect) {
|
||||
return rect.left;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SplitPositionOption> getSplitPositionOptions(DeviceProfile dp) {
|
||||
// Add "left" side of phone which is actually the top
|
||||
return Collections.singletonList(new SplitPositionOption(
|
||||
R.drawable.ic_split_horizontal, R.string.recent_task_option_split_screen,
|
||||
STAGE_POSITION_TOP_OR_LEFT, STAGE_TYPE_MAIN));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getInitialSplitPlaceholderBounds(int placeholderHeight, int placeholderInset,
|
||||
DeviceProfile dp, @StagePosition int stagePosition, Rect out) {
|
||||
// In fake land/seascape, the placeholder always needs to go to the "top" of the device,
|
||||
// which is the same bounds as 0 rotation.
|
||||
int width = dp.widthPx;
|
||||
int insetSizeAdjustment = getPlaceholderSizeAdjustment(dp);
|
||||
out.set(0, 0, width, placeholderHeight + insetSizeAdjustment);
|
||||
out.inset(placeholderInset, 0);
|
||||
|
||||
// Adjust the top to account for content off screen. This will help to animate the view in
|
||||
// with rounded corners.
|
||||
int screenWidth = dp.widthPx;
|
||||
int screenHeight = dp.heightPx;
|
||||
int totalHeight = (int) (1.0f * screenHeight / 2 * (screenWidth - 2 * placeholderInset)
|
||||
/ screenWidth);
|
||||
out.top -= (totalHeight - placeholderHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSplitIconParams(View out, float onScreenRectCenterX,
|
||||
float onScreenRectCenterY, float fullscreenScaleX, float fullscreenScaleY,
|
||||
int drawableWidth, int drawableHeight, DeviceProfile dp,
|
||||
@StagePosition int stagePosition) {
|
||||
float insetAdjustment = getPlaceholderSizeAdjustment(dp) / 2f;
|
||||
out.setX(onScreenRectCenterX / fullscreenScaleX
|
||||
- 1.0f * drawableWidth / 2);
|
||||
out.setY((onScreenRectCenterY + insetAdjustment) / fullscreenScaleY
|
||||
- 1.0f * drawableHeight / 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* The split placeholder comes with a default inset to buffer the icon from the top of the
|
||||
* screen. But if the device already has a large inset (from cutouts etc), use that instead.
|
||||
*/
|
||||
private int getPlaceholderSizeAdjustment(DeviceProfile dp) {
|
||||
return Math.max(dp.getInsets().top - dp.splitPlaceholderInset, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSplitInstructionsParams(View out, DeviceProfile dp, int splitInstructionsHeight,
|
||||
int splitInstructionsWidth) {
|
||||
out.setPivotX(0);
|
||||
out.setPivotY(splitInstructionsHeight);
|
||||
out.setRotation(getDegreesRotated());
|
||||
int distanceToEdge = out.getResources().getDimensionPixelSize(
|
||||
R.dimen.split_instructions_bottom_margin_phone_landscape);
|
||||
// Adjust for any insets on the left edge
|
||||
int insetCorrectionX = dp.getInsets().left;
|
||||
// Center the view in case of unbalanced insets on top or bottom of screen
|
||||
int insetCorrectionY = (dp.getInsets().bottom - dp.getInsets().top) / 2;
|
||||
out.setTranslationX(distanceToEdge - insetCorrectionX);
|
||||
out.setTranslationY(((-splitInstructionsHeight - splitInstructionsWidth) / 2f)
|
||||
+ insetCorrectionY);
|
||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) out.getLayoutParams();
|
||||
// Setting gravity to LEFT instead of the lint-recommended START because we always want this
|
||||
// view to be screen-left when phone is in landscape, regardless of the RtL setting.
|
||||
lp.gravity = LEFT | CENTER_VERTICAL;
|
||||
out.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getFinalSplitPlaceholderBounds(int splitDividerSize, DeviceProfile dp,
|
||||
@StagePosition int stagePosition, Rect out1, Rect out2) {
|
||||
// In fake land/seascape, the window bounds are always top and bottom half
|
||||
int screenHeight = dp.heightPx;
|
||||
int screenWidth = dp.widthPx;
|
||||
out1.set(0, 0, screenWidth, screenHeight / 2 - splitDividerSize);
|
||||
out2.set(0, screenHeight / 2 + splitDividerSize, screenWidth, screenHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSplitTaskSwipeRect(DeviceProfile dp, Rect outRect,
|
||||
SplitBounds splitInfo, int desiredStagePosition) {
|
||||
float topLeftTaskPercent = splitInfo.appsStackedVertically
|
||||
? splitInfo.topTaskPercent
|
||||
: splitInfo.leftTaskPercent;
|
||||
float dividerBarPercent = splitInfo.appsStackedVertically
|
||||
? splitInfo.dividerHeightPercent
|
||||
: splitInfo.dividerWidthPercent;
|
||||
|
||||
if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) {
|
||||
outRect.bottom = outRect.top + (int) (outRect.height() * topLeftTaskPercent);
|
||||
} else {
|
||||
outRect.top += (int) (outRect.height() * (topLeftTaskPercent + dividerBarPercent));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void measureGroupedTaskViewThumbnailBounds(View primarySnapshot, View secondarySnapshot,
|
||||
int parentWidth, int parentHeight, SplitBounds splitBoundsConfig, DeviceProfile dp,
|
||||
boolean isRtl) {
|
||||
FrameLayout.LayoutParams primaryParams =
|
||||
(FrameLayout.LayoutParams) primarySnapshot.getLayoutParams();
|
||||
FrameLayout.LayoutParams secondaryParams =
|
||||
(FrameLayout.LayoutParams) secondarySnapshot.getLayoutParams();
|
||||
|
||||
// Swap the margins that are set in TaskView#setRecentsOrientedState()
|
||||
secondaryParams.topMargin = dp.overviewTaskThumbnailTopMarginPx;
|
||||
primaryParams.topMargin = 0;
|
||||
|
||||
// Measure and layout the thumbnails bottom up, since the primary is on the visual left
|
||||
// (portrait bottom) and secondary is on the right (portrait top)
|
||||
int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx;
|
||||
int totalThumbnailHeight = parentHeight - spaceAboveSnapshot;
|
||||
int dividerBar = Math.round(totalThumbnailHeight * (splitBoundsConfig.appsStackedVertically
|
||||
? splitBoundsConfig.dividerHeightPercent
|
||||
: splitBoundsConfig.dividerWidthPercent));
|
||||
int primarySnapshotHeight;
|
||||
int primarySnapshotWidth;
|
||||
int secondarySnapshotHeight;
|
||||
int secondarySnapshotWidth;
|
||||
|
||||
float taskPercent = splitBoundsConfig.appsStackedVertically ?
|
||||
splitBoundsConfig.topTaskPercent : splitBoundsConfig.leftTaskPercent;
|
||||
primarySnapshotWidth = parentWidth;
|
||||
primarySnapshotHeight = (int) (totalThumbnailHeight * (taskPercent));
|
||||
|
||||
secondarySnapshotWidth = parentWidth;
|
||||
secondarySnapshotHeight = totalThumbnailHeight - primarySnapshotHeight - dividerBar;
|
||||
|
||||
int translationY = primarySnapshotHeight + spaceAboveSnapshot + dividerBar;
|
||||
primarySnapshot.setTranslationY(spaceAboveSnapshot);
|
||||
secondarySnapshot.setTranslationY(translationY - spaceAboveSnapshot);
|
||||
|
||||
primarySnapshot.measure(
|
||||
View.MeasureSpec.makeMeasureSpec(primarySnapshotWidth, View.MeasureSpec.EXACTLY),
|
||||
View.MeasureSpec.makeMeasureSpec(primarySnapshotHeight, View.MeasureSpec.EXACTLY)
|
||||
);
|
||||
secondarySnapshot.measure(
|
||||
View.MeasureSpec.makeMeasureSpec(secondarySnapshotWidth, View.MeasureSpec.EXACTLY),
|
||||
View.MeasureSpec.makeMeasureSpec(secondarySnapshotHeight, View.MeasureSpec.EXACTLY)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTaskIconParams(FrameLayout.LayoutParams iconParams, int taskIconMargin,
|
||||
int taskIconHeight, int thumbnailTopMargin, boolean isRtl) {
|
||||
if (enableOverviewIconMenu()) {
|
||||
iconParams.gravity = Gravity.START | Gravity.CENTER_VERTICAL;
|
||||
iconParams.topMargin = 0;
|
||||
return;
|
||||
}
|
||||
iconParams.gravity = (isRtl ? START : END) | CENTER_VERTICAL;
|
||||
iconParams.rightMargin = -taskIconHeight - taskIconMargin / 2;
|
||||
iconParams.leftMargin = 0;
|
||||
iconParams.topMargin = thumbnailTopMargin / 2;
|
||||
iconParams.bottomMargin = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIconAppChipMenuParams(IconAppChipView iconAppChipView,
|
||||
FrameLayout.LayoutParams iconMenuParams, int iconMenuMargin, int thumbnailTopMargin) {
|
||||
boolean isRtl = iconAppChipView.getLayoutDirection() == LAYOUT_DIRECTION_RTL;
|
||||
iconMenuParams.gravity = (isRtl ? START : END) | (isRtl ? BOTTOM : TOP);
|
||||
iconMenuParams.setMarginStart(isRtl ? iconMenuMargin : 0);
|
||||
iconMenuParams.topMargin = iconMenuMargin;
|
||||
iconMenuParams.bottomMargin = isRtl ? iconMenuMargin : 0;
|
||||
iconMenuParams.setMarginEnd(iconMenuMargin);
|
||||
|
||||
iconAppChipView.setPivotX(isRtl ? iconMenuParams.width - (iconMenuParams.height / 2f)
|
||||
: iconMenuParams.width / 2f);
|
||||
iconAppChipView.setPivotY(
|
||||
isRtl ? (iconMenuParams.height / 2f) : iconMenuParams.width / 2f);
|
||||
iconAppChipView.setTranslationY(0);
|
||||
iconAppChipView.setRotation(getDegreesRotated());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSplitIconParams(View primaryIconView, View secondaryIconView,
|
||||
int taskIconHeight, int primarySnapshotWidth, int primarySnapshotHeight,
|
||||
int groupedTaskViewHeight, int groupedTaskViewWidth, boolean isRtl,
|
||||
DeviceProfile deviceProfile, SplitBounds splitConfig) {
|
||||
FrameLayout.LayoutParams primaryIconParams =
|
||||
(FrameLayout.LayoutParams) primaryIconView.getLayoutParams();
|
||||
FrameLayout.LayoutParams secondaryIconParams = enableOverviewIconMenu()
|
||||
? (FrameLayout.LayoutParams) secondaryIconView.getLayoutParams()
|
||||
: new FrameLayout.LayoutParams(primaryIconParams);
|
||||
|
||||
// We calculate the "midpoint" of the thumbnail area, and place the icons there.
|
||||
// This is the place where the thumbnail area splits by default, in a near-50/50 split.
|
||||
// It is usually not exactly 50/50, due to insets/screen cutouts.
|
||||
int fullscreenInsetThickness = deviceProfile.getInsets().top
|
||||
- deviceProfile.getInsets().bottom;
|
||||
int fullscreenMidpointFromBottom = ((deviceProfile.heightPx - fullscreenInsetThickness)
|
||||
/ 2);
|
||||
float midpointFromBottomPct = (float) fullscreenMidpointFromBottom / deviceProfile.heightPx;
|
||||
float insetPct = (float) fullscreenInsetThickness / deviceProfile.heightPx;
|
||||
int spaceAboveSnapshots = deviceProfile.overviewTaskThumbnailTopMarginPx;
|
||||
int overviewThumbnailAreaThickness = groupedTaskViewHeight - spaceAboveSnapshots;
|
||||
int bottomToMidpointOffset = (int) (overviewThumbnailAreaThickness * midpointFromBottomPct);
|
||||
int insetOffset = (int) (overviewThumbnailAreaThickness * insetPct);
|
||||
|
||||
if (enableOverviewIconMenu()) {
|
||||
primaryIconParams.gravity = isRtl ? BOTTOM | START : TOP | END;
|
||||
secondaryIconParams.gravity = isRtl ? BOTTOM | START : TOP | END;
|
||||
} else {
|
||||
primaryIconParams.gravity = BOTTOM | (isRtl ? START : END);
|
||||
secondaryIconParams.gravity = BOTTOM | (isRtl ? START : END);
|
||||
}
|
||||
primaryIconView.setTranslationX(0);
|
||||
secondaryIconView.setTranslationX(0);
|
||||
if (enableOverviewIconMenu()) {
|
||||
if (primaryIconView.getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
|
||||
secondaryIconView.setTranslationY(-primarySnapshotHeight);
|
||||
primaryIconView.setTranslationY(0);
|
||||
} else {
|
||||
int secondarySnapshotHeight = groupedTaskViewHeight - primarySnapshotHeight;
|
||||
primaryIconView.setTranslationY(secondarySnapshotHeight);
|
||||
}
|
||||
} else if (splitConfig.initiatedFromSeascape) {
|
||||
// if the split was initiated from seascape,
|
||||
// the task on the right (secondary) is slightly larger
|
||||
primaryIconView.setTranslationY(-bottomToMidpointOffset - insetOffset);
|
||||
secondaryIconView.setTranslationY(-bottomToMidpointOffset - insetOffset
|
||||
+ taskIconHeight);
|
||||
} else {
|
||||
// if not,
|
||||
// the task on the left (primary) is slightly larger
|
||||
primaryIconView.setTranslationY(-bottomToMidpointOffset);
|
||||
secondaryIconView.setTranslationY(-bottomToMidpointOffset + taskIconHeight);
|
||||
}
|
||||
|
||||
primaryIconView.setLayoutParams(primaryIconParams);
|
||||
secondaryIconView.setLayoutParams(secondaryIconParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultSplitPosition(DeviceProfile deviceProfile) {
|
||||
throw new IllegalStateException("Default position not available in fake landscape");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<FloatProperty, FloatProperty> getSplitSelectTaskOffset(FloatProperty primary,
|
||||
FloatProperty secondary, DeviceProfile deviceProfile) {
|
||||
return new Pair<>(primary, secondary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloatingTaskOffscreenTranslationTarget(View floatingTask, RectF onScreenRect,
|
||||
@StagePosition int stagePosition, DeviceProfile dp) {
|
||||
float currentTranslationY = floatingTask.getTranslationY();
|
||||
return currentTranslationY - onScreenRect.height();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFloatingTaskPrimaryTranslation(View floatingTask, float translation,
|
||||
DeviceProfile dp) {
|
||||
floatingTask.setTranslationY(translation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float getFloatingTaskPrimaryTranslation(View floatingTask, DeviceProfile dp) {
|
||||
return floatingTask.getTranslationY();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,778 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.quickstep.orientation;
|
||||
|
||||
import static android.view.Gravity.BOTTOM;
|
||||
import static android.view.Gravity.CENTER_HORIZONTAL;
|
||||
import static android.view.Gravity.END;
|
||||
import static android.view.Gravity.START;
|
||||
import static android.view.Gravity.TOP;
|
||||
import static android.view.View.LAYOUT_DIRECTION_RTL;
|
||||
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
|
||||
import static com.android.launcher3.Flags.enableOverviewIconMenu;
|
||||
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.VERTICAL;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_TYPE_MAIN;
|
||||
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.util.FloatProperty;
|
||||
import android.util.Pair;
|
||||
import android.view.Gravity;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.touch.DefaultPagedViewHandler;
|
||||
import com.android.launcher3.touch.SingleAxisSwipeDetector;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.SplitBounds;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.StagePosition;
|
||||
import com.android.quickstep.views.IconAppChipView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PortraitPagedViewHandler extends DefaultPagedViewHandler implements
|
||||
RecentsPagedOrientationHandler {
|
||||
|
||||
private final Matrix mTmpMatrix = new Matrix();
|
||||
private final RectF mTmpRectF = new RectF();
|
||||
|
||||
@Override
|
||||
public <T> T getPrimaryValue(T x, T y) {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getSecondaryValue(T x, T y) {
|
||||
return y;
|
||||
}
|
||||
@Override
|
||||
public boolean isLayoutNaturalToLauncher() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustFloatingIconStartVelocity(PointF velocity) {
|
||||
//no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fixBoundsForHomeAnimStartRect(RectF outStartRect, DeviceProfile deviceProfile) {
|
||||
if (outStartRect.left > deviceProfile.widthPx) {
|
||||
outStartRect.offsetTo(0, outStartRect.top);
|
||||
} else if (outStartRect.left < -deviceProfile.widthPx) {
|
||||
outStartRect.offsetTo(0, outStartRect.top);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void setSecondary(T target, Float2DAction<T> action, float param) {
|
||||
action.call(target, 0, param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void set(T target, Int2DAction<T> action, int primaryParam,
|
||||
int secondaryParam) {
|
||||
action.call(target, primaryParam, secondaryParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrimarySize(View view) {
|
||||
return view.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPrimarySize(RectF rect) {
|
||||
return rect.width();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStart(RectF rect) {
|
||||
return rect.left;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEnd(RectF rect) {
|
||||
return rect.right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getClearAllSidePadding(View view, boolean isRtl) {
|
||||
return (isRtl ? view.getPaddingRight() : - view.getPaddingLeft()) / 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSecondaryDimension(View view) {
|
||||
return view.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloatProperty<View> getPrimaryViewTranslate() {
|
||||
return VIEW_TRANSLATE_X;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloatProperty<View> getSecondaryViewTranslate() {
|
||||
return VIEW_TRANSLATE_Y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDegreesRotated() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRotation() {
|
||||
return Surface.ROTATION_0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrimaryScale(View view, float scale) {
|
||||
view.setScaleX(scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecondaryScale(View view, float scale) {
|
||||
view.setScaleY(scale);
|
||||
}
|
||||
|
||||
public int getSecondaryTranslationDirectionFactor() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSplitTranslationDirectionFactor(int stagePosition, DeviceProfile deviceProfile) {
|
||||
if (deviceProfile.isLeftRightSplit && stagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTaskMenuX(float x, View thumbnailView,
|
||||
DeviceProfile deviceProfile, float taskInsetMargin, View taskViewIcon) {
|
||||
if (enableOverviewIconMenu()) {
|
||||
if (thumbnailView.getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
|
||||
return x + taskInsetMargin - taskViewIcon.getHeight() - (taskInsetMargin / 2f);
|
||||
}
|
||||
return x + taskInsetMargin;
|
||||
} else if (deviceProfile.isLandscape) {
|
||||
return x + taskInsetMargin
|
||||
+ (thumbnailView.getMeasuredWidth() - thumbnailView.getMeasuredHeight()) / 2f;
|
||||
} else {
|
||||
return x + taskInsetMargin;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTaskMenuY(float y, View thumbnailView, int stagePosition,
|
||||
View taskMenuView, float taskInsetMargin, View taskViewIcon) {
|
||||
if (enableOverviewIconMenu()) {
|
||||
return y;
|
||||
}
|
||||
return y + taskInsetMargin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTaskMenuWidth(View thumbnailView, DeviceProfile deviceProfile,
|
||||
@StagePosition int stagePosition) {
|
||||
if (enableOverviewIconMenu()) {
|
||||
return thumbnailView.getResources().getDimensionPixelSize(
|
||||
R.dimen.task_thumbnail_icon_menu_max_width);
|
||||
}
|
||||
int padding = thumbnailView.getResources()
|
||||
.getDimensionPixelSize(R.dimen.task_menu_edge_padding);
|
||||
return (deviceProfile.isLandscape && !deviceProfile.isTablet
|
||||
? thumbnailView.getMeasuredHeight()
|
||||
: thumbnailView.getMeasuredWidth()) - (2 * padding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTaskOptionsMenuLayoutOrientation(DeviceProfile deviceProfile,
|
||||
LinearLayout taskMenuLayout, int dividerSpacing,
|
||||
ShapeDrawable dividerDrawable) {
|
||||
taskMenuLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
dividerDrawable.setIntrinsicHeight(dividerSpacing);
|
||||
taskMenuLayout.setDividerDrawable(dividerDrawable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLayoutParamsForTaskMenuOptionItem(LinearLayout.LayoutParams lp,
|
||||
LinearLayout viewGroup, DeviceProfile deviceProfile) {
|
||||
viewGroup.setOrientation(LinearLayout.HORIZONTAL);
|
||||
lp.width = LinearLayout.LayoutParams.MATCH_PARENT;
|
||||
lp.height = WRAP_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Float, Float> getDwbLayoutTranslations(int taskViewWidth,
|
||||
int taskViewHeight, SplitBounds splitBounds, DeviceProfile deviceProfile,
|
||||
View[] thumbnailViews, int desiredTaskId, View banner) {
|
||||
float translationX = 0;
|
||||
float translationY = 0;
|
||||
FrameLayout.LayoutParams bannerParams = (FrameLayout.LayoutParams) banner.getLayoutParams();
|
||||
banner.setPivotX(0);
|
||||
banner.setPivotY(0);
|
||||
banner.setRotation(getDegreesRotated());
|
||||
if (splitBounds == null) {
|
||||
// Single, fullscreen case
|
||||
bannerParams.width = MATCH_PARENT;
|
||||
bannerParams.gravity = BOTTOM | CENTER_HORIZONTAL;
|
||||
return new Pair<>(translationX, translationY);
|
||||
}
|
||||
|
||||
bannerParams.gravity = BOTTOM | ((deviceProfile.isLandscape) ? START : CENTER_HORIZONTAL);
|
||||
|
||||
// Set correct width
|
||||
if (desiredTaskId == splitBounds.leftTopTaskId) {
|
||||
bannerParams.width = thumbnailViews[0].getMeasuredWidth();
|
||||
} else {
|
||||
bannerParams.width = thumbnailViews[1].getMeasuredWidth();
|
||||
}
|
||||
|
||||
// Set translations
|
||||
if (deviceProfile.isLeftRightSplit) {
|
||||
if (desiredTaskId == splitBounds.rightBottomTaskId) {
|
||||
float leftTopTaskPercent = splitBounds.appsStackedVertically
|
||||
? splitBounds.topTaskPercent
|
||||
: splitBounds.leftTaskPercent;
|
||||
float dividerThicknessPercent = splitBounds.appsStackedVertically
|
||||
? splitBounds.dividerHeightPercent
|
||||
: splitBounds.dividerWidthPercent;
|
||||
translationX = ((taskViewWidth * leftTopTaskPercent)
|
||||
+ (taskViewWidth * dividerThicknessPercent));
|
||||
}
|
||||
} else {
|
||||
if (desiredTaskId == splitBounds.leftTopTaskId) {
|
||||
FrameLayout.LayoutParams snapshotParams =
|
||||
(FrameLayout.LayoutParams) thumbnailViews[0]
|
||||
.getLayoutParams();
|
||||
float bottomRightTaskPlusDividerPercent = splitBounds.appsStackedVertically
|
||||
? (1f - splitBounds.topTaskPercent)
|
||||
: (1f - splitBounds.leftTaskPercent);
|
||||
translationY = -((taskViewHeight - snapshotParams.topMargin)
|
||||
* bottomRightTaskPlusDividerPercent);
|
||||
}
|
||||
}
|
||||
return new Pair<>(translationX, translationY);
|
||||
}
|
||||
|
||||
/* ---------- The following are only used by TaskViewTouchHandler. ---------- */
|
||||
|
||||
@Override
|
||||
public SingleAxisSwipeDetector.Direction getUpDownSwipeDirection() {
|
||||
return VERTICAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUpDirection(boolean isRtl) {
|
||||
// Ignore rtl since it only affects X value displacement, Y displacement doesn't change
|
||||
return SingleAxisSwipeDetector.DIRECTION_POSITIVE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGoingUp(float displacement, boolean isRtl) {
|
||||
// Ignore rtl since it only affects X value displacement, Y displacement doesn't change
|
||||
return displacement < 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTaskDragDisplacementFactor(boolean isRtl) {
|
||||
// Ignore rtl since it only affects X value displacement, Y displacement doesn't change
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* -------------------- */
|
||||
@Override
|
||||
public int getDistanceToBottomOfRect(DeviceProfile dp, Rect rect) {
|
||||
return dp.heightPx - rect.bottom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SplitPositionOption> getSplitPositionOptions(DeviceProfile dp) {
|
||||
if (dp.isTablet) {
|
||||
return Utilities.getSplitPositionOptions(dp);
|
||||
}
|
||||
|
||||
List<SplitPositionOption> options = new ArrayList<>();
|
||||
if (dp.isSeascape()) {
|
||||
options.add(new SplitPositionOption(
|
||||
R.drawable.ic_split_horizontal, R.string.recent_task_option_split_screen,
|
||||
STAGE_POSITION_BOTTOM_OR_RIGHT, STAGE_TYPE_MAIN));
|
||||
} else if (dp.isLeftRightSplit) {
|
||||
options.add(new SplitPositionOption(
|
||||
R.drawable.ic_split_horizontal, R.string.recent_task_option_split_screen,
|
||||
STAGE_POSITION_TOP_OR_LEFT, STAGE_TYPE_MAIN));
|
||||
} else {
|
||||
// Only add top option
|
||||
options.add(new SplitPositionOption(
|
||||
R.drawable.ic_split_vertical, R.string.recent_task_option_split_screen,
|
||||
STAGE_POSITION_TOP_OR_LEFT, STAGE_TYPE_MAIN));
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getInitialSplitPlaceholderBounds(int placeholderHeight, int placeholderInset,
|
||||
DeviceProfile dp, @StagePosition int stagePosition, Rect out) {
|
||||
int screenWidth = dp.widthPx;
|
||||
int screenHeight = dp.heightPx;
|
||||
boolean pinToRight = stagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT;
|
||||
int insetSizeAdjustment = getPlaceholderSizeAdjustment(dp, pinToRight);
|
||||
|
||||
out.set(0, 0, screenWidth, placeholderHeight + insetSizeAdjustment);
|
||||
if (!dp.isLeftRightSplit) {
|
||||
// portrait, phone or tablet - spans width of screen, nothing else to do
|
||||
out.inset(placeholderInset, 0);
|
||||
|
||||
// Adjust the top to account for content off screen. This will help to animate the view
|
||||
// in with rounded corners.
|
||||
int totalHeight = (int) (1.0f * screenHeight / 2 * (screenWidth - 2 * placeholderInset)
|
||||
/ screenWidth);
|
||||
out.top -= (totalHeight - placeholderHeight);
|
||||
return;
|
||||
}
|
||||
|
||||
// Now we rotate the portrait rect depending on what side we want pinned
|
||||
|
||||
float postRotateScale = (float) screenHeight / screenWidth;
|
||||
mTmpMatrix.reset();
|
||||
mTmpMatrix.postRotate(pinToRight ? 90 : 270);
|
||||
mTmpMatrix.postTranslate(pinToRight ? screenWidth : 0, pinToRight ? 0 : screenWidth);
|
||||
// The placeholder height stays constant after rotation, so we don't change width scale
|
||||
mTmpMatrix.postScale(1, postRotateScale);
|
||||
|
||||
mTmpRectF.set(out);
|
||||
mTmpMatrix.mapRect(mTmpRectF);
|
||||
mTmpRectF.inset(0, placeholderInset);
|
||||
mTmpRectF.roundOut(out);
|
||||
|
||||
// Adjust the top to account for content off screen. This will help to animate the view in
|
||||
// with rounded corners.
|
||||
int totalWidth = (int) (1.0f * screenWidth / 2 * (screenHeight - 2 * placeholderInset)
|
||||
/ screenHeight);
|
||||
int width = out.width();
|
||||
if (pinToRight) {
|
||||
out.right += totalWidth - width;
|
||||
} else {
|
||||
out.left -= totalWidth - width;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSplitIconParams(View out, float onScreenRectCenterX,
|
||||
float onScreenRectCenterY, float fullscreenScaleX, float fullscreenScaleY,
|
||||
int drawableWidth, int drawableHeight, DeviceProfile dp,
|
||||
@StagePosition int stagePosition) {
|
||||
boolean pinToRight = stagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT;
|
||||
float insetAdjustment = getPlaceholderSizeAdjustment(dp, pinToRight) / 2f;
|
||||
if (!dp.isLeftRightSplit) {
|
||||
out.setX(onScreenRectCenterX / fullscreenScaleX
|
||||
- 1.0f * drawableWidth / 2);
|
||||
out.setY((onScreenRectCenterY + insetAdjustment) / fullscreenScaleY
|
||||
- 1.0f * drawableHeight / 2);
|
||||
} else {
|
||||
if (pinToRight) {
|
||||
out.setX((onScreenRectCenterX - insetAdjustment) / fullscreenScaleX
|
||||
- 1.0f * drawableWidth / 2);
|
||||
} else {
|
||||
out.setX((onScreenRectCenterX + insetAdjustment) / fullscreenScaleX
|
||||
- 1.0f * drawableWidth / 2);
|
||||
}
|
||||
out.setY(onScreenRectCenterY / fullscreenScaleY
|
||||
- 1.0f * drawableHeight / 2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The split placeholder comes with a default inset to buffer the icon from the top of the
|
||||
* screen. But if the device already has a large inset (from cutouts etc), use that instead.
|
||||
*/
|
||||
private int getPlaceholderSizeAdjustment(DeviceProfile dp, boolean pinToRight) {
|
||||
int insetThickness;
|
||||
if (!dp.isLandscape) {
|
||||
insetThickness = dp.getInsets().top;
|
||||
} else {
|
||||
insetThickness = pinToRight ? dp.getInsets().right : dp.getInsets().left;
|
||||
}
|
||||
return Math.max(insetThickness - dp.splitPlaceholderInset, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSplitInstructionsParams(View out, DeviceProfile dp, int splitInstructionsHeight,
|
||||
int splitInstructionsWidth) {
|
||||
out.setPivotX(0);
|
||||
out.setPivotY(splitInstructionsHeight);
|
||||
out.setRotation(getDegreesRotated());
|
||||
int distanceToEdge;
|
||||
if (dp.isPhone) {
|
||||
if (dp.isLandscape) {
|
||||
distanceToEdge = out.getResources().getDimensionPixelSize(
|
||||
R.dimen.split_instructions_bottom_margin_phone_landscape);
|
||||
} else {
|
||||
distanceToEdge = out.getResources().getDimensionPixelSize(
|
||||
R.dimen.split_instructions_bottom_margin_phone_portrait);
|
||||
}
|
||||
} else {
|
||||
distanceToEdge = dp.getOverviewActionsClaimedSpaceBelow();
|
||||
}
|
||||
|
||||
// Center the view in case of unbalanced insets on left or right of screen
|
||||
int insetCorrectionX = (dp.getInsets().right - dp.getInsets().left) / 2;
|
||||
// Adjust for any insets on the bottom edge
|
||||
int insetCorrectionY = dp.getInsets().bottom;
|
||||
out.setTranslationX(insetCorrectionX);
|
||||
out.setTranslationY(-distanceToEdge + insetCorrectionY);
|
||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) out.getLayoutParams();
|
||||
lp.gravity = CENTER_HORIZONTAL | BOTTOM;
|
||||
out.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getFinalSplitPlaceholderBounds(int splitDividerSize, DeviceProfile dp,
|
||||
@StagePosition int stagePosition, Rect out1, Rect out2) {
|
||||
int screenHeight = dp.heightPx;
|
||||
int screenWidth = dp.widthPx;
|
||||
out1.set(0, 0, screenWidth, screenHeight / 2 - splitDividerSize);
|
||||
out2.set(0, screenHeight / 2 + splitDividerSize, screenWidth, screenHeight);
|
||||
if (!dp.isLeftRightSplit) {
|
||||
// Portrait - the window bounds are always top and bottom half
|
||||
return;
|
||||
}
|
||||
|
||||
// Now we rotate the portrait rect depending on what side we want pinned
|
||||
boolean pinToRight = stagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT;
|
||||
float postRotateScale = (float) screenHeight / screenWidth;
|
||||
|
||||
mTmpMatrix.reset();
|
||||
mTmpMatrix.postRotate(pinToRight ? 90 : 270);
|
||||
mTmpMatrix.postTranslate(pinToRight ? screenHeight : 0, pinToRight ? 0 : screenWidth);
|
||||
mTmpMatrix.postScale(1 / postRotateScale, postRotateScale);
|
||||
|
||||
mTmpRectF.set(out1);
|
||||
mTmpMatrix.mapRect(mTmpRectF);
|
||||
mTmpRectF.roundOut(out1);
|
||||
|
||||
mTmpRectF.set(out2);
|
||||
mTmpMatrix.mapRect(mTmpRectF);
|
||||
mTmpRectF.roundOut(out2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSplitTaskSwipeRect(DeviceProfile dp, Rect outRect,
|
||||
SplitBounds splitInfo, int desiredStagePosition) {
|
||||
float topLeftTaskPercent = splitInfo.appsStackedVertically
|
||||
? splitInfo.topTaskPercent
|
||||
: splitInfo.leftTaskPercent;
|
||||
float dividerBarPercent = splitInfo.appsStackedVertically
|
||||
? splitInfo.dividerHeightPercent
|
||||
: splitInfo.dividerWidthPercent;
|
||||
|
||||
int taskbarHeight = dp.isTransientTaskbar ? 0 : dp.taskbarHeight;
|
||||
float scale = (float) outRect.height() / (dp.availableHeightPx - taskbarHeight);
|
||||
float topTaskHeight = dp.availableHeightPx * topLeftTaskPercent;
|
||||
float scaledTopTaskHeight = topTaskHeight * scale;
|
||||
float dividerHeight = dp.availableHeightPx * dividerBarPercent;
|
||||
float scaledDividerHeight = dividerHeight * scale;
|
||||
|
||||
if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) {
|
||||
if (dp.isLeftRightSplit) {
|
||||
outRect.right = outRect.left + Math.round(outRect.width() * topLeftTaskPercent);
|
||||
} else {
|
||||
outRect.bottom = Math.round(outRect.top + scaledTopTaskHeight);
|
||||
}
|
||||
} else {
|
||||
if (dp.isLeftRightSplit) {
|
||||
outRect.left += Math.round(outRect.width()
|
||||
* (topLeftTaskPercent + dividerBarPercent));
|
||||
} else {
|
||||
outRect.top += Math.round(scaledTopTaskHeight + scaledDividerHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void measureGroupedTaskViewThumbnailBounds(View primarySnapshot, View secondarySnapshot,
|
||||
int parentWidth, int parentHeight, SplitBounds splitBoundsConfig,
|
||||
DeviceProfile dp, boolean isRtl) {
|
||||
int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx;
|
||||
int totalThumbnailHeight = parentHeight - spaceAboveSnapshot;
|
||||
float dividerScale = splitBoundsConfig.appsStackedVertically
|
||||
? splitBoundsConfig.dividerHeightPercent
|
||||
: splitBoundsConfig.dividerWidthPercent;
|
||||
int primarySnapshotHeight;
|
||||
int primarySnapshotWidth;
|
||||
int secondarySnapshotHeight;
|
||||
int secondarySnapshotWidth;
|
||||
float taskPercent = splitBoundsConfig.appsStackedVertically ?
|
||||
splitBoundsConfig.topTaskPercent : splitBoundsConfig.leftTaskPercent;
|
||||
if (dp.isLeftRightSplit) {
|
||||
int scaledDividerBar = Math.round(parentWidth * dividerScale);
|
||||
primarySnapshotHeight = totalThumbnailHeight;
|
||||
primarySnapshotWidth = Math.round(parentWidth * taskPercent);
|
||||
|
||||
secondarySnapshotHeight = totalThumbnailHeight;
|
||||
secondarySnapshotWidth = parentWidth - primarySnapshotWidth - scaledDividerBar;
|
||||
if (isRtl) {
|
||||
int translationX = secondarySnapshotWidth + scaledDividerBar;
|
||||
primarySnapshot.setTranslationX(-translationX);
|
||||
secondarySnapshot.setTranslationX(0);
|
||||
} else {
|
||||
int translationX = primarySnapshotWidth + scaledDividerBar;
|
||||
secondarySnapshot.setTranslationX(translationX);
|
||||
primarySnapshot.setTranslationX(0);
|
||||
}
|
||||
secondarySnapshot.setTranslationY(spaceAboveSnapshot);
|
||||
|
||||
// Reset unused translations
|
||||
primarySnapshot.setTranslationY(0);
|
||||
} else {
|
||||
int taskbarHeight = dp.isTransientTaskbar ? 0 : dp.taskbarHeight;
|
||||
float scale = (float) totalThumbnailHeight / (dp.availableHeightPx - taskbarHeight);
|
||||
float topTaskHeight = dp.availableHeightPx * taskPercent;
|
||||
float finalDividerHeight = Math.round(totalThumbnailHeight * dividerScale);
|
||||
float scaledTopTaskHeight = topTaskHeight * scale;
|
||||
primarySnapshotWidth = parentWidth;
|
||||
primarySnapshotHeight = Math.round(scaledTopTaskHeight);
|
||||
|
||||
secondarySnapshotWidth = parentWidth;
|
||||
secondarySnapshotHeight = Math.round(totalThumbnailHeight - primarySnapshotHeight
|
||||
- finalDividerHeight);
|
||||
float translationY = primarySnapshotHeight + spaceAboveSnapshot + finalDividerHeight;
|
||||
secondarySnapshot.setTranslationY(translationY);
|
||||
|
||||
FrameLayout.LayoutParams primaryParams =
|
||||
(FrameLayout.LayoutParams) primarySnapshot.getLayoutParams();
|
||||
FrameLayout.LayoutParams secondaryParams =
|
||||
(FrameLayout.LayoutParams) secondarySnapshot.getLayoutParams();
|
||||
secondaryParams.topMargin = 0;
|
||||
primaryParams.topMargin = spaceAboveSnapshot;
|
||||
|
||||
// Reset unused translations
|
||||
primarySnapshot.setTranslationY(0);
|
||||
secondarySnapshot.setTranslationX(0);
|
||||
primarySnapshot.setTranslationX(0);
|
||||
}
|
||||
primarySnapshot.measure(
|
||||
View.MeasureSpec.makeMeasureSpec(primarySnapshotWidth, View.MeasureSpec.EXACTLY),
|
||||
View.MeasureSpec.makeMeasureSpec(primarySnapshotHeight, View.MeasureSpec.EXACTLY));
|
||||
secondarySnapshot.measure(
|
||||
View.MeasureSpec.makeMeasureSpec(secondarySnapshotWidth, View.MeasureSpec.EXACTLY),
|
||||
View.MeasureSpec.makeMeasureSpec(secondarySnapshotHeight,
|
||||
View.MeasureSpec.EXACTLY));
|
||||
primarySnapshot.setScaleX(1);
|
||||
secondarySnapshot.setScaleX(1);
|
||||
primarySnapshot.setScaleY(1);
|
||||
secondarySnapshot.setScaleY(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTaskIconParams(FrameLayout.LayoutParams iconParams, int taskIconMargin,
|
||||
int taskIconHeight, int thumbnailTopMargin, boolean isRtl) {
|
||||
if (enableOverviewIconMenu()) {
|
||||
iconParams.setMarginStart(taskIconMargin);
|
||||
iconParams.gravity = Gravity.START | Gravity.CENTER_VERTICAL;
|
||||
iconParams.topMargin = 0;
|
||||
return;
|
||||
}
|
||||
iconParams.gravity = TOP | CENTER_HORIZONTAL;
|
||||
// Reset margins, since they may have been set on rotation
|
||||
iconParams.leftMargin = iconParams.rightMargin = 0;
|
||||
iconParams.topMargin = iconParams.bottomMargin = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIconAppChipMenuParams(IconAppChipView iconAppChipView,
|
||||
FrameLayout.LayoutParams iconMenuParams, int iconMenuMargin, int thumbnailTopMargin) {
|
||||
iconMenuParams.gravity = TOP | START;
|
||||
iconMenuParams.setMarginStart(iconMenuMargin);
|
||||
iconMenuParams.topMargin = thumbnailTopMargin;
|
||||
iconMenuParams.bottomMargin = 0;
|
||||
iconMenuParams.setMarginEnd(0);
|
||||
|
||||
iconAppChipView.setPivotX(0);
|
||||
iconAppChipView.setPivotY(0);
|
||||
iconAppChipView.setTranslationY(0);
|
||||
iconAppChipView.setRotation(getDegreesRotated());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSplitIconParams(View primaryIconView, View secondaryIconView,
|
||||
int taskIconHeight, int primarySnapshotWidth, int primarySnapshotHeight,
|
||||
int groupedTaskViewHeight, int groupedTaskViewWidth, boolean isRtl,
|
||||
DeviceProfile deviceProfile, SplitBounds splitConfig) {
|
||||
FrameLayout.LayoutParams primaryIconParams =
|
||||
(FrameLayout.LayoutParams) primaryIconView.getLayoutParams();
|
||||
FrameLayout.LayoutParams secondaryIconParams = enableOverviewIconMenu()
|
||||
? (FrameLayout.LayoutParams) secondaryIconView.getLayoutParams()
|
||||
: new FrameLayout.LayoutParams(primaryIconParams);
|
||||
|
||||
if (enableOverviewIconMenu()) {
|
||||
primaryIconParams.gravity = TOP | START;
|
||||
secondaryIconParams.gravity = TOP | START;
|
||||
secondaryIconParams.topMargin = primaryIconParams.topMargin;
|
||||
secondaryIconParams.setMarginStart(primaryIconParams.getMarginStart());
|
||||
if (deviceProfile.isLeftRightSplit) {
|
||||
if (isRtl) {
|
||||
int secondarySnapshotWidth = groupedTaskViewWidth - primarySnapshotWidth;
|
||||
primaryIconView.setTranslationX(-secondarySnapshotWidth);
|
||||
} else {
|
||||
secondaryIconView.setTranslationX(primarySnapshotWidth);
|
||||
}
|
||||
} else {
|
||||
primaryIconView.setTranslationX(0);
|
||||
secondaryIconView.setTranslationX(0);
|
||||
int dividerThickness = Math.min(splitConfig.visualDividerBounds.width(),
|
||||
splitConfig.visualDividerBounds.height());
|
||||
secondaryIconView.setTranslationY(
|
||||
primarySnapshotHeight + (deviceProfile.isTablet ? 0 : dividerThickness));
|
||||
}
|
||||
} else if (deviceProfile.isLeftRightSplit) {
|
||||
// We calculate the "midpoint" of the thumbnail area, and place the icons there.
|
||||
// This is the place where the thumbnail area splits by default, in a near-50/50 split.
|
||||
// It is usually not exactly 50/50, due to insets/screen cutouts.
|
||||
int fullscreenInsetThickness = deviceProfile.isSeascape()
|
||||
? deviceProfile.getInsets().right
|
||||
: deviceProfile.getInsets().left;
|
||||
int fullscreenMidpointFromBottom = ((deviceProfile.widthPx
|
||||
- fullscreenInsetThickness) / 2);
|
||||
float midpointFromEndPct = (float) fullscreenMidpointFromBottom
|
||||
/ deviceProfile.widthPx;
|
||||
float insetPct = (float) fullscreenInsetThickness / deviceProfile.widthPx;
|
||||
int spaceAboveSnapshots = 0;
|
||||
int overviewThumbnailAreaThickness = groupedTaskViewWidth - spaceAboveSnapshots;
|
||||
int bottomToMidpointOffset = (int) (overviewThumbnailAreaThickness
|
||||
* midpointFromEndPct);
|
||||
int insetOffset = (int) (overviewThumbnailAreaThickness * insetPct);
|
||||
|
||||
if (deviceProfile.isSeascape()) {
|
||||
primaryIconParams.gravity = TOP | (isRtl ? END : START);
|
||||
secondaryIconParams.gravity = TOP | (isRtl ? END : START);
|
||||
if (splitConfig.initiatedFromSeascape) {
|
||||
// if the split was initiated from seascape,
|
||||
// the task on the right (secondary) is slightly larger
|
||||
primaryIconView.setTranslationX(bottomToMidpointOffset - taskIconHeight);
|
||||
secondaryIconView.setTranslationX(bottomToMidpointOffset);
|
||||
} else {
|
||||
// if not,
|
||||
// the task on the left (primary) is slightly larger
|
||||
primaryIconView.setTranslationX(bottomToMidpointOffset + insetOffset
|
||||
- taskIconHeight);
|
||||
secondaryIconView.setTranslationX(bottomToMidpointOffset + insetOffset);
|
||||
}
|
||||
} else {
|
||||
primaryIconParams.gravity = TOP | (isRtl ? START : END);
|
||||
secondaryIconParams.gravity = TOP | (isRtl ? START : END);
|
||||
if (!splitConfig.initiatedFromSeascape) {
|
||||
// if the split was initiated from landscape,
|
||||
// the task on the left (primary) is slightly larger
|
||||
primaryIconView.setTranslationX(-bottomToMidpointOffset);
|
||||
secondaryIconView.setTranslationX(-bottomToMidpointOffset + taskIconHeight);
|
||||
} else {
|
||||
// if not,
|
||||
// the task on the right (secondary) is slightly larger
|
||||
primaryIconView.setTranslationX(-bottomToMidpointOffset - insetOffset);
|
||||
secondaryIconView.setTranslationX(-bottomToMidpointOffset - insetOffset
|
||||
+ taskIconHeight);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
primaryIconParams.gravity = TOP | CENTER_HORIZONTAL;
|
||||
// shifts icon half a width left (height is used here since icons are square)
|
||||
primaryIconView.setTranslationX(-(taskIconHeight / 2f));
|
||||
secondaryIconParams.gravity = TOP | CENTER_HORIZONTAL;
|
||||
secondaryIconView.setTranslationX(taskIconHeight / 2f);
|
||||
}
|
||||
if (!enableOverviewIconMenu()) {
|
||||
primaryIconView.setTranslationY(0);
|
||||
secondaryIconView.setTranslationY(0);
|
||||
}
|
||||
|
||||
primaryIconView.setLayoutParams(primaryIconParams);
|
||||
secondaryIconView.setLayoutParams(secondaryIconParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultSplitPosition(DeviceProfile deviceProfile) {
|
||||
if (!deviceProfile.isTablet) {
|
||||
throw new IllegalStateException("Default position available only for large screens");
|
||||
}
|
||||
if (deviceProfile.isLeftRightSplit) {
|
||||
return STAGE_POSITION_BOTTOM_OR_RIGHT;
|
||||
} else {
|
||||
return STAGE_POSITION_TOP_OR_LEFT;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<FloatProperty, FloatProperty> getSplitSelectTaskOffset(FloatProperty primary,
|
||||
FloatProperty secondary, DeviceProfile deviceProfile) {
|
||||
if (deviceProfile.isLeftRightSplit) { // or seascape
|
||||
return new Pair<>(primary, secondary);
|
||||
} else {
|
||||
return new Pair<>(secondary, primary);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloatingTaskOffscreenTranslationTarget(View floatingTask, RectF onScreenRect,
|
||||
@StagePosition int stagePosition, DeviceProfile dp) {
|
||||
if (dp.isLeftRightSplit) {
|
||||
float currentTranslationX = floatingTask.getTranslationX();
|
||||
return stagePosition == STAGE_POSITION_TOP_OR_LEFT
|
||||
? currentTranslationX - onScreenRect.width()
|
||||
: currentTranslationX + onScreenRect.width();
|
||||
} else {
|
||||
float currentTranslationY = floatingTask.getTranslationY();
|
||||
return currentTranslationY - onScreenRect.height();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFloatingTaskPrimaryTranslation(View floatingTask, float translation,
|
||||
DeviceProfile dp) {
|
||||
if (dp.isLeftRightSplit) {
|
||||
floatingTask.setTranslationX(translation);
|
||||
} else {
|
||||
floatingTask.setTranslationY(translation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float getFloatingTaskPrimaryTranslation(View floatingTask, DeviceProfile dp) {
|
||||
return dp.isLeftRightSplit
|
||||
? floatingTask.getTranslationX()
|
||||
: floatingTask.getTranslationY();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.quickstep.orientation;
|
||||
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.util.FloatProperty;
|
||||
import android.util.Pair;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.touch.SingleAxisSwipeDetector;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.SplitBounds;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.StagePosition;
|
||||
import com.android.quickstep.views.IconAppChipView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Abstraction layer to separate horizontal and vertical specific implementations
|
||||
* for {@link com.android.quickstep.views.RecentsView}. Majority of these implementations are
|
||||
* (should be) as simple as choosing the correct X and Y analogous methods.
|
||||
*/
|
||||
public interface RecentsPagedOrientationHandler extends PagedOrientationHandler {
|
||||
|
||||
RecentsPagedOrientationHandler PORTRAIT = new PortraitPagedViewHandler();
|
||||
RecentsPagedOrientationHandler LANDSCAPE = new LandscapePagedViewHandler();
|
||||
RecentsPagedOrientationHandler SEASCAPE = new SeascapePagedViewHandler();
|
||||
|
||||
<T> void setSecondary(T target, Float2DAction<T> action, float param);
|
||||
<T> void set(T target, Int2DAction<T> action, int primaryParam, int secondaryParam);
|
||||
int getPrimarySize(View view);
|
||||
float getPrimarySize(RectF rect);
|
||||
int getSecondaryTranslationDirectionFactor();
|
||||
float getDegreesRotated();
|
||||
int getRotation();
|
||||
boolean isLayoutNaturalToLauncher();
|
||||
|
||||
<T> T getPrimaryValue(T x, T y);
|
||||
<T> T getSecondaryValue(T x, T y);
|
||||
void setPrimaryScale(View view, float scale);
|
||||
void setSecondaryScale(View view, float scale);
|
||||
float getStart(RectF rect);
|
||||
float getEnd(RectF rect);
|
||||
int getClearAllSidePadding(View view, boolean isRtl);
|
||||
int getSecondaryDimension(View view);
|
||||
FloatProperty<View> getPrimaryViewTranslate();
|
||||
FloatProperty<View> getSecondaryViewTranslate();
|
||||
int getSplitTranslationDirectionFactor(@StagePosition int stagePosition,
|
||||
DeviceProfile deviceProfile);
|
||||
Pair<FloatProperty, FloatProperty> getSplitSelectTaskOffset(FloatProperty primary,
|
||||
FloatProperty secondary, DeviceProfile deviceProfile);
|
||||
int getDistanceToBottomOfRect(DeviceProfile dp, Rect rect);
|
||||
List<SplitPositionOption> getSplitPositionOptions(DeviceProfile dp);
|
||||
/**
|
||||
* @param placeholderHeight height of placeholder view in portrait, width in landscape
|
||||
*/
|
||||
void getInitialSplitPlaceholderBounds(int placeholderHeight, int placeholderInset,
|
||||
DeviceProfile dp, @StagePosition int stagePosition, Rect out);
|
||||
|
||||
/**
|
||||
* Centers an icon in the split staging area, accounting for insets.
|
||||
* @param out The icon that needs to be centered.
|
||||
* @param onScreenRectCenterX The x-center of the on-screen staging area (most of the Rect is
|
||||
* offscreen).
|
||||
* @param onScreenRectCenterY The y-center of the on-screen staging area (most of the Rect is
|
||||
* offscreen).
|
||||
* @param fullscreenScaleX A x-scaling factor used to convert coordinates back into pixels.
|
||||
* @param fullscreenScaleY A y-scaling factor used to convert coordinates back into pixels.
|
||||
* @param drawableWidth The icon's drawable (final) width.
|
||||
* @param drawableHeight The icon's drawable (final) height.
|
||||
* @param dp The device profile, used to report rotation and hardware insets.
|
||||
* @param stagePosition 0 if the staging area is pinned to top/left, 1 for bottom/right.
|
||||
*/
|
||||
void updateSplitIconParams(View out, float onScreenRectCenterX,
|
||||
float onScreenRectCenterY, float fullscreenScaleX, float fullscreenScaleY,
|
||||
int drawableWidth, int drawableHeight, DeviceProfile dp,
|
||||
@StagePosition int stagePosition);
|
||||
|
||||
/**
|
||||
* Sets positioning and rotation for a SplitInstructionsView.
|
||||
* @param out The SplitInstructionsView that needs to be positioned.
|
||||
* @param dp The device profile, used to report rotation and device type.
|
||||
* @param splitInstructionsHeight The SplitInstructionView's height.
|
||||
* @param splitInstructionsWidth The SplitInstructionView's width.
|
||||
*/
|
||||
void setSplitInstructionsParams(View out, DeviceProfile dp, int splitInstructionsHeight,
|
||||
int splitInstructionsWidth);
|
||||
|
||||
/**
|
||||
* @param splitDividerSize height of split screen drag handle in portrait, width in landscape
|
||||
* @param stagePosition the split position option (top/left, bottom/right) of the first
|
||||
* task selected for entering split
|
||||
* @param out1 the bounds for where the first selected app will be
|
||||
* @param out2 the bounds for where the second selected app will be, complimentary to
|
||||
* {@param out1} based on {@param initialSplitOption}
|
||||
*/
|
||||
void getFinalSplitPlaceholderBounds(int splitDividerSize, DeviceProfile dp,
|
||||
@StagePosition int stagePosition, Rect out1, Rect out2);
|
||||
|
||||
int getDefaultSplitPosition(DeviceProfile deviceProfile);
|
||||
|
||||
/**
|
||||
* @param outRect This is expected to be the rect that has the dimensions for a non-split,
|
||||
* fullscreen task in overview. This will directly be modified.
|
||||
* @param desiredStagePosition Which stage position (topLeft/rightBottom) we want to resize
|
||||
* outRect for
|
||||
*/
|
||||
void setSplitTaskSwipeRect(DeviceProfile dp, Rect outRect, SplitBounds splitInfo,
|
||||
@SplitConfigurationOptions.StagePosition int desiredStagePosition);
|
||||
|
||||
void measureGroupedTaskViewThumbnailBounds(View primarySnapshot, View secondarySnapshot,
|
||||
int parentWidth, int parentHeight,
|
||||
SplitBounds splitBoundsConfig, DeviceProfile dp, boolean isRtl);
|
||||
|
||||
// Overview TaskMenuView methods
|
||||
void setTaskIconParams(FrameLayout.LayoutParams iconParams,
|
||||
int taskIconMargin, int taskIconHeight, int thumbnailTopMargin, boolean isRtl);
|
||||
|
||||
void setIconAppChipMenuParams(IconAppChipView iconAppChipView,
|
||||
FrameLayout.LayoutParams iconMenuParams,
|
||||
int iconMenuMargin, int thumbnailTopMargin);
|
||||
void setSplitIconParams(View primaryIconView, View secondaryIconView,
|
||||
int taskIconHeight, int primarySnapshotWidth, int primarySnapshotHeight,
|
||||
int groupedTaskViewHeight, int groupedTaskViewWidth, boolean isRtl,
|
||||
DeviceProfile deviceProfile, SplitBounds splitConfig);
|
||||
|
||||
/*
|
||||
* The following two methods try to center the TaskMenuView in landscape by finding the center
|
||||
* of the thumbnail view and then subtracting half of the taskMenu width. In this case, the
|
||||
* taskMenu width is the same size as the thumbnail width (what got set below in
|
||||
* getTaskMenuWidth()), so we directly use that in the calculations.
|
||||
*/
|
||||
float getTaskMenuX(float x, View thumbnailView, DeviceProfile deviceProfile,
|
||||
float taskInsetMargin, View taskViewIcon);
|
||||
float getTaskMenuY(float y, View thumbnailView, int stagePosition,
|
||||
View taskMenuView, float taskInsetMargin, View taskViewIcon);
|
||||
int getTaskMenuWidth(View thumbnailView, DeviceProfile deviceProfile,
|
||||
@StagePosition int stagePosition);
|
||||
/**
|
||||
* Sets linear layout orientation for {@link com.android.launcher3.popup.SystemShortcut} items
|
||||
* inside task menu view.
|
||||
*/
|
||||
void setTaskOptionsMenuLayoutOrientation(DeviceProfile deviceProfile,
|
||||
LinearLayout taskMenuLayout, int dividerSpacing,
|
||||
ShapeDrawable dividerDrawable);
|
||||
/**
|
||||
* Sets layout param attributes for {@link com.android.launcher3.popup.SystemShortcut} child
|
||||
* views inside task menu view.
|
||||
*/
|
||||
void setLayoutParamsForTaskMenuOptionItem(LinearLayout.LayoutParams lp,
|
||||
LinearLayout viewGroup, DeviceProfile deviceProfile);
|
||||
|
||||
/**
|
||||
* Calculates the position where a Digital Wellbeing Banner should be placed on its parent
|
||||
* TaskView.
|
||||
* @return A Pair of Floats representing the proper x and y translations.
|
||||
*/
|
||||
Pair<Float, Float> getDwbLayoutTranslations(int taskViewWidth,
|
||||
int taskViewHeight, SplitBounds splitBounds, DeviceProfile deviceProfile,
|
||||
View[] thumbnailViews, int desiredTaskId, View banner);
|
||||
|
||||
// The following are only used by TaskViewTouchHandler.
|
||||
/** @return Either VERTICAL or HORIZONTAL. */
|
||||
SingleAxisSwipeDetector.Direction getUpDownSwipeDirection();
|
||||
/** @return Given {@link #getUpDownSwipeDirection()}, whether POSITIVE or NEGATIVE is up. */
|
||||
int getUpDirection(boolean isRtl);
|
||||
/** @return Whether the displacement is going towards the top of the screen. */
|
||||
boolean isGoingUp(float displacement, boolean isRtl);
|
||||
/** @return Either 1 or -1, a factor to multiply by so the animation goes the correct way. */
|
||||
int getTaskDragDisplacementFactor(boolean isRtl);
|
||||
|
||||
/**
|
||||
* Maps the velocity from the coordinate plane of the foreground app to that
|
||||
* of Launcher's (which now will always be portrait)
|
||||
*/
|
||||
void adjustFloatingIconStartVelocity(PointF velocity);
|
||||
|
||||
/**
|
||||
* Ensures that outStartRect left bound is within the DeviceProfile's visual boundaries
|
||||
* @param outStartRect The start rect that will directly be modified
|
||||
*/
|
||||
void fixBoundsForHomeAnimStartRect(RectF outStartRect, DeviceProfile deviceProfile);
|
||||
|
||||
/**
|
||||
* Determine the target translation for animating the FloatingTaskView out. This value could
|
||||
* either be an x-coordinate or a y-coordinate, depending on which way the FloatingTaskView was
|
||||
* docked.
|
||||
*
|
||||
* @param floatingTask The FloatingTaskView.
|
||||
* @param onScreenRect The current on-screen dimensions of the FloatingTaskView.
|
||||
* @param stagePosition STAGE_POSITION_TOP_OR_LEFT or STAGE_POSITION_BOTTOM_OR_RIGHT.
|
||||
* @param dp The device profile.
|
||||
* @return A float. When an animation translates the FloatingTaskView to this position, it will
|
||||
* appear to tuck away off the edge of the screen.
|
||||
*/
|
||||
float getFloatingTaskOffscreenTranslationTarget(View floatingTask, RectF onScreenRect,
|
||||
@StagePosition int stagePosition, DeviceProfile dp);
|
||||
|
||||
/**
|
||||
* Sets the translation of a FloatingTaskView along its "slide-in/slide-out" axis (could be
|
||||
* either x or y), depending on how the view is oriented.
|
||||
*
|
||||
* @param floatingTask The FloatingTaskView to be translated.
|
||||
* @param translation The target translation value.
|
||||
* @param dp The current device profile.
|
||||
*/
|
||||
void setFloatingTaskPrimaryTranslation(View floatingTask, float translation, DeviceProfile dp);
|
||||
|
||||
/**
|
||||
* Gets the translation of a FloatingTaskView along its "slide-in/slide-out" axis (could be
|
||||
* either x or y), depending on how the view is oriented.
|
||||
*
|
||||
* @param floatingTask The FloatingTaskView in question.
|
||||
* @param dp The current device profile.
|
||||
* @return The current translation value.
|
||||
*/
|
||||
Float getFloatingTaskPrimaryTranslation(View floatingTask, DeviceProfile dp);
|
||||
}
|
||||
@@ -0,0 +1,394 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.quickstep.orientation;
|
||||
|
||||
import static android.view.Gravity.BOTTOM;
|
||||
import static android.view.Gravity.CENTER_VERTICAL;
|
||||
import static android.view.Gravity.END;
|
||||
import static android.view.Gravity.RIGHT;
|
||||
import static android.view.Gravity.START;
|
||||
import static android.view.Gravity.TOP;
|
||||
import static android.view.View.LAYOUT_DIRECTION_RTL;
|
||||
|
||||
import static com.android.launcher3.Flags.enableOverviewIconMenu;
|
||||
import static com.android.launcher3.touch.SingleAxisSwipeDetector.HORIZONTAL;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_UNDEFINED;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_TYPE_MAIN;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.util.Pair;
|
||||
import android.view.Gravity;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.touch.SingleAxisSwipeDetector;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.SplitBounds;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
import com.android.quickstep.views.IconAppChipView;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class SeascapePagedViewHandler extends LandscapePagedViewHandler {
|
||||
|
||||
@Override
|
||||
public int getSecondaryTranslationDirectionFactor() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSplitTranslationDirectionFactor(int stagePosition, DeviceProfile deviceProfile) {
|
||||
if (stagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getRecentsRtlSetting(Resources resources) {
|
||||
return Utilities.isRtl(resources);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDegreesRotated() {
|
||||
return 270;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRotation() {
|
||||
return Surface.ROTATION_270;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustFloatingIconStartVelocity(PointF velocity) {
|
||||
float oldX = velocity.x;
|
||||
float oldY = velocity.y;
|
||||
velocity.set(oldY, -oldX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTaskMenuX(float x, View thumbnailView,
|
||||
DeviceProfile deviceProfile, float taskInsetMargin, View taskViewIcon) {
|
||||
if (enableOverviewIconMenu()) {
|
||||
return x + (taskViewIcon.getHeight() * 2);
|
||||
}
|
||||
return x + taskInsetMargin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTaskMenuY(float y, View thumbnailView, int stagePosition,
|
||||
View taskMenuView, float taskInsetMargin, View taskViewIcon) {
|
||||
if (enableOverviewIconMenu()) {
|
||||
return y + taskViewIcon.getWidth() + (
|
||||
thumbnailView.getLayoutDirection() == LAYOUT_DIRECTION_RTL ? taskInsetMargin
|
||||
/ 2f : -taskViewIcon.getHeight());
|
||||
}
|
||||
BaseDragLayer.LayoutParams lp = (BaseDragLayer.LayoutParams) taskMenuView.getLayoutParams();
|
||||
int taskMenuWidth = lp.width;
|
||||
if (stagePosition == STAGE_POSITION_UNDEFINED) {
|
||||
return y + taskInsetMargin
|
||||
+ (thumbnailView.getMeasuredHeight() + taskMenuWidth) / 2f;
|
||||
} else {
|
||||
return y + taskMenuWidth + taskInsetMargin;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSplitTaskSwipeRect(DeviceProfile dp, Rect outRect, SplitBounds splitInfo,
|
||||
int desiredStagePosition) {
|
||||
float topLeftTaskPercent = splitInfo.appsStackedVertically
|
||||
? splitInfo.topTaskPercent
|
||||
: splitInfo.leftTaskPercent;
|
||||
float dividerBarPercent = splitInfo.appsStackedVertically
|
||||
? splitInfo.dividerHeightPercent
|
||||
: splitInfo.dividerWidthPercent;
|
||||
|
||||
// In seascape, the primary thumbnail is counterintuitively placed at the physical bottom of
|
||||
// the screen. This is to preserve consistency when the user rotates: From the user's POV,
|
||||
// the primary should always be on the left.
|
||||
if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) {
|
||||
outRect.top += (int) (outRect.height() * ((1 - topLeftTaskPercent)));
|
||||
} else {
|
||||
outRect.bottom -= (int) (outRect.height() * (topLeftTaskPercent + dividerBarPercent));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Float, Float> getDwbLayoutTranslations(int taskViewWidth,
|
||||
int taskViewHeight, SplitBounds splitBounds, DeviceProfile deviceProfile,
|
||||
View[] thumbnailViews, int desiredTaskId, View banner) {
|
||||
boolean isRtl = banner.getLayoutDirection() == LAYOUT_DIRECTION_RTL;
|
||||
float translationX = 0;
|
||||
float translationY = 0;
|
||||
FrameLayout.LayoutParams bannerParams = (FrameLayout.LayoutParams) banner.getLayoutParams();
|
||||
banner.setPivotX(0);
|
||||
banner.setPivotY(0);
|
||||
banner.setRotation(getDegreesRotated());
|
||||
translationX = taskViewWidth - banner.getHeight();
|
||||
FrameLayout.LayoutParams snapshotParams =
|
||||
(FrameLayout.LayoutParams) thumbnailViews[0]
|
||||
.getLayoutParams();
|
||||
bannerParams.gravity = BOTTOM | (isRtl ? END : START);
|
||||
|
||||
if (splitBounds == null) {
|
||||
// Single, fullscreen case
|
||||
bannerParams.width = taskViewHeight - snapshotParams.topMargin;
|
||||
translationY = banner.getHeight();
|
||||
return new Pair<>(translationX, translationY);
|
||||
}
|
||||
|
||||
// Set correct width
|
||||
if (desiredTaskId == splitBounds.leftTopTaskId) {
|
||||
bannerParams.width = thumbnailViews[0].getMeasuredHeight();
|
||||
} else {
|
||||
bannerParams.width = thumbnailViews[1].getMeasuredHeight();
|
||||
}
|
||||
|
||||
// Set translations
|
||||
if (desiredTaskId == splitBounds.rightBottomTaskId) {
|
||||
translationY = banner.getHeight();
|
||||
}
|
||||
if (desiredTaskId == splitBounds.leftTopTaskId) {
|
||||
float bottomRightTaskPlusDividerPercent = splitBounds.appsStackedVertically
|
||||
? (1f - splitBounds.topTaskPercent)
|
||||
: (1f - splitBounds.leftTaskPercent);
|
||||
translationY = banner.getHeight()
|
||||
- ((taskViewHeight - snapshotParams.topMargin)
|
||||
* bottomRightTaskPlusDividerPercent);
|
||||
}
|
||||
return new Pair<>(translationX, translationY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistanceToBottomOfRect(DeviceProfile dp, Rect rect) {
|
||||
return dp.widthPx - rect.right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SplitPositionOption> getSplitPositionOptions(DeviceProfile dp) {
|
||||
// Add "right" option which is actually the top
|
||||
return Collections.singletonList(new SplitPositionOption(
|
||||
R.drawable.ic_split_horizontal, R.string.recent_task_option_split_screen,
|
||||
STAGE_POSITION_BOTTOM_OR_RIGHT, STAGE_TYPE_MAIN));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSplitInstructionsParams(View out, DeviceProfile dp, int splitInstructionsHeight,
|
||||
int splitInstructionsWidth) {
|
||||
out.setPivotX(0);
|
||||
out.setPivotY(splitInstructionsHeight);
|
||||
out.setRotation(getDegreesRotated());
|
||||
int distanceToEdge = out.getResources().getDimensionPixelSize(
|
||||
R.dimen.split_instructions_bottom_margin_phone_landscape);
|
||||
// Adjust for any insets on the right edge
|
||||
int insetCorrectionX = dp.getInsets().right;
|
||||
// Center the view in case of unbalanced insets on top or bottom of screen
|
||||
int insetCorrectionY = (dp.getInsets().bottom - dp.getInsets().top) / 2;
|
||||
out.setTranslationX(splitInstructionsWidth - distanceToEdge + insetCorrectionX);
|
||||
out.setTranslationY(((-splitInstructionsHeight + splitInstructionsWidth) / 2f)
|
||||
+ insetCorrectionY);
|
||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) out.getLayoutParams();
|
||||
// Setting gravity to RIGHT instead of the lint-recommended END because we always want this
|
||||
// view to be screen-right when phone is in seascape, regardless of the RtL setting.
|
||||
lp.gravity = RIGHT | CENTER_VERTICAL;
|
||||
out.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTaskIconParams(FrameLayout.LayoutParams iconParams,
|
||||
int taskIconMargin, int taskIconHeight, int thumbnailTopMargin, boolean isRtl) {
|
||||
iconParams.rightMargin = 0;
|
||||
iconParams.bottomMargin = 0;
|
||||
if (enableOverviewIconMenu()) {
|
||||
iconParams.setMarginStart(taskIconMargin);
|
||||
iconParams.gravity = Gravity.START | Gravity.CENTER_VERTICAL;
|
||||
iconParams.leftMargin = 0;
|
||||
iconParams.topMargin = 0;
|
||||
} else {
|
||||
iconParams.gravity = (isRtl ? END : START) | CENTER_VERTICAL;
|
||||
iconParams.leftMargin = -taskIconHeight - taskIconMargin / 2;
|
||||
iconParams.topMargin = thumbnailTopMargin / 2;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIconAppChipMenuParams(IconAppChipView iconAppChipView,
|
||||
FrameLayout.LayoutParams iconMenuParams, int iconMenuMargin, int thumbnailTopMargin) {
|
||||
boolean isRtl = iconAppChipView.getLayoutDirection() == LAYOUT_DIRECTION_RTL;
|
||||
iconMenuParams.gravity = (isRtl ? TOP : BOTTOM) | (isRtl ? END : START);
|
||||
iconMenuParams.setMarginStart(0);
|
||||
iconMenuParams.topMargin = isRtl ? iconMenuMargin : 0;
|
||||
iconMenuParams.bottomMargin = 0;
|
||||
iconMenuParams.setMarginEnd(isRtl ? thumbnailTopMargin : 0);
|
||||
|
||||
// Use half menu height to place the pivot within the X/Y center of icon in the menu.
|
||||
float iconCenter = iconAppChipView.getHeight() / 2f;
|
||||
iconAppChipView.setPivotX(isRtl ? iconMenuParams.width / 2f : iconCenter);
|
||||
iconAppChipView.setPivotY(
|
||||
isRtl ? iconMenuParams.width / 2f : iconCenter - iconMenuMargin);
|
||||
iconAppChipView.setTranslationY(0);
|
||||
iconAppChipView.setRotation(getDegreesRotated());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSplitIconParams(View primaryIconView, View secondaryIconView,
|
||||
int taskIconHeight, int primarySnapshotWidth, int primarySnapshotHeight,
|
||||
int groupedTaskViewHeight, int groupedTaskViewWidth, boolean isRtl,
|
||||
DeviceProfile deviceProfile, SplitBounds splitConfig) {
|
||||
super.setSplitIconParams(primaryIconView, secondaryIconView, taskIconHeight,
|
||||
primarySnapshotWidth, primarySnapshotHeight, groupedTaskViewHeight,
|
||||
groupedTaskViewWidth, isRtl, deviceProfile, splitConfig);
|
||||
FrameLayout.LayoutParams primaryIconParams =
|
||||
(FrameLayout.LayoutParams) primaryIconView.getLayoutParams();
|
||||
FrameLayout.LayoutParams secondaryIconParams =
|
||||
(FrameLayout.LayoutParams) secondaryIconView.getLayoutParams();
|
||||
|
||||
// We calculate the "midpoint" of the thumbnail area, and place the icons there.
|
||||
// This is the place where the thumbnail area splits by default, in a near-50/50 split.
|
||||
// It is usually not exactly 50/50, due to insets/screen cutouts.
|
||||
int fullscreenInsetThickness = deviceProfile.getInsets().top
|
||||
- deviceProfile.getInsets().bottom;
|
||||
int fullscreenMidpointFromBottom = ((deviceProfile.heightPx
|
||||
- fullscreenInsetThickness) / 2);
|
||||
float midpointFromBottomPct = (float) fullscreenMidpointFromBottom / deviceProfile.heightPx;
|
||||
float insetPct = (float) fullscreenInsetThickness / deviceProfile.heightPx;
|
||||
int spaceAboveSnapshots = deviceProfile.overviewTaskThumbnailTopMarginPx;
|
||||
int overviewThumbnailAreaThickness = groupedTaskViewHeight - spaceAboveSnapshots;
|
||||
int bottomToMidpointOffset = (int) (overviewThumbnailAreaThickness * midpointFromBottomPct);
|
||||
int insetOffset = (int) (overviewThumbnailAreaThickness * insetPct);
|
||||
|
||||
int gravity = (isRtl ? TOP : BOTTOM) | (isRtl ? END : START);
|
||||
primaryIconParams.gravity = gravity;
|
||||
secondaryIconParams.gravity = gravity;
|
||||
primaryIconView.setTranslationX(0);
|
||||
secondaryIconView.setTranslationX(0);
|
||||
if (enableOverviewIconMenu()) {
|
||||
if (isRtl) {
|
||||
primaryIconView.setTranslationY(groupedTaskViewHeight - primarySnapshotHeight);
|
||||
secondaryIconView.setTranslationY(0);
|
||||
} else {
|
||||
secondaryIconView.setTranslationY(-primarySnapshotHeight);
|
||||
primaryIconView.setTranslationY(0);
|
||||
}
|
||||
} else if (splitConfig.initiatedFromSeascape) {
|
||||
// if the split was initiated from seascape,
|
||||
// the task on the right (secondary) is slightly larger
|
||||
if (isRtl) {
|
||||
primaryIconView.setTranslationY(bottomToMidpointOffset - insetOffset
|
||||
+ taskIconHeight);
|
||||
secondaryIconView.setTranslationY(bottomToMidpointOffset - insetOffset);
|
||||
} else {
|
||||
primaryIconView.setTranslationY(-bottomToMidpointOffset - insetOffset
|
||||
+ taskIconHeight);
|
||||
secondaryIconView.setTranslationY(-bottomToMidpointOffset - insetOffset);
|
||||
}
|
||||
} else {
|
||||
// if not,
|
||||
// the task on the left (primary) is slightly larger
|
||||
if (isRtl) {
|
||||
primaryIconView.setTranslationY(bottomToMidpointOffset + taskIconHeight);
|
||||
secondaryIconView.setTranslationY(bottomToMidpointOffset);
|
||||
} else {
|
||||
primaryIconView.setTranslationY(-bottomToMidpointOffset + taskIconHeight);
|
||||
secondaryIconView.setTranslationY(-bottomToMidpointOffset);
|
||||
}
|
||||
}
|
||||
|
||||
primaryIconView.setLayoutParams(primaryIconParams);
|
||||
secondaryIconView.setLayoutParams(secondaryIconParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void measureGroupedTaskViewThumbnailBounds(View primarySnapshot, View secondarySnapshot,
|
||||
int parentWidth, int parentHeight, SplitBounds splitBoundsConfig, DeviceProfile dp,
|
||||
boolean isRtl) {
|
||||
FrameLayout.LayoutParams primaryParams =
|
||||
(FrameLayout.LayoutParams) primarySnapshot.getLayoutParams();
|
||||
FrameLayout.LayoutParams secondaryParams =
|
||||
(FrameLayout.LayoutParams) secondarySnapshot.getLayoutParams();
|
||||
|
||||
// Swap the margins that are set in TaskView#setRecentsOrientedState()
|
||||
secondaryParams.topMargin = dp.overviewTaskThumbnailTopMarginPx;
|
||||
primaryParams.topMargin = 0;
|
||||
|
||||
// Measure and layout the thumbnails bottom up, since the primary is on the visual left
|
||||
// (portrait bottom) and secondary is on the right (portrait top)
|
||||
int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx;
|
||||
int totalThumbnailHeight = parentHeight - spaceAboveSnapshot;
|
||||
int dividerBar = Math.round(totalThumbnailHeight * (splitBoundsConfig.appsStackedVertically
|
||||
? splitBoundsConfig.dividerHeightPercent
|
||||
: splitBoundsConfig.dividerWidthPercent));
|
||||
int primarySnapshotHeight;
|
||||
int primarySnapshotWidth;
|
||||
int secondarySnapshotHeight;
|
||||
int secondarySnapshotWidth;
|
||||
|
||||
float taskPercent = splitBoundsConfig.appsStackedVertically ?
|
||||
splitBoundsConfig.topTaskPercent : splitBoundsConfig.leftTaskPercent;
|
||||
primarySnapshotWidth = parentWidth;
|
||||
primarySnapshotHeight = (int) (totalThumbnailHeight * (taskPercent));
|
||||
|
||||
secondarySnapshotWidth = parentWidth;
|
||||
secondarySnapshotHeight = totalThumbnailHeight - primarySnapshotHeight - dividerBar;
|
||||
secondarySnapshot.setTranslationY(0);
|
||||
primarySnapshot.setTranslationY(secondarySnapshotHeight + spaceAboveSnapshot + dividerBar);
|
||||
|
||||
primarySnapshot.measure(
|
||||
View.MeasureSpec.makeMeasureSpec(primarySnapshotWidth, View.MeasureSpec.EXACTLY),
|
||||
View.MeasureSpec.makeMeasureSpec(primarySnapshotHeight, View.MeasureSpec.EXACTLY)
|
||||
);
|
||||
secondarySnapshot.measure(
|
||||
View.MeasureSpec.makeMeasureSpec(secondarySnapshotWidth, View.MeasureSpec.EXACTLY),
|
||||
View.MeasureSpec.makeMeasureSpec(secondarySnapshotHeight, View.MeasureSpec.EXACTLY)
|
||||
);
|
||||
}
|
||||
|
||||
/* ---------- The following are only used by TaskViewTouchHandler. ---------- */
|
||||
|
||||
@Override
|
||||
public SingleAxisSwipeDetector.Direction getUpDownSwipeDirection() {
|
||||
return HORIZONTAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUpDirection(boolean isRtl) {
|
||||
return isRtl ? SingleAxisSwipeDetector.DIRECTION_POSITIVE
|
||||
: SingleAxisSwipeDetector.DIRECTION_NEGATIVE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGoingUp(float displacement, boolean isRtl) {
|
||||
return isRtl ? displacement > 0 : displacement < 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTaskDragDisplacementFactor(boolean isRtl) {
|
||||
return isRtl ? -1 : 1;
|
||||
}
|
||||
|
||||
/* -------------------- */
|
||||
}
|
||||
@@ -43,7 +43,7 @@ import com.android.launcher3.statemanager.StateManager;
|
||||
import com.android.launcher3.statemanager.StatefulActivity;
|
||||
import com.android.launcher3.states.StateAnimationConfig;
|
||||
import com.android.launcher3.touch.AllAppsSwipeController;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
|
||||
/**
|
||||
@@ -200,7 +200,7 @@ public class AnimatorControllerWithResistance {
|
||||
public static <SCALE, TRANSLATION> PendingAnimation createRecentsResistanceAnim(
|
||||
RecentsParams<SCALE, TRANSLATION> params) {
|
||||
Rect startRect = new Rect();
|
||||
PagedOrientationHandler orientationHandler = params.recentsOrientedState
|
||||
RecentsPagedOrientationHandler orientationHandler = params.recentsOrientedState
|
||||
.getOrientationHandler();
|
||||
params.recentsOrientedState.getActivityInterface()
|
||||
.calculateTaskSize(params.context, params.dp, startRect, orientationHandler);
|
||||
|
||||
@@ -21,10 +21,10 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.quickstep.LauncherActivityInterface;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
|
||||
public class LayoutUtils {
|
||||
|
||||
@@ -40,7 +40,7 @@ public class LayoutUtils {
|
||||
}
|
||||
|
||||
public static int getShelfTrackingDistance(Context context, DeviceProfile dp,
|
||||
PagedOrientationHandler orientationHandler) {
|
||||
RecentsPagedOrientationHandler orientationHandler) {
|
||||
// Track the bottom of the window.
|
||||
Rect taskSize = new Rect();
|
||||
LauncherActivityInterface.INSTANCE.calculateTaskSize(context, dp, taskSize,
|
||||
|
||||
@@ -53,6 +53,7 @@ import com.android.launcher3.util.SettingsCache;
|
||||
import com.android.quickstep.BaseActivityInterface;
|
||||
import com.android.quickstep.SystemUiProxy;
|
||||
import com.android.quickstep.TaskAnimationManager;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.util.function.IntConsumer;
|
||||
@@ -75,7 +76,8 @@ public class RecentsOrientedState implements
|
||||
@IntDef({ROTATION_0, ROTATION_90, ROTATION_180, ROTATION_270})
|
||||
public @interface SurfaceRotation {}
|
||||
|
||||
private PagedOrientationHandler mOrientationHandler = PagedOrientationHandler.PORTRAIT;
|
||||
private RecentsPagedOrientationHandler mOrientationHandler =
|
||||
RecentsPagedOrientationHandler.PORTRAIT;
|
||||
|
||||
private @SurfaceRotation int mTouchRotation = ROTATION_0;
|
||||
private @SurfaceRotation int mDisplayRotation = ROTATION_0;
|
||||
@@ -225,13 +227,13 @@ public class RecentsOrientedState implements
|
||||
private boolean updateHandler() {
|
||||
mRecentsActivityRotation = inferRecentsActivityRotation(mDisplayRotation);
|
||||
if (mRecentsActivityRotation == mTouchRotation || isRecentsActivityRotationAllowed()) {
|
||||
mOrientationHandler = PagedOrientationHandler.PORTRAIT;
|
||||
mOrientationHandler = RecentsPagedOrientationHandler.PORTRAIT;
|
||||
} else if (mTouchRotation == ROTATION_90) {
|
||||
mOrientationHandler = PagedOrientationHandler.LANDSCAPE;
|
||||
mOrientationHandler = RecentsPagedOrientationHandler.LANDSCAPE;
|
||||
} else if (mTouchRotation == ROTATION_270) {
|
||||
mOrientationHandler = PagedOrientationHandler.SEASCAPE;
|
||||
mOrientationHandler = RecentsPagedOrientationHandler.SEASCAPE;
|
||||
} else {
|
||||
mOrientationHandler = PagedOrientationHandler.PORTRAIT;
|
||||
mOrientationHandler = RecentsPagedOrientationHandler.PORTRAIT;
|
||||
}
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "current RecentsOrientedState: " + this);
|
||||
@@ -413,7 +415,7 @@ public class RecentsOrientedState implements
|
||||
return scale;
|
||||
}
|
||||
|
||||
public PagedOrientationHandler getOrientationHandler() {
|
||||
public RecentsPagedOrientationHandler getOrientationHandler() {
|
||||
return mOrientationHandler;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import android.widget.Button;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.statemanager.StatefulActivity;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
|
||||
public class ClearAllButton extends Button {
|
||||
|
||||
@@ -81,7 +81,8 @@ public class ClearAllButton extends Button {
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
PagedOrientationHandler orientationHandler = getRecentsView().getPagedOrientationHandler();
|
||||
RecentsPagedOrientationHandler orientationHandler =
|
||||
getRecentsView().getPagedOrientationHandler();
|
||||
mSidePadding = orientationHandler.getClearAllSidePadding(getRecentsView(), mIsRtl);
|
||||
}
|
||||
|
||||
@@ -131,7 +132,8 @@ public class ClearAllButton extends Button {
|
||||
return;
|
||||
}
|
||||
|
||||
PagedOrientationHandler orientationHandler = recentsView.getPagedOrientationHandler();
|
||||
RecentsPagedOrientationHandler orientationHandler =
|
||||
recentsView.getPagedOrientationHandler();
|
||||
float orientationSize = orientationHandler.getPrimaryValue(getWidth(), getHeight());
|
||||
if (orientationSize == 0) {
|
||||
return;
|
||||
@@ -219,7 +221,8 @@ public class ClearAllButton extends Button {
|
||||
return;
|
||||
}
|
||||
|
||||
PagedOrientationHandler orientationHandler = recentsView.getPagedOrientationHandler();
|
||||
RecentsPagedOrientationHandler orientationHandler =
|
||||
recentsView.getPagedOrientationHandler();
|
||||
orientationHandler.getPrimaryViewTranslate().set(this,
|
||||
orientationHandler.getPrimaryValue(0f, getOriginalTranslationY())
|
||||
+ mNormalTranslationPrimary + getFullscreenTrans(
|
||||
@@ -232,7 +235,8 @@ public class ClearAllButton extends Button {
|
||||
return;
|
||||
}
|
||||
|
||||
PagedOrientationHandler orientationHandler = recentsView.getPagedOrientationHandler();
|
||||
RecentsPagedOrientationHandler orientationHandler =
|
||||
recentsView.getPagedOrientationHandler();
|
||||
orientationHandler.getSecondaryViewTranslate().set(this,
|
||||
orientationHandler.getSecondaryValue(0f, getOriginalTranslationY()));
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ import com.android.launcher3.BaseDraggingActivity;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.SplitBounds;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
import com.android.systemui.shared.recents.model.Task;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -321,7 +321,7 @@ public final class DigitalWellBeingToast {
|
||||
DeviceProfile deviceProfile = mActivity.getDeviceProfile();
|
||||
layoutParams.bottomMargin = ((ViewGroup.MarginLayoutParams)
|
||||
mTaskView.getThumbnail().getLayoutParams()).bottomMargin;
|
||||
PagedOrientationHandler orientationHandler = mTaskView.getPagedOrientationHandler();
|
||||
RecentsPagedOrientationHandler orientationHandler = mTaskView.getPagedOrientationHandler();
|
||||
Pair<Float, Float> translations = orientationHandler
|
||||
.getDwbLayoutTranslations(mTaskView.getMeasuredWidth(),
|
||||
mTaskView.getMeasuredHeight(), mSplitBounds, deviceProfile,
|
||||
|
||||
@@ -43,9 +43,9 @@ import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.PendingAnimation;
|
||||
import com.android.launcher3.statemanager.StatefulActivity;
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
import com.android.quickstep.util.AnimUtils;
|
||||
import com.android.quickstep.util.MultiValueUpdateListener;
|
||||
import com.android.quickstep.util.SplitAnimationTimings;
|
||||
@@ -95,7 +95,7 @@ public class FloatingTaskView extends FrameLayout {
|
||||
private final StatefulActivity mActivity;
|
||||
private final boolean mIsRtl;
|
||||
private final FullscreenDrawParams mFullscreenParams;
|
||||
private PagedOrientationHandler mOrientationHandler;
|
||||
private RecentsPagedOrientationHandler mOrientationHandler;
|
||||
@SplitConfigurationOptions.StagePosition
|
||||
private int mStagePosition;
|
||||
private final Rect mTmpRect = new Rect();
|
||||
@@ -220,7 +220,7 @@ public class FloatingTaskView extends FrameLayout {
|
||||
mOrientationHandler.setSecondaryScale(mSplitPlaceholderView.getIconView(), childScaleY);
|
||||
}
|
||||
|
||||
public void updateOrientationHandler(PagedOrientationHandler orientationHandler) {
|
||||
public void updateOrientationHandler(RecentsPagedOrientationHandler orientationHandler) {
|
||||
mOrientationHandler = orientationHandler;
|
||||
mSplitPlaceholderView.getIconView().setRotation(mOrientationHandler.getDegreesRotated());
|
||||
}
|
||||
|
||||
@@ -39,9 +39,9 @@ import androidx.annotation.Nullable;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.util.MultiValueAlpha;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
import com.android.quickstep.util.RecentsOrientedState;
|
||||
|
||||
/**
|
||||
@@ -211,7 +211,8 @@ public class IconAppChipView extends FrameLayout implements TaskViewIcon {
|
||||
|
||||
@Override
|
||||
public void setIconOrientation(RecentsOrientedState orientationState, boolean isGridTask) {
|
||||
PagedOrientationHandler orientationHandler = orientationState.getOrientationHandler();
|
||||
RecentsPagedOrientationHandler orientationHandler =
|
||||
orientationState.getOrientationHandler();
|
||||
boolean isRtl = isLayoutRtl();
|
||||
DeviceProfile deviceProfile =
|
||||
ActivityContext.lookupContext(getContext()).getDeviceProfile();
|
||||
|
||||
@@ -30,8 +30,8 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
import com.android.quickstep.util.RecentsOrientedState;
|
||||
|
||||
/**
|
||||
@@ -173,7 +173,8 @@ public class IconView extends View implements TaskViewIcon {
|
||||
|
||||
@Override
|
||||
public void setIconOrientation(RecentsOrientedState orientationState, boolean isGridTask) {
|
||||
PagedOrientationHandler orientationHandler = orientationState.getOrientationHandler();
|
||||
RecentsPagedOrientationHandler orientationHandler =
|
||||
orientationState.getOrientationHandler();
|
||||
boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
|
||||
DeviceProfile deviceProfile =
|
||||
ActivityContext.lookupContext(getContext()).getDeviceProfile();
|
||||
|
||||
@@ -156,7 +156,6 @@ import com.android.launcher3.statemanager.StatefulActivity;
|
||||
import com.android.launcher3.testing.TestLogging;
|
||||
import com.android.launcher3.testing.shared.TestProtocol;
|
||||
import com.android.launcher3.touch.OverScroll;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.util.DynamicResource;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.IntSet;
|
||||
@@ -187,6 +186,7 @@ import com.android.quickstep.TaskThumbnailCache;
|
||||
import com.android.quickstep.TaskViewUtils;
|
||||
import com.android.quickstep.TopTaskTracker;
|
||||
import com.android.quickstep.ViewUtils;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
import com.android.quickstep.util.ActiveGestureErrorDetector;
|
||||
import com.android.quickstep.util.ActiveGestureLog;
|
||||
import com.android.quickstep.util.AnimUtils;
|
||||
@@ -788,7 +788,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
mDesktopTaskViewPool = new ViewPool<>(context, this, R.layout.task_desktop,
|
||||
5 /* max size */, 1 /* initial size */);
|
||||
|
||||
mIsRtl = mOrientationHandler.getRecentsRtlSetting(getResources());
|
||||
setOrientationHandler(mOrientationState.getOrientationHandler());
|
||||
mIsRtl = getPagedOrientationHandler().getRecentsRtlSetting(getResources());
|
||||
setLayoutDirection(mIsRtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR);
|
||||
mSplitPlaceholderSize = getResources().getDimensionPixelSize(
|
||||
R.dimen.split_placeholder_size);
|
||||
@@ -812,7 +813,6 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
.getDimensionPixelSize(R.dimen.recents_empty_message_text_padding);
|
||||
setWillNotDraw(false);
|
||||
updateEmptyMessage();
|
||||
mOrientationHandler = mOrientationState.getOrientationHandler();
|
||||
|
||||
mTaskOverlayFactory = Overrides.getObject(
|
||||
TaskOverlayFactory.class,
|
||||
@@ -918,9 +918,9 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
if (mAllowOverScroll && (!mEdgeGlowRight.isFinished() || !mEdgeGlowLeft.isFinished())) {
|
||||
final int restoreCount = canvas.save();
|
||||
|
||||
int primarySize = mOrientationHandler.getPrimaryValue(getWidth(), getHeight());
|
||||
int primarySize = getPagedOrientationHandler().getPrimaryValue(getWidth(), getHeight());
|
||||
int scroll = OverScroll.dampedScroll(getUndampedOverScrollShift(), primarySize);
|
||||
mOrientationHandler.setPrimary(canvas, CANVAS_TRANSLATE, scroll);
|
||||
getPagedOrientationHandler().setPrimary(canvas, CANVAS_TRANSLATE, scroll);
|
||||
|
||||
if (mOverScrollShift != scroll) {
|
||||
mOverScrollShift = scroll;
|
||||
@@ -944,8 +944,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
private float getUndampedOverScrollShift() {
|
||||
final int width = getWidth();
|
||||
final int height = getHeight();
|
||||
int primarySize = mOrientationHandler.getPrimaryValue(width, height);
|
||||
int secondarySize = mOrientationHandler.getSecondaryValue(width, height);
|
||||
int primarySize = getPagedOrientationHandler().getPrimaryValue(width, height);
|
||||
int secondarySize = getPagedOrientationHandler().getSecondaryValue(width, height);
|
||||
|
||||
float effectiveShift = 0;
|
||||
if (!mEdgeGlowLeft.isFinished()) {
|
||||
@@ -1270,8 +1270,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
|
||||
public boolean isTaskViewVisible(TaskView tv) {
|
||||
if (showAsGrid()) {
|
||||
int screenStart = mOrientationHandler.getPrimaryScroll(this);
|
||||
int screenEnd = screenStart + mOrientationHandler.getMeasuredSize(this);
|
||||
int screenStart = getPagedOrientationHandler().getPrimaryScroll(this);
|
||||
int screenEnd = screenStart + getPagedOrientationHandler().getMeasuredSize(this);
|
||||
return isTaskViewWithinBounds(tv, screenStart, screenEnd);
|
||||
} else {
|
||||
// For now, just check if it's the active task or an adjacent task
|
||||
@@ -1281,8 +1281,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
|
||||
public boolean isTaskViewFullyVisible(TaskView tv) {
|
||||
if (showAsGrid()) {
|
||||
int screenStart = mOrientationHandler.getPrimaryScroll(this);
|
||||
int screenEnd = screenStart + mOrientationHandler.getMeasuredSize(this);
|
||||
int screenStart = getPagedOrientationHandler().getPrimaryScroll(this);
|
||||
int screenEnd = screenStart + getPagedOrientationHandler().getMeasuredSize(this);
|
||||
return isTaskViewFullyWithinBounds(tv, screenStart, screenEnd);
|
||||
} else {
|
||||
// For now, just check if it's the active task
|
||||
@@ -1307,9 +1307,9 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
|
||||
private int getSnapToLastTaskScrollDiff() {
|
||||
// Snap to a position where ClearAll is just invisible.
|
||||
int screenStart = mOrientationHandler.getPrimaryScroll(this);
|
||||
int screenStart = getPagedOrientationHandler().getPrimaryScroll(this);
|
||||
int clearAllScroll = getScrollForPage(indexOfChild(mClearAllButton));
|
||||
int clearAllWidth = mOrientationHandler.getPrimarySize(mClearAllButton);
|
||||
int clearAllWidth = getPagedOrientationHandler().getPrimarySize(mClearAllButton);
|
||||
int lastTaskScroll = getLastTaskScroll(clearAllScroll, clearAllWidth);
|
||||
return screenStart - lastTaskScroll;
|
||||
}
|
||||
@@ -1320,20 +1320,20 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
}
|
||||
|
||||
private boolean isTaskViewWithinBounds(TaskView tv, int start, int end) {
|
||||
int taskStart = mOrientationHandler.getChildStart(tv) + (int) tv.getOffsetAdjustment(
|
||||
showAsGrid());
|
||||
int taskSize = (int) (mOrientationHandler.getMeasuredSize(tv) * tv.getSizeAdjustment(
|
||||
showAsFullscreen()));
|
||||
int taskStart = getPagedOrientationHandler().getChildStart(tv)
|
||||
+ (int) tv.getOffsetAdjustment(showAsGrid());
|
||||
int taskSize = (int) (getPagedOrientationHandler().getMeasuredSize(tv)
|
||||
* tv.getSizeAdjustment(showAsFullscreen()));
|
||||
int taskEnd = taskStart + taskSize;
|
||||
return (taskStart >= start && taskStart <= end) || (taskEnd >= start
|
||||
&& taskEnd <= end);
|
||||
}
|
||||
|
||||
private boolean isTaskViewFullyWithinBounds(TaskView tv, int start, int end) {
|
||||
int taskStart = mOrientationHandler.getChildStart(tv) + (int) tv.getOffsetAdjustment(
|
||||
showAsGrid());
|
||||
int taskSize = (int) (mOrientationHandler.getMeasuredSize(tv) * tv.getSizeAdjustment(
|
||||
showAsFullscreen()));
|
||||
int taskStart = getPagedOrientationHandler().getChildStart(tv)
|
||||
+ (int) tv.getOffsetAdjustment(showAsGrid());
|
||||
int taskSize = (int) (getPagedOrientationHandler().getMeasuredSize(tv)
|
||||
* tv.getSizeAdjustment(showAsFullscreen()));
|
||||
int taskEnd = taskStart + taskSize;
|
||||
return taskStart >= start && taskEnd <= end;
|
||||
}
|
||||
@@ -1628,7 +1628,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
return;
|
||||
}
|
||||
|
||||
int primaryScroll = mOrientationHandler.getPrimaryScroll(this);
|
||||
int primaryScroll = getPagedOrientationHandler().getPrimaryScroll(this);
|
||||
int currentPageScroll = getScrollForPage(mCurrentPage);
|
||||
mCurrentPageScrollDiff = primaryScroll - currentPageScroll;
|
||||
|
||||
@@ -2021,20 +2021,20 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
|
||||
private void updateOrientationHandler(boolean forceRecreateDragLayerControllers) {
|
||||
// Handle orientation changes.
|
||||
PagedOrientationHandler oldOrientationHandler = mOrientationHandler;
|
||||
mOrientationHandler = mOrientationState.getOrientationHandler();
|
||||
RecentsPagedOrientationHandler oldOrientationHandler = getPagedOrientationHandler();
|
||||
setOrientationHandler(mOrientationState.getOrientationHandler());
|
||||
|
||||
mIsRtl = mOrientationHandler.getRecentsRtlSetting(getResources());
|
||||
mIsRtl = getPagedOrientationHandler().getRecentsRtlSetting(getResources());
|
||||
setLayoutDirection(mIsRtl
|
||||
? View.LAYOUT_DIRECTION_RTL
|
||||
: View.LAYOUT_DIRECTION_LTR);
|
||||
mClearAllButton.setLayoutDirection(mIsRtl
|
||||
? View.LAYOUT_DIRECTION_LTR
|
||||
: View.LAYOUT_DIRECTION_RTL);
|
||||
mClearAllButton.setRotation(mOrientationHandler.getDegreesRotated());
|
||||
mClearAllButton.setRotation(getPagedOrientationHandler().getDegreesRotated());
|
||||
|
||||
if (forceRecreateDragLayerControllers
|
||||
|| !mOrientationHandler.equals(oldOrientationHandler)) {
|
||||
|| !getPagedOrientationHandler().equals(oldOrientationHandler)) {
|
||||
// Changed orientations, update controllers so they intercept accordingly.
|
||||
mActivity.getDragLayer().recreateControllers();
|
||||
onOrientationChanged();
|
||||
@@ -2081,7 +2081,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
mSizeStrategy.calculateGridSize(mActivity.getDeviceProfile(), mActivity,
|
||||
mLastComputedGridSize);
|
||||
mSizeStrategy.calculateGridTaskSize(mActivity, mActivity.getDeviceProfile(),
|
||||
mLastComputedGridTaskSize, mOrientationHandler);
|
||||
mLastComputedGridTaskSize, getPagedOrientationHandler());
|
||||
if (isDesktopModeSupported()) {
|
||||
mSizeStrategy.calculateDesktopTaskSize(mActivity, mActivity.getDeviceProfile(),
|
||||
mLastComputedDesktopTaskSize);
|
||||
@@ -2136,7 +2136,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
|
||||
public void getTaskSize(Rect outRect) {
|
||||
mSizeStrategy.calculateTaskSize(mActivity, mActivity.getDeviceProfile(), outRect,
|
||||
mOrientationHandler);
|
||||
getPagedOrientationHandler());
|
||||
mLastComputedTaskSize.set(outRect);
|
||||
}
|
||||
|
||||
@@ -2159,7 +2159,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
|
||||
private Rect getTaskBounds(TaskView taskView) {
|
||||
int selectedPage = indexOfChild(taskView);
|
||||
int primaryScroll = mOrientationHandler.getPrimaryScroll(this);
|
||||
int primaryScroll = getPagedOrientationHandler().getPrimaryScroll(this);
|
||||
int selectedPageScroll = getScrollForPage(selectedPage);
|
||||
boolean isTopRow = taskView != null && mTopRowIdSet.contains(taskView.getTaskViewId());
|
||||
Rect outRect = new Rect(mLastComputedTaskSize);
|
||||
@@ -2187,7 +2187,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
/** Gets the task size for modal state. */
|
||||
public void getModalTaskSize(Rect outRect) {
|
||||
mSizeStrategy.calculateModalTaskSize(mActivity, mActivity.getDeviceProfile(), outRect,
|
||||
mOrientationHandler);
|
||||
getPagedOrientationHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2243,7 +2243,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
if (getPageCount() == 0 || getPageAt(0).getMeasuredWidth() == 0) {
|
||||
return;
|
||||
}
|
||||
int scroll = mOrientationHandler.getPrimaryScroll(this);
|
||||
int scroll = getPagedOrientationHandler().getPrimaryScroll(this);
|
||||
mClearAllButton.onRecentsViewScroll(scroll, mOverviewGridEnabled);
|
||||
|
||||
// Clear all button alpha was set by the previous line.
|
||||
@@ -2293,8 +2293,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
int visibleStart = 0;
|
||||
int visibleEnd = 0;
|
||||
if (showAsGrid()) {
|
||||
int screenStart = mOrientationHandler.getPrimaryScroll(this);
|
||||
int pageOrientedSize = mOrientationHandler.getMeasuredSize(this);
|
||||
int screenStart = getPagedOrientationHandler().getPrimaryScroll(this);
|
||||
int pageOrientedSize = getPagedOrientationHandler().getMeasuredSize(this);
|
||||
// For GRID_ONLY_OVERVIEW, use +/- 1 task column as visible area for preloading
|
||||
// adjacent thumbnails, otherwise use +/-50% screen width
|
||||
int extraWidth = enableGridOnlyOverview() ? getLastComputedTaskSize().width()
|
||||
@@ -3232,8 +3232,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
clampToProgress(isOnGridBottomRow(taskView) ? ACCELERATE : FINAL_FRAME, 0, 0.5f));
|
||||
FloatProperty<TaskView> secondaryViewTranslate =
|
||||
taskView.getSecondaryDismissTranslationProperty();
|
||||
int secondaryTaskDimension = mOrientationHandler.getSecondaryDimension(taskView);
|
||||
int verticalFactor = mOrientationHandler.getSecondaryTranslationDirectionFactor();
|
||||
int secondaryTaskDimension = getPagedOrientationHandler().getSecondaryDimension(taskView);
|
||||
int verticalFactor = getPagedOrientationHandler().getSecondaryTranslationDirectionFactor();
|
||||
|
||||
ResourceProvider rp = DynamicResource.provider(mActivity);
|
||||
SpringProperty sp = new SpringProperty(SpringProperty.FLAG_CAN_SPRING_ON_START)
|
||||
@@ -3248,7 +3248,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
if (!mEnableDrawingLiveTile) return;
|
||||
runActionOnRemoteHandles(
|
||||
remoteTargetHandle -> remoteTargetHandle.getTaskViewSimulator()
|
||||
.taskSecondaryTranslation.value = mOrientationHandler
|
||||
.taskSecondaryTranslation.value = getPagedOrientationHandler()
|
||||
.getSecondaryValue(taskView.getTranslationX(),
|
||||
taskView.getTranslationY()
|
||||
));
|
||||
@@ -3262,7 +3262,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
* and then animates it into the split position that was desired
|
||||
*/
|
||||
private void createInitialSplitSelectAnimation(PendingAnimation anim) {
|
||||
mOrientationHandler.getInitialSplitPlaceholderBounds(mSplitPlaceholderSize,
|
||||
getPagedOrientationHandler().getInitialSplitPlaceholderBounds(mSplitPlaceholderSize,
|
||||
mSplitPlaceholderInset, mActivity.getDeviceProfile(),
|
||||
mSplitSelectStateController.getActiveSplitStagePosition(), mTempRect);
|
||||
SplitAnimationTimings timings =
|
||||
@@ -3491,7 +3491,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
// beyond that, we'll need to snap to last task instead.
|
||||
TaskView lastTask = getLastGridTaskView();
|
||||
if (lastTask != null) {
|
||||
int primaryScroll = mOrientationHandler.getPrimaryScroll(this);
|
||||
int primaryScroll = getPagedOrientationHandler().getPrimaryScroll(this);
|
||||
int lastTaskScroll = getScrollForPage(indexOfChild(lastTask));
|
||||
if ((mIsRtl && primaryScroll < lastTaskScroll)
|
||||
|| (!mIsRtl && primaryScroll > lastTaskScroll)) {
|
||||
@@ -3597,7 +3597,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
if (scrollDiff != 0) {
|
||||
FloatProperty translationProperty = child instanceof TaskView
|
||||
? ((TaskView) child).getPrimaryDismissTranslationProperty()
|
||||
: mOrientationHandler.getPrimaryViewTranslate();
|
||||
: getPagedOrientationHandler().getPrimaryViewTranslate();
|
||||
|
||||
float additionalDismissDuration =
|
||||
ADDITIONAL_DISMISS_TRANSLATION_INTERPOLATION_OFFSET * Math.abs(
|
||||
@@ -3633,7 +3633,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
remoteTargetHandle ->
|
||||
remoteTargetHandle.getTaskViewSimulator()
|
||||
.taskPrimaryTranslation.value =
|
||||
mOrientationHandler.getPrimaryValue(
|
||||
getPagedOrientationHandler().getPrimaryValue(
|
||||
child.getTranslationX(),
|
||||
child.getTranslationY()
|
||||
));
|
||||
@@ -3709,7 +3709,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
if (isStagingFocusedTask) {
|
||||
// Moves less if focused task is not in scroll position.
|
||||
int focusedTaskScroll = getScrollForPage(dismissedIndex);
|
||||
int primaryScroll = mOrientationHandler.getPrimaryScroll(this);
|
||||
int primaryScroll = getPagedOrientationHandler().getPrimaryScroll(this);
|
||||
int focusedTaskScrollDiff = primaryScroll - focusedTaskScroll;
|
||||
primaryTranslation +=
|
||||
mIsRtl ? focusedTaskScrollDiff : -focusedTaskScrollDiff;
|
||||
@@ -3837,7 +3837,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
}
|
||||
|
||||
if (calculateScrollDiff) {
|
||||
int primaryScroll = mOrientationHandler.getPrimaryScroll(
|
||||
int primaryScroll = getPagedOrientationHandler().getPrimaryScroll(
|
||||
RecentsView.this);
|
||||
int currentPageScroll = getScrollForPage(mCurrentPage);
|
||||
mCurrentPageScrollDiff = primaryScroll - currentPageScroll;
|
||||
@@ -3878,9 +3878,9 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
TaskView taskView = requireTaskViewAt(highestVisibleTaskIndex);
|
||||
|
||||
boolean shouldRebalance;
|
||||
int screenStart = mOrientationHandler.getPrimaryScroll(
|
||||
int screenStart = getPagedOrientationHandler().getPrimaryScroll(
|
||||
RecentsView.this);
|
||||
int taskStart = mOrientationHandler.getChildStart(taskView)
|
||||
int taskStart = getPagedOrientationHandler().getChildStart(taskView)
|
||||
+ (int) taskView.getOffsetAdjustment(/*gridEnabled=*/ true);
|
||||
|
||||
// Rebalance only if there is a maximum gap between the task and the
|
||||
@@ -3889,10 +3889,11 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
if (mIsRtl) {
|
||||
shouldRebalance = taskStart <= screenStart + mPageSpacing;
|
||||
} else {
|
||||
int screenEnd =
|
||||
screenStart + mOrientationHandler.getMeasuredSize(
|
||||
RecentsView.this);
|
||||
int taskSize = (int) (mOrientationHandler.getMeasuredSize(
|
||||
int screenEnd = screenStart
|
||||
+ getPagedOrientationHandler().getMeasuredSize(
|
||||
RecentsView.this);
|
||||
int taskSize = (int) (
|
||||
getPagedOrientationHandler().getMeasuredSize(
|
||||
taskView) * taskView
|
||||
.getSizeAdjustment(/*fullscreenEnabled=*/false));
|
||||
int taskEnd = taskStart + taskSize;
|
||||
@@ -4287,8 +4288,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
return mOrientationState;
|
||||
}
|
||||
|
||||
public PagedOrientationHandler getPagedOrientationHandler() {
|
||||
return mOrientationHandler;
|
||||
public RecentsPagedOrientationHandler getPagedOrientationHandler() {
|
||||
return (RecentsPagedOrientationHandler) super.getPagedOrientationHandler();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -4466,7 +4467,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
View child = getChildAt(i);
|
||||
FloatProperty translationPropertyX = child instanceof TaskView
|
||||
? ((TaskView) child).getPrimaryTaskOffsetTranslationProperty()
|
||||
: mOrientationHandler.getPrimaryViewTranslate();
|
||||
: getPagedOrientationHandler().getPrimaryViewTranslate();
|
||||
translationPropertyX.set(child, totalTranslationX);
|
||||
if (mEnableDrawingLiveTile && i == getRunningTaskIndex()) {
|
||||
runActionOnRemoteHandles(
|
||||
@@ -4504,8 +4505,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
mIsRtl ? outRect.right : outRect.left, outRect.top);
|
||||
mTempMatrix.mapRect(outRect);
|
||||
}
|
||||
outRect.offset(mOrientationHandler.getPrimaryValue(-midPointScroll, 0),
|
||||
mOrientationHandler.getSecondaryValue(-midPointScroll, 0));
|
||||
outRect.offset(getPagedOrientationHandler().getPrimaryValue(-midPointScroll, 0),
|
||||
getPagedOrientationHandler().getSecondaryValue(-midPointScroll, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4530,14 +4531,15 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
// to reach offscreen. Offset the task position to the task's starting point, and offset
|
||||
// by current page's scroll diff.
|
||||
int midpointScroll = getScrollForPage(midpointIndex)
|
||||
+ mOrientationHandler.getPrimaryScroll(this) - getScrollForPage(mCurrentPage);
|
||||
+ getPagedOrientationHandler().getPrimaryScroll(this)
|
||||
- getScrollForPage(mCurrentPage);
|
||||
|
||||
getPersistentChildPosition(midpointIndex, midpointScroll, taskPosition);
|
||||
float midpointStart = mOrientationHandler.getStart(taskPosition);
|
||||
float midpointStart = getPagedOrientationHandler().getStart(taskPosition);
|
||||
|
||||
getPersistentChildPosition(childIndex, midpointScroll, taskPosition);
|
||||
// Assume child does not overlap with midPointChild.
|
||||
isStartShift = mOrientationHandler.getStart(taskPosition) < midpointStart;
|
||||
isStartShift = getPagedOrientationHandler().getStart(taskPosition) < midpointStart;
|
||||
} else {
|
||||
// Position the task at scroll position.
|
||||
getPersistentChildPosition(childIndex, getScrollForPage(childIndex), taskPosition);
|
||||
@@ -4551,27 +4553,29 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
// desired position, and adjust the computed distance accordingly.
|
||||
float distanceToOffscreen;
|
||||
if (isStartShift) {
|
||||
float desiredStart = -mOrientationHandler.getPrimarySize(taskPosition);
|
||||
distanceToOffscreen = -mOrientationHandler.getEnd(taskPosition);
|
||||
float desiredStart = -getPagedOrientationHandler().getPrimarySize(taskPosition);
|
||||
distanceToOffscreen = -getPagedOrientationHandler().getEnd(taskPosition);
|
||||
if (mLastComputedTaskStartPushOutDistance == null) {
|
||||
taskPosition.offsetTo(
|
||||
mOrientationHandler.getPrimaryValue(desiredStart, 0f),
|
||||
mOrientationHandler.getSecondaryValue(desiredStart, 0f));
|
||||
getPagedOrientationHandler().getPrimaryValue(desiredStart, 0f),
|
||||
getPagedOrientationHandler().getSecondaryValue(desiredStart, 0f));
|
||||
getMatrix().mapRect(taskPosition);
|
||||
mLastComputedTaskStartPushOutDistance = mOrientationHandler.getEnd(taskPosition)
|
||||
/ mOrientationHandler.getPrimaryScale(this);
|
||||
mLastComputedTaskStartPushOutDistance = getPagedOrientationHandler().getEnd(
|
||||
taskPosition) / getPagedOrientationHandler().getPrimaryScale(this);
|
||||
}
|
||||
distanceToOffscreen -= mLastComputedTaskStartPushOutDistance;
|
||||
} else {
|
||||
float desiredStart = mOrientationHandler.getPrimarySize(this);
|
||||
distanceToOffscreen = desiredStart - mOrientationHandler.getStart(taskPosition);
|
||||
float desiredStart = getPagedOrientationHandler().getPrimarySize(this);
|
||||
distanceToOffscreen = desiredStart - getPagedOrientationHandler().getStart(
|
||||
taskPosition);
|
||||
if (mLastComputedTaskEndPushOutDistance == null) {
|
||||
taskPosition.offsetTo(
|
||||
mOrientationHandler.getPrimaryValue(desiredStart, 0f),
|
||||
mOrientationHandler.getSecondaryValue(desiredStart, 0f));
|
||||
getPagedOrientationHandler().getPrimaryValue(desiredStart, 0f),
|
||||
getPagedOrientationHandler().getSecondaryValue(desiredStart, 0f));
|
||||
getMatrix().mapRect(taskPosition);
|
||||
mLastComputedTaskEndPushOutDistance = (mOrientationHandler.getStart(taskPosition)
|
||||
- desiredStart) / mOrientationHandler.getPrimaryScale(this);
|
||||
mLastComputedTaskEndPushOutDistance = (getPagedOrientationHandler().getStart(
|
||||
taskPosition) - desiredStart)
|
||||
/ getPagedOrientationHandler().getPrimaryScale(this);
|
||||
}
|
||||
distanceToOffscreen -= mLastComputedTaskEndPushOutDistance;
|
||||
}
|
||||
@@ -4660,7 +4664,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
* of split invocation as such.
|
||||
*/
|
||||
public void initiateSplitSelect(TaskView taskView) {
|
||||
int defaultSplitPosition = mOrientationHandler
|
||||
int defaultSplitPosition = getPagedOrientationHandler()
|
||||
.getDefaultSplitPosition(mActivity.getDeviceProfile());
|
||||
initiateSplitSelect(taskView, defaultSplitPosition, LAUNCHER_OVERVIEW_ACTIONS_SPLIT);
|
||||
}
|
||||
@@ -4803,7 +4807,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
|
||||
int halfDividerSize = getResources()
|
||||
.getDimensionPixelSize(R.dimen.multi_window_task_divider_size) / 2;
|
||||
mOrientationHandler.getFinalSplitPlaceholderBounds(halfDividerSize,
|
||||
getPagedOrientationHandler().getFinalSplitPlaceholderBounds(halfDividerSize,
|
||||
mActivity.getDeviceProfile(),
|
||||
mSplitSelectStateController.getActiveSplitStagePosition(), firstTaskEndingBounds,
|
||||
secondTaskEndingBounds);
|
||||
@@ -4920,7 +4924,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
*/
|
||||
public float getSplitSelectTranslation() {
|
||||
DeviceProfile deviceProfile = mActivity.getDeviceProfile();
|
||||
PagedOrientationHandler orientationHandler = getPagedOrientationHandler();
|
||||
RecentsPagedOrientationHandler orientationHandler = getPagedOrientationHandler();
|
||||
int splitPosition = getSplitSelectController().getActiveSplitStagePosition();
|
||||
int splitPlaceholderSize =
|
||||
mActivity.getResources().getDimensionPixelSize(R.dimen.split_placeholder_size);
|
||||
@@ -4945,16 +4949,16 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
}
|
||||
|
||||
protected void onRotateInSplitSelectionState() {
|
||||
mOrientationHandler.getInitialSplitPlaceholderBounds(mSplitPlaceholderSize,
|
||||
getPagedOrientationHandler().getInitialSplitPlaceholderBounds(mSplitPlaceholderSize,
|
||||
mSplitPlaceholderInset, mActivity.getDeviceProfile(),
|
||||
mSplitSelectStateController.getActiveSplitStagePosition(), mTempRect);
|
||||
mTempRectF.set(mTempRect);
|
||||
FloatingTaskView firstFloatingTaskView =
|
||||
mSplitSelectStateController.getFirstFloatingTaskView();
|
||||
firstFloatingTaskView.updateOrientationHandler(mOrientationHandler);
|
||||
firstFloatingTaskView.updateOrientationHandler(getPagedOrientationHandler());
|
||||
firstFloatingTaskView.update(mTempRectF, /*progress=*/1f);
|
||||
|
||||
PagedOrientationHandler orientationHandler = getPagedOrientationHandler();
|
||||
RecentsPagedOrientationHandler orientationHandler = getPagedOrientationHandler();
|
||||
Pair<FloatProperty, FloatProperty> taskViewsFloat =
|
||||
orientationHandler.getSplitSelectTaskOffset(
|
||||
TASK_PRIMARY_SPLIT_TRANSLATION, TASK_SECONDARY_SPLIT_TRANSLATION,
|
||||
@@ -5059,7 +5063,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
float displacementX = tv.getWidth() * (toScale - 1f);
|
||||
float primaryTranslation = mIsRtl ? -displacementX : displacementX;
|
||||
anim.play(ObjectAnimator.ofFloat(getPageAt(centerTaskIndex),
|
||||
mOrientationHandler.getPrimaryViewTranslate(), primaryTranslation));
|
||||
getPagedOrientationHandler().getPrimaryViewTranslate(), primaryTranslation));
|
||||
int runningTaskIndex = getRunningTaskIndex();
|
||||
if (runningTaskIndex != -1 && runningTaskIndex != taskIndex
|
||||
&& getRemoteTargetHandles() != null) {
|
||||
@@ -5075,7 +5079,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
if (otherAdjacentTaskIndex >= 0 && otherAdjacentTaskIndex < getPageCount()) {
|
||||
PropertyValuesHolder[] properties = new PropertyValuesHolder[3];
|
||||
properties[0] = PropertyValuesHolder.ofFloat(
|
||||
mOrientationHandler.getPrimaryViewTranslate(), primaryTranslation);
|
||||
getPagedOrientationHandler().getPrimaryViewTranslate(), primaryTranslation);
|
||||
properties[1] = PropertyValuesHolder.ofFloat(View.SCALE_X, 1);
|
||||
properties[2] = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1);
|
||||
|
||||
@@ -5495,8 +5499,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
// Align ClearAllButton to the left (RTL) or right (non-RTL), which is different from other
|
||||
// TaskViews. This must be called after laying out ClearAllButton.
|
||||
if (layoutChildren) {
|
||||
int clearAllWidthDiff = mOrientationHandler.getPrimaryValue(mTaskWidth, mTaskHeight)
|
||||
- mOrientationHandler.getPrimarySize(mClearAllButton);
|
||||
int clearAllWidthDiff = getPagedOrientationHandler().getPrimaryValue(mTaskWidth,
|
||||
mTaskHeight) - getPagedOrientationHandler().getPrimarySize(mClearAllButton);
|
||||
mClearAllButton.setScrollOffsetPrimary(mIsRtl ? clearAllWidthDiff : -clearAllWidthDiff);
|
||||
}
|
||||
|
||||
@@ -5504,7 +5508,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
|
||||
int clearAllIndex = indexOfChild(mClearAllButton);
|
||||
int clearAllScroll = 0;
|
||||
int clearAllWidth = mOrientationHandler.getPrimarySize(mClearAllButton);
|
||||
int clearAllWidth = getPagedOrientationHandler().getPrimarySize(mClearAllButton);
|
||||
if (clearAllIndex != -1 && clearAllIndex < outPageScrolls.length) {
|
||||
float scrollDiff = mClearAllButton.getScrollAdjustment(showAsFullscreen, showAsGrid);
|
||||
clearAllScroll = newPageScrolls[clearAllIndex] + (int) scrollDiff;
|
||||
@@ -5613,7 +5617,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
overScrollShift = (int) Utilities.mapRange(mAdjacentPageHorizontalOffset,
|
||||
overScrollShift, getUndampedOverScrollShift());
|
||||
}
|
||||
return getScrollForPage(pageIndex) - mOrientationHandler.getPrimaryScroll(this)
|
||||
return getScrollForPage(pageIndex) - getPagedOrientationHandler().getPrimaryScroll(this)
|
||||
+ overScrollShift + getOffsetFromScrollPosition(pageIndex);
|
||||
}
|
||||
|
||||
@@ -5682,7 +5686,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
public Consumer<MotionEvent> getEventDispatcher(float navbarRotation) {
|
||||
float degreesRotated;
|
||||
if (navbarRotation == 0) {
|
||||
degreesRotated = mOrientationHandler.getDegreesRotated();
|
||||
degreesRotated = getPagedOrientationHandler().getDegreesRotated();
|
||||
} else {
|
||||
degreesRotated = -navbarRotation;
|
||||
}
|
||||
|
||||
@@ -48,10 +48,10 @@ import com.android.launcher3.R;
|
||||
import com.android.launcher3.anim.AnimationSuccessListener;
|
||||
import com.android.launcher3.anim.RoundedRectRevealOutlineProvider;
|
||||
import com.android.launcher3.popup.SystemShortcut;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
import com.android.quickstep.TaskOverlayFactory;
|
||||
import com.android.quickstep.TaskUtils;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
import com.android.quickstep.util.TaskCornerRadius;
|
||||
import com.android.quickstep.views.TaskView.TaskIdAttributeContainer;
|
||||
|
||||
@@ -215,7 +215,8 @@ public class TaskMenuView extends AbstractFloatingView {
|
||||
|
||||
private void orientAroundTaskView(TaskIdAttributeContainer taskContainer) {
|
||||
RecentsView recentsView = mActivity.getOverviewPanel();
|
||||
PagedOrientationHandler orientationHandler = recentsView.getPagedOrientationHandler();
|
||||
RecentsPagedOrientationHandler orientationHandler =
|
||||
recentsView.getPagedOrientationHandler();
|
||||
measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
|
||||
|
||||
// Get Position
|
||||
|
||||
@@ -51,11 +51,11 @@ import androidx.core.graphics.ColorUtils;
|
||||
import com.android.launcher3.BaseActivity;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
import com.android.launcher3.util.SystemUiController;
|
||||
import com.android.launcher3.util.SystemUiController.SystemUiControllerFlags;
|
||||
import com.android.quickstep.TaskOverlayFactory.TaskOverlay;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
import com.android.quickstep.views.TaskView.FullscreenDrawParams;
|
||||
import com.android.systemui.shared.recents.model.Task;
|
||||
import com.android.systemui.shared.recents.model.ThumbnailData;
|
||||
@@ -513,7 +513,7 @@ public class TaskThumbnailView extends View {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (recents.getPagedOrientationHandler() == PagedOrientationHandler.PORTRAIT) {
|
||||
if (recents.getPagedOrientationHandler() == RecentsPagedOrientationHandler.PORTRAIT) {
|
||||
int currentRotation = recents.getPagedViewOrientedState().getRecentsActivityRotation();
|
||||
return (currentRotation - mThumbnailData.rotation) % 2 != 0;
|
||||
} else {
|
||||
|
||||
@@ -87,7 +87,6 @@ import com.android.launcher3.popup.SystemShortcut;
|
||||
import com.android.launcher3.statemanager.StatefulActivity;
|
||||
import com.android.launcher3.testing.TestLogging;
|
||||
import com.android.launcher3.testing.shared.TestProtocol;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.util.ActivityOptionsWrapper;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.launcher3.util.RunnableList;
|
||||
@@ -104,6 +103,7 @@ import com.android.quickstep.TaskIconCache;
|
||||
import com.android.quickstep.TaskThumbnailCache;
|
||||
import com.android.quickstep.TaskUtils;
|
||||
import com.android.quickstep.TaskViewUtils;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
import com.android.quickstep.util.ActiveGestureLog;
|
||||
import com.android.quickstep.util.BorderAnimator;
|
||||
import com.android.quickstep.util.CancellableTask;
|
||||
@@ -116,6 +116,8 @@ import com.android.systemui.shared.recents.model.ThumbnailData;
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
import com.android.systemui.shared.system.QuickStepContract;
|
||||
|
||||
import kotlin.Unit;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -124,8 +126,6 @@ import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import kotlin.Unit;
|
||||
|
||||
/**
|
||||
* A task in the Recents view.
|
||||
*/
|
||||
@@ -1660,7 +1660,7 @@ public class TaskView extends FrameLayout implements Reusable {
|
||||
return (RecentsView) getParent();
|
||||
}
|
||||
|
||||
PagedOrientationHandler getPagedOrientationHandler() {
|
||||
RecentsPagedOrientationHandler getPagedOrientationHandler() {
|
||||
return getRecentsView().mOrientationState.getOrientationHandler();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user