Merge "Prevent thumbnails from shifting if placeholder view doesn't overlap" into sc-dev

This commit is contained in:
Vinit Nayak
2021-05-12 18:04:49 +00:00
committed by Android (Google) Code Review
4 changed files with 51 additions and 6 deletions

View File

@@ -105,7 +105,7 @@ public abstract class BaseRecentsViewStateController<T extends RecentsView>
TASK_PRIMARY_SPLIT_TRANSLATION, TASK_SECONDARY_SPLIT_TRANSLATION,
mLauncher.getDeviceProfile());
setter.setFloat(mRecentsView, taskViewsFloat,
toState.getOverviewSecondaryTranslation(mLauncher), LINEAR);
toState.getSplitSelectTranslation(mLauncher), LINEAR);
setter.setFloat(mRecentsView, getContentAlphaProperty(), toState.overviewUi ? 1 : 0,
config.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT));

View File

@@ -41,11 +41,14 @@ public class SplitScreenSelectState extends OverviewState {
}
@Override
public float getOverviewSecondaryTranslation(Launcher launcher) {
public float getSplitSelectTranslation(Launcher launcher) {
RecentsView recentsView = launcher.getOverviewPanel();
PagedOrientationHandler orientationHandler = recentsView.getPagedOrientationHandler();
int splitPosition = recentsView.getSplitPlaceholder().getSplitController()
.getActiveSplitPositionOption().mStagePosition;
if (!recentsView.shouldShiftThumbnailsForSplitSelect(splitPosition)) {
return 0f;
}
PagedOrientationHandler orientationHandler = recentsView.getPagedOrientationHandler();
int direction = orientationHandler.getSplitTranslationDirectionFactor(splitPosition);
return launcher.getResources().getDimension(R.dimen.split_placeholder_size) * direction;
}

View File

@@ -127,6 +127,7 @@ import com.android.launcher3.util.DynamicResource;
import com.android.launcher3.util.IntSet;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.ResourceBasedOverride.Overrides;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.TranslateEdgeEffect;
@@ -2417,6 +2418,47 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
return anim;
}
/**
* @return {@code true} if one of the task thumbnails would intersect/overlap with the
* {@link #mSplitPlaceholderView}
*/
public boolean shouldShiftThumbnailsForSplitSelect(@SplitConfigurationOptions.StagePosition
int stagePosition) {
if (!mActivity.getDeviceProfile().isTablet) {
// Never enough space on phones
return true;
} else if (!mActivity.getDeviceProfile().isLandscape) {
return false;
}
Rect splitBounds = new Rect();
float placeholderSize = getResources().getDimension(R.dimen.split_placeholder_size);
// This acts as a best approximation on where the splitplaceholder view would be,
// doesn't need to be exact necessarily. This also doesn't need to take translations
// into account since placeholder view is not translated
if (stagePosition == SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT) {
splitBounds.set((int) (getWidth() - placeholderSize), 0, getWidth(), getHeight());
} else {
splitBounds.set(0, 0, (int) (placeholderSize), getHeight());
}
Rect taskBounds = new Rect();
int taskCount = getTaskViewCount();
for (int i = 0; i < taskCount; i++) {
TaskView taskView = getTaskViewAt(i);
if (taskView == mSplitHiddenTaskView && taskView != getFocusedTaskView()) {
// Case where the hidden task view would have overlapped w/ placeholder,
// but because it's going to hide we don't care
// TODO (b/187312247) edge case for thumbnails that are off screen but scroll on
continue;
}
taskView.getBoundsOnScreen(taskBounds);
if (Rect.intersects(taskBounds, splitBounds)) {
return true;
}
}
return false;
}
protected void onDismissAnimationEnds() {
}

View File

@@ -237,10 +237,10 @@ public abstract class LauncherState implements BaseState<LauncherState> {
}
/**
* For this state, how much additional vertical translation there should be for each of the
* child TaskViews.
* For this state, 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 getOverviewSecondaryTranslation(Launcher launcher) {
public float getSplitSelectTranslation(Launcher launcher) {
return 0;
}