Merge "Use target size to scale down a widget preview image" into sc-v2-dev
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
index d822c8c..f8c9fd1 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 @@
@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
diff --git a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java
index f1b4e3d..baca76c 100644
--- a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java
+++ b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java
@@ -48,15 +48,16 @@
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 @@
* 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 @@
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 @@
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;
}
diff --git a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
index ac2534e..65be624 100644
--- a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
+++ b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
@@ -17,6 +17,7 @@
import android.content.Context;
import android.content.res.Resources;
+import android.util.Log;
import android.view.MotionEvent;
import android.view.VelocityTracker;
@@ -85,7 +86,12 @@
mSpeedSomewhatFast = res.getDimension(R.dimen.motion_pause_detector_speed_somewhat_fast);
mSpeedFast = res.getDimension(R.dimen.motion_pause_detector_speed_fast);
mForcePauseTimeout = new Alarm();
- mForcePauseTimeout.setOnAlarmListener(alarm -> updatePaused(true /* isPaused */));
+ mForcePauseTimeout.setOnAlarmListener(alarm -> {
+ if (TestProtocol.sDebugTracing) {
+ Log.d(TestProtocol.MOTION_PAUSE_TIMEOUT, "onAlarm");
+ }
+ updatePaused(true /* isPaused */);
+ });
mMakePauseHarderToTrigger = makePauseHarderToTrigger;
mVelocityProvider = new SystemVelocityProvider(axis);
}
@@ -119,9 +125,13 @@
* @param pointerIndex Index for the pointer being tracked in the motion event
*/
public void addPosition(MotionEvent ev, int pointerIndex) {
- mForcePauseTimeout.setAlarm(TestProtocol.sForcePauseTimeout != null
+ long timeoutMs = TestProtocol.sForcePauseTimeout != null
? TestProtocol.sForcePauseTimeout
- : mMakePauseHarderToTrigger ? HARDER_TRIGGER_TIMEOUT : FORCE_PAUSE_TIMEOUT);
+ : mMakePauseHarderToTrigger ? HARDER_TRIGGER_TIMEOUT : FORCE_PAUSE_TIMEOUT;
+ if (TestProtocol.sDebugTracing) {
+ Log.d(TestProtocol.MOTION_PAUSE_TIMEOUT, "setAlarm: " + timeoutMs);
+ }
+ mForcePauseTimeout.setAlarm(timeoutMs);
float newVelocity = mVelocityProvider.addMotionEvent(ev, ev.getPointerId(pointerIndex));
if (mPreviousVelocity != null) {
checkMotionPaused(newVelocity, mPreviousVelocity, ev.getEventTime());
@@ -162,6 +172,9 @@
}
}
}
+ if (TestProtocol.sDebugTracing) {
+ Log.d(TestProtocol.MOTION_PAUSE_TIMEOUT, "checkMotionPaused: " + isPaused);
+ }
updatePaused(isPaused);
}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index b077ca6..26664de 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -42,6 +42,7 @@
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_DISMISS_SWIPE_UP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_LAUNCH_SWIPE_DOWN;
import static com.android.launcher3.statehandlers.DepthController.DEPTH;
+import static com.android.launcher3.testing.TestProtocol.TASK_VIEW_ID_CRASH;
import static com.android.launcher3.touch.PagedOrientationHandler.CANVAS_TRANSLATE;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
@@ -82,6 +83,7 @@
import android.text.TextPaint;
import android.util.AttributeSet;
import android.util.FloatProperty;
+import android.util.Log;
import android.util.SparseBooleanArray;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
@@ -1170,7 +1172,7 @@
mMovingTaskView = focusedTaskView;
removeView(focusedTaskView);
mMovingTaskView = null;
- focusedTaskView.onRecycle();
+ focusedTaskView.resetPersistentViewTransforms();
addView(focusedTaskView, mTaskViewStartIndex);
setCurrentPage(mTaskViewStartIndex);
@@ -1222,6 +1224,9 @@
// TODO set these type to array and check all taskIDs? Maybe we can get away w/ only one
int runningTaskId = getTaskIdsForTaskViewId(mRunningTaskViewId)[0];
int focusedTaskId = getTaskIdsForTaskViewId(mFocusedTaskViewId)[0];
+ Log.d(TASK_VIEW_ID_CRASH, "runningTaskId beforeBind: " + runningTaskId
+ + " runningTaskViewId: " + mRunningTaskViewId
+ + " forTaskView: " + getTaskViewFromTaskViewId(mRunningTaskViewId));
// Rebind and reset all task views
for (int i = requiredTaskCount - 1; i >= 0; i--) {
@@ -1246,6 +1251,18 @@
// Update mRunningTaskViewId to be the new TaskView that was assigned by binding
// the full list of tasks to taskViews
newRunningTaskView = getTaskViewByTaskId(runningTaskId);
+ if (newRunningTaskView == null) {
+ StringBuilder sb = new StringBuilder();
+ for (int i = requiredTaskCount - 1; i >= 0; i--) {
+ final int pageIndex = requiredTaskCount - i - 1 + mTaskViewStartIndex;
+ final TaskView taskView = (TaskView) getChildAt(pageIndex);
+ int taskViewId = taskView.getTaskViewId();
+ sb.append(" taskViewId: " + taskViewId
+ + " taskId: " + getTaskIdsForTaskViewId(taskViewId)[0]
+ + " for taskView: " + taskView + "\n");
+ }
+ Log.d(TASK_VIEW_ID_CRASH, sb.toString());
+ }
mRunningTaskViewId = newRunningTaskView.getTaskViewId();
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 02c5d84..29810e3 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -871,6 +871,12 @@
setIconAndDimTransitionProgress(iconScale, invert);
}
+ protected void resetPersistentViewTransforms() {
+ mNonGridTranslationX = mNonGridTranslationY =
+ mGridTranslationX = mGridTranslationY = mBoxTranslationY = 0f;
+ resetViewTransforms();
+ }
+
protected void resetViewTransforms() {
// fullscreenTranslation and accumulatedTranslation should not be reset, as
// resetViewTransforms is called during Quickswitch scrolling.
@@ -894,9 +900,7 @@
@Override
public void onRecycle() {
- mNonGridTranslationX = mNonGridTranslationY =
- mGridTranslationX = mGridTranslationY = mBoxTranslationY = 0f;
- resetViewTransforms();
+ resetPersistentViewTransforms();
// Clear any references to the thumbnail (it will be re-read either from the cache or the
// system on next bind)
mSnapshotView.setThumbnail(mTask, null);
diff --git a/res/values-te/strings.xml b/res/values-te/strings.xml
index 80a6f10..6893888 100644
--- a/res/values-te/strings.xml
+++ b/res/values-te/strings.xml
@@ -68,7 +68,7 @@
<string name="long_accessible_way_to_add_shortcut" msgid="2199537273817090740">"షార్ట్కట్ను తరలించడానికి లేదా అనుకూల చర్యలను ఉపయోగించడానికి రెండుసార్లు నొక్కండి & హోల్డ్ చేయండి."</string>
<string name="out_of_space" msgid="6692471482459245734">"ఈ మొదటి స్క్రీన్లో స్థలం లేదు"</string>
<string name="hotseat_out_of_space" msgid="7448809638125333693">"ఇష్టమైనవి ట్రేలో ఖాళీ లేదు"</string>
- <string name="all_apps_button_label" msgid="8130441508702294465">"అనువర్తనాల జాబితా"</string>
+ <string name="all_apps_button_label" msgid="8130441508702294465">"యాప్ల జాబితా"</string>
<string name="all_apps_button_personal_label" msgid="1315764287305224468">"వ్యక్తిగత యాప్ల జాబితా"</string>
<string name="all_apps_button_work_label" msgid="7270707118948892488">"కార్యాలయ యాప్ల జాబితా"</string>
<string name="remove_drop_target_label" msgid="7812859488053230776">"తీసివేయి"</string>
@@ -83,7 +83,7 @@
<string name="permdesc_read_settings" msgid="5833423719057558387">"హోమ్లో సెట్టింగ్లు మరియు సత్వరమార్గాలను చదవడానికి యాప్ను అనుమతిస్తుంది."</string>
<string name="permlab_write_settings" msgid="3574213698004620587">"హోమ్ సెట్టింగ్లు మరియు సత్వరమార్గాలను వ్రాయడం"</string>
<string name="permdesc_write_settings" msgid="5440712911516509985">"హోమ్లో సెట్టింగ్లు మరియు సత్వరమార్గాలను మార్చడానికి యాప్ను అనుమతిస్తుంది."</string>
- <string name="msg_no_phone_permission" msgid="9208659281529857371">"ఫోన్ కాల్లను చేసేందుకు <xliff:g id="APP_NAME">%1$s</xliff:g>కి అనుమతి లేదు"</string>
+ <string name="msg_no_phone_permission" msgid="9208659281529857371">"ఫోన్ కాల్స్ను చేసేందుకు <xliff:g id="APP_NAME">%1$s</xliff:g>కి అనుమతి లేదు"</string>
<string name="gadget_error_text" msgid="740356548025791839">"విడ్జెట్ను లోడ్ చేయడం సాధ్యం కాలేదు"</string>
<string name="gadget_setup_text" msgid="1745356155479272374">"సెటప్ను పూర్తి చేయడానికి ట్యాప్ చేయండి"</string>
<string name="uninstall_system_app_text" msgid="4172046090762920660">"ఇది సిస్టమ్ యాప్ మరియు దీన్ని అన్ఇన్స్టాల్ చేయడం సాధ్యపడదు."</string>
diff --git a/res/values-v31/colors.xml b/res/values-v31/colors.xml
index c2ebeff..55cedf4 100644
--- a/res/values-v31/colors.xml
+++ b/res/values-v31/colors.xml
@@ -41,6 +41,8 @@
<color name="wallpaper_popup_scrim">@android:color/system_neutral1_900</color>
<color name="folder_dot_color">@android:color/system_accent2_50</color>
+ <color name="folder_pagination_color_light">@android:color/system_accent1_600</color>
+ <color name="folder_pagination_color_dark">@android:color/system_accent2_100</color>
<color name="home_settings_header_accent">@android:color/system_accent1_600</color>
<color name="home_settings_header_collapsed">@android:color/system_neutral1_100</color>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 00cf31c..c05016d 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -42,6 +42,7 @@
<attr name="popupNotificationDotColor" format="color" />
<attr name="folderDotColor" format="color" />
+ <attr name="folderPaginationColor" format="color" />
<attr name="folderFillColor" format="color" />
<attr name="folderIconRadius" format="float" />
<attr name="folderIconBorderColor" format="color" />
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 1b68fb6..cc5c5a3 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -73,6 +73,8 @@
<color name="folder_background_dark">#464746</color>
<color name="folder_dot_color">?attr/colorPrimary</color>
+ <color name="folder_pagination_color_light">#ff006c5f</color>
+ <color name="folder_pagination_color_dark">#ffbfebe3</color>
<color name="text_color_primary_dark">#FFFFFFFF</color>
<color name="text_color_secondary_dark">#FFFFFFFF</color>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index b7661b9..8ad4fcd 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -50,6 +50,7 @@
<item name="workspaceStatusBarScrim">@drawable/workspace_bg</item>
<item name="widgetsTheme">@style/WidgetContainerTheme</item>
<item name="folderDotColor">@color/folder_dot_color</item>
+ <item name="folderPaginationColor">@color/folder_pagination_color_light</item>
<item name="folderFillColor">@color/folder_background_light</item>
<item name="folderIconBorderColor">?android:attr/colorPrimary</item>
<item name="folderTextColor">@color/workspace_text_color_dark</item>
@@ -108,6 +109,7 @@
<item name="popupShadeThird">@color/popup_shade_third_dark</item>
<item name="widgetsTheme">@style/WidgetContainerTheme.Dark</item>
<item name="folderDotColor">@color/folder_dot_color</item>
+ <item name="folderPaginationColor">@color/folder_pagination_color_dark</item>
<item name="folderFillColor">@color/folder_background_dark</item>
<item name="folderIconBorderColor">?android:attr/colorPrimary</item>
<item name="folderTextColor">@color/workspace_text_color_light</item>
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 696c308..1ebfda1 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1298,7 +1298,7 @@
}
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 83ca08d..3bfa1e2 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -16,8 +16,6 @@
package com.android.launcher3;
-import static androidx.annotation.VisibleForTesting.PROTECTED;
-
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
import static com.android.launcher3.LauncherState.ALL_APPS;
@@ -65,7 +63,7 @@
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.Toast;
-import androidx.annotation.VisibleForTesting;
+import androidx.annotation.Nullable;
import com.android.launcher3.accessibility.AccessibleDragListenerAdapter;
import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper;
@@ -86,6 +84,7 @@
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;
@@ -462,7 +461,6 @@
}
@Override
- @VisibleForTesting(otherwise = PROTECTED)
public int getPanelCount() {
return isTwoPanelEnabled() ? 2 : super.getPanelCount();
}
@@ -1609,7 +1607,7 @@
// 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;
}
}
@@ -1911,7 +1909,7 @@
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);
@@ -1979,10 +1977,16 @@
}
}
- 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 79e5b5d..d959ee2 100644
--- a/src/com/android/launcher3/logging/StatsLogManager.java
+++ b/src/com/android/launcher3/logging/StatsLogManager.java
@@ -486,7 +486,10 @@
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
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
index f7c730a..29eefe2 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
@@ -53,6 +53,9 @@
private static final int ENTER_ANIMATION_STAGGERED_DELAY = 150;
private static final int ENTER_ANIMATION_DURATION = 400;
+ private static final int DOT_ACTIVE_ALPHA = 255;
+ private static final int DOT_INACTIVE_ALPHA = 128;
+
// This value approximately overshoots to 1.5 times the original size.
private static final float ENTER_ANIMATION_OVERSHOOT_TENSION = 4.9f;
@@ -75,8 +78,6 @@
private final Paint mCirclePaint;
private final float mDotRadius;
- private final int mActiveColor;
- private final int mInActiveColor;
private final boolean mIsRtl;
private int mNumPages;
@@ -110,12 +111,10 @@
mCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mCirclePaint.setStyle(Style.FILL);
+ mCirclePaint.setColor(Themes.getAttrColor(context, R.attr.folderPaginationColor));
mDotRadius = getResources().getDimension(R.dimen.page_indicator_dot_size) / 2;
setOutlineProvider(new MyOutlineProver());
- mActiveColor = Themes.getColorAccent(context);
- mInActiveColor = Themes.getAttrColor(context, android.R.attr.colorControlHighlight);
-
mIsRtl = Utilities.isRtl(getResources());
}
@@ -253,18 +252,18 @@
circleGap = -circleGap;
}
for (int i = 0; i < mEntryAnimationRadiusFactors.length; i++) {
- mCirclePaint.setColor(i == mActivePage ? mActiveColor : mInActiveColor);
+ mCirclePaint.setAlpha(i == mActivePage ? DOT_ACTIVE_ALPHA : DOT_INACTIVE_ALPHA);
canvas.drawCircle(x, y, mDotRadius * mEntryAnimationRadiusFactors[i], mCirclePaint);
x += circleGap;
}
} else {
- mCirclePaint.setColor(mInActiveColor);
+ mCirclePaint.setAlpha(DOT_INACTIVE_ALPHA);
for (int i = 0; i < mNumPages; i++) {
canvas.drawCircle(x, y, mDotRadius, mCirclePaint);
x += circleGap;
}
- mCirclePaint.setColor(mActiveColor);
+ mCirclePaint.setAlpha(DOT_ACTIVE_ALPHA);
canvas.drawRoundRect(getActiveRect(), mDotRadius, mDotRadius, mCirclePaint);
}
}
diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java
index 6f61c0e..86acff7 100644
--- a/src/com/android/launcher3/testing/TestInformationHandler.java
+++ b/src/com/android/launcher3/testing/TestInformationHandler.java
@@ -102,14 +102,22 @@
l -> WidgetsFullSheet.getWidgetsView(l).getCurrentScrollY());
}
+ case TestProtocol.REQUEST_TARGET_INSETS: {
+ return getUIProperty(Bundle::putParcelable, activity -> {
+ WindowInsets insets = activity.getWindow()
+ .getDecorView().getRootWindowInsets();
+ return Insets.max(
+ insets.getSystemGestureInsets(),
+ insets.getSystemWindowInsets());
+ }, this::getCurrentActivity);
+ }
+
case TestProtocol.REQUEST_WINDOW_INSETS: {
- return getUIProperty(Bundle::putParcelable, a -> {
- WindowInsets insets = a.getWindow()
+ return getUIProperty(Bundle::putParcelable, activity -> {
+ WindowInsets insets = activity.getWindow()
.getDecorView().getRootWindowInsets();
return Insets.subtract(
- Insets.max(
- insets.getSystemGestureInsets(),
- insets.getSystemWindowInsets()),
+ insets.getSystemWindowInsets(),
Insets.of(0, 0, 0, mDeviceProfile.nonOverlappingTaskbarInset));
}, this::getCurrentActivity);
}
diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java
index 7d8f479..38cbbe7 100644
--- a/src/com/android/launcher3/testing/TestProtocol.java
+++ b/src/com/android/launcher3/testing/TestProtocol.java
@@ -86,6 +86,7 @@
public static final String REQUEST_APP_LIST_FREEZE_FLAGS = "app-list-freeze-flags";
public static final String REQUEST_APPS_LIST_SCROLL_Y = "apps-list-scroll-y";
public static final String REQUEST_WIDGETS_SCROLL_Y = "widgets-scroll-y";
+ public static final String REQUEST_TARGET_INSETS = "target-insets";
public static final String REQUEST_WINDOW_INSETS = "window-insets";
public static final String REQUEST_PID = "pid";
public static final String REQUEST_FORCE_GC = "gc";
@@ -117,4 +118,6 @@
public static final String WORK_PROFILE_REMOVED = "b/159671700";
public static final String FALLBACK_ACTIVITY_NO_SET = "b/181019015";
public static final String THIRD_PARTY_LAUNCHER_NOT_SET = "b/187080582";
+ public static final String MOTION_PAUSE_TIMEOUT = "b/194114179";
+ public static final String TASK_VIEW_ID_CRASH = "b/195430732";
}
diff --git a/src/com/android/launcher3/util/WallpaperOffsetInterpolator.java b/src/com/android/launcher3/util/WallpaperOffsetInterpolator.java
index b8554e4..c51f66f 100644
--- a/src/com/android/launcher3/util/WallpaperOffsetInterpolator.java
+++ b/src/com/android/launcher3/util/WallpaperOffsetInterpolator.java
@@ -63,31 +63,37 @@
*
* TODO: do different behavior if it's a live wallpaper?
*/
- private void wallpaperOffsetForScroll(int scroll, int numScrollingPages, final int[] out) {
+ private void wallpaperOffsetForScroll(int scroll, int numScrollableScreens, final int[] out) {
out[1] = 1;
// To match the default wallpaper behavior in the system, we default to either the left
// or right edge on initialization
- if (mLockedToDefaultPage || numScrollingPages <= 1) {
+ if (mLockedToDefaultPage || numScrollableScreens <= 1) {
out[0] = mIsRtl ? 1 : 0;
return;
}
// Distribute the wallpaper parallax over a minimum of MIN_PARALLAX_PAGE_SPAN workspace
// screens, not including the custom screen, and empty screens (if > MIN_PARALLAX_PAGE_SPAN)
- int numPagesForWallpaperParallax = mWallpaperIsLiveWallpaper ? numScrollingPages :
- Math.max(MIN_PARALLAX_PAGE_SPAN, numScrollingPages);
+ int numScreensForWallpaperParallax = mWallpaperIsLiveWallpaper ? numScrollableScreens :
+ Math.max(MIN_PARALLAX_PAGE_SPAN, numScrollableScreens);
// Offset by the custom screen
- int leftPageIndex;
- int rightPageIndex;
- if (mIsRtl) {
- rightPageIndex = 0;
- leftPageIndex = rightPageIndex + numScrollingPages - 1;
- } else {
- leftPageIndex = 0;
- rightPageIndex = leftPageIndex + numScrollingPages - 1;
- }
+
+ // Don't confuse screens & pages in this function. In a phone UI, we often use screens &
+ // pages interchangeably. However, in a n-panels UI, where n > 1, the screen in this class
+ // means the scrollable screen. Each screen can consist of at most n panels.
+ // Each panel has at most 1 page. Take 5 pages in 2 panels UI as an example, the Workspace
+ // looks as follow:
+ //
+ // S: scrollable screen, P: page, <E>: empty
+ // S0 S1 S2
+ // _______ _______ ________
+ // |P0|P1| |P2|P3| |P4|<E>|
+ // ¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯
+ int endIndex = getNumPagesExcludingEmpty() - 1;
+ final int leftPageIndex = mIsRtl ? endIndex : 0;
+ final int rightPageIndex = mIsRtl ? 0 : endIndex;
// Calculate the scroll range
int leftPageScrollX = mWorkspace.getScrollForPage(leftPageIndex);
@@ -103,34 +109,56 @@
int adjustedScroll = scroll - leftPageScrollX -
mWorkspace.getLayoutTransitionOffsetForPage(0);
adjustedScroll = Utilities.boundToRange(adjustedScroll, 0, scrollRange);
- out[1] = (numPagesForWallpaperParallax - 1) * scrollRange;
+ out[1] = (numScreensForWallpaperParallax - 1) * scrollRange;
// The offset is now distributed 0..1 between the left and right pages that we care about,
// so we just map that between the pages that we are using for parallax
int rtlOffset = 0;
if (mIsRtl) {
// In RTL, the pages are right aligned, so adjust the offset from the end
- rtlOffset = out[1] - (numScrollingPages - 1) * scrollRange;
+ rtlOffset = out[1] - (numScrollableScreens - 1) * scrollRange;
}
- out[0] = rtlOffset + adjustedScroll * (numScrollingPages - 1);
+ out[0] = rtlOffset + adjustedScroll * (numScrollableScreens - 1);
}
public float wallpaperOffsetForScroll(int scroll) {
- wallpaperOffsetForScroll(scroll, getNumScreensExcludingEmpty(), sTempInt);
+ wallpaperOffsetForScroll(scroll, getNumScrollableScreensExcludingEmpty(), sTempInt);
return ((float) sTempInt[0]) / sTempInt[1];
}
- private int getNumScreensExcludingEmpty() {
- int numScrollingPages = mWorkspace.getChildCount();
- if (numScrollingPages >= MIN_PARALLAX_PAGE_SPAN && mWorkspace.hasExtraEmptyScreen()) {
- return numScrollingPages - 1;
+ /**
+ * Returns the number of screens that can be scrolled.
+ *
+ * <p>In an usual phone UI, the number of scrollable screens is equal to the number of
+ * CellLayouts because each screen has exactly 1 CellLayout.
+ *
+ * <p>In a n-panels UI, a screen shows n panels. Each panel has at most 1 CellLayout. Take
+ * 2-panels UI as an example: let's say there are 5 CellLayouts in the Workspace. the number of
+ * scrollable screens will be 3 = ⌈5 / 2⌉.
+ */
+ private int getNumScrollableScreensExcludingEmpty() {
+ float numOfPages = getNumPagesExcludingEmpty();
+ return (int) Math.ceil(numOfPages / mWorkspace.getPanelCount());
+ }
+
+ /**
+ * Returns the number of non-empty pages in the Workspace.
+ *
+ * <p>If a user starts dragging on the rightmost (or leftmost in RTL), an empty CellLayout is
+ * added to the Workspace. This empty CellLayout add as a hover-over target for adding a new
+ * page. To avoid janky motion effect, we ignore this empty CellLayout.
+ */
+ private int getNumPagesExcludingEmpty() {
+ int numOfPages = mWorkspace.getChildCount();
+ if (numOfPages >= MIN_PARALLAX_PAGE_SPAN && mWorkspace.hasExtraEmptyScreen()) {
+ return numOfPages - 1;
} else {
- return numScrollingPages;
+ return numOfPages;
}
}
public void syncWithScroll() {
- int numScreens = getNumScreensExcludingEmpty();
+ int numScreens = getNumScrollableScreensExcludingEmpty();
wallpaperOffsetForScroll(mWorkspace.getScrollX(), numScreens, sTempInt);
Message msg = Message.obtain(mHandler, MSG_UPDATE_OFFSET, sTempInt[0], sTempInt[1],
mWindowToken);
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index c2930f1..ded4282 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -288,6 +288,11 @@
}
Insets getTargetInsets() {
+ return getTestInfo(TestProtocol.REQUEST_TARGET_INSETS)
+ .getParcelable(TestProtocol.TEST_INFO_RESPONSE_FIELD);
+ }
+
+ Insets getWindowInsets() {
return getTestInfo(TestProtocol.REQUEST_WINDOW_INSETS)
.getParcelable(TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
@@ -1133,7 +1138,7 @@
}
int getBottomGestureSize() {
- return Math.max(getTargetInsets().bottom, ResourceUtils.getNavbarSize(
+ return Math.max(getWindowInsets().bottom, ResourceUtils.getNavbarSize(
ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, getResources())) + 1;
}