Merge "Re-land "Update workspace, cell layout, shortcut and widget, and cell size calculations."" into tm-dev
diff --git a/quickstep/res/values-sw600dp-land/dimens.xml b/quickstep/res/values-sw600dp-land/dimens.xml
index 2cd48d5..0cd9b2b 100644
--- a/quickstep/res/values-sw600dp-land/dimens.xml
+++ b/quickstep/res/values-sw600dp-land/dimens.xml
@@ -15,7 +15,6 @@
*/
-->
<resources>
+ <!-- Overview actions -->
<dimen name="overview_actions_top_margin">12dp</dimen>
- <dimen name="overview_grid_side_margin">52dp</dimen>
- <dimen name="overview_page_spacing">38dp</dimen>
</resources>
diff --git a/quickstep/res/values-sw600dp/dimens.xml b/quickstep/res/values-sw600dp/dimens.xml
index 5153afa..7494683 100644
--- a/quickstep/res/values-sw600dp/dimens.xml
+++ b/quickstep/res/values-sw600dp/dimens.xml
@@ -17,11 +17,13 @@
<resources>
<dimen name="navigation_key_padding">25dp</dimen>
+ <!-- Task View -->
+ <dimen name="task_thumbnail_icon_size">48dp</dimen>
+ <dimen name="task_thumbnail_icon_drawable_size">44dp</dimen>
<dimen name="overview_task_margin">12dp</dimen>
- <dimen name="overview_task_margin_grid">4dp</dimen>
- <dimen name="overview_actions_button_spacing">36dp</dimen>
- <dimen name="overview_grid_side_margin">60dp</dimen>
- <dimen name="overview_grid_row_spacing">36dp</dimen>
+ <dimen name="task_thumbnail_icon_drawable_size_grid">44dp</dimen>
+ <dimen name="overview_task_margin_grid">12dp</dimen>
+ <dimen name="overview_grid_row_spacing">28dp</dimen>
<dimen name="overview_page_spacing">36dp</dimen>
- <dimen name="task_thumbnail_icon_drawable_size_grid">32dp</dimen>
+ <dimen name="overview_grid_side_margin">64dp</dimen>
</resources>
diff --git a/quickstep/res/values-sw720dp-land/dimens.xml b/quickstep/res/values-sw720dp-land/dimens.xml
new file mode 100644
index 0000000..02d1189
--- /dev/null
+++ b/quickstep/res/values-sw720dp-land/dimens.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ * Copyright (c) 2022, 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.
+*/
+-->
+<resources>
+ <!-- Overview actions -->
+ <dimen name="overview_actions_top_margin">20dp</dimen>
+</resources>
diff --git a/quickstep/res/values-sw720dp/dimens.xml b/quickstep/res/values-sw720dp/dimens.xml
index e381cb0..ceaa8f8 100644
--- a/quickstep/res/values-sw720dp/dimens.xml
+++ b/quickstep/res/values-sw720dp/dimens.xml
@@ -15,11 +15,13 @@
*/
-->
<resources>
+ <!-- Task View -->
+ <dimen name="task_thumbnail_icon_size">48dp</dimen>
+ <dimen name="task_thumbnail_icon_drawable_size">44dp</dimen>
<dimen name="overview_task_margin">16dp</dimen>
+ <dimen name="task_thumbnail_icon_drawable_size_grid">44dp</dimen>
<dimen name="overview_task_margin_grid">16dp</dimen>
- <dimen name="overview_grid_side_margin">64dp</dimen>
<dimen name="overview_grid_row_spacing">36dp</dimen>
<dimen name="overview_page_spacing">44dp</dimen>
- <dimen name="task_thumbnail_icon_drawable_size">44dp</dimen>
- <dimen name="task_thumbnail_icon_drawable_size_grid">44dp</dimen>
+ <dimen name="overview_grid_side_margin">64dp</dimen>
</resources>
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index 4210052..3072a3e 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -15,8 +15,6 @@
-->
<resources>
- <dimen name="task_thumbnail_icon_size">48dp</dimen>
- <dimen name="task_thumbnail_icon_drawable_size">48dp</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 -->
@@ -32,18 +30,20 @@
<dimen name="overview_proactive_row_bottom_margin">16dp</dimen>
<dimen name="overview_minimum_next_prev_size">50dp</dimen>
+
+ <!-- Task View -->
+ <dimen name="task_thumbnail_icon_size">48dp</dimen>
+ <dimen name="task_thumbnail_icon_drawable_size">44dp</dimen>
<dimen name="overview_task_margin">16dp</dimen>
- <dimen name="overview_task_margin_grid">0dp</dimen>
+ <dimen name="overview_page_spacing">16dp</dimen>
+
<item name="overview_max_scale" format="float" type="dimen">0.7</item>
<item name="overview_modal_max_scale" format="float" type="dimen">1.1</item>
<!-- Overrideable in overlay that provides the Overview Actions. -->
- <dimen name="overview_actions_height">48dp</dimen>
- <dimen name="overview_actions_button_spacing">32dp</dimen>
<dimen name="overview_actions_top_margin">24dp</dimen>
- <dimen name="overview_actions_horizontal_margin">16dp</dimen>
-
- <dimen name="overview_page_spacing">16dp</dimen>
+ <dimen name="overview_actions_height">48dp</dimen>
+ <dimen name="overview_actions_button_spacing">36dp</dimen>
<!-- These speeds are in dp/s -->
<dimen name="max_task_dismiss_drag_velocity">2.25dp</dimen>
diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
index 6745246..2fcd286 100644
--- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
@@ -222,32 +222,27 @@
*/
public final void calculateTaskSize(Context context, DeviceProfile dp, Rect outRect) {
Resources res = context.getResources();
+ float maxScale = res.getFloat(R.dimen.overview_max_scale);
if (dp.isTablet) {
Rect gridRect = new Rect();
calculateGridSize(dp, gridRect);
- PointF taskDimension = getTaskDimension(context, dp);
- float scale = gridRect.height() / taskDimension.y;
- scale = Math.min(scale, res.getFloat(R.dimen.overview_max_scale));
- int outWidth = Math.round(scale * taskDimension.x);
- int outHeight = Math.round(scale * taskDimension.y);
-
- int gravity = Gravity.CENTER;
- Gravity.apply(gravity, outWidth, outHeight, gridRect, outRect);
+ calculateTaskSizeInternal(context, dp, gridRect, maxScale, Gravity.CENTER, outRect);
} else {
int taskMargin = dp.overviewTaskMarginPx;
calculateTaskSizeInternal(context, dp,
dp.overviewTaskThumbnailTopMarginPx,
dp.getOverviewActionsClaimedSpace(),
res.getDimensionPixelSize(R.dimen.overview_minimum_next_prev_size) + taskMargin,
+ maxScale,
Gravity.CENTER,
outRect);
}
}
private void calculateTaskSizeInternal(Context context, DeviceProfile dp, int claimedSpaceAbove,
- int claimedSpaceBelow, int minimumHorizontalPadding, int gravity, Rect outRect) {
- PointF taskDimension = getTaskDimension(context, dp);
+ int claimedSpaceBelow, int minimumHorizontalPadding, float maxScale, int gravity,
+ Rect outRect) {
Rect insets = dp.getInsets();
Rect potentialTaskRect = new Rect(0, 0, dp.widthPx, dp.heightPx);
@@ -258,9 +253,17 @@
minimumHorizontalPadding,
claimedSpaceBelow);
+ calculateTaskSizeInternal(context, dp, potentialTaskRect, maxScale, gravity, outRect);
+ }
+
+ private void calculateTaskSizeInternal(Context context, DeviceProfile dp,
+ Rect potentialTaskRect, float maxScale, int gravity, Rect outRect) {
+ PointF taskDimension = getTaskDimension(context, dp);
+
float scale = Math.min(
potentialTaskRect.width() / taskDimension.x,
potentialTaskRect.height() / taskDimension.y);
+ scale = Math.min(scale, maxScale);
int outWidth = Math.round(scale * taskDimension.x);
int outHeight = Math.round(scale * taskDimension.y);
@@ -359,6 +362,7 @@
dp.overviewTaskMarginPx,
dp.heightPx - outRect.bottom - dp.getInsets().bottom,
Math.round((dp.availableWidthPx - outRect.width() * maxScale) / 2),
+ 1f /*maxScale*/,
Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM,
outRect);
}
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ee5e024..829a21d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -277,6 +277,9 @@
<!-- Summary for Notification dots setting. Tapping this will link enable/disable notification dots feature on the home screen. [CHAR LIMIT=50] -->
<string name="notification_dots_service_title">Show notification dots</string>
+ <!-- Title for Developer Options setting. [CHAR LIMIT=50] -->
+ <string name="developer_options_title">Developer Options</string>
+
<!-- Label for the setting that allows the automatic placement of launcher shortcuts for applications and games installed on the device [CHAR LIMIT=60] -->
<string name="auto_add_shortcuts_label">Add app icons to home screen</string>
<!-- Text description of the setting that allows the automatic placement of launcher shortcuts for applications and games installed on the device [CHAR LIMIT=NONE] -->
diff --git a/res/xml/launcher_preferences.xml b/res/xml/launcher_preferences.xml
index 90de498..8a0c909 100644
--- a/res/xml/launcher_preferences.xml
+++ b/res/xml/launcher_preferences.xml
@@ -53,7 +53,7 @@
<androidx.preference.PreferenceScreen
android:key="pref_developer_options"
android:persistent="false"
- android:title="Developer Options"
+ android:title="@string/developer_options_title"
android:fragment="com.android.launcher3.settings.DeveloperOptionsFragment"/>
</androidx.preference.PreferenceScreen>
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 96aa1c8..be180a6 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -1168,7 +1168,7 @@
return ((taskbarSize - overviewActionsHeight) / 2) + getTaskbarOffsetY();
}
- return 0;
+ return isTaskbarPresent ? stashedTaskbarSize : mInsets.bottom;
}
/** Gets the space that the overview actions will take, including bottom margin. */
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index ad87451..135b88d 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1169,6 +1169,7 @@
}
AbstractFloatingView.closeAllOpenViewsExcept(this, false, TYPE_REBIND_SAFE);
+ DragView.removeAllViews(this);
TraceHelper.INSTANCE.endSection(traceToken);
}
diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java
index a3945fd..0264ae2 100644
--- a/src/com/android/launcher3/dragndrop/DragView.java
+++ b/src/com/android/launcher3/dragndrop/DragView.java
@@ -578,4 +578,19 @@
iv.setImageDrawable(drawable);
return iv;
}
+
+ /**
+ * Removes any stray DragView from the DragLayer.
+ */
+ public static void removeAllViews(ActivityContext activity) {
+ BaseDragLayer dragLayer = activity.getDragLayer();
+ // Iterate in reverse order. DragView is added later to the dragLayer,
+ // and will be one of the last views.
+ for (int i = dragLayer.getChildCount() - 1; i >= 0; i--) {
+ View child = dragLayer.getChildAt(i);
+ if (child instanceof DragView) {
+ dragLayer.removeView(child);
+ }
+ }
+ }
}