Merge "Fix WidgetsSearchBarControllerTest" into sc-dev am: 2c880a321d am: 1bb6119a8f
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/14639868
Change-Id: Ice7bc0c885a6d6d7e3f0ed6528fa79f4d2840435
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index 735cb24..2d801ba 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -16,7 +16,7 @@
<resources>
<dimen name="task_thumbnail_icon_size">48dp</dimen>
- <dimen name="task_thumbnail_icon_size_grid">32dp</dimen>
+ <dimen name="task_thumbnail_icon_size_grid">40dp</dimen>
<!-- For screens without rounded corners -->
<dimen name="task_corner_radius_small">2dp</dimen>
<!-- For Launchers that want to override the default dialog corner radius -->
@@ -35,10 +35,10 @@
<dimen name="overview_actions_horizontal_margin">16dp</dimen>
<dimen name="overview_grid_top_margin">77dp</dimen>
- <dimen name="overview_grid_bottom_margin">90dp</dimen>
+ <dimen name="overview_grid_bottom_margin">70dp</dimen>
<dimen name="overview_grid_side_margin">54dp</dimen>
<dimen name="overview_grid_row_spacing">42dp</dimen>
- <dimen name="overview_grid_focus_vertical_margin">90dp</dimen>
+ <dimen name="overview_grid_focus_vertical_margin">40dp</dimen>
<dimen name="split_placeholder_size">110dp</dimen>
<!-- These speeds are in dp/s -->
diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
index f5ddd0e..1b1c6b4 100644
--- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
@@ -203,17 +203,18 @@
Rect gridRect = new Rect();
calculateGridSize(context, dp, gridRect);
- int verticalMargin = res.getDimensionPixelSize(
- R.dimen.overview_grid_focus_vertical_margin);
- float taskHeight = gridRect.height() - verticalMargin * 2;
+ int verticalMargin = Math.max(
+ res.getDimensionPixelSize(R.dimen.overview_grid_focus_vertical_margin),
+ res.getDimensionPixelSize(R.dimen.overview_actions_height));
+ float taskHeight =
+ gridRect.height() - verticalMargin * 2 - dp.overviewTaskThumbnailTopMarginPx;
PointF taskDimension = getTaskDimension(context, dp);
- float scale = taskHeight / Math.max(taskDimension.x, taskDimension.y);
+ float scale = taskHeight / taskDimension.y;
int outWidth = Math.round(scale * taskDimension.x);
int outHeight = Math.round(scale * taskDimension.y);
- int gravity = Gravity.CENTER_VERTICAL;
- gravity |= orientedState.getRecentsRtlSetting(res) ? Gravity.RIGHT : Gravity.LEFT;
+ int gravity = Gravity.CENTER;
Gravity.apply(gravity, outWidth, outHeight, gridRect, outRect);
} else {
int taskMargin = dp.overviewTaskMarginPx;
@@ -302,8 +303,7 @@
float rowHeight = (gridRect.height() - rowSpacing) / 2f;
PointF taskDimension = getTaskDimension(context, dp);
- float scale = (rowHeight - dp.overviewTaskThumbnailTopMarginPx) / Math.max(
- taskDimension.x, taskDimension.y);
+ float scale = (rowHeight - dp.overviewTaskThumbnailTopMarginPx) / taskDimension.y;
int outWidth = Math.round(scale * taskDimension.x);
int outHeight = Math.round(scale * taskDimension.y);
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 376cb31..25e850c 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -487,7 +487,6 @@
protected boolean mRunningTaskTileHidden;
private Task mTmpRunningTask;
protected int mFocusedTaskId = -1;
- private float mFocusedTaskRatio;
private boolean mRunningTaskIconScaledDown = false;
@@ -1351,19 +1350,7 @@
public Point getSelectedTaskSize() {
mSizeStrategy.calculateTaskSize(mActivity, mActivity.getDeviceProfile(), mTempRect,
mOrientationHandler);
- int taskWidth = mTempRect.width();
- int taskHeight = mTempRect.height();
- if (mRunningTaskId != -1) {
- int boxLength = Math.max(taskWidth, taskHeight);
- if (mFocusedTaskRatio > 1) {
- taskWidth = boxLength;
- taskHeight = (int) (boxLength / mFocusedTaskRatio);
- } else {
- taskWidth = (int) (boxLength * mFocusedTaskRatio);
- taskHeight = boxLength;
- }
- }
- return new Point(taskWidth, taskHeight);
+ return new Point(mTempRect.width(), mTempRect.height());
}
/** Gets the last computed task size */
@@ -1593,13 +1580,6 @@
}
/**
- * Returns the width to height ratio of the focused {@link TaskView}.
- */
- public float getFocusedTaskRatio() {
- return mFocusedTaskRatio;
- }
-
- /**
* Get the index of the task view whose id matches {@param taskId}.
* @return -1 if there is no task view for the task id, else the index of the task view.
*/
@@ -1778,7 +1758,7 @@
int runningTaskId = runningTaskInfo == null ? -1 : runningTaskInfo.taskId;
setCurrentTask(runningTaskId);
if (mActivity.getDeviceProfile().isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) {
- setFocusedTask(runningTaskId);
+ mFocusedTaskId = runningTaskId;
}
setCurrentPage(getRunningTaskIndex());
setRunningTaskViewShowScreenshot(false);
@@ -1808,15 +1788,6 @@
}
/**
- * Sets the focused task id and store the width to height ratio of the focused task.
- */
- protected void setFocusedTask(int focusedTaskId) {
- mFocusedTaskId = focusedTaskId;
- mFocusedTaskRatio =
- mLastComputedTaskSize.width() / (float) mLastComputedTaskSize.height();
- }
-
- /**
* Hides the tile associated with {@link #mRunningTaskId}
*/
public void setRunningTaskHidden(boolean isHidden) {
@@ -1905,8 +1876,6 @@
return;
}
- final int boxLength = Math.max(mLastComputedGridTaskSize.width(),
- mLastComputedGridTaskSize.height());
int taskTopMargin = mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx;
/*
@@ -1917,7 +1886,8 @@
*/
final float taskGridVerticalDiff =
mLastComputedGridTaskSize.top - mLastComputedTaskSize.top;
- final float heightOffset = (boxLength + taskTopMargin) + mRowSpacing;
+ final float heightOffset =
+ (mLastComputedGridTaskSize.height() + taskTopMargin) + mRowSpacing;
int topRowWidth = 0;
int bottomRowWidth = 0;
@@ -2061,20 +2031,9 @@
float clearAllShorterRowCompensation =
mIsRtl ? -shorterRowCompensation : shorterRowCompensation;
- // If the total width is shorter than one grid's width, move ClearAllButton further away
- // accordingly. Update longRowWidth if ClearAllButton has been moved.
- float clearAllShortTotalCompensation = 0;
- int longRowWidth = Math.max(topRowWidth, bottomRowWidth);
- if (longRowWidth < mLastComputedGridSize.width()) {
- float shortTotalCompensation = mLastComputedGridSize.width() - longRowWidth;
- clearAllShortTotalCompensation =
- mIsRtl ? -shortTotalCompensation : shortTotalCompensation;
- longRowWidth = mLastComputedGridSize.width();
- }
-
float clearAllTotalTranslationX =
clearAllAccumulatedTranslation + clearAllShorterRowCompensation
- + clearAllShortTotalCompensation + snappedTaskFullscreenScrollAdjustment;
+ + snappedTaskFullscreenScrollAdjustment;
if (focusedTaskIndex < taskCount) {
// Shift by focused task's width and spacing if a task is focused.
clearAllTotalTranslationX +=
@@ -2084,9 +2043,12 @@
// Make sure there are enough space between snapped page and ClearAllButton, for the case
// of swiping up after quick switch.
if (snappedTaskView != null) {
+ int longRowWidth = Math.max(topRowWidth, bottomRowWidth);
int distanceFromClearAll = longRowWidth - snappedTaskRowWidth;
+ // ClearAllButton should be off screen when snapped task is in its snapped position.
int minimumDistance =
- mLastComputedGridSize.width() - snappedTaskView.getLayoutParams().width;
+ mTaskWidth - snappedTaskView.getLayoutParams().width
+ + (mLastComputedGridSize.width() - mTaskWidth) / 2;
if (distanceFromClearAll < minimumDistance) {
int distanceDifference = minimumDistance - distanceFromClearAll;
clearAllTotalTranslationX += mIsRtl ? -distanceDifference : distanceDifference;
diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
index 02888a1..1bfd430 100644
--- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -411,7 +411,9 @@
*/
public static class PreviewPositionHelper {
- // Contains the portion of the thumbnail that is clipped when fullscreen progress = 0.
+ private static final RectF EMPTY_RECT_F = new RectF();
+
+ // Contains the portion of the thumbnail that is unclipped when fullscreen progress = 1.
private final RectF mClippedInsets = new RectF();
private final Matrix mMatrix = new Matrix();
private boolean mIsOrientationChanged;
@@ -616,15 +618,17 @@
break;
}
mClippedInsets.offsetTo(newLeftInset * scale, newTopInset * scale);
- mMatrix.postTranslate(translateX - mClippedInsets.left,
- translateY - mClippedInsets.top);
+ mMatrix.postTranslate(translateX, translateY);
+ if (TaskView.FULL_THUMBNAIL) {
+ mMatrix.postTranslate(-mClippedInsets.left, -mClippedInsets.top);
+ }
}
/**
* Insets to used for clipping the thumbnail (in case it is drawing outside its own space)
*/
public RectF getInsetsToDrawInFullscreen() {
- return mClippedInsets;
+ return TaskView.FULL_THUMBNAIL ? mClippedInsets : EMPTY_RECT_F;
}
}
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index cfac32c..55a32ea 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -141,6 +141,11 @@
*/
public static final boolean CLIP_STATUS_AND_NAV_BARS = false;
+ /**
+ * Should the TaskView scale down to fit whole thumbnail in fullscreen.
+ */
+ public static final boolean FULL_THUMBNAIL = false;
+
private static final float EDGE_SCALE_DOWN_FACTOR_CAROUSEL = 0.03f;
private static final float EDGE_SCALE_DOWN_FACTOR_GRID = 0.00f;
@@ -1343,46 +1348,26 @@
int boxWidth;
int boxHeight;
- float thumbnailRatio;
boolean isFocusedTask = isFocusedTask();
if (isFocusedTask) {
// Task will be focused and should use focused task size. Use focusTaskRatio
// that is associated with the original orientation of the focused task.
boxWidth = taskWidth;
boxHeight = taskHeight;
- thumbnailRatio = getRecentsView().getFocusedTaskRatio();
} else {
// Otherwise task is in grid, and should use lastComputedGridTaskSize.
Rect lastComputedGridTaskSize = getRecentsView().getLastComputedGridTaskSize();
boxWidth = lastComputedGridTaskSize.width();
boxHeight = lastComputedGridTaskSize.height();
- thumbnailRatio = mTask != null ? mTask.getVisibleThumbnailRatio(
- TaskView.CLIP_STATUS_AND_NAV_BARS) : 0f;
}
- int boxLength = Math.max(boxWidth, boxHeight);
// Bound width/height to the box size.
- if (thumbnailRatio == 0f) {
- expectedWidth = boxWidth;
- expectedHeight = boxHeight + thumbnailPadding;
- } else if (thumbnailRatio > 1) {
- expectedWidth = boxLength;
- expectedHeight = (int) (boxLength / thumbnailRatio) + thumbnailPadding;
- } else {
- expectedWidth = (int) (boxLength * thumbnailRatio);
- expectedHeight = boxLength + thumbnailPadding;
- }
+ expectedWidth = boxWidth;
+ expectedHeight = boxHeight + thumbnailPadding;
// Scale to to fit task Rect.
fullscreenScale = taskWidth / (float) boxWidth;
- // In full screen, scale back TaskView to original size.
- if (expectedWidth > boxWidth) {
- fullscreenScale *= boxWidth / (float) expectedWidth;
- } else if (expectedHeight - thumbnailPadding > boxHeight) {
- fullscreenScale *= boxHeight / (float) (expectedHeight - thumbnailPadding);
- }
-
// Align to top of task Rect.
boxTranslationY = (expectedHeight - thumbnailPadding - taskHeight) / 2.0f;
} else {
diff --git a/res/drawable-v28/widgets_bottom_sheet_background.xml b/res/drawable-v28/widgets_bottom_sheet_background.xml
new file mode 100644
index 0000000..c3009c3
--- /dev/null
+++ b/res/drawable-v28/widgets_bottom_sheet_background.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2021 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.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <solid android:color="@color/widgets_picker_surface" />
+ <corners
+ android:topLeftRadius="?android:attr/dialogCornerRadius"
+ android:topRightRadius="?android:attr/dialogCornerRadius"
+ android:bottomLeftRadius="0dp"
+ android:bottomRightRadius="0dp"
+ />
+</shape>
\ No newline at end of file
diff --git a/res/drawable/widgets_bottom_sheet_background.xml b/res/drawable/widgets_bottom_sheet_background.xml
index faa414c..2460767 100644
--- a/res/drawable/widgets_bottom_sheet_background.xml
+++ b/res/drawable/widgets_bottom_sheet_background.xml
@@ -18,8 +18,8 @@
android:shape="rectangle">
<solid android:color="@color/widgets_picker_surface" />
<corners
- android:topLeftRadius="@dimen/bg_round_rect_radius"
- android:topRightRadius="@dimen/bg_round_rect_radius"
+ android:topLeftRadius="@dimen/default_dialog_corner_radius"
+ android:topRightRadius="@dimen/default_dialog_corner_radius"
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"
/>
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index 0c0c92e..1715161 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -214,14 +214,14 @@
+ "predictions to be updated while they are visible to the user.");
public static final BooleanFlag ENABLE_TASKBAR = getDebugFlag(
- "ENABLE_TASKBAR", false, "Allows a system Taskbar to be shown on larger devices.");
+ "ENABLE_TASKBAR", true, "Allows a system Taskbar to be shown on larger devices.");
public static final BooleanFlag ENABLE_OVERVIEW_GRID = getDebugFlag(
- "ENABLE_OVERVIEW_GRID", false, "Uses grid overview layout. "
+ "ENABLE_OVERVIEW_GRID", true, "Uses grid overview layout. "
+ "Only applicable on large screen devices.");
public static final BooleanFlag ENABLE_TWO_PANEL_HOME = getDebugFlag(
- "ENABLE_TWO_PANEL_HOME", false,
+ "ENABLE_TWO_PANEL_HOME", true,
"Uses two panel on home screen. Only applicable on large screen devices.");
public static final BooleanFlag ENABLE_SPLIT_SELECT = getDebugFlag(
diff --git a/src/com/android/launcher3/views/TopRoundedCornerView.java b/src/com/android/launcher3/views/TopRoundedCornerView.java
index 7888b08..5519df1 100644
--- a/src/com/android/launcher3/views/TopRoundedCornerView.java
+++ b/src/com/android/launcher3/views/TopRoundedCornerView.java
@@ -21,7 +21,6 @@
import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;
-import android.widget.FrameLayout;
import com.android.launcher3.R;
import com.android.launcher3.util.Themes;
@@ -41,7 +40,7 @@
public TopRoundedCornerView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- int radius = getResources().getDimensionPixelSize(R.dimen.bg_round_rect_radius);
+ float radius = Themes.getDialogCornerRadius(context);
mRadii = new float[] {radius, radius, radius, radius, 0, 0, 0, 0};
mNavBarScrimPaint = new Paint();