From 29e71bdd7257cb4919762e10c7915da4d2ae8752 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Mon, 31 Oct 2022 14:13:44 -0700 Subject: [PATCH 1/7] Improve Split portrait gesture animation * Crop out taskbar from bottom thumbnail for vertical split * TODO: Need to re-calculate thumbnail sizes if taskbar is stashed. There's also a very slight rounding error somewhere even in the unstashed case that needs to be revisited Bug: 219411750 Test: Start gesture animation in split in potrait Change-Id: I35f2415e13af7467e0735ac8865cee0e3e3d27f8 --- .../quickstep/util/TaskViewSimulator.java | 2 +- .../quickstep/views/TaskThumbnailView.java | 4 +-- .../quickstep/FullscreenDrawParamsTest.kt | 4 +-- .../touch/PortraitPagedViewHandler.java | 35 ++++++++++++------- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index 5c37da16b5..b476c12a51 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -322,7 +322,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { boolean isRtlEnabled = !mIsRecentsRtl; mPositionHelper.updateThumbnailMatrix( mThumbnailPosition, mThumbnailData, mTaskRect.width(), mTaskRect.height(), - mDp.widthPx, mDp.taskbarSize, mDp.isTablet, + mDp.widthPx, mDp.heightPx, mDp.taskbarSize, mDp.isTablet, mOrientationState.getRecentsActivityRotation(), isRtlEnabled); mPositionHelper.getMatrix().invert(mInversePositionMatrix); if (DEBUG) { diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java index 6792dc5445..904c944c1a 100644 --- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java +++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java @@ -473,8 +473,8 @@ public class TaskThumbnailView extends View { boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL; DeviceProfile dp = mActivity.getDeviceProfile(); mPreviewPositionHelper.updateThumbnailMatrix(mPreviewRect, mThumbnailData, - getMeasuredWidth(), getMeasuredHeight(), dp.widthPx, dp.taskbarSize, - dp.isTablet, currentRotation, isRtl); + getMeasuredWidth(), getMeasuredHeight(), dp.widthPx, dp.heightPx, + dp.taskbarSize, dp.isTablet, currentRotation, isRtl); mBitmapShader.setLocalMatrix(mPreviewPositionHelper.getMatrix()); mPaint.setShader(mBitmapShader); diff --git a/quickstep/tests/src/com/android/quickstep/FullscreenDrawParamsTest.kt b/quickstep/tests/src/com/android/quickstep/FullscreenDrawParamsTest.kt index 478535051c..963da2793d 100644 --- a/quickstep/tests/src/com/android/quickstep/FullscreenDrawParamsTest.kt +++ b/quickstep/tests/src/com/android/quickstep/FullscreenDrawParamsTest.kt @@ -57,7 +57,7 @@ class FullscreenDrawParamsTest : DeviceProfileBaseTest() { val isRtl = false mPreviewPositionHelper.updateThumbnailMatrix(previewRect, mThumbnailData, canvasWidth, - canvasHeight, dp.widthPx, dp.taskbarSize, dp.isTablet, currentRotation, + canvasHeight, dp.widthPx, dp.heightPx, dp.taskbarSize, dp.isTablet, currentRotation, isRtl) params.setProgress(/* fullscreenProgress= */ 1.0f, /* parentScale= */ 1.0f, /* taskViewScale= */ 1.0f, /* previewWidth= */ 0, dp, mPreviewPositionHelper) @@ -78,7 +78,7 @@ class FullscreenDrawParamsTest : DeviceProfileBaseTest() { val isRtl = false mPreviewPositionHelper.updateThumbnailMatrix(previewRect, mThumbnailData, canvasWidth, - canvasHeight, dp.widthPx, dp.taskbarSize, dp.isTablet, currentRotation, + canvasHeight, dp.widthPx, dp.heightPx, dp.taskbarSize, dp.isTablet, currentRotation, isRtl) params.setProgress(/* fullscreenProgress= */ 1.0f, /* parentScale= */ 1.0f, /* taskViewScale= */ 1.0f, /* previewWidth= */ 0, dp, mPreviewPositionHelper) diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java index af689dc3a3..78e17d835d 100644 --- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java +++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java @@ -585,7 +585,6 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { @Override public void setSplitTaskSwipeRect(DeviceProfile dp, Rect outRect, SplitBounds splitInfo, int desiredStagePosition) { - boolean isLandscape = dp.isLandscape; float topLeftTaskPercent = splitInfo.appsStackedVertically ? splitInfo.topTaskPercent : splitInfo.leftTaskPercent; @@ -593,18 +592,24 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { ? splitInfo.dividerHeightPercent : splitInfo.dividerWidthPercent; + int deviceHeightWithoutTaskbar = dp.availableHeightPx - dp.taskbarSize; + float scale = (float) outRect.height() / deviceHeightWithoutTaskbar; + float topTaskHeight = dp.availableHeightPx * topLeftTaskPercent; + float scaledTopTaskHeight = topTaskHeight * scale; + float dividerHeight = dp.availableHeightPx * dividerBarPercent; + float scaledDividerHeight = dividerHeight * scale; + if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) { - if (isLandscape) { - outRect.right = outRect.left + Math.round(outRect.width() * topLeftTaskPercent); + if (splitInfo.appsStackedVertically) { + outRect.bottom = Math.round(outRect.top + scaledTopTaskHeight); } else { - outRect.bottom = outRect.top + Math.round(outRect.height() * topLeftTaskPercent); + outRect.right = outRect.left + Math.round(outRect.width() * topLeftTaskPercent); } } else { - if (isLandscape) { - outRect.left += Math.round(outRect.width() - * (topLeftTaskPercent + dividerBarPercent)); + if (splitInfo.appsStackedVertically) { + outRect.top += Math.round(scaledTopTaskHeight + scaledDividerHeight); } else { - outRect.top += Math.round(outRect.height() + outRect.left += Math.round(outRect.width() * (topLeftTaskPercent + dividerBarPercent)); } } @@ -617,7 +622,7 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx; int totalThumbnailHeight = parentHeight - spaceAboveSnapshot; int dividerBar = Math.round(splitBoundsConfig.appsStackedVertically - ? splitBoundsConfig.dividerHeightPercent * totalThumbnailHeight + ? splitBoundsConfig.dividerHeightPercent * dp.availableHeightPx : splitBoundsConfig.dividerWidthPercent * parentWidth); int primarySnapshotHeight; int primarySnapshotWidth; @@ -641,12 +646,18 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { } secondarySnapshot.setTranslationY(spaceAboveSnapshot); } else { + int deviceHeightWithoutTaskbar = dp.availableHeightPx - dp.taskbarSize; + float scale = (float) totalThumbnailHeight / deviceHeightWithoutTaskbar; + float topTaskHeight = dp.availableHeightPx * taskPercent; + float finalDividerHeight = dividerBar * scale; + float scaledTopTaskHeight = topTaskHeight * scale; primarySnapshotWidth = parentWidth; - primarySnapshotHeight = Math.round(totalThumbnailHeight * taskPercent); + primarySnapshotHeight = Math.round(scaledTopTaskHeight); secondarySnapshotWidth = parentWidth; - secondarySnapshotHeight = totalThumbnailHeight - primarySnapshotHeight - dividerBar; - int translationY = primarySnapshotHeight + spaceAboveSnapshot + dividerBar; + secondarySnapshotHeight = Math.round(totalThumbnailHeight - primarySnapshotHeight + - finalDividerHeight); + float translationY = primarySnapshotHeight + spaceAboveSnapshot + finalDividerHeight; secondarySnapshot.setTranslationY(translationY); FrameLayout.LayoutParams primaryParams = From 93fc0f3a7c73017463167bb2db1e8b3d6a7e6c03 Mon Sep 17 00:00:00 2001 From: Jeremy Sim Date: Wed, 2 Nov 2022 22:24:33 -0700 Subject: [PATCH 2/7] Allow user to select second split app from Taskbar This patch makes it so that (when we enable Taskbar in Overview) users will be able to select their second app for splitscreen by tapping the Taskbar icon, or the icon in AllApps. This was done by performing a check to SplitSelectStateController when a taskbar icon is hit. If we are currently in split select mode, Taskbar/AllApps icons will no longer launch their respective fullscreen apps, but instead confirm the split attempt. The confirmed app will either be an already-running instance of the app, or a fresh instance of the app (if none is currently running). The split confirmation function is located in TaskbarUIController, where it is accessible to both LauncherTaskbarUIController (for 1P Launcher) and FallbackTaskbarUIController (for 3P launchers). Also cleans up ~2 lines of unused code from the old splitscreen instructions toast. Outstanding issues: - When selecting a second app from within AllApps, the AllApps shade does not animate away in a satisfying way - When selecting a second app and launching a fresh instance of that app, the animation appears to come from the wrong location - Intent + Intent splitting does not currently work - If the selected app is already running with multiple instances, it picks the oldest instance. Ideally, the newest instance is preferred. Bug: 251747761 Test: Manual testing with Taskbar in Overview flag enabled Change-Id: I302dc092740bb880f9134ba8e2e587c4f2c29d01 --- .../taskbar/FallbackTaskbarUIController.java | 8 +- .../taskbar/LauncherTaskbarUIController.java | 6 ++ .../taskbar/TaskbarActivityContext.java | 85 ++++++++++++------- .../taskbar/TaskbarUIController.java | 39 +++++++++ .../android/quickstep/views/RecentsView.java | 61 ++++++++++--- .../com/android/quickstep/views/TaskView.java | 3 +- 6 files changed, 154 insertions(+), 48 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/FallbackTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/FallbackTaskbarUIController.java index f1e67479f5..53ca7ed18e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/FallbackTaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/FallbackTaskbarUIController.java @@ -40,8 +40,7 @@ public class FallbackTaskbarUIController extends TaskbarUIController { animateToRecentsState(toState); // Handle tapping on live tile. - RecentsView recentsView = mRecentsActivity.getOverviewPanel(); - recentsView.setTaskLaunchListener(toState == RecentsState.DEFAULT + getRecentsView().setTaskLaunchListener(toState == RecentsState.DEFAULT ? (() -> animateToRecentsState(RecentsState.BACKGROUND_APP)) : null); } }; @@ -85,4 +84,9 @@ public class FallbackTaskbarUIController extends TaskbarUIController { anim.start(); } } + + @Override + public RecentsView getRecentsView() { + return mRecentsActivity.getOverviewPanel(); + } } diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java index 317f6a4884..2bcf179a4c 100644 --- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java @@ -48,6 +48,7 @@ import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.OnboardingPrefs; import com.android.quickstep.AnimatedFloat; import com.android.quickstep.RecentsAnimationCallbacks; +import com.android.quickstep.views.RecentsView; import java.io.PrintWriter; import java.util.Arrays; @@ -393,4 +394,9 @@ public class LauncherTaskbarUIController extends TaskbarUIController { mTaskbarLauncherStateController.dumpLogs(prefix + "\t", pw); } + + @Override + public RecentsView getRecentsView() { + return mLauncher.getOverviewPanel(); + } } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index fad9ff490c..9fb13db8f6 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -90,6 +90,7 @@ import com.android.launcher3.util.SettingsCache; import com.android.launcher3.util.TraceHelper; import com.android.launcher3.util.ViewCache; import com.android.launcher3.views.ActivityContext; +import com.android.quickstep.views.RecentsView; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.rotation.RotationButtonController; import com.android.systemui.shared.system.ActivityManagerWrapper; @@ -132,6 +133,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { private final boolean mIsUserSetupComplete; private final boolean mIsNavBarForceVisible; private final boolean mIsNavBarKidsMode; + private boolean mIsDestroyed = false; // The flag to know if the window is excluded from magnification region computation. private boolean mIsExcludeFromMagnificationRegion = false; @@ -755,42 +757,63 @@ public class TaskbarActivityContext extends BaseTaskbarContext { if (info.isDisabled()) { ItemClickHandler.handleDisabledItemClicked(info, this); } else { - Intent intent = new Intent(info.getIntent()) - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - try { - if (mIsSafeModeEnabled && !PackageManagerHelper.isSystemApp(this, intent)) { - Toast.makeText(this, R.string.safemode_shortcut_error, - Toast.LENGTH_SHORT).show(); - } else if (info.isPromise()) { - TestLogging.recordEvent( - TestProtocol.SEQUENCE_MAIN, "start: taskbarPromiseIcon"); - intent = new PackageManagerHelper(this) - .getMarketIntent(info.getTargetPackage()) - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); + TaskbarUIController taskbarUIController = mControllers.uiController; + RecentsView recents = taskbarUIController.getRecentsView(); + if (recents != null + && taskbarUIController.getRecentsView().isSplitSelectionActive()) { + // If we are selecting a second app for split, launch the split tasks + taskbarUIController.triggerSecondAppForSplit(info, info.intent, view); + } else { + // Else launch the selected task + Intent intent = new Intent(info.getIntent()) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + try { + if (mIsSafeModeEnabled && !PackageManagerHelper.isSystemApp(this, intent)) { + Toast.makeText(this, R.string.safemode_shortcut_error, + Toast.LENGTH_SHORT).show(); + } else if (info.isPromise()) { + TestLogging.recordEvent( + TestProtocol.SEQUENCE_MAIN, "start: taskbarPromiseIcon"); + intent = new PackageManagerHelper(this) + .getMarketIntent(info.getTargetPackage()) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); - } else if (info.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) { - TestLogging.recordEvent( - TestProtocol.SEQUENCE_MAIN, "start: taskbarDeepShortcut"); - String id = info.getDeepShortcutId(); - String packageName = intent.getPackage(); - getSystemService(LauncherApps.class) - .startShortcut(packageName, id, null, null, info.user); - } else { - startItemInfoActivity(info); + } else if (info.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) { + TestLogging.recordEvent( + TestProtocol.SEQUENCE_MAIN, "start: taskbarDeepShortcut"); + String id = info.getDeepShortcutId(); + String packageName = intent.getPackage(); + getSystemService(LauncherApps.class) + .startShortcut(packageName, id, null, null, info.user); + } else { + startItemInfoActivity(info); + } + + mControllers.uiController.onTaskbarIconLaunched(info); + } catch (NullPointerException + | ActivityNotFoundException + | SecurityException e) { + Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT) + .show(); + Log.e(TAG, "Unable to launch. tag=" + info + " intent=" + intent, e); } - - mControllers.uiController.onTaskbarIconLaunched(info); - mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true); - } catch (NullPointerException | ActivityNotFoundException | SecurityException e) { - Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT) - .show(); - Log.e(TAG, "Unable to launch. tag=" + info + " intent=" + intent, e); } + mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true); } } else if (tag instanceof AppInfo) { - startItemInfoActivity((AppInfo) tag); - mControllers.uiController.onTaskbarIconLaunched((AppInfo) tag); + AppInfo info = (AppInfo) tag; + TaskbarUIController taskbarUIController = mControllers.uiController; + RecentsView recents = taskbarUIController.getRecentsView(); + if (recents != null + && taskbarUIController.getRecentsView().isSplitSelectionActive()) { + // If we are selecting a second app for split, launch the split tasks + taskbarUIController.triggerSecondAppForSplit(info, info.intent, view); + } else { + // Else launch the selected task + startItemInfoActivity((AppInfo) tag); + mControllers.uiController.onTaskbarIconLaunched((AppInfo) tag); + } mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true); } else { Log.e(TAG, "Unknown type clicked: " + tag); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java index 11521260e9..0af25966ea 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java @@ -15,13 +15,18 @@ */ package com.android.launcher3.taskbar; +import android.content.Intent; +import android.graphics.drawable.BitmapDrawable; import android.view.MotionEvent; import android.view.View; import androidx.annotation.CallSuper; +import androidx.annotation.Nullable; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.ItemInfoWithIcon; +import com.android.quickstep.views.RecentsView; +import com.android.quickstep.views.TaskView; import java.io.PrintWriter; import java.util.stream.Stream; @@ -128,4 +133,38 @@ public class TaskbarUIController { prefix, getClass().getSimpleName())); } + + /** + * Returns RecentsView. Overwritten in LauncherTaskbarUIController and + * FallbackTaskbarUIController with Launcher-specific implementations. Returns null for other + * UI controllers (like DesktopTaskbarUIController) that don't have a RecentsView. + */ + public @Nullable RecentsView getRecentsView() { + return null; + } + + /** + * Uses the clicked Taskbar icon to launch a second app for splitscreen. + */ + public void triggerSecondAppForSplit(ItemInfoWithIcon info, Intent intent, View startingView) { + RecentsView recents = getRecentsView(); + TaskView foundTaskView = recents.getTaskViewByComponentName(info.getTargetComponent()); + if (foundTaskView != null) { + recents.confirmSplitSelect( + foundTaskView, + foundTaskView.getTask(), + foundTaskView.getIconView().getDrawable(), + foundTaskView.getThumbnail(), + foundTaskView.getThumbnail().getThumbnail(), + /* intent */ null); + } else { + recents.confirmSplitSelect( + /* containerTaskView */ null, + /* task */ null, + new BitmapDrawable(info.bitmap.icon), + startingView, + /* thumbnail */ null, + intent); + } + } } diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 35414a644a..fed982c6fe 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -74,9 +74,12 @@ import android.animation.ValueAnimator; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.WindowConfiguration; +import android.content.ComponentName; import android.content.Context; +import android.content.Intent; import android.content.LocusId; import android.content.res.Configuration; +import android.graphics.Bitmap; import android.graphics.BlendMode; import android.graphics.Canvas; import android.graphics.Color; @@ -661,8 +664,6 @@ public abstract class RecentsView Date: Tue, 8 Nov 2022 14:25:09 +0000 Subject: [PATCH 3/7] Align system navigation setting link in AllSet page for tablets to top/start. Fix: 233610579 Test: manual Change-Id: If6d462df02bf795e8a6e73fbb040a6a84ea99404 --- .../allset_navigation_and_hint.xml | 43 ------------------- .../allset_navigation_and_hint.xml | 7 ++- quickstep/res/values-sw600dp-land/dimens.xml | 1 - quickstep/res/values-sw600dp/dimens.xml | 1 - quickstep/res/values-sw720dp-land/dimens.xml | 3 -- quickstep/res/values-sw720dp/dimens.xml | 1 - quickstep/res/values/dimens.xml | 1 - 7 files changed, 3 insertions(+), 54 deletions(-) delete mode 100644 quickstep/res/layout-sw600dp-land/allset_navigation_and_hint.xml diff --git a/quickstep/res/layout-sw600dp-land/allset_navigation_and_hint.xml b/quickstep/res/layout-sw600dp-land/allset_navigation_and_hint.xml deleted file mode 100644 index 3bfa6da49d..0000000000 --- a/quickstep/res/layout-sw600dp-land/allset_navigation_and_hint.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/quickstep/res/layout-sw600dp/allset_navigation_and_hint.xml b/quickstep/res/layout-sw600dp/allset_navigation_and_hint.xml index 9559072f8f..44b3ecbd97 100644 --- a/quickstep/res/layout-sw600dp/allset_navigation_and_hint.xml +++ b/quickstep/res/layout-sw600dp/allset_navigation_and_hint.xml @@ -21,12 +21,11 @@ style="@style/TextAppearance.GestureTutorial.LinkText" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginBottom="96dp" + android:layout_marginTop="24dp" android:background="?android:attr/selectableItemBackground" android:minHeight="48dp" android:text="@string/allset_navigation_settings" - app:layout_constraintBottom_toTopOf="@id/hint" - app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toBottomOf="@id/subtitle" app:layout_constraintStart_toStartOf="parent" /> 48dp - 24dp diff --git a/quickstep/res/values-sw600dp/dimens.xml b/quickstep/res/values-sw600dp/dimens.xml index c96ad11e8b..5899814600 100644 --- a/quickstep/res/values-sw600dp/dimens.xml +++ b/quickstep/res/values-sw600dp/dimens.xml @@ -36,7 +36,6 @@ 120dp - 24dp 38sp 15sp diff --git a/quickstep/res/values-sw720dp-land/dimens.xml b/quickstep/res/values-sw720dp-land/dimens.xml index 4bc8bf3c03..02d11892dd 100644 --- a/quickstep/res/values-sw720dp-land/dimens.xml +++ b/quickstep/res/values-sw720dp-land/dimens.xml @@ -17,7 +17,4 @@ 20dp - - - 24dp diff --git a/quickstep/res/values-sw720dp/dimens.xml b/quickstep/res/values-sw720dp/dimens.xml index a84b9394b1..585f01e46a 100644 --- a/quickstep/res/values-sw720dp/dimens.xml +++ b/quickstep/res/values-sw720dp/dimens.xml @@ -35,7 +35,6 @@ 64dp - 0dp 42sp 16sp diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index 6e3fd32329..cd60879580 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -202,7 +202,6 @@ 40dp - 0dp 36sp 14sp From b67bfa7512092d38cb7e29851148cebaf4b0387f Mon Sep 17 00:00:00 2001 From: Thales Lima Date: Wed, 2 Nov 2022 15:30:11 +0000 Subject: [PATCH 4/7] Create test for default grid Fixes: 256044695 Test: DeviceDefaultGridTest Change-Id: Ie0a4de12f777ad3d15020252b2f67b575cc0eca9 --- src/com/android/launcher3/InvariantDeviceProfile.java | 5 +++++ src/com/android/launcher3/Utilities.java | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 0c6f340cb1..ca92aa48f6 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -324,6 +324,11 @@ public class InvariantDeviceProfile { return displayOption.grid.name; } + @VisibleForTesting + public static String getDefaultGridName(Context context) { + return new InvariantDeviceProfile().initGrid(context, null); + } + private void initGrid(Context context, Info displayInfo, DisplayOption displayOption, @DeviceType int deviceType) { DisplayMetrics metrics = context.getResources().getDisplayMetrics(); diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index f70511af7b..a5075327d0 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -521,6 +521,11 @@ public final class Utilities { return (int) (dp * Resources.getSystem().getDisplayMetrics().density); } + /** Converts a dp value to pixels for a certain density. */ + public static int dpToPx(float dp, int densityDpi) { + float densityRatio = (float) densityDpi / DisplayMetrics.DENSITY_DEFAULT; + return (int) (dp * densityRatio); + } public static int pxFromSp(float size, DisplayMetrics metrics) { return pxFromSp(size, metrics, 1f); From d82fc92b2db86fc8d17b4346a0222569829a1d45 Mon Sep 17 00:00:00 2001 From: Saumya Prakash Date: Wed, 9 Nov 2022 01:11:54 +0000 Subject: [PATCH 5/7] Add padding around clear all button in overview. With different languages, the length of the string "clear all" varies, leading to the clear all button in overview looking different. This change adds padding to account for these different lengths to ensure that users have a consistent experience. Screenshot for English: https://screenshot.googleplex.com/4oijo96WSfGNwWp.png Screenshot for Ukrainian: https://screenshot.googleplex.com/Bv2963Vn96BkMeT.png Test: Manual Fix: 225119413 Change-Id: I09fe7bc95ca0c2fd7fe620997d1298f2670b50a4 --- quickstep/res/values/styles.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/quickstep/res/values/styles.xml b/quickstep/res/values/styles.xml index 868d38bd81..4f0fdf182d 100644 --- a/quickstep/res/values/styles.xml +++ b/quickstep/res/values/styles.xml @@ -152,6 +152,8 @@ @drawable/bg_overview_clear_all_button 96dp 48dp + 12dp + 12dp @null From f213afc0a7b4ca68f5546040b3a06072d2415699 Mon Sep 17 00:00:00 2001 From: Anushree Ganjam Date: Tue, 8 Nov 2022 03:11:56 +0000 Subject: [PATCH 6/7] Add OnLayoutCompleted() Listener. OnLayoutCompleted() Listener for RecyclerView.LayoutManager#onLayoutCompleted(RecyclerView.State) so we can do impression logging when RecyclerView has finished laying out the items. Bug: 204781396 Test: Manual Change-Id: I59b81e98415b2b0c6f3b26d2c41d348242342048 --- .../launcher3/allapps/AllAppsGridAdapter.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java index 368a37384d..e34d4c85ae 100644 --- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java +++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java @@ -31,6 +31,7 @@ import androidx.recyclerview.widget.RecyclerView.Adapter; import com.android.launcher3.util.ScrollableLayoutManager; import com.android.launcher3.views.ActivityContext; +import java.util.ArrayList; import java.util.List; /** @@ -43,6 +44,31 @@ public class AllAppsGridAdapter extends public static final String TAG = "AppsGridAdapter"; private final AppsGridLayoutManager mGridLayoutMgr; + private final List mOnLayoutCompletedListeners = new ArrayList<>(); + + /** + * Listener for {@link RecyclerView.LayoutManager#onLayoutCompleted(RecyclerView.State)} + */ + public interface OnLayoutCompletedListener { + void onLayoutCompleted(); + } + + /** + * Adds a {@link OnLayoutCompletedListener} to receive a callback when {@link + * RecyclerView.LayoutManager#onLayoutCompleted(RecyclerView.State)} is called + */ + public void addOnLayoutCompletedListener(OnLayoutCompletedListener listener) { + mOnLayoutCompletedListeners.add(listener); + } + + /** + * Removes a {@link OnLayoutCompletedListener} to not receive a callback when {@link + * RecyclerView.LayoutManager#onLayoutCompleted(RecyclerView.State)} is called + */ + public void removeOnLayoutCompletedListener(OnLayoutCompletedListener listener) { + mOnLayoutCompletedListeners.remove(listener); + } + public AllAppsGridAdapter(T activityContext, LayoutInflater inflater, AlphabeticalAppsList apps, BaseAdapterProvider[] adapterProviders) { @@ -132,6 +158,14 @@ public class AllAppsGridAdapter extends return extraRows; } + @Override + public void onLayoutCompleted(RecyclerView.State state) { + super.onLayoutCompleted(state); + for (OnLayoutCompletedListener listener : mOnLayoutCompletedListeners) { + listener.onLayoutCompleted(); + } + } + @Override protected int incrementTotalHeight(Adapter adapter, int position, int heightUntilLastPos) { AllAppsGridAdapter.AdapterItem item = mApps.getAdapterItems().get(position); From 29eb74f9bd7f906f390d4f06b6f51183a812371d Mon Sep 17 00:00:00 2001 From: Anushree Ganjam Date: Tue, 8 Nov 2022 03:19:50 +0000 Subject: [PATCH 7/7] Add ENABLE_TOAST_IMPRESSION_LOGGING to FeatureFlags. Bug: 204781396 Test: Manual Change-Id: Icd1170d8fc349ca3a50836ef0d1d0c9a0c793002 --- src/com/android/launcher3/config/FeatureFlags.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 4287779c31..3a580203c6 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -323,6 +323,9 @@ public final class FeatureFlags { public static final BooleanFlag SHOW_DOT_PAGINATION = getDebugFlag( "SHOW_DOT_PAGINATION", false, "Enable showing dot pagination in workspace"); + public static final BooleanFlag ENABLE_TOAST_IMPRESSION_LOGGING = getDebugFlag( + "ENABLE_TOAST_IMPRESSION_LOGGING", false, "Enable toast impression logging"); + public static void initialize(Context context) { synchronized (sDebugFlags) { for (DebugFlag flag : sDebugFlags) {