Set KeyboardQuickSwitchView ratio correctly.

This CL sets the thumbnailView ratio correctly in Alt-Tab UI. The currently supported ratios are `SNAP_TO_30_70, SNAP_TO_50_50, SNAP_TO_70_30`. This can be extended when we add more split modes later.

Bug: 328691131
Test: manual in both landscape and portrait mode.
Flag: EXEMPT bugfix
Recall: http://recall/clips/79f3b250-d691-4b03-93c3-825a80478ae0

Change-Id: Idf4f174d1b222a8f3c80e5c6ed17c5bf53d3368c
This commit is contained in:
Shuming Hao
2024-08-28 11:31:39 -07:00
parent 4394cc777d
commit 3ff6087d98
2 changed files with 62 additions and 4 deletions

View File

@@ -36,14 +36,15 @@ import androidx.constraintlayout.widget.ConstraintLayout;
import com.android.launcher3.R;
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.SplitConfigurationOptions.SplitBounds;
import com.android.quickstep.util.BorderAnimator;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.ThumbnailData;
import java.util.function.Consumer;
import kotlin.Unit;
import java.util.function.Consumer;
/**
* A view that displays a recent task during a keyboard quick switch.
*/
@@ -173,6 +174,61 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout {
});
}
protected void setThumbnailsForSplitTasks(
@NonNull Task task1,
@Nullable Task task2,
@Nullable ThumbnailUpdateFunction thumbnailUpdateFunction,
@Nullable IconUpdateFunction iconUpdateFunction,
@Nullable SplitBounds splitBounds) {
setThumbnails(task1, task2, thumbnailUpdateFunction, iconUpdateFunction);
if (splitBounds == null) {
return;
}
final boolean isLeftRightSplit = !splitBounds.appsStackedVertically;
final float leftOrTopTaskPercent = isLeftRightSplit
? splitBounds.leftTaskPercent : splitBounds.topTaskPercent;
ConstraintLayout.LayoutParams leftTopParams = (ConstraintLayout.LayoutParams)
mThumbnailView1.getLayoutParams();
ConstraintLayout.LayoutParams rightBottomParams = (ConstraintLayout.LayoutParams)
mThumbnailView2.getLayoutParams();
if (isLeftRightSplit) {
// Set thumbnail view ratio in left right split mode.
leftTopParams.width = 0; // Set width to 0dp, so it uses the constraint dimension ratio.
leftTopParams.height = ConstraintLayout.LayoutParams.MATCH_PARENT;
leftTopParams.matchConstraintPercentWidth = leftOrTopTaskPercent;
leftTopParams.leftToLeft = ConstraintLayout.LayoutParams.PARENT_ID;
leftTopParams.rightToLeft = R.id.thumbnail_2;
mThumbnailView1.setLayoutParams(leftTopParams);
rightBottomParams.width = 0;
rightBottomParams.height = ConstraintLayout.LayoutParams.MATCH_PARENT;
rightBottomParams.matchConstraintPercentWidth = 1 - leftOrTopTaskPercent;
rightBottomParams.leftToRight = R.id.thumbnail_1;
rightBottomParams.rightToRight = ConstraintLayout.LayoutParams.PARENT_ID;
mThumbnailView2.setLayoutParams(rightBottomParams);
} else {
// Set thumbnail view ratio in top bottom split mode.
leftTopParams.height = 0;
leftTopParams.width = ConstraintLayout.LayoutParams.MATCH_PARENT;
leftTopParams.matchConstraintPercentHeight = leftOrTopTaskPercent;
leftTopParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID;
leftTopParams.bottomToTop = R.id.thumbnail_2;
mThumbnailView1.setLayoutParams(leftTopParams);
rightBottomParams.height = 0;
rightBottomParams.width = ConstraintLayout.LayoutParams.MATCH_PARENT;
rightBottomParams.matchConstraintPercentHeight = 1 - leftOrTopTaskPercent;
rightBottomParams.topToBottom = R.id.thumbnail_1;
rightBottomParams.bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID;
mThumbnailView2.setLayoutParams(rightBottomParams);
}
}
private void applyThumbnail(
@Nullable ImageView thumbnailView,
@Nullable Task task,