From 206db75b872058ceb68776efa464bd663cca7ac5 Mon Sep 17 00:00:00 2001 From: Pat Manning Date: Thu, 3 Jun 2021 15:01:49 +0000 Subject: [PATCH 01/11] [DO NOT MERGE] Animate live tile translation and update live tile page scroll on dismissal of non-live tile tasks. Test: manual Fix: 188453992 Bug: 188453992 Change-Id: I661c7a2900118ea02e4947feed99308d1a3a5619 --- .../com/android/quickstep/views/RecentsView.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 27f2078580..7991614abb 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -2198,7 +2198,7 @@ public abstract class RecentsView dismissingTaskViewTranslate = - taskView.getSecondaryDissmissTranslationProperty();; + taskView.getSecondaryDissmissTranslationProperty(); // TODO(b/186800707) translate entire grid size distance int translateDistance = mOrientationHandler.getSecondaryDimension(taskView); int positiveNegativeFactor = mOrientationHandler.getSecondaryTranslationDirectionFactor(); @@ -2231,7 +2231,7 @@ public abstract class RecentsView { mLiveTileTaskViewSimulator.taskSecondaryTranslation.value = mOrientationHandler.getSecondaryValue( @@ -2311,6 +2311,15 @@ public abstract class RecentsView { + mLiveTileTaskViewSimulator.taskPrimaryTranslation.value = + mOrientationHandler.getPrimaryValue(child.getTranslationX(), + child.getTranslationY()); + redrawLiveTile(); + }); + } needsCurveUpdates = true; } } else if (child instanceof TaskView) { @@ -2391,6 +2400,7 @@ public abstract class RecentsView Date: Mon, 7 Jun 2021 15:02:05 -0700 Subject: [PATCH 02/11] Revert the squish translate from all apps Bug: 189973274 Bug: 189975416 Test: manual, attached video on the bug Change-Id: I881a2b79462e8d420b3dcb6a6b98adbe9e8e0394 --- .../allapps/AllAppsContainerView.java | 28 +++---------------- .../launcher3/views/SpringRelativeLayout.java | 2 +- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index cb20fec47a..681f5e7a30 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -669,30 +669,10 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo } public void onPull(float deltaDistance, float displacement) { - absorbPullDeltaDistance(PULL_MULTIPLIER * deltaDistance, - PULL_MULTIPLIER * displacement); - // ideally, this should be done using EdgeEffect.onPush to create squish effect. - // However, until such method is available, launcher to simulate the onPush method. - mHeader.setTranslationY(-.5f * mHeaderTop * deltaDistance); - getRecyclerViewContainer().setTranslationY(-mHeaderTop * deltaDistance); - } - - public void onRelease() { - ValueAnimator anim1 = ValueAnimator.ofFloat(1f, 0f); - final float floatingHeaderHeight = getFloatingHeaderView().getTranslationY(); - final float recyclerViewHeight = getRecyclerViewContainer().getTranslationY(); - anim1.setDuration(200); - anim1.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator valueAnimator) { - getFloatingHeaderView().setTranslationY( - ((float) valueAnimator.getAnimatedValue()) * floatingHeaderHeight); - getRecyclerViewContainer().setTranslationY( - ((float) valueAnimator.getAnimatedValue()) * recyclerViewHeight); - } - }); - anim1.start(); - super.onRelease(); + absorbPullDeltaDistance(PULL_MULTIPLIER * deltaDistance, PULL_MULTIPLIER * displacement); + // Current motion spec is to actually push and not pull + // on this surface. However, until EdgeEffect.onPush (b/190612804) is + // implemented at view level, we will simply pull } @Override diff --git a/src/com/android/launcher3/views/SpringRelativeLayout.java b/src/com/android/launcher3/views/SpringRelativeLayout.java index 8342d3e9d2..8e3ac20574 100644 --- a/src/com/android/launcher3/views/SpringRelativeLayout.java +++ b/src/com/android/launcher3/views/SpringRelativeLayout.java @@ -93,7 +93,7 @@ public class SpringRelativeLayout extends RelativeLayout { invalidate(); } - protected void onRelease() { + public void onRelease() { mEdgeGlowBottom.onRelease(); } From f564b65f2a23d81f7ccafaca5727b2daf7e216f4 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Tue, 8 Jun 2021 15:35:33 -0700 Subject: [PATCH 03/11] Folder preview polish. - Fixes notification dot not aligning in 4x5 grid - Fixes clipping issues with large folders - Fixes clipping issues with preview item animations Bug: 188095988 Test: manual Change-Id: I6821b3cb3c65e5928c7be1cddd7f292a37842698 --- .../folder/ClippedFolderIconLayoutRule.java | 6 +-- src/com/android/launcher3/folder/Folder.java | 2 +- .../folder/FolderAnimationManager.java | 34 +++++++++++-- .../android/launcher3/folder/FolderIcon.java | 1 + .../folder/FolderPreviewItemAnim.java | 1 + .../folder/PreviewItemDrawingParams.java | 1 + .../launcher3/folder/PreviewItemManager.java | 50 ++++++++++++++----- 7 files changed, 75 insertions(+), 20 deletions(-) diff --git a/src/com/android/launcher3/folder/ClippedFolderIconLayoutRule.java b/src/com/android/launcher3/folder/ClippedFolderIconLayoutRule.java index 68bed443c7..3457804c3a 100644 --- a/src/com/android/launcher3/folder/ClippedFolderIconLayoutRule.java +++ b/src/com/android/launcher3/folder/ClippedFolderIconLayoutRule.java @@ -6,9 +6,9 @@ public class ClippedFolderIconLayoutRule { private static final int MIN_NUM_ITEMS_IN_PREVIEW = 2; private static final float MIN_SCALE = 0.44f; - private static final float MAX_SCALE = 0.54f; - private static final float MAX_RADIUS_DILATION = 0.10f; - private static final float ITEM_RADIUS_SCALE_FACTOR = 1.2f; + private static final float MAX_SCALE = 0.51f; + private static final float MAX_RADIUS_DILATION = 0.1f; + private static final float ITEM_RADIUS_SCALE_FACTOR = 1.15f; public static final int EXIT_INDEX = -2; public static final int ENTER_INDEX = -3; diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index 17c1329ed9..dc188f27d4 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -743,7 +743,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo } mContent.completePendingPageChanges(); - mContent.snapToPageImmediately(pageNo); + mContent.setCurrentPage(pageNo); // This is set to true in close(), but isn't reset to false until onDropCompleted(). This // leads to an inconsistent state if you drag out of the folder and drag back in without diff --git a/src/com/android/launcher3/folder/FolderAnimationManager.java b/src/com/android/launcher3/folder/FolderAnimationManager.java index bd0dbfde08..e66e2f6fc1 100644 --- a/src/com/android/launcher3/folder/FolderAnimationManager.java +++ b/src/com/android/launcher3/folder/FolderAnimationManager.java @@ -16,6 +16,8 @@ package com.android.launcher3.folder; +import static android.view.View.ALPHA; + import static com.android.launcher3.BubbleTextView.TEXT_ALPHA_PROPERTY; import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.MAX_NUM_ITEMS_IN_PREVIEW; @@ -57,6 +59,7 @@ import java.util.List; public class FolderAnimationManager { private static final int FOLDER_NAME_ALPHA_DURATION = 32; + private static final int LARGE_FOLDER_FOOTER_DURATION = 128; private Folder mFolder; private FolderPagedView mContent; @@ -214,7 +217,22 @@ public class FolderAnimationManager { play(a, getAnimator(mFolder, View.TRANSLATION_Y, yDistance, 0f)); play(a, getAnimator(mFolder.mContent, SCALE_PROPERTY, initialScale, finalScale)); play(a, getAnimator(mFolder.mFooter, SCALE_PROPERTY, initialScale, finalScale)); - play(a, mFolderIcon.mFolderName.createTextAlphaAnimator(!mIsOpening)); + + final int footerAlphaDuration; + final int footerStartDelay; + if (isLargeFolder()) { + if (mIsOpening) { + footerAlphaDuration = LARGE_FOLDER_FOOTER_DURATION; + footerStartDelay = mDuration - footerAlphaDuration; + } else { + footerAlphaDuration = 0; + footerStartDelay = 0; + } + } else { + footerStartDelay = 0; + footerAlphaDuration = mDuration; + } + play(a, getAnimator(mFolder.mFooter, ALPHA, 0, 1f), footerStartDelay, footerAlphaDuration); // Create reveal animator for the folder background play(a, getShape().createRevealAnimator( @@ -225,9 +243,13 @@ public class FolderAnimationManager { + mDeviceProfile.folderCellWidthPx * 2; int height = mContent.getPaddingTop() + mDeviceProfile.folderCellLayoutBorderSpacingPx + mDeviceProfile.folderCellHeightPx * 2; - Rect startRect2 = new Rect(0, 0, width, height); + int page = mIsOpening ? mContent.getCurrentPage() : mContent.getDestinationPage(); + int left = mContent.getPaddingLeft() + page * mContent.getWidth(); + Rect contentStart = new Rect(left, 0, left + width, height); + Rect contentEnd = new Rect(endRect.left + left, endRect.top, endRect.right + left, + endRect.bottom); play(a, getShape().createRevealAnimator( - mFolder.getContent(), startRect2, endRect, finalRadius, !mIsOpening)); + mFolder.getContent(), contentStart, contentEnd, finalRadius, !mIsOpening)); // Fade in the folder name, as the text can overlap the icons when grid size is small. @@ -420,8 +442,12 @@ public class FolderAnimationManager { as.play(a); } + private boolean isLargeFolder() { + return mFolder.getItemCount() > MAX_NUM_ITEMS_IN_PREVIEW; + } + private TimeInterpolator getPreviewItemInterpolator() { - if (mFolder.getItemCount() > MAX_NUM_ITEMS_IN_PREVIEW) { + if (isLargeFolder()) { // With larger folders, we want the preview items to reach their final positions faster // (when opening) and later (when closing) so that they appear aligned with the rest of // the folder items when they are both visible. diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java index 6b12d86d13..ed2d0a943a 100644 --- a/src/com/android/launcher3/folder/FolderIcon.java +++ b/src/com/android/launcher3/folder/FolderIcon.java @@ -627,6 +627,7 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel if (!mForceHideDot && ((mDotInfo != null && mDotInfo.hasDot()) || mDotScale > 0)) { Rect iconBounds = mDotParams.iconBounds; BubbleTextView.getIconBounds(this, iconBounds, mActivity.getDeviceProfile().iconSizePx); + iconBounds.offset(0, mBackground.paddingY); float iconScale = (float) mBackground.previewSize / iconBounds.width(); Utilities.scaleRectAboutCenter(iconBounds, iconScale); diff --git a/src/com/android/launcher3/folder/FolderPreviewItemAnim.java b/src/com/android/launcher3/folder/FolderPreviewItemAnim.java index 22f73330ef..edfd2ba35e 100644 --- a/src/com/android/launcher3/folder/FolderPreviewItemAnim.java +++ b/src/com/android/launcher3/folder/FolderPreviewItemAnim.java @@ -68,6 +68,7 @@ class FolderPreviewItemAnim { int duration, final Runnable onCompleteRunnable) { mItemManager = itemManager; mParams = params; + mParams.index = index1; mItemManager.computePreviewItemDrawingParams(index1, items1, sTmpParams); finalState = new float[] {sTmpParams.scale, sTmpParams.transX, sTmpParams.transY}; diff --git a/src/com/android/launcher3/folder/PreviewItemDrawingParams.java b/src/com/android/launcher3/folder/PreviewItemDrawingParams.java index a14a0d8efc..5746be89d9 100644 --- a/src/com/android/launcher3/folder/PreviewItemDrawingParams.java +++ b/src/com/android/launcher3/folder/PreviewItemDrawingParams.java @@ -23,6 +23,7 @@ import com.android.launcher3.model.data.WorkspaceItemInfo; * Manages the parameters used to draw a Folder preview item. */ class PreviewItemDrawingParams { + float index; float transX; float transY; float scale; diff --git a/src/com/android/launcher3/folder/PreviewItemManager.java b/src/com/android/launcher3/folder/PreviewItemManager.java index 6adef01514..baafbc92bc 100644 --- a/src/com/android/launcher3/folder/PreviewItemManager.java +++ b/src/com/android/launcher3/folder/PreviewItemManager.java @@ -28,6 +28,8 @@ import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.content.Context; import android.graphics.Canvas; +import android.graphics.Path; +import android.graphics.PointF; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.util.FloatProperty; @@ -81,6 +83,10 @@ public class PreviewItemManager { // These hold the current page preview items. It is empty if the current page is the first page. private ArrayList mCurrentPageParams = new ArrayList<>(); + // We clip the preview items during the middle of the animation, so that it does not go outside + // of the visual shape. We stop clipping at this threshold, since the preview items ultimately + // do not get cropped in their resting state. + private final float mClipThreshold; private float mCurrentPageItemsTransX = 0; private boolean mShouldSlideInFirstPage; @@ -96,6 +102,7 @@ public class PreviewItemManager { mIcon = icon; mIconSize = ActivityContext.lookupContext( mContext).getDeviceProfile().folderChildIconSizePx; + mClipThreshold = Utilities.dpToPx(1f); } /** @@ -163,41 +170,60 @@ public class PreviewItemManager { } public void drawParams(Canvas canvas, ArrayList params, - float transX) { - canvas.translate(transX, 0); + PointF offset, boolean shouldClipPath, Path clipPath) { // The first item should be drawn last (ie. on top of later items) for (int i = params.size() - 1; i >= 0; i--) { PreviewItemDrawingParams p = params.get(i); if (!p.hidden) { - drawPreviewItem(canvas, p); + // Exiting param should always be clipped. + boolean isExiting = p.index == EXIT_INDEX; + drawPreviewItem(canvas, p, offset, isExiting | shouldClipPath, clipPath); } } - canvas.translate(-transX, 0); } + /** + * Draws the preview items on {@param canvas}. + */ public void draw(Canvas canvas) { + int saveCount = canvas.getSaveCount(); // The items are drawn in coordinates relative to the preview offset PreviewBackground bg = mIcon.getFolderBackground(); - canvas.translate(bg.basePreviewOffsetX, bg.basePreviewOffsetY); - + Path clipPath = bg.getClipPath(); float firstPageItemsTransX = 0; if (mShouldSlideInFirstPage) { - drawParams(canvas, mCurrentPageParams, mCurrentPageItemsTransX); - + PointF firstPageOffset = new PointF(bg.basePreviewOffsetX + mCurrentPageItemsTransX, + bg.basePreviewOffsetY); + boolean shouldClip = mCurrentPageItemsTransX > mClipThreshold; + drawParams(canvas, mCurrentPageParams, firstPageOffset, shouldClip, clipPath); firstPageItemsTransX = -ITEM_SLIDE_IN_OUT_DISTANCE_PX + mCurrentPageItemsTransX; } - drawParams(canvas, mFirstPageParams, firstPageItemsTransX); - canvas.translate(-bg.basePreviewOffsetX, -bg.basePreviewOffsetY); + PointF firstPageOffset = new PointF(bg.basePreviewOffsetX + firstPageItemsTransX, + bg.basePreviewOffsetY); + boolean shouldClipFirstPage = firstPageItemsTransX < -mClipThreshold; + drawParams(canvas, mFirstPageParams, firstPageOffset, shouldClipFirstPage, clipPath); + canvas.restoreToCount(saveCount); } public void onParamsChanged() { mIcon.invalidate(); } - private void drawPreviewItem(Canvas canvas, PreviewItemDrawingParams params) { + /** + * Draws each preview item. + * + * @param offset The offset needed to draw the preview items. + * @param shouldClipPath Iff true, clip path using {@param clipPath}. + * @param clipPath The clip path of the folder icon. + */ + private void drawPreviewItem(Canvas canvas, PreviewItemDrawingParams params, PointF offset, + boolean shouldClipPath, Path clipPath) { canvas.save(); - canvas.translate(params.transX, params.transY); + if (shouldClipPath) { + canvas.clipPath(clipPath); + } + canvas.translate(offset.x + params.transX, offset.y + params.transY); canvas.scale(params.scale, params.scale); Drawable d = params.drawable; From c0f29c6f956ac6e9bb25a4f4362f0ea9d48695a6 Mon Sep 17 00:00:00 2001 From: Yogisha Dixit Date: Tue, 25 May 2021 01:13:33 +0100 Subject: [PATCH 04/11] Add a content description for the widget reconfigure button. Bug: 186761890 Test: manual Change-Id: Ia36972b606a524827ade8bd1c191f8b972bbb382 --- res/layout/app_widget_resize_frame.xml | 3 ++- res/values/strings.xml | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/res/layout/app_widget_resize_frame.xml b/res/layout/app_widget_resize_frame.xml index 53db5edd8a..249e42ce86 100644 --- a/res/layout/app_widget_resize_frame.xml +++ b/res/layout/app_widget_resize_frame.xml @@ -83,7 +83,8 @@ android:layout_marginEnd="@dimen/widget_reconfigure_button_margin" android:src="@drawable/widget_reconfigure_button_frame" android:background="?android:attr/selectableItemBackground" - android:visibility="gone" /> + android:visibility="gone" + android:contentDescription="@string/widget_reconfigure_button_content_description" /> \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index c851cf8273..ab1b32d68a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -108,6 +108,10 @@ Got it + + Change widget settings + Search apps From ecdf6575ec2546ecbd888865be4d48513537992d Mon Sep 17 00:00:00 2001 From: Alina Zaidi Date: Mon, 7 Jun 2021 10:27:23 +0100 Subject: [PATCH 05/11] Add more education tips for widgets. (3/3) Show tip on reconfigurable widget in launcher. Bug: 185354491 Test: Manually tested tips in widget picker, all apps, and reconfigurable widgets tip. Change-Id: I08154c944285cac6a21c3ef4aafd878bbbccf44b --- res/layout/arrow_toast.xml | 5 +- res/values-v28/dimens.xml | 2 +- res/values/dimens.xml | 1 + res/values/strings.xml | 5 ++ .../launcher3/AppWidgetResizeFrame.java | 29 +++++++++++ .../android/launcher3/views/ArrowTipView.java | 52 ++++++++++++------- .../launcher3/widget/BaseWidgetSheet.java | 18 ++++--- 7 files changed, 83 insertions(+), 29 deletions(-) diff --git a/res/layout/arrow_toast.xml b/res/layout/arrow_toast.xml index aee00a95ae..9a6f8c35bd 100644 --- a/res/layout/arrow_toast.xml +++ b/res/layout/arrow_toast.xml @@ -28,13 +28,14 @@ android:padding="16dp" android:background="@drawable/arrow_toast_rounded_background" android:elevation="2dp" + android:outlineProvider="none" android:textColor="@color/arrow_tip_view_content" android:textSize="14sp"/> + android:layout_height="10dp"/> diff --git a/res/values-v28/dimens.xml b/res/values-v28/dimens.xml index ffa8cc4258..3f118cd9eb 100644 --- a/res/values-v28/dimens.xml +++ b/res/values-v28/dimens.xml @@ -1,5 +1,5 @@ - 6dp diff --git a/res/values/strings.xml b/res/values/strings.xml index c851cf8273..a470bcdf4e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -105,6 +105,11 @@ To get info without opening apps, you can add widgets to your Home screen + + + Tap to change widget settings + Got it diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java index 74ac8c24c4..ac582cdcbf 100644 --- a/src/com/android/launcher3/AppWidgetResizeFrame.java +++ b/src/com/android/launcher3/AppWidgetResizeFrame.java @@ -30,6 +30,7 @@ import com.android.launcher3.logging.InstanceId; import com.android.launcher3.logging.InstanceIdSequence; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.util.PendingRequestArgs; +import com.android.launcher3.views.ArrowTipView; import com.android.launcher3.widget.LauncherAppWidgetHostView; import com.android.launcher3.widget.LauncherAppWidgetProviderInfo; import com.android.launcher3.widget.util.WidgetSizes; @@ -42,6 +43,8 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O private static final float DIMMED_HANDLE_ALPHA = 0f; private static final float RESIZE_THRESHOLD = 0.66f; + private static final String KEY_RECONFIGURABLE_WIDGET_EDUCATION_TIP_SEEN = + "launcher.reconfigurable_widget_education_tip_seen"; private static final Rect sTmpRect = new Rect(); private static final int HANDLE_COUNT = 4; @@ -238,6 +241,15 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O mWidgetView.getAppWidgetId(), Launcher.REQUEST_RECONFIGURE_APPWIDGET); }); + if (!hasSeenReconfigurableWidgetEducationTip()) { + post(() -> { + if (showReconfigurableWidgetEducationTip() != null) { + mLauncher.getSharedPrefs().edit() + .putBoolean(KEY_RECONFIGURABLE_WIDGET_EDUCATION_TIP_SEEN, + true).apply(); + } + }); + } } // When we create the resize frame, we first mark all cells as unoccupied. The appropriate @@ -679,4 +691,21 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O || keyCode == KeyEvent.KEYCODE_MOVE_HOME || keyCode == KeyEvent.KEYCODE_MOVE_END || keyCode == KeyEvent.KEYCODE_PAGE_UP || keyCode == KeyEvent.KEYCODE_PAGE_DOWN); } + + private ArrowTipView showReconfigurableWidgetEducationTip() { + int[] coords = new int[2]; + mReconfigureButton.getLocationOnScreen(coords); + int tipTopMargin = mLauncher.getResources() + .getDimensionPixelSize(R.dimen.widget_reconfigure_tip_top_margin); + return new ArrowTipView(mLauncher, /* isPointingUp= */ true).showAtLocation( + getContext().getString(R.string.reconfigurable_widget_education_tip), + /* arrowXCoord= */ coords[0] + mReconfigureButton.getWidth() / 2, + /* yCoord= */ coords[1] + mReconfigureButton.getHeight() + tipTopMargin); + } + + private boolean hasSeenReconfigurableWidgetEducationTip() { + return mLauncher.getSharedPrefs() + .getBoolean(KEY_RECONFIGURABLE_WIDGET_EDUCATION_TIP_SEEN, false) + || Utilities.IS_RUNNING_IN_TEST_HARNESS; + } } diff --git a/src/com/android/launcher3/views/ArrowTipView.java b/src/com/android/launcher3/views/ArrowTipView.java index 07d377615b..f3068a7d43 100644 --- a/src/com/android/launcher3/views/ArrowTipView.java +++ b/src/com/android/launcher3/views/ArrowTipView.java @@ -73,6 +73,9 @@ public class ArrowTipView extends AbstractFloatingView { public boolean onControllerInterceptTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { close(true); + if (mActivity.getDragLayer().isEventOverView(this, ev)) { + return true; + } } return false; } @@ -111,19 +114,19 @@ public class ArrowTipView extends AbstractFloatingView { ShapeDrawable arrowDrawable = new ShapeDrawable(TriangleShape.create( arrowLp.width, arrowLp.height, mIsPointingUp)); Paint arrowPaint = arrowDrawable.getPaint(); + @Px int arrowTipRadius = getContext().getResources() + .getDimensionPixelSize(R.dimen.arrow_toast_corner_radius); arrowPaint.setColor(ContextCompat.getColor(getContext(), R.color.arrow_tip_view_bg)); - // The corner path effect won't be reflected in the shadow, but shouldn't be noticeable. - arrowPaint.setPathEffect(new CornerPathEffect( - context.getResources().getDimension(R.dimen.arrow_toast_corner_radius))); + arrowPaint.setPathEffect(new CornerPathEffect(arrowTipRadius)); arrowView.setBackground(arrowDrawable); + // Add negative margin so that the rounded corners on base of arrow are not visible. if (mIsPointingUp) { removeView(arrowView); addView(arrowView, 0); + ((ViewGroup.MarginLayoutParams) arrowLp).setMargins(0, 0, 0, -1 * arrowTipRadius); + } else { + ((ViewGroup.MarginLayoutParams) arrowLp).setMargins(0, -1 * arrowTipRadius, 0, 0); } - - mIsOpen = true; - - mHandler.postDelayed(() -> handleClose(true), AUTO_CLOSE_TIMEOUT_MILLIS); } /** @@ -136,10 +139,10 @@ public class ArrowTipView extends AbstractFloatingView { /** * Show the ArrowTipView (tooltip) center, start, or end aligned. * - * @param text The text to be shown in the tooltip. - * @param gravity The gravity aligns the tooltip center, start, or end. + * @param text The text to be shown in the tooltip. + * @param gravity The gravity aligns the tooltip center, start, or end. * @param arrowMarginStart The margin from start to place arrow (ignored if center) - * @param top The Y coordinate of the bottom of tooltip. + * @param top The Y coordinate of the bottom of tooltip. * @return The tooltip. */ public ArrowTipView show(String text, int gravity, int arrowMarginStart, int top) { @@ -166,6 +169,9 @@ public class ArrowTipView extends AbstractFloatingView { params.leftMargin = mActivity.getDeviceProfile().workspacePadding.left; params.rightMargin = mActivity.getDeviceProfile().workspacePadding.right; post(() -> setY(top - (mIsPointingUp ? 0 : getHeight()))); + + mIsOpen = true; + mHandler.postDelayed(() -> handleClose(true), AUTO_CLOSE_TIMEOUT_MILLIS); setAlpha(0); animate() .alpha(1f) @@ -180,14 +186,13 @@ public class ArrowTipView extends AbstractFloatingView { /** * Show the ArrowTipView (tooltip) custom aligned. * - * @param text The text to be shown in the tooltip. - * @param arrowXCoord The X coordinate for the arrow on the tip. The arrow is usually in the - * center of ArrowTipView unless the ArrowTipView goes beyond screen margin. - * @param yCoord The Y coordinate of the bottom of the tooltip. - * @return The tool tip view. + * @param text The text to be shown in the tooltip. + * @param arrowXCoord The X coordinate for the arrow on the tooltip. The arrow is usually in the + * center of tooltip unless the tooltip goes beyond screen margin. + * @param yCoord The Y coordinate of the pointed tip end of the tooltip. + * @return The tool tip view. {@code null} if the tip can not be shown. */ - @Nullable - public ArrowTipView showAtLocation(String text, int arrowXCoord, int yCoord) { + @Nullable public ArrowTipView showAtLocation(String text, @Px int arrowXCoord, @Px int yCoord) { ViewGroup parent = mActivity.getDragLayer(); @Px int parentViewWidth = parent.getWidth(); @Px int maxTextViewWidth = getContext().getResources() @@ -209,19 +214,30 @@ public class ArrowTipView extends AbstractFloatingView { float halfWidth = getWidth() / 2f; float xCoord; if (arrowXCoord - halfWidth < minViewMargin) { + // If the tooltip is estimated to go beyond the left margin, place its start just at + // the left margin. xCoord = minViewMargin; } else if (arrowXCoord + halfWidth > parentViewWidth - minViewMargin) { + // If the tooltip is estimated to go beyond the right margin, place it such that its + // end is just at the right margin. xCoord = parentViewWidth - minViewMargin - getWidth(); } else { + // Place the tooltip such that its center is at arrowXCoord. xCoord = arrowXCoord - halfWidth; } setX(xCoord); - setY(yCoord - getHeight()); + // Place the tooltip such that its top is at yCoord if arrow is pointing upwards, + // otherwise place it such that its bottom is at yCoord. + setY(mIsPointingUp ? yCoord : yCoord - getHeight()); + // Adjust the arrow's relative position on tooltip to make sure the actual position of + // arrow's pointed tip is always at arrowXCoord. View arrowView = findViewById(R.id.arrow); arrowView.setX(arrowXCoord - xCoord - arrowView.getWidth() / 2f); requestLayout(); }); + mIsOpen = true; + mHandler.postDelayed(() -> handleClose(true), AUTO_CLOSE_TIMEOUT_MILLIS); setAlpha(0); animate() .alpha(1f) diff --git a/src/com/android/launcher3/widget/BaseWidgetSheet.java b/src/com/android/launcher3/widget/BaseWidgetSheet.java index edd42b4683..3bf993e199 100644 --- a/src/com/android/launcher3/widget/BaseWidgetSheet.java +++ b/src/com/android/launcher3/widget/BaseWidgetSheet.java @@ -207,16 +207,18 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView if (view == null || !ViewCompat.isLaidOut(view)) { return null; } - - mActivityContext.getSharedPrefs().edit() - .putBoolean(KEY_WIDGETS_EDUCATION_TIP_SEEN, true).apply(); int[] coords = new int[2]; view.getLocationOnScreen(coords); - ArrowTipView arrowTipView = new ArrowTipView(mActivityContext); - return arrowTipView.showAtLocation( - getContext().getString(R.string.long_press_widget_to_add), - /* arrowXCoord= */coords[0] + view.getWidth() / 2, - /* yCoord= */coords[1]); + ArrowTipView arrowTipView = + new ArrowTipView(mActivityContext, /* isPointingUp= */ false).showAtLocation( + getContext().getString(R.string.long_press_widget_to_add), + /* arrowXCoord= */coords[0] + view.getWidth() / 2, + /* yCoord= */coords[1]); + if (arrowTipView != null) { + mActivityContext.getSharedPrefs().edit() + .putBoolean(KEY_WIDGETS_EDUCATION_TIP_SEEN, true).apply(); + } + return arrowTipView; } /** Returns {@code true} if tip has previously been shown on any of {@link BaseWidgetSheet}. */ From dca47432fcce4cbb91a29d0e3e0deef6460a7cc8 Mon Sep 17 00:00:00 2001 From: Alina Zaidi Date: Tue, 8 Jun 2021 14:35:22 +0100 Subject: [PATCH 06/11] Flip ArrowTipView when it goes beyond screen height. Bug: 185354491 Test: Manually tested tips in widget picker, all apps, and reconfigurable widgets tip. Change-Id: I5d1c9e4b8bc3ae89834bc198016ffa409a2b28ad --- .../launcher3/AppWidgetResizeFrame.java | 23 ++-- .../android/launcher3/views/ArrowTipView.java | 123 ++++++++++++++---- 2 files changed, 111 insertions(+), 35 deletions(-) diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java index ac582cdcbf..9e21e1a0f1 100644 --- a/src/com/android/launcher3/AppWidgetResizeFrame.java +++ b/src/com/android/launcher3/AppWidgetResizeFrame.java @@ -24,6 +24,9 @@ import android.view.View; import android.widget.ImageButton; import android.widget.ImageView; +import androidx.annotation.Nullable; +import androidx.annotation.Px; + import com.android.launcher3.accessibility.DragViewStateAnnouncer; import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.logging.InstanceId; @@ -692,15 +695,19 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O || keyCode == KeyEvent.KEYCODE_PAGE_UP || keyCode == KeyEvent.KEYCODE_PAGE_DOWN); } - private ArrowTipView showReconfigurableWidgetEducationTip() { - int[] coords = new int[2]; - mReconfigureButton.getLocationOnScreen(coords); - int tipTopMargin = mLauncher.getResources() + @Nullable private ArrowTipView showReconfigurableWidgetEducationTip() { + Rect rect = new Rect(); + if (!mReconfigureButton.getGlobalVisibleRect(rect)) { + return null; + } + @Px int tipMargin = mLauncher.getResources() .getDimensionPixelSize(R.dimen.widget_reconfigure_tip_top_margin); - return new ArrowTipView(mLauncher, /* isPointingUp= */ true).showAtLocation( - getContext().getString(R.string.reconfigurable_widget_education_tip), - /* arrowXCoord= */ coords[0] + mReconfigureButton.getWidth() / 2, - /* yCoord= */ coords[1] + mReconfigureButton.getHeight() + tipTopMargin); + return new ArrowTipView(mLauncher, /* isPointingUp= */ true) + .showAroundRect( + getContext().getString(R.string.reconfigurable_widget_education_tip), + /* arrowXCoord= */ rect.left + mReconfigureButton.getWidth() / 2, + /* rect= */ rect, + /* margin= */ tipMargin); } private boolean hasSeenReconfigurableWidgetEducationTip() { diff --git a/src/com/android/launcher3/views/ArrowTipView.java b/src/com/android/launcher3/views/ArrowTipView.java index f3068a7d43..e449a4bfbf 100644 --- a/src/com/android/launcher3/views/ArrowTipView.java +++ b/src/com/android/launcher3/views/ArrowTipView.java @@ -17,8 +17,10 @@ package com.android.launcher3.views; import android.content.Context; +import android.content.res.Configuration; import android.graphics.CornerPathEffect; import android.graphics.Paint; +import android.graphics.Rect; import android.graphics.drawable.ShapeDrawable; import android.os.Handler; import android.util.Log; @@ -53,9 +55,10 @@ public class ArrowTipView extends AbstractFloatingView { protected final BaseDraggingActivity mActivity; private final Handler mHandler = new Handler(); - private final boolean mIsPointingUp; private final int mArrowWidth; + private boolean mIsPointingUp; private Runnable mOnClosed; + private View mArrowView; public ArrowTipView(Context context) { this(context, false); @@ -109,24 +112,8 @@ public class ArrowTipView extends AbstractFloatingView { inflate(context, R.layout.arrow_toast, this); setOrientation(LinearLayout.VERTICAL); - View arrowView = findViewById(R.id.arrow); - ViewGroup.LayoutParams arrowLp = arrowView.getLayoutParams(); - ShapeDrawable arrowDrawable = new ShapeDrawable(TriangleShape.create( - arrowLp.width, arrowLp.height, mIsPointingUp)); - Paint arrowPaint = arrowDrawable.getPaint(); - @Px int arrowTipRadius = getContext().getResources() - .getDimensionPixelSize(R.dimen.arrow_toast_corner_radius); - arrowPaint.setColor(ContextCompat.getColor(getContext(), R.color.arrow_tip_view_bg)); - arrowPaint.setPathEffect(new CornerPathEffect(arrowTipRadius)); - arrowView.setBackground(arrowDrawable); - // Add negative margin so that the rounded corners on base of arrow are not visible. - if (mIsPointingUp) { - removeView(arrowView); - addView(arrowView, 0); - ((ViewGroup.MarginLayoutParams) arrowLp).setMargins(0, 0, 0, -1 * arrowTipRadius); - } else { - ((ViewGroup.MarginLayoutParams) arrowLp).setMargins(0, -1 * arrowTipRadius, 0, 0); - } + mArrowView = findViewById(R.id.arrow); + updateArrowTipInView(); } /** @@ -152,8 +139,7 @@ public class ArrowTipView extends AbstractFloatingView { DragLayer.LayoutParams params = (DragLayer.LayoutParams) getLayoutParams(); params.gravity = gravity; - LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) findViewById( - R.id.arrow).getLayoutParams(); + LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mArrowView.getLayoutParams(); lp.gravity = gravity; if (parent.getLayoutDirection() == LAYOUT_DIRECTION_RTL) { @@ -184,7 +170,8 @@ public class ArrowTipView extends AbstractFloatingView { } /** - * Show the ArrowTipView (tooltip) custom aligned. + * Show the ArrowTipView (tooltip) custom aligned. The tooltip is vertically flipped if it + * cannot fit on screen in the requested orientation. * * @param text The text to be shown in the tooltip. * @param arrowXCoord The X coordinate for the arrow on the tooltip. The arrow is usually in the @@ -193,8 +180,51 @@ public class ArrowTipView extends AbstractFloatingView { * @return The tool tip view. {@code null} if the tip can not be shown. */ @Nullable public ArrowTipView showAtLocation(String text, @Px int arrowXCoord, @Px int yCoord) { + return showAtLocation( + text, + arrowXCoord, + /* yCoordDownPointingTip= */ yCoord, + /* yCoordUpPointingTip= */ yCoord); + } + + /** + * Show the ArrowTipView (tooltip) custom aligned. The tooltip is vertically flipped if it + * cannot fit on screen in the requested orientation. + * + * @param text The text to be shown in the tooltip. + * @param arrowXCoord The X coordinate for the arrow on the tooltip. The arrow is usually in the + * center of tooltip unless the tooltip goes beyond screen margin. + * @param rect The coordinates of the view which requests the tooltip to be shown. + * @param margin The margin between {@param rect} and the tooltip. + * @return The tool tip view. {@code null} if the tip can not be shown. + */ + @Nullable public ArrowTipView showAroundRect( + String text, @Px int arrowXCoord, Rect rect, @Px int margin) { + return showAtLocation( + text, + arrowXCoord, + /* yCoordDownPointingTip= */ rect.top - margin, + /* yCoordUpPointingTip= */ rect.bottom + margin); + } + + /** + * Show the ArrowTipView (tooltip) custom aligned. The tooltip is vertically flipped if it + * cannot fit on screen in the requested orientation. + * + * @param text The text to be shown in the tooltip. + * @param arrowXCoord The X coordinate for the arrow on the tooltip. The arrow is usually in the + * center of tooltip unless the tooltip goes beyond screen margin. + * @param yCoordDownPointingTip The Y coordinate of the pointed tip end of the tooltip when the + * tooltip is placed pointing downwards. + * @param yCoordUpPointingTip The Y coordinate of the pointed tip end of the tooltip when the + * tooltip is placed pointing upwards. + * @return The tool tip view. {@code null} if the tip can not be shown. + */ + @Nullable private ArrowTipView showAtLocation(String text, @Px int arrowXCoord, + @Px int yCoordDownPointingTip, @Px int yCoordUpPointingTip) { ViewGroup parent = mActivity.getDragLayer(); @Px int parentViewWidth = parent.getWidth(); + @Px int parentViewHeight = parent.getHeight(); @Px int maxTextViewWidth = getContext().getResources() .getDimensionPixelSize(R.dimen.widget_picker_education_tip_max_width); @Px int minViewMargin = getContext().getResources() @@ -211,6 +241,7 @@ public class ArrowTipView extends AbstractFloatingView { requestLayout(); post(() -> { + // Adjust the tooltip horizontally. float halfWidth = getWidth() / 2f; float xCoord; if (arrowXCoord - halfWidth < minViewMargin) { @@ -226,13 +257,24 @@ public class ArrowTipView extends AbstractFloatingView { xCoord = arrowXCoord - halfWidth; } setX(xCoord); - // Place the tooltip such that its top is at yCoord if arrow is pointing upwards, - // otherwise place it such that its bottom is at yCoord. - setY(mIsPointingUp ? yCoord : yCoord - getHeight()); + + // Adjust the tooltip vertically. + @Px int viewHeight = getHeight(); + if (mIsPointingUp + ? (yCoordUpPointingTip + viewHeight > parentViewHeight) + : (yCoordDownPointingTip - viewHeight < 0)) { + // Flip the view if it exceeds the vertical bounds of screen. + mIsPointingUp = !mIsPointingUp; + updateArrowTipInView(); + } + // Place the tooltip such that its top is at yCoordUpPointingTip if arrow is displayed + // pointing upwards, otherwise place it such that its bottom is at + // yCoordDownPointingTip. + setY(mIsPointingUp ? yCoordUpPointingTip : yCoordDownPointingTip - viewHeight); + // Adjust the arrow's relative position on tooltip to make sure the actual position of // arrow's pointed tip is always at arrowXCoord. - View arrowView = findViewById(R.id.arrow); - arrowView.setX(arrowXCoord - xCoord - arrowView.getWidth() / 2f); + mArrowView.setX(arrowXCoord - xCoord - mArrowView.getWidth() / 2f); requestLayout(); }); @@ -249,6 +291,27 @@ public class ArrowTipView extends AbstractFloatingView { return this; } + private void updateArrowTipInView() { + ViewGroup.LayoutParams arrowLp = mArrowView.getLayoutParams(); + ShapeDrawable arrowDrawable = new ShapeDrawable(TriangleShape.create( + arrowLp.width, arrowLp.height, mIsPointingUp)); + Paint arrowPaint = arrowDrawable.getPaint(); + @Px int arrowTipRadius = getContext().getResources() + .getDimensionPixelSize(R.dimen.arrow_toast_corner_radius); + arrowPaint.setColor(ContextCompat.getColor(getContext(), R.color.arrow_tip_view_bg)); + arrowPaint.setPathEffect(new CornerPathEffect(arrowTipRadius)); + mArrowView.setBackground(arrowDrawable); + // Add negative margin so that the rounded corners on base of arrow are not visible. + removeView(mArrowView); + if (mIsPointingUp) { + addView(mArrowView, 0); + ((ViewGroup.MarginLayoutParams) arrowLp).setMargins(0, 0, 0, -1 * arrowTipRadius); + } else { + addView(mArrowView, 1); + ((ViewGroup.MarginLayoutParams) arrowLp).setMargins(0, -1 * arrowTipRadius, 0, 0); + } + } + /** * Register a callback fired when toast is hidden */ @@ -256,4 +319,10 @@ public class ArrowTipView extends AbstractFloatingView { mOnClosed = runnable; return this; } + + @Override + protected void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + close(/* animate= */ false); + } } From b1b76c34f5cb5c6f912a20361551f4be49707c95 Mon Sep 17 00:00:00 2001 From: Ryan Savitski Date: Thu, 10 Jun 2021 15:30:14 +0100 Subject: [PATCH 07/11] Revert "Revert "Set FLAG_IMMUTABLE flag on FirstScreenBroadcast PendingIntent. This reverts commit 1aa95b84006a8eeeac54e25e1444a5ea66fc5b02. Reason for revert: automerger got confused by the revert of a merge, and skipped it downstream. NB: resending this as a standalone patch, NOT generated via Gerrit's "revert" functionality, to avoid confusing AM further (I'm told there are hidden tags involved). IGNORE_MERGE_CONFLICT_CHECK=="trying to fix the build, see the rest of the topic" Since the revert was skipped downstream, using a merged-in tag to also stop this change from propagating. Bug: 183927137 Merged-In: I8d8e38a1aa6bdf13879d460cfa84cabe6c6bb1f2 Change-Id: I541eeb1cc1b589dc0134a5e2e4c16be9f658fbbb --- .../launcher3/model/FirstScreenBroadcast.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/model/FirstScreenBroadcast.java b/src/com/android/launcher3/model/FirstScreenBroadcast.java index 5112304fb8..18ce0358bb 100644 --- a/src/com/android/launcher3/model/FirstScreenBroadcast.java +++ b/src/com/android/launcher3/model/FirstScreenBroadcast.java @@ -15,7 +15,18 @@ */ package com.android.launcher3.model; +<<<<<<< TARGET BRANCH (878601 Block recent work profile apps content capture) import static android.os.Process.myUserHandle; +======= +import static android.app.PendingIntent.FLAG_IMMUTABLE; +import static android.app.PendingIntent.FLAG_ONE_SHOT; +import static android.os.Process.myUserHandle; + +import static com.android.launcher3.pm.InstallSessionHelper.getUserHandle; + +import static java.util.stream.Collectors.groupingBy; +import static java.util.stream.Collectors.mapping; +>>>>>>> SOURCE BRANCH (578578 Set FLAG_IMMUTABLE flag on FirstScreenBroadcast PendingInten) import android.app.PendingIntent; import android.content.Context; @@ -145,7 +156,7 @@ public class FirstScreenBroadcast { .putStringArrayListExtra(HOTSEAT_ITEM_EXTRA, new ArrayList<>(hotseatItems)) .putStringArrayListExtra(WIDGET_ITEM_EXTRA, new ArrayList<>(widgetItems)) .putExtra(VERIFICATION_TOKEN_EXTRA, PendingIntent.getActivity(context, 0, - new Intent(), PendingIntent.FLAG_ONE_SHOT))); + new Intent(), FLAG_ONE_SHOT | FLAG_IMMUTABLE))); } private static String getPackageName(ItemInfo info) { From 5af0edefdb1f1b86f2d3112a7394c04324e79d74 Mon Sep 17 00:00:00 2001 From: Ryan Savitski Date: Thu, 10 Jun 2021 15:39:36 +0100 Subject: [PATCH 08/11] Set FLAG_IMMUTABLE flag on FirstScreenBroadcast PendingIntent. Fixing build by getting rid of the erroneously merged conflict markers, and applying the end state of ag/14651125. Bug: 183927137 Merged-In: I881a2b79462e8d420b3dcb6a6b98adbe9e8e0394 Change-Id: I70acd4ce48853be728be1fb80b4b885d00a059a9 --- .../android/launcher3/model/FirstScreenBroadcast.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/com/android/launcher3/model/FirstScreenBroadcast.java b/src/com/android/launcher3/model/FirstScreenBroadcast.java index 18ce0358bb..f9ed2c78b6 100644 --- a/src/com/android/launcher3/model/FirstScreenBroadcast.java +++ b/src/com/android/launcher3/model/FirstScreenBroadcast.java @@ -15,19 +15,10 @@ */ package com.android.launcher3.model; -<<<<<<< TARGET BRANCH (878601 Block recent work profile apps content capture) -import static android.os.Process.myUserHandle; -======= import static android.app.PendingIntent.FLAG_IMMUTABLE; import static android.app.PendingIntent.FLAG_ONE_SHOT; import static android.os.Process.myUserHandle; -import static com.android.launcher3.pm.InstallSessionHelper.getUserHandle; - -import static java.util.stream.Collectors.groupingBy; -import static java.util.stream.Collectors.mapping; ->>>>>>> SOURCE BRANCH (578578 Set FLAG_IMMUTABLE flag on FirstScreenBroadcast PendingInten) - import android.app.PendingIntent; import android.content.Context; import android.content.Intent; From bc5099e9a6bd66a8b9fa1c512c84545f059a8680 Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Thu, 10 Jun 2021 15:47:40 +0100 Subject: [PATCH 09/11] Fix height estimation of the widgets recommendation table There are two vertical paddings 1. Table padding 2. Widget cell padding We haven't taken account the widget cells padding Test: Manual Bug: 189814077 Change-Id: I9b1dc9e880d4402b9c461d0024a0748c0afc408a --- .../widget/picker/WidgetsRecommendationTableLayout.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java b/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java index 9167d870e3..fe42ddfb15 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java +++ b/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java @@ -45,6 +45,7 @@ public final class WidgetsRecommendationTableLayout extends TableLayout { private static final float DOWN_SCALE_RATIO = 0.9f; private static final float MAX_DOWN_SCALE_RATIO = 0.5f; private final float mWidgetsRecommendationTableVerticalPadding; + private final float mWidgetCellVerticalPadding; private final float mWidgetCellTextViewsHeight; private float mRecommendationTableMaxHeight = Float.MAX_VALUE; @@ -60,6 +61,8 @@ public final class WidgetsRecommendationTableLayout extends TableLayout { super(context, attrs); // There are 1 row for title, 1 row for dimension and 2 rows for description. mWidgetsRecommendationTableVerticalPadding = 2 * getResources() + .getDimensionPixelSize(R.dimen.recommended_widgets_table_vertical_padding); + mWidgetCellVerticalPadding = 2 * getResources() .getDimensionPixelSize(R.dimen.widget_cell_vertical_padding); mWidgetCellTextViewsHeight = 4 * getResources().getDimension(R.dimen.widget_cell_font_size); } @@ -152,7 +155,8 @@ public final class WidgetsRecommendationTableLayout extends TableLayout { Size widgetSize = WidgetSizes.getWidgetSizePx( deviceProfile, widgetItem.spanX, widgetItem.spanY); float previewHeight = widgetSize.getHeight() * previewScale; - rowHeight = Math.max(rowHeight, previewHeight + mWidgetCellTextViewsHeight); + rowHeight = Math.max(rowHeight, + previewHeight + mWidgetCellTextViewsHeight + mWidgetCellVerticalPadding); } totalHeight += rowHeight; } From 89299047d7d4760545d1269de69f581700abcdde Mon Sep 17 00:00:00 2001 From: Jonathan Miranda Date: Thu, 10 Jun 2021 16:12:38 +0000 Subject: [PATCH 10/11] Forward fix for: Set FLAG_IMMUTABLE flag on FirstScreenBroadcast PendingIntent. Bug: 179289753 Bug: 183927137 Test: restore phone and ensure broadcast is sent Change-Id: I60e179d35957309f404937473fb5272f115b65ce Merged-In: I70acd4ce48853be728be1fb80b4b885d00a059a9 --- src/com/android/launcher3/model/FirstScreenBroadcast.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/com/android/launcher3/model/FirstScreenBroadcast.java b/src/com/android/launcher3/model/FirstScreenBroadcast.java index b8dbd08901..4d017bd4e8 100644 --- a/src/com/android/launcher3/model/FirstScreenBroadcast.java +++ b/src/com/android/launcher3/model/FirstScreenBroadcast.java @@ -17,12 +17,6 @@ package com.android.launcher3.model; import static android.app.PendingIntent.FLAG_IMMUTABLE; import static android.app.PendingIntent.FLAG_ONE_SHOT; -import static android.os.Process.myUserHandle; - -import static com.android.launcher3.pm.InstallSessionHelper.getUserHandle; - -import static java.util.stream.Collectors.groupingBy; -import static java.util.stream.Collectors.mapping; import android.app.PendingIntent; import android.content.Context; From 139a54f20e6f1e58e56b379045c11f726a54e16b Mon Sep 17 00:00:00 2001 From: zakcohen Date: Thu, 10 Jun 2021 10:39:32 -0700 Subject: [PATCH 11/11] Suppress failing view inflation tests until investigation Widget parts of ViewInflationDuringSwipeUp are failing on some devices, looks like a test architecture problem, not a code failing problem. Bug: 190729479 Test: Ran remaining tests Change-Id: I7598f381053f7136b2fcd861ec73d2fda239bb8d --- .../src/com/android/quickstep/ViewInflationDuringSwipeUp.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/quickstep/tests/src/com/android/quickstep/ViewInflationDuringSwipeUp.java b/quickstep/tests/src/com/android/quickstep/ViewInflationDuringSwipeUp.java index b4329c1765..ea7b7f5dfb 100644 --- a/quickstep/tests/src/com/android/quickstep/ViewInflationDuringSwipeUp.java +++ b/quickstep/tests/src/com/android/quickstep/ViewInflationDuringSwipeUp.java @@ -43,6 +43,7 @@ import android.view.ViewConfiguration; import android.widget.RemoteViews; import androidx.test.filters.LargeTest; +import androidx.test.filters.Suppress; import androidx.test.runner.AndroidJUnit4; import androidx.test.uiautomator.By; import androidx.test.uiautomator.UiDevice; @@ -133,6 +134,7 @@ public class ViewInflationDuringSwipeUp extends AbstractQuickStepTest { @Test @NavigationModeSwitch(mode = ZERO_BUTTON) + @Suppress // until b/190729479 is fixed public void testSwipeUpFromApp_widget_update() { String stubText = "Some random stub text"; @@ -145,6 +147,7 @@ public class ViewInflationDuringSwipeUp extends AbstractQuickStepTest { @Test @NavigationModeSwitch(mode = ZERO_BUTTON) + @Suppress // until b/190729479 is fixed public void testSwipeUp_with_list_widgets() { SimpleViewsFactory viewFactory = new SimpleViewsFactory(); viewFactory.viewCount = 1;