Handle split select rotation
- Update floatingTaskView, apply splitsSelectTranslation and splitPrimaryScorllOffest when rotating while in split select - Moved getSplitSelectTranslation to RecentsView - When in portrait, treat STAGE_POSITION_BOTTOM_OR_RIGHT as STAGE_POSITION_TOP_OR_LEFT in split translation calculation - Apply splitsSelectTranslation for portrait grid too Fix: 201721153 Test: manual Change-Id: I768a3b15de4d434674058b274c368798f5852917
This commit is contained in:
parent
57b9c472dc
commit
86ef5e924a
|
@ -17,8 +17,6 @@
|
|||
package com.android.launcher3.uioverrides.states;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
|
||||
/**
|
||||
|
@ -38,12 +36,6 @@ public class SplitScreenSelectState extends OverviewState {
|
|||
@Override
|
||||
public float getSplitSelectTranslation(Launcher launcher) {
|
||||
RecentsView recentsView = launcher.getOverviewPanel();
|
||||
int splitPosition = recentsView.getSplitPlaceholder().getActiveSplitStagePosition();
|
||||
if (!recentsView.shouldShiftThumbnailsForSplitSelect()) {
|
||||
return 0f;
|
||||
}
|
||||
PagedOrientationHandler orientationHandler = recentsView.getPagedOrientationHandler();
|
||||
int direction = orientationHandler.getSplitTranslationDirectionFactor(splitPosition);
|
||||
return launcher.getResources().getDimension(R.dimen.split_placeholder_size) * direction;
|
||||
return recentsView.getSplitSelectTranslation();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,6 +150,11 @@ public class FloatingTaskView extends FrameLayout {
|
|||
mOrientationHandler.setSecondaryScale(mSplitPlaceholderView.getIconView(), childScaleY);
|
||||
}
|
||||
|
||||
public void updateOrientationHandler(PagedOrientationHandler orientationHandler) {
|
||||
mOrientationHandler = orientationHandler;
|
||||
mSplitPlaceholderView.getIconView().setRotation(mOrientationHandler.getDegreesRotated());
|
||||
}
|
||||
|
||||
protected void initPosition(RectF pos, InsettableFrameLayout.LayoutParams lp) {
|
||||
mStartingPosition.set(pos);
|
||||
lp.ignoreInsets = true;
|
||||
|
|
|
@ -24,7 +24,6 @@ import static com.android.launcher3.LauncherState.SPRING_LOADED;
|
|||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -171,10 +170,13 @@ public class LauncherRecentsView extends RecentsView<BaseQuickstepLauncher, Laun
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
protected void onOrientationChanged() {
|
||||
super.onOrientationChanged();
|
||||
// If overview is in modal state when rotate, reset it to overview state without running
|
||||
// animation.
|
||||
setModalStateEnabled(false);
|
||||
if (mActivity.isInState(OVERVIEW_SPLIT_SELECT)) {
|
||||
onRotateInSplitSelectionState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,6 +91,7 @@ import android.text.TextPaint;
|
|||
import android.util.AttributeSet;
|
||||
import android.util.FloatProperty;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.KeyEvent;
|
||||
|
@ -1620,7 +1621,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
|||
|| !mOrientationHandler.equals(oldOrientationHandler)) {
|
||||
// Changed orientations, update controllers so they intercept accordingly.
|
||||
mActivity.getDragLayer().recreateControllers();
|
||||
setModalStateEnabled(false);
|
||||
onOrientationChanged();
|
||||
}
|
||||
|
||||
boolean isInLandscape = mOrientationState.getTouchRotation() != ROTATION_0
|
||||
|
@ -1639,6 +1640,9 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
|||
setCurrentPage(mCurrentPage);
|
||||
}
|
||||
|
||||
protected void onOrientationChanged() {
|
||||
}
|
||||
|
||||
// Update task size and padding that are dependent on DeviceProfile and insets.
|
||||
private void updateSizeAndPadding() {
|
||||
DeviceProfile dp = mActivity.getDeviceProfile();
|
||||
|
@ -3333,7 +3337,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
|||
* {@link #mFirstFloatingTaskView}.
|
||||
*/
|
||||
public boolean shouldShiftThumbnailsForSplitSelect() {
|
||||
return !mActivity.getDeviceProfile().isTablet;
|
||||
return !mActivity.getDeviceProfile().isTablet || !mActivity.getDeviceProfile().isLandscape;
|
||||
}
|
||||
|
||||
protected void onDismissAnimationEnds() {
|
||||
|
@ -3519,6 +3523,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
|||
protected void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
updateRecentsRotation();
|
||||
onOrientationChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3833,13 +3838,18 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
|||
* Apply scroll offset to children of RecentsView when entering split select.
|
||||
*/
|
||||
public void applySplitPrimaryScrollOffset() {
|
||||
float taskSplitScrollOffsetPrimary = 0f;
|
||||
float clearAllSplitScrollOffsetPrimar = 0f;
|
||||
if (isSplitPlaceholderFirstInGrid()) {
|
||||
for (int i = 0; i < getTaskViewCount(); i++) {
|
||||
requireTaskViewAt(i).setSplitScrollOffsetPrimary(mSplitPlaceholderSize);
|
||||
}
|
||||
taskSplitScrollOffsetPrimary = mSplitPlaceholderSize;
|
||||
} else if (isSplitPlaceholderLastInGrid()) {
|
||||
mClearAllButton.setSplitSelectScrollOffsetPrimary(-mSplitPlaceholderSize);
|
||||
clearAllSplitScrollOffsetPrimar = -mSplitPlaceholderSize;
|
||||
}
|
||||
|
||||
for (int i = 0; i < getTaskViewCount(); i++) {
|
||||
requireTaskViewAt(i).setSplitScrollOffsetPrimary(taskSplitScrollOffsetPrimary);
|
||||
}
|
||||
mClearAllButton.setSplitSelectScrollOffsetPrimary(clearAllSplitScrollOffsetPrimar);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3987,6 +3997,41 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns how much additional translation there should be for each of the child TaskViews.
|
||||
* Note that the translation can be its primary or secondary dimension.
|
||||
*/
|
||||
public float getSplitSelectTranslation() {
|
||||
int splitPosition = getSplitPlaceholder().getActiveSplitStagePosition();
|
||||
if (!shouldShiftThumbnailsForSplitSelect()) {
|
||||
return 0f;
|
||||
}
|
||||
PagedOrientationHandler orientationHandler = getPagedOrientationHandler();
|
||||
int direction = orientationHandler.getSplitTranslationDirectionFactor(
|
||||
splitPosition, mActivity.getDeviceProfile());
|
||||
return mActivity.getResources().getDimension(R.dimen.split_placeholder_size) * direction;
|
||||
}
|
||||
|
||||
protected void onRotateInSplitSelectionState() {
|
||||
mOrientationHandler.getInitialSplitPlaceholderBounds(mSplitPlaceholderSize,
|
||||
mActivity.getDeviceProfile(),
|
||||
mSplitSelectStateController.getActiveSplitStagePosition(), mTempRect);
|
||||
mTempRectF.set(mTempRect);
|
||||
// TODO(194414938) set correct corner radius
|
||||
mFirstFloatingTaskView.updateOrientationHandler(mOrientationHandler);
|
||||
mFirstFloatingTaskView.update(mTempRectF, /*progress=*/1f, /*windowRadius=*/0f);
|
||||
|
||||
PagedOrientationHandler orientationHandler = getPagedOrientationHandler();
|
||||
Pair<FloatProperty, FloatProperty> taskViewsFloat =
|
||||
orientationHandler.getSplitSelectTaskOffset(
|
||||
TASK_PRIMARY_SPLIT_TRANSLATION, TASK_SECONDARY_SPLIT_TRANSLATION,
|
||||
mActivity.getDeviceProfile());
|
||||
taskViewsFloat.first.set(this, getSplitSelectTranslation());
|
||||
taskViewsFloat.second.set(this, 0f);
|
||||
|
||||
applySplitPrimaryScrollOffset();
|
||||
}
|
||||
|
||||
private void updateDeadZoneRects() {
|
||||
// Get the deadzone rect surrounding the clear all button to not dismiss overview to home
|
||||
mClearAllButtonDeadZoneRect.setEmpty();
|
||||
|
|
|
@ -255,7 +255,7 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getSplitTranslationDirectionFactor(int stagePosition) {
|
||||
public int getSplitTranslationDirectionFactor(int stagePosition, DeviceProfile deviceProfile) {
|
||||
if (stagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT) {
|
||||
return -1;
|
||||
} else {
|
||||
|
|
|
@ -95,7 +95,8 @@ public interface PagedOrientationHandler {
|
|||
int getScrollOffsetStart(View view, Rect insets);
|
||||
int getScrollOffsetEnd(View view, Rect insets);
|
||||
int getSecondaryTranslationDirectionFactor();
|
||||
int getSplitTranslationDirectionFactor(@StagePosition int stagePosition);
|
||||
int getSplitTranslationDirectionFactor(@StagePosition int stagePosition,
|
||||
DeviceProfile deviceProfile);
|
||||
ChildBounds getChildBounds(View child, int childStart, int pageCenter, boolean layoutChild);
|
||||
void setMaxScroll(AccessibilityEvent event, int maxScroll);
|
||||
boolean getRecentsRtlSetting(Resources resources);
|
||||
|
|
|
@ -261,8 +261,8 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getSplitTranslationDirectionFactor(int stagePosition) {
|
||||
if (stagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT) {
|
||||
public int getSplitTranslationDirectionFactor(int stagePosition, DeviceProfile deviceProfile) {
|
||||
if (deviceProfile.isLandscape && stagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
|
|
|
@ -37,7 +37,6 @@ import android.widget.LinearLayout;
|
|||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.StagedSplitBounds;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
|
@ -53,7 +52,7 @@ public class SeascapePagedViewHandler extends LandscapePagedViewHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getSplitTranslationDirectionFactor(int stagePosition) {
|
||||
public int getSplitTranslationDirectionFactor(int stagePosition, DeviceProfile deviceProfile) {
|
||||
if (stagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT) {
|
||||
return -1;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue