From 26a5f7f8cbd46a8c4006445ee4fb06c232275675 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Fri, 6 Aug 2021 18:37:44 +0100 Subject: [PATCH 1/7] Tune swipe up resistance - Make TaskView only scale between startResist scale and until maxResist scale's TaskView top touches 100% scale's TaskView top (https://drive.google.com/file/d/1r0qdP9TOTYw2upkJ-jEP8BAfLsrv8EOa/view) - Tuned the scaling parameter for tablet Bug: 194190263 Test: manual Change-Id: Ibc3e82744c5a6a8ce4207dff30d80889c66aa038 --- .../AnimatorControllerWithResistance.java | 61 +++++++++++-------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java index f1b4e3d89d..baca76cfba 100644 --- a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java +++ b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java @@ -48,15 +48,16 @@ import com.android.quickstep.views.RecentsView; public class AnimatorControllerWithResistance { private enum RecentsResistanceParams { - FROM_APP(0.75f, 0.5f, 1f), - FROM_APP_TABLET(0.9f, 0.75f, 1f), - FROM_OVERVIEW(1f, 0.75f, 0.5f); + FROM_APP(0.75f, 0.5f, 1f, false), + FROM_APP_TABLET(1f, 0.7f, 1f, true), + FROM_OVERVIEW(1f, 0.75f, 0.5f, false); RecentsResistanceParams(float scaleStartResist, float scaleMaxResist, - float translationFactor) { + float translationFactor, boolean stopScalingAtTop) { this.scaleStartResist = scaleStartResist; this.scaleMaxResist = scaleMaxResist; this.translationFactor = translationFactor; + this.stopScalingAtTop = stopScalingAtTop; } /** @@ -74,6 +75,12 @@ public class AnimatorControllerWithResistance { * where 0 will keep it centered and 1 will have it barely touch the top of the screen. */ public final float translationFactor; + + /** + * Whether to end scaling effect when the scaled down version of TaskView's top reaches the + * non-scaled version of TaskView's top. + */ + public final boolean stopScalingAtTop; } private static final TimeInterpolator RECENTS_SCALE_RESIST_INTERPOLATOR = DEACCEL; @@ -161,26 +168,6 @@ public class AnimatorControllerWithResistance { PointF pivot = new PointF(); float fullscreenScale = params.recentsOrientedState.getFullScreenScaleAndPivot( startRect, params.dp, pivot); - float prevScaleRate = (fullscreenScale - params.startScale) - / (params.dp.heightPx - startRect.bottom); - // This is what the scale would be at the end of the drag if we didn't apply resistance. - float endScale = params.startScale - prevScaleRate * distanceToCover; - // Create an interpolator that resists the scale so the scale doesn't get smaller than - // RECENTS_SCALE_MAX_RESIST. - float startResist = Utilities.getProgress(params.resistanceParams.scaleStartResist, - params.startScale, endScale); - float maxResist = Utilities.getProgress(params.resistanceParams.scaleMaxResist, - params.startScale, endScale); - final TimeInterpolator scaleInterpolator = t -> { - if (t < startResist) { - return t; - } - float resistProgress = Utilities.getProgress(t, startResist, 1); - resistProgress = RECENTS_SCALE_RESIST_INTERPOLATOR.getInterpolation(resistProgress); - return startResist + resistProgress * (maxResist - startResist); - }; - resistAnim.addFloat(params.scaleTarget, params.scaleProperty, params.startScale, endScale, - scaleInterpolator); // Compute where the task view would be based on the end scale. RectF endRectF = new RectF(startRect); @@ -195,6 +182,32 @@ public class AnimatorControllerWithResistance { resistAnim.addFloat(params.translationTarget, params.translationProperty, params.startTranslation, endTranslation, RECENTS_TRANSLATE_RESIST_INTERPOLATOR); + float prevScaleRate = (fullscreenScale - params.startScale) + / (params.dp.heightPx - startRect.bottom); + // This is what the scale would be at the end of the drag if we didn't apply resistance. + float endScale = params.startScale - prevScaleRate * distanceToCover; + // Create an interpolator that resists the scale so the scale doesn't get smaller than + // RECENTS_SCALE_MAX_RESIST. + float startResist = Utilities.getProgress(params.resistanceParams.scaleStartResist, + params.startScale, endScale); + float maxResist = Utilities.getProgress(params.resistanceParams.scaleMaxResist, + params.startScale, endScale); + float stopResist = + params.resistanceParams.stopScalingAtTop ? 1f - startRect.top / endRectF.top : 1f; + final TimeInterpolator scaleInterpolator = t -> { + if (t < startResist) { + return t; + } + if (t > stopResist) { + return maxResist; + } + float resistProgress = Utilities.getProgress(t, startResist, stopResist); + resistProgress = RECENTS_SCALE_RESIST_INTERPOLATOR.getInterpolation(resistProgress); + return startResist + resistProgress * (maxResist - startResist); + }; + resistAnim.addFloat(params.scaleTarget, params.scaleProperty, params.startScale, endScale, + scaleInterpolator); + return resistAnim; } From be767c9108d0cb49cacc613977d3df42a3dc6bec Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Mon, 9 Aug 2021 19:06:01 +0100 Subject: [PATCH 2/7] Don't call TaskView.onRecycle when moving focused task to front - onRecycle removes the icon cache resulting on icon disappearing when entering overview - only call necessary view transform reset in moveFocusedTaskToFront Bug: 195415765 Test: quick switch, launch app then swipe up Change-Id: Iadb7287ea307a3a4aa0acce2e37837142aeb90db --- .../src/com/android/quickstep/views/RecentsView.java | 2 +- .../src/com/android/quickstep/views/TaskView.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index b077ca6741..db9f7f7a4b 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1170,7 +1170,7 @@ public abstract class RecentsView Date: Mon, 9 Aug 2021 22:32:39 +0000 Subject: [PATCH 3/7] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: I9756b94a3aa7a2184028620a9c569e6cad763e55 --- res/values-te/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/values-te/strings.xml b/res/values-te/strings.xml index 80a6f10bf1..68938883b1 100644 --- a/res/values-te/strings.xml +++ b/res/values-te/strings.xml @@ -68,7 +68,7 @@ "షార్ట్‌కట్‌ను తరలించడానికి లేదా అనుకూల చర్యలను ఉపయోగించడానికి రెండుసార్లు నొక్కండి & హోల్డ్ చేయండి." "ఈ మొదటి స్క్రీన్‌లో స్థలం లేదు" "ఇష్టమైనవి ట్రేలో ఖాళీ లేదు" - "అనువర్తనాల జాబితా" + "యాప్‌ల జాబితా" "వ్యక్తిగత యాప్‌ల జాబితా" "కార్యాలయ యాప్‌ల జాబితా" "తీసివేయి" @@ -83,7 +83,7 @@ "హోమ్‌లో సెట్టింగ్‌లు మరియు సత్వరమార్గాలను చదవడానికి యాప్‌ను అనుమతిస్తుంది." "హోమ్ సెట్టింగ్‌లు మరియు సత్వరమార్గాలను వ్రాయడం" "హోమ్‌లో సెట్టింగ్‌లు మరియు సత్వరమార్గాలను మార్చడానికి యాప్‌ను అనుమతిస్తుంది." - "ఫోన్ కాల్‌లను చేసేందుకు %1$sకి అనుమతి లేదు" + "ఫోన్ కాల్స్‌ను చేసేందుకు %1$sకి అనుమతి లేదు" "విడ్జెట్‌ను లోడ్ చేయడం సాధ్యం కాలేదు" "సెటప్‌ను పూర్తి చేయడానికి ట్యాప్ చేయండి" "ఇది సిస్టమ్ యాప్ మరియు దీన్ని అన్‌ఇన్‌స్టాల్ చేయడం సాధ్యపడదు." From 40383acc823f879161a1da677b20e243759afcaf Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Mon, 9 Aug 2021 22:34:14 +0000 Subject: [PATCH 4/7] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: I781c07c1c2cab40346ae80a3d01e227a475db67c --- res/values-te/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/values-te/strings.xml b/res/values-te/strings.xml index 80a6f10bf1..68938883b1 100644 --- a/res/values-te/strings.xml +++ b/res/values-te/strings.xml @@ -68,7 +68,7 @@ "షార్ట్‌కట్‌ను తరలించడానికి లేదా అనుకూల చర్యలను ఉపయోగించడానికి రెండుసార్లు నొక్కండి & హోల్డ్ చేయండి." "ఈ మొదటి స్క్రీన్‌లో స్థలం లేదు" "ఇష్టమైనవి ట్రేలో ఖాళీ లేదు" - "అనువర్తనాల జాబితా" + "యాప్‌ల జాబితా" "వ్యక్తిగత యాప్‌ల జాబితా" "కార్యాలయ యాప్‌ల జాబితా" "తీసివేయి" @@ -83,7 +83,7 @@ "హోమ్‌లో సెట్టింగ్‌లు మరియు సత్వరమార్గాలను చదవడానికి యాప్‌ను అనుమతిస్తుంది." "హోమ్ సెట్టింగ్‌లు మరియు సత్వరమార్గాలను వ్రాయడం" "హోమ్‌లో సెట్టింగ్‌లు మరియు సత్వరమార్గాలను మార్చడానికి యాప్‌ను అనుమతిస్తుంది." - "ఫోన్ కాల్‌లను చేసేందుకు %1$sకి అనుమతి లేదు" + "ఫోన్ కాల్స్‌ను చేసేందుకు %1$sకి అనుమతి లేదు" "విడ్జెట్‌ను లోడ్ చేయడం సాధ్యం కాలేదు" "సెటప్‌ను పూర్తి చేయడానికి ట్యాప్ చేయండి" "ఇది సిస్టమ్ యాప్ మరియు దీన్ని అన్‌ఇన్‌స్టాల్ చేయడం సాధ్యపడదు." From f168bb7aaf94dc3e7c483278ee6eb671485c38c1 Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Mon, 9 Aug 2021 17:45:22 -0700 Subject: [PATCH 5/7] Adjust all apps zoom level The All Apps scrim fades in early, covering part of the zoom animation. We need to adjust the max zoom in order to make All Apps consistent with Overview, -1, and Shade. Test: pull up the all apps drawer Fixes: 195992422 Change-Id: Ia7bbe17fe7f227dd0a16ba7d21b402cff57176f0 --- .../android/launcher3/uioverrides/states/AllAppsState.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java index d822c8cf82..f8c9fd128f 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java @@ -70,7 +70,9 @@ public class AllAppsState extends LauncherState { @Override protected float getDepthUnchecked(Context context) { - return 1f; + // The scrim fades in at approximately 50% of the swipe gesture. + // This means that the depth should be greater than 1, in order to fully zoom out. + return 2f; } @Override From 104d09f143e7d1418b1af28063a3e280fad38d2b Mon Sep 17 00:00:00 2001 From: Yogisha Dixit Date: Mon, 19 Jul 2021 14:05:17 +0100 Subject: [PATCH 6/7] Add logging when item not added due to insufficient space. Bug: 194061824 Test: manual Change-Id: Ib6f6b9ab4a8e1b59b1dbd1c7c137962efa3e880e --- src/com/android/launcher3/Launcher.java | 2 +- src/com/android/launcher3/Workspace.java | 15 ++++++++++++--- .../launcher3/logging/StatsLogManager.java | 5 ++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 696c3089ab..1ebfda18ff 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1298,7 +1298,7 @@ public class Launcher extends StatefulActivity implements Launche } if (!foundCellSpan) { - mWorkspace.onNoCellFound(layout); + mWorkspace.onNoCellFound(layout, info, /* logInstanceId= */ null); return; } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index ae42d74c2a..3bfa1e2d2e 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -63,6 +63,8 @@ import android.view.ViewTreeObserver; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.Toast; +import androidx.annotation.Nullable; + import com.android.launcher3.accessibility.AccessibleDragListenerAdapter; import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper; import com.android.launcher3.anim.Interpolators; @@ -82,6 +84,7 @@ import com.android.launcher3.graphics.DragPreviewProvider; import com.android.launcher3.icons.BitmapRenderer; import com.android.launcher3.icons.FastBitmapDrawable; import com.android.launcher3.logger.LauncherAtom; +import com.android.launcher3.logging.InstanceId; import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.logging.StatsLogManager.LauncherEvent; import com.android.launcher3.model.data.AppInfo; @@ -1604,7 +1607,7 @@ public class Workspace extends PagedView // Don't accept the drop if there's no room for the item if (!foundCell) { - onNoCellFound(dropTargetLayout); + onNoCellFound(dropTargetLayout, d.dragInfo, d.logInstanceId); return false; } } @@ -1906,7 +1909,7 @@ public class Workspace extends PagedView lp.cellX, lp.cellY, item.spanX, item.spanY); } else { if (!returnToOriginalCellToPreventShuffling) { - onNoCellFound(dropTargetLayout); + onNoCellFound(dropTargetLayout, d.dragInfo, d.logInstanceId); } if (mDragInfo.cell instanceof LauncherAppWidgetHostView) { d.dragView.detachContentView(/* reattachToPreviousParent= */ true); @@ -1974,10 +1977,16 @@ public class Workspace extends PagedView } } - public void onNoCellFound(View dropTargetLayout) { + public void onNoCellFound( + View dropTargetLayout, ItemInfo itemInfo, @Nullable InstanceId logInstanceId) { int strId = mLauncher.isHotseatLayout(dropTargetLayout) ? R.string.hotseat_out_of_space : R.string.out_of_space; Toast.makeText(mLauncher, mLauncher.getString(strId), Toast.LENGTH_SHORT).show(); + StatsLogManager.StatsLogger logger = mStatsLogManager.logger().withItemInfo(itemInfo); + if (logInstanceId != null) { + logger = logger.withInstanceId(logInstanceId); + } + logger.log(LauncherEvent.LAUNCHER_ITEM_DROP_FAILED_INSUFFICIENT_SPACE); } /** diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java index 79e5b5d04c..d959ee288b 100644 --- a/src/com/android/launcher3/logging/StatsLogManager.java +++ b/src/com/android/launcher3/logging/StatsLogManager.java @@ -486,7 +486,10 @@ public class StatsLogManager implements ResourceBasedOverride { LAUNCHER_TURN_ON_WORK_APPS_TAP(838), @UiEvent(doc = "User tapped on 'Turn off work apps' button in all apps window.") - LAUNCHER_TURN_OFF_WORK_APPS_TAP(839) + LAUNCHER_TURN_OFF_WORK_APPS_TAP(839), + + @UiEvent(doc = "Launcher item drop failed since there was not enough room on the screen.") + LAUNCHER_ITEM_DROP_FAILED_INSUFFICIENT_SPACE(872) ; // ADD MORE From caf2e5f350ef99dcb31dc1dd71d8a4a4f9ce954d Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Tue, 10 Aug 2021 00:04:49 +0100 Subject: [PATCH 7/7] Use target size to scale down a widget preview image WidgetCells are being recycled in WidgetFullSheet. getWidth/getHeight could be a recycled dimension. There is also no guarantee that measure has taken placed before the scale down logic. Let's use the targeted width for the scale down logic instead. Test: Manual Fix: 195417705 Change-Id: Idfb3cc485604d19658e210709bebde6f163003cf --- src/com/android/launcher3/widget/WidgetCell.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/widget/WidgetCell.java b/src/com/android/launcher3/widget/WidgetCell.java index 167eb0983e..a8ed1549d6 100644 --- a/src/com/android/launcher3/widget/WidgetCell.java +++ b/src/com/android/launcher3/widget/WidgetCell.java @@ -325,10 +325,10 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener { return; } if (drawable != null) { + // Scale down the preview size if it's wider than the cell. float scale = 1f; - if (getWidth() > 0 && getHeight() > 0) { - // Scale down the preview size if it's wider than the cell. - float maxWidth = getWidth(); + if (mTargetPreviewWidth > 0) { + float maxWidth = mTargetPreviewWidth; float previewWidth = drawable.getIntrinsicWidth() * mPreviewContainerScale; scale = Math.min(maxWidth / previewWidth, 1); }