Merge "Take account of IME insets" into tm-qpr-dev
diff --git a/protos/view_capture.proto b/protos/view_capture.proto
new file mode 100644
index 0000000..98574dd
--- /dev/null
+++ b/protos/view_capture.proto
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package com.android.launcher3.view;
+
+option java_outer_classname = "ViewCaptureData";
+
+message ExportedData {
+
+ repeated FrameData frameData = 1;
+}
+
+message FrameData {
+ optional int64 timestamp = 1;
+ optional ViewNode node = 2;
+}
+
+message ViewNode {
+ optional string classname = 1;
+ optional string id = 2;
+ optional int32 left = 3;
+ optional int32 top = 4;
+ optional int32 width = 5;
+ optional int32 height = 6;
+ optional int32 scrollX = 7;
+ optional int32 scrollY = 8;
+
+ optional float translationX = 9;
+ optional float translationY = 10;
+ optional float scaleX = 11 [default = 1];
+ optional float scaleY = 12 [default = 1];
+ optional float alpha = 13 [default = 1];
+
+ optional bool willNotDraw = 14;
+ optional bool clipChildren = 15;
+ optional int32 visibility = 16;
+
+ repeated ViewNode children = 17;
+}
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index 0fd3c4a..17a48a7 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -66,7 +66,6 @@
<dimen name="quickstep_fling_threshold_speed">0.5dp</dimen>
<!-- Launcher app transition -->
- <item name="content_scale" format="float" type="dimen">0.97</item>
<dimen name="closing_window_trans_y">115dp</dimen>
<dimen name="quick_switch_scaling_scroll_threshold">100dp</dimen>
diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
index b20752d..bb79c1b 100644
--- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
@@ -200,7 +200,6 @@
final Handler mHandler;
- private final float mContentScale;
private final float mClosingWindowTransY;
private final float mMaxShadowRadius;
@@ -245,7 +244,6 @@
mBackAnimationController = new LauncherBackAnimationController(mLauncher, this);
Resources res = mLauncher.getResources();
- mContentScale = res.getFloat(R.dimen.content_scale);
mClosingWindowTransY = res.getDimensionPixelSize(R.dimen.closing_window_trans_y);
mMaxShadowRadius = res.getDimensionPixelSize(R.dimen.max_shadow_radius);
@@ -483,8 +481,8 @@
: new float[]{0, 1};
float[] scales = isAppOpening
- ? new float[]{1, mContentScale}
- : new float[]{mContentScale, 1};
+ ? new float[]{1, mDeviceProfile.workspaceContentScale}
+ : new float[]{mDeviceProfile.workspaceContentScale, 1};
// Pause expensive view updates as they can lead to layer thrashing and skipped frames.
mLauncher.pauseExpensiveViewUpdates();
diff --git a/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java b/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java
index 0284ae4..f42b39f 100644
--- a/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java
+++ b/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java
@@ -21,7 +21,6 @@
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
-import android.graphics.Rect;
import android.graphics.Typeface;
import android.os.Build;
import android.text.Layout;
@@ -33,7 +32,6 @@
import androidx.annotation.ColorInt;
import androidx.core.content.ContextCompat;
-import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.allapps.FloatingHeaderRow;
import com.android.launcher3.allapps.FloatingHeaderView;
@@ -239,12 +237,6 @@
}
@Override
- public void setInsets(Rect insets, DeviceProfile grid) {
- int leftRightPadding = grid.allAppsLeftRightPadding;
- setPadding(leftRightPadding, getPaddingTop(), leftRightPadding, getPaddingBottom());
- }
-
- @Override
public void setVerticalScroll(int scroll, boolean isScrolledOut) {
setTranslationY(scroll);
mIsScrolledOut = isScrolledOut;
diff --git a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java
index 1dec737..351a3bc 100644
--- a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java
+++ b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java
@@ -19,7 +19,6 @@
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
-import android.graphics.Rect;
import android.os.Build;
import android.util.AttributeSet;
import android.view.LayoutInflater;
@@ -252,12 +251,6 @@
}
@Override
- public void setInsets(Rect insets, DeviceProfile grid) {
- int leftRightPadding = grid.allAppsLeftRightPadding;
- setPadding(leftRightPadding, getPaddingTop(), leftRightPadding, getPaddingBottom());
- }
-
- @Override
public Class<PredictionRowView> getTypeClass() {
return PredictionRowView.class;
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
index 23a0334..db7dc78 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
@@ -298,9 +298,7 @@
isRtl ? -halfQsbIconWidthDiff : halfQsbIconWidthDiff,
hotseatIconCenter - childCenter, LINEAR);
- int qsbContentHeight = child.getHeight() - child.getPaddingTop()
- - child.getPaddingBottom();
- float scale = ((float) taskbarDp.iconSizePx) / qsbContentHeight;
+ float scale = ((float) taskbarDp.iconSizePx) / launcherDp.hotseatQsbVisualHeight;
setter.addFloat(child, SCALE_PROPERTY, scale, 1f, LINEAR);
setter.addFloat(child, VIEW_ALPHA, 0f, 1f,
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
index a74774c..9f2efc4 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
@@ -31,8 +31,6 @@
*/
public class AllAppsState extends LauncherState {
- private static final float WORKSPACE_SCALE_FACTOR = 0.97f;
-
private static final int STATE_FLAGS =
FLAG_WORKSPACE_INACCESSIBLE | FLAG_CLOSE_POPUPS | FLAG_HOTSEAT_INACCESSIBLE;
@@ -60,7 +58,8 @@
@Override
public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
- return new ScaleAndTranslation(WORKSPACE_SCALE_FACTOR, NO_OFFSET, NO_OFFSET);
+ return new ScaleAndTranslation(launcher.getDeviceProfile().workspaceContentScale, NO_OFFSET,
+ NO_OFFSET);
}
@Override
@@ -71,7 +70,7 @@
ScaleAndTranslation overviewScaleAndTranslation = LauncherState.OVERVIEW
.getWorkspaceScaleAndTranslation(launcher);
return new ScaleAndTranslation(
- WORKSPACE_SCALE_FACTOR,
+ launcher.getDeviceProfile().workspaceContentScale,
overviewScaleAndTranslation.translationX,
overviewScaleAndTranslation.translationY);
}
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 0972e4e..9eb4d62 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -58,6 +58,7 @@
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ActivityManager;
+import android.app.WindowConfiguration;
import android.content.Context;
import android.content.Intent;
import android.graphics.Matrix;
@@ -297,9 +298,12 @@
mActivityInterface = gestureState.getActivityInterface();
mActivityInitListener = mActivityInterface.createActivityInitListener(this::onActivityInit);
mInputConsumerProxy =
- new InputConsumerProxy(context,
- () -> mRecentsView.getPagedViewOrientedState().getRecentsActivityRotation(),
- inputConsumer, () -> {
+ new InputConsumerProxy(context, /* rotationSupplier = */ () -> {
+ if (mRecentsView == null) {
+ return ROTATION_0;
+ }
+ return mRecentsView.getPagedViewOrientedState().getRecentsActivityRotation();
+ }, inputConsumer, /* callback = */ () -> {
endRunningWindowAnim(mGestureState.getEndTarget() == HOME /* cancel */);
endLauncherTransitionController();
}, new InputProxyHandlerFactory(mActivityInterface, mGestureState));
@@ -441,7 +445,7 @@
});
setupRecentsViewUi();
- linkRecentsViewScroll();
+ mRecentsView.runOnPageScrollsInitialized(this::linkRecentsViewScroll);
activity.runOnBindToTouchInteractionService(this::onLauncherBindToService);
mActivity.registerActivityLifecycleCallbacks(mLifecycleCallbacks);
@@ -1418,6 +1422,16 @@
runningTaskTarget.taskInfo.pictureInPictureParams,
homeRotation,
mDp.hotseatBarSizePx);
+ final Rect appBounds = new Rect();
+ final WindowConfiguration winConfig = taskInfo.configuration.windowConfiguration;
+ // Adjust the appBounds for TaskBar by using the calculated window crop Rect
+ // from TaskViewSimulator and fallback to the bounds in TaskInfo when it's originated
+ // from windowing modes other than full-screen.
+ if (winConfig.getWindowingMode() == WindowConfiguration.WINDOWING_MODE_FULLSCREEN) {
+ mRemoteTargetHandles[0].getTaskViewSimulator().getCurrentCropRect().round(appBounds);
+ } else {
+ appBounds.set(winConfig.getBounds());
+ }
final SwipePipToHomeAnimator.Builder builder = new SwipePipToHomeAnimator.Builder()
.setContext(mContext)
.setTaskId(runningTaskTarget.taskId)
@@ -1425,7 +1439,7 @@
.setLeash(runningTaskTarget.leash)
.setSourceRectHint(
runningTaskTarget.taskInfo.pictureInPictureParams.getSourceRectHint())
- .setAppBounds(taskInfo.configuration.windowConfiguration.getBounds())
+ .setAppBounds(appBounds)
.setHomeToWindowPositionMap(homeToWindowPositionMap)
.setStartBounds(startRect)
.setDestinationBounds(destinationBounds)
diff --git a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
index a3f7ae0..e758f5b 100644
--- a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
+++ b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
@@ -23,8 +23,8 @@
import com.android.launcher3.Alarm;
import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AccessibilityManagerCompat;
-import com.android.launcher3.testing.TestProtocol;
/**
* Given positions along x- or y-axis, tracks velocity and acceleration and determines when there is
@@ -46,6 +46,12 @@
*/
private static final long HARDER_TRIGGER_TIMEOUT = 400;
+ /**
+ * When running in a test harness, if no motion is added for this amount of time, assume the
+ * motion has paused. (We use an increased timeout since sometimes test devices can be slow.)
+ */
+ private static final long TEST_HARNESS_TRIGGER_TIMEOUT = 2000;
+
private final float mSpeedVerySlow;
private final float mSpeedSlow;
private final float mSpeedSomewhatFast;
@@ -123,9 +129,11 @@
* @param pointerIndex Index for the pointer being tracked in the motion event
*/
public void addPosition(MotionEvent ev, int pointerIndex) {
- long timeoutMs = TestProtocol.sForcePauseTimeout != null
- ? TestProtocol.sForcePauseTimeout
- : mMakePauseHarderToTrigger ? HARDER_TRIGGER_TIMEOUT : FORCE_PAUSE_TIMEOUT;
+ long timeoutMs = Utilities.IS_RUNNING_IN_TEST_HARNESS
+ ? TEST_HARNESS_TRIGGER_TIMEOUT
+ : mMakePauseHarderToTrigger
+ ? HARDER_TRIGGER_TIMEOUT
+ : FORCE_PAUSE_TIMEOUT;
mForcePauseTimeout.setAlarm(timeoutMs);
float newVelocity = mVelocityProvider.addMotionEvent(ev, ev.getPointerId(pointerIndex));
if (mPreviousVelocity != null) {
diff --git a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
index 14190b3..f2fcd06 100644
--- a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
+++ b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
@@ -221,8 +221,7 @@
private boolean updateHandler() {
mRecentsActivityRotation = inferRecentsActivityRotation(mDisplayRotation);
- if (mRecentsActivityRotation == mTouchRotation || (isRecentsActivityRotationAllowed()
- && (mFlags & FLAG_SWIPE_UP_NOT_RUNNING) != 0)) {
+ if (mRecentsActivityRotation == mTouchRotation || isRecentsActivityRotationAllowed()) {
mOrientationHandler = PagedOrientationHandler.PORTRAIT;
} else if (mTouchRotation == ROTATION_90) {
mOrientationHandler = PagedOrientationHandler.LANDSCAPE;
diff --git a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java
index 3133453..bfb43c1 100644
--- a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java
+++ b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java
@@ -78,8 +78,9 @@
private static final int INDEX_VISIBILITY_ALPHA = 1;
private static final int INDEX_FULLSCREEN_ALPHA = 2;
private static final int INDEX_HIDDEN_FLAGS_ALPHA = 3;
+ private static final int INDEX_SHARE_TARGET_ALPHA = 4;
- private final MultiValueAlpha mMultiValueAlpha;
+ private MultiValueAlpha mMultiValueAlpha;
private Button mSplitButton;
@ActionsHiddenFlags
@@ -105,13 +106,14 @@
public OverviewActionsView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr, 0);
- mMultiValueAlpha = new MultiValueAlpha(this, 5);
- mMultiValueAlpha.setUpdateVisibility(true);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
+ mMultiValueAlpha = new MultiValueAlpha(findViewById(R.id.action_buttons), 5);
+ mMultiValueAlpha.setUpdateVisibility(true);
+
findViewById(R.id.action_screenshot).setOnClickListener(this);
mSplitButton = findViewById(R.id.action_split);
@@ -193,6 +195,10 @@
return mMultiValueAlpha.getProperty(INDEX_FULLSCREEN_ALPHA);
}
+ public AlphaProperty getShareTargetAlpha() {
+ return mMultiValueAlpha.getProperty(INDEX_SHARE_TARGET_ALPHA);
+ }
+
/**
* Offsets OverviewActionsView horizontal position based on 3 button nav container in taskbar.
*/
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 50c1044..274a691 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -2303,7 +2303,7 @@
boolean runningTaskTileHidden = mRunningTaskTileHidden;
setCurrentTask(runningTaskViewId);
mFocusedTaskViewId = runningTaskViewId;
- setCurrentPage(getRunningTaskIndex());
+ runOnPageScrollsInitialized(() -> setCurrentPage(getRunningTaskIndex()));
setRunningTaskViewShowScreenshot(false);
setRunningTaskHidden(runningTaskTileHidden);
// Update task size after setting current task.
@@ -4014,7 +4014,8 @@
stagePosition);
mSplitHiddenTaskViewIndex = indexOfChild(taskView);
if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
- finishRecentsAnimation(true, null);
+ finishRecentsAnimation(true /* toRecents */, false /* shouldPip */,
+ null /* onFinishComplete */);
}
}
@@ -4873,10 +4874,10 @@
}
private void updateEnabledOverlays() {
- int overlayEnabledPage = mOverlayEnabled ? getNextPage() : -1;
int taskCount = getTaskViewCount();
for (int i = 0; i < taskCount; i++) {
- requireTaskViewAt(i).setOverlayEnabled(i == overlayEnabledPage);
+ TaskView taskView = requireTaskViewAt(i);
+ taskView.setOverlayEnabled(mOverlayEnabled && isTaskViewFullyVisible(taskView));
}
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
index 1629bb7..32dc4d8 100644
--- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -560,33 +560,16 @@
thumbnailScale = targetW / (croppedWidth * scale);
}
- Rect splitScreenInsets = dp.getInsets();
if (!isRotated) {
- // No Rotation
- mClippedInsets.offsetTo(thumbnailClipHint.left * scale,
- thumbnailClipHint.top * scale);
mMatrix.setTranslate(
-thumbnailClipHint.left * scale,
-thumbnailClipHint.top * scale);
} else {
- setThumbnailRotation(deltaRotate, thumbnailClipHint, scale, thumbnailBounds, dp);
+ setThumbnailRotation(deltaRotate, thumbnailBounds);
}
- final float widthWithInsets;
- final float heightWithInsets;
- if (isOrientationDifferent) {
- widthWithInsets = thumbnailBounds.height() * thumbnailScale;
- heightWithInsets = thumbnailBounds.width() * thumbnailScale;
- } else {
- widthWithInsets = thumbnailBounds.width() * thumbnailScale;
- heightWithInsets = thumbnailBounds.height() * thumbnailScale;
- }
- mClippedInsets.left *= thumbnailScale;
- mClippedInsets.top *= thumbnailScale;
- mClippedInsets.right = Math.max(0,
- widthWithInsets - mClippedInsets.left - canvasWidth);
- mClippedInsets.bottom = Math.max(0,
- heightWithInsets - mClippedInsets.top - canvasHeight);
+ float canvasScreenRatio = canvasWidth / (float) dp.widthPx;
+ mClippedInsets.set(0, 0, 0, dp.taskbarSize * canvasScreenRatio);
mMatrix.postScale(thumbnailScale, thumbnailScale);
mIsOrientationChanged = isOrientationDifferent;
@@ -607,44 +590,32 @@
return deltaRotation == Surface.ROTATION_90 || deltaRotation == Surface.ROTATION_270;
}
- private void setThumbnailRotation(int deltaRotate, RectF thumbnailInsets, float scale,
- Rect thumbnailPosition, DeviceProfile dp) {
- float newLeftInset = 0;
- float newTopInset = 0;
+ private void setThumbnailRotation(int deltaRotate, Rect thumbnailPosition) {
float translateX = 0;
float translateY = 0;
mMatrix.setRotate(90 * deltaRotate);
switch (deltaRotate) { /* Counter-clockwise */
case Surface.ROTATION_90:
- newLeftInset = thumbnailInsets.bottom;
- newTopInset = thumbnailInsets.left;
translateX = thumbnailPosition.height();
break;
case Surface.ROTATION_270:
- newLeftInset = thumbnailInsets.top;
- newTopInset = thumbnailInsets.right;
translateY = thumbnailPosition.width();
break;
case Surface.ROTATION_180:
- newLeftInset = -thumbnailInsets.top;
- newTopInset = -thumbnailInsets.left;
translateX = thumbnailPosition.width();
translateY = thumbnailPosition.height();
break;
}
- mClippedInsets.offsetTo(newLeftInset * scale, newTopInset * scale);
mMatrix.postTranslate(translateX, translateY);
- if (TaskView.useFullThumbnail(dp)) {
- mMatrix.postTranslate(-mClippedInsets.left, -mClippedInsets.top);
- }
}
/**
* Insets to used for clipping the thumbnail (in case it is drawing outside its own space)
*/
public RectF getInsetsToDrawInFullscreen(DeviceProfile dp) {
- return TaskView.useFullThumbnail(dp) ? mClippedInsets : EMPTY_RECT_F;
+ return dp.isTaskbarPresent && !dp.isTaskbarPresentInApps
+ ? mClippedInsets : EMPTY_RECT_F;
}
}
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 723701d..68e9f5a 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -164,13 +164,6 @@
return deviceProfile.isTablet;
}
- /**
- * Should the TaskView scale down to fit whole thumbnail in fullscreen.
- */
- public static boolean useFullThumbnail(DeviceProfile deviceProfile) {
- return deviceProfile.isTablet && !deviceProfile.isTaskbarPresentInApps;
- }
-
private static final float EDGE_SCALE_DOWN_FACTOR_CAROUSEL = 0.03f;
private static final float EDGE_SCALE_DOWN_FACTOR_GRID = 0.00f;
@@ -1576,13 +1569,11 @@
RectF insets = pph.getInsetsToDrawInFullscreen(dp);
float currentInsetsLeft = insets.left * fullscreenProgress;
+ float currentInsetsTop = insets.top * fullscreenProgress;
float currentInsetsRight = insets.right * fullscreenProgress;
- float insetsBottom = insets.bottom;
- if (dp.isTaskbarPresentInApps) {
- insetsBottom = Math.max(0, insetsBottom - dp.taskbarSize);
- }
- mCurrentDrawnInsets.set(currentInsetsLeft, insets.top * fullscreenProgress,
- currentInsetsRight, insetsBottom * fullscreenProgress);
+ float currentInsetsBottom = insets.bottom * fullscreenProgress;
+ mCurrentDrawnInsets.set(
+ currentInsetsLeft, currentInsetsTop, currentInsetsRight, currentInsetsBottom);
mCurrentDrawnCornerRadius =
Utilities.mapRange(fullscreenProgress, mCornerRadius, mWindowCornerRadius)
diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileQuickstepTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileQuickstepTest.kt
index 368dc2a..20b5a64 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileQuickstepTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileQuickstepTest.kt
@@ -48,8 +48,8 @@
val dp = newDP()
- assertThat(dp.cellLayoutWidth).isEqualTo(1235)
- assertThat(dp.cellLayoutHeight).isEqualTo(1235)
+ assertThat(dp.cellLayoutWidth).isEqualTo(1237)
+ assertThat(dp.cellLayoutHeight).isEqualTo(1215)
}
@Test
@@ -67,8 +67,8 @@
val dp = newDP()
- assertThat(dp.getCellSize().y).isEqualTo(264)
- assertThat(dp.getCellSize().x).isEqualTo(258)
+ assertThat(dp.getCellSize().y).isEqualTo(260)
+ assertThat(dp.getCellSize().x).isEqualTo(259)
}
@Test
@@ -117,6 +117,6 @@
assertThat(dp.isVerticalBarLayout).isEqualTo(false)
assertThat(dp.cellLayoutSpringLoadShrunkTop).isEqualTo(364)
- assertThat(dp.cellLayoutSpringLoadShrunkBottom).isEqualTo(2199)
+ assertThat(dp.cellLayoutSpringLoadShrunkBottom).isEqualTo(2185)
}
}
\ No newline at end of file
diff --git a/res/drawable/bg_work_apps_paused_action_button.xml b/res/drawable/bg_work_apps_paused_action_button.xml
new file mode 100644
index 0000000..74d4693
--- /dev/null
+++ b/res/drawable/bg_work_apps_paused_action_button.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2022 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="@color/accent_ripple_color">
+ <item android:id="@android:id/mask">
+ <shape android:shape="rectangle">
+ <corners android:radius="@dimen/rounded_button_radius" />
+ <solid android:color="@android:color/white" />
+ </shape>
+ </item>
+
+ <item android:id="@android:id/background">
+ <shape android:shape="rectangle">
+ <solid android:color="?android:attr/colorControlHighlight" />
+ <corners android:radius="@dimen/rounded_button_radius" />
+ </shape>
+ </item>
+</ripple>
\ No newline at end of file
diff --git a/res/drawable/work_apps_toggle_background.xml b/res/drawable/work_apps_toggle_background.xml
index a47c8fe..6ad6c82 100644
--- a/res/drawable/work_apps_toggle_background.xml
+++ b/res/drawable/work_apps_toggle_background.xml
@@ -13,16 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_enabled="false">
- <shape android:shape="rectangle">
- <corners android:radius="@dimen/work_fab_radius" />
- <solid android:color="?android:attr/colorControlHighlight" />
- <padding
- android:left="@dimen/work_profile_footer_padding"
- android:right="@dimen/work_profile_footer_padding" />
- </shape>
- </item>
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="@color/accent_ripple_color">
<item>
<shape android:shape="rectangle">
<corners android:radius="@dimen/work_fab_radius" />
@@ -32,4 +24,4 @@
android:right="@dimen/work_profile_footer_padding" />
</shape>
</item>
-</selector>
+</ripple>
diff --git a/res/layout/work_apps_paused.xml b/res/layout/work_apps_paused.xml
index 79bce70..f614d9b 100644
--- a/res/layout/work_apps_paused.xml
+++ b/res/layout/work_apps_paused.xml
@@ -48,7 +48,7 @@
android:textColor="?attr/workProfileOverlayTextColor"
android:text="@string/work_apps_enable_btn_text"
android:textAlignment="center"
- android:background="@drawable/rounded_action_button"
+ android:background="@drawable/bg_work_apps_paused_action_button"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textSize="14sp" />
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 9f25905..af8d8eb 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -329,6 +329,24 @@
<!-- defaults to hotseatBorderSpace, if not specified -->
<attr name="hotseatBorderSpaceTwoPanelPortrait" format="float" />
+ <!-- defaults to res.hotseat_bar_bottom_space_default, if not specified -->
+ <attr name="hotseatBarBottomSpace" format="float" />
+ <!-- defaults to hotseatBarBottomSpace, if not specified -->
+ <attr name="hotseatBarBottomSpaceLandscape" format="float" />
+ <!-- defaults to hotseatBarBottomSpace, if not specified -->
+ <attr name="hotseatBarBottomSpaceTwoPanelLandscape" format="float" />
+ <!-- defaults to hotseatBarBottomSpace, if not specified -->
+ <attr name="hotseatBarBottomSpaceTwoPanelPortrait" format="float" />
+
+ <!-- defaults to res.hotseat_qsb_space_default, if not specified -->
+ <attr name="hotseatQsbSpace" format="float" />
+ <!-- defaults to hotseatQsbSpace, if not specified -->
+ <attr name="hotseatQsbSpaceLandscape" format="float" />
+ <!-- defaults to hotseatQsbSpace, if not specified -->
+ <attr name="hotseatQsbSpaceTwoPanelLandscape" format="float" />
+ <!-- defaults to hotseatQsbSpace, if not specified -->
+ <attr name="hotseatQsbSpaceTwoPanelPortrait" format="float" />
+
<attr name="iconImageSize" format="float" />
<!-- defaults to iconImageSize, if not specified -->
<attr name="iconSizeLandscape" format="float" />
diff --git a/res/values/config.xml b/res/values/config.xml
index 9aa1f03..3f94c34 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -130,6 +130,11 @@
<item type="id" name="search_container_all_apps" />
<item type="id" name="search_container_hotseat" />
+ <!-- Scalable Grid configuration -->
+ <!-- This is a float because it is converted to dp later in DeviceProfile -->
+ <dimen name="hotseat_bar_bottom_space_default">48</dimen>
+ <dimen name="hotseat_qsb_space_default">0</dimen>
+
<!-- Recents -->
<item type="id" name="overview_panel"/>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 39f0a2b..a3a30e1 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -32,10 +32,7 @@
<dimen name="dynamic_grid_cell_padding_x">8dp</dimen>
<!-- Hotseat -->
- <dimen name="dynamic_grid_hotseat_top_padding">8dp</dimen>
- <dimen name="dynamic_grid_hotseat_bottom_padding">2dp</dimen>
<dimen name="dynamic_grid_hotseat_bottom_tall_padding">0dp</dimen>
- <dimen name="inline_qsb_bottom_margin">0dp</dimen>
<dimen name="spring_loaded_hotseat_top_margin">76dp</dimen>
<!-- Qsb -->
@@ -44,13 +41,10 @@
it is close to the bottom of the screen -->
<item name="qsb_center_factor" format="float" type="dimen">0.325</item>
- <!-- Extra bottom padding for non-tall devices. -->
- <dimen name="dynamic_grid_hotseat_bottom_non_tall_padding">0dp</dimen>
- <dimen name="dynamic_grid_hotseat_extra_vertical_size">34dp</dimen>
<dimen name="dynamic_grid_hotseat_side_padding">0dp</dimen>
<!-- Scalable Grid -->
- <dimen name="scalable_grid_qsb_bottom_margin">42dp</dimen>
+ <dimen name="min_qsb_margin">8dp</dimen>
<!-- Workspace page indicator -->
<dimen name="workspace_page_indicator_height">24dp</dimen>
@@ -364,6 +358,7 @@
<dimen name="taskbar_size">0dp</dimen>
<dimen name="taskbar_stashed_size">0dp</dimen>
<dimen name="qsb_widget_height">0dp</dimen>
+ <dimen name="qsb_shadow_height">0dp</dimen>
<dimen name="taskbar_icon_size">44dp</dimen>
<!-- Note that this applies to both sides of all icons, so visible space is double this. -->
<dimen name="taskbar_icon_spacing">8dp</dimen>
@@ -418,4 +413,7 @@
<dimen name="bottom_sheet_handle_height">4dp</dimen>
<dimen name="bottom_sheet_handle_margin">16dp</dimen>
<dimen name="bottom_sheet_handle_corner_radius">2dp</dimen>
+
+ <!-- State transition -->
+ <item name="workspace_content_scale" format="float" type="dimen">0.97</item>
</resources>
diff --git a/res/xml/device_profiles.xml b/res/xml/device_profiles.xml
index 0802552..5ee291b 100644
--- a/res/xml/device_profiles.xml
+++ b/res/xml/device_profiles.xml
@@ -199,6 +199,8 @@
launcher:allAppsBorderSpaceLandscape="16"
launcher:hotseatBorderSpace="58"
launcher:hotseatBorderSpaceLandscape="50.4"
+ launcher:hotseatBarBottomSpace="76"
+ launcher:hotseatBarBottomSpaceLandscape="40"
launcher:canBeDefault="true" />
</grid-option>
diff --git a/res/xml/paddings_6x5.xml b/res/xml/paddings_6x5.xml
index a72f554..2f421b7 100644
--- a/res/xml/paddings_6x5.xml
+++ b/res/xml/paddings_6x5.xml
@@ -17,60 +17,29 @@
<device-paddings xmlns:launcher="http://schemas.android.com/apk/res-auto" >
- <!-- Some non default screen sizes -->
<device-padding
- launcher:maxEmptySpace="30dp">
+ launcher:maxEmptySpace="100dp">
<workspaceTopPadding
- launcher:a="0.34"
+ launcher:a="0.31"
launcher:b="0"/>
<workspaceBottomPadding
- launcher:a="0.26"
+ launcher:a="0.69"
launcher:b="0"/>
<hotseatBottomPadding
- launcher:a="0.4"
- launcher:b="0"/>
- </device-padding>
-
- <device-padding
- launcher:maxEmptySpace="170dp">
- <workspaceTopPadding
launcher:a="0"
- launcher:b="20dp"/>
- <workspaceBottomPadding
- launcher:a="0.4"
- launcher:b="0"
- launcher:c="20dp"/>
- <hotseatBottomPadding
- launcher:a="0.6"
- launcher:b="0"
- launcher:c="20dp"/>
- </device-padding>
-
- <device-padding
- launcher:maxEmptySpace="410dp">
- <workspaceTopPadding
- launcher:a="0"
- launcher:b="112dp"/>
- <workspaceBottomPadding
- launcher:a="0.4"
- launcher:b="0"
- launcher:c="112dp"/>
- <hotseatBottomPadding
- launcher:a="0.6"
- launcher:b="0"
- launcher:c="112dp"/>
+ launcher:b="0"/>
</device-padding>
<device-padding
launcher:maxEmptySpace="9999dp">
<workspaceTopPadding
- launcher:a="0.40"
- launcher:c="36dp"/>
+ launcher:a="0.48"
+ launcher:b="0"/>
<workspaceBottomPadding
- launcher:a="0.60"
- launcher:c="36dp"/>
+ launcher:a="0.52"
+ launcher:b="0"/>
<hotseatBottomPadding
launcher:a="0"
- launcher:b="36dp"/>
+ launcher:b="0"/>
</device-padding>
</device-paddings>
\ No newline at end of file
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 60af347..673ab54 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -107,6 +107,7 @@
public Rect cellLayoutPaddingPx = new Rect();
public final int edgeMarginPx;
+ public final float workspaceContentScale;
public float workspaceSpringLoadShrunkTop;
public float workspaceSpringLoadShrunkBottom;
public final int workspaceSpringLoadedBottomSpace;
@@ -115,7 +116,6 @@
private final int extraSpace;
public int workspaceTopPadding;
public int workspaceBottomPadding;
- public int extraHotseatBottomPadding;
// Workspace page indicator
public final int workspacePageIndicatorHeight;
@@ -157,24 +157,22 @@
public int folderChildDrawablePaddingPx;
// Hotseat
- public int hotseatBarSizeExtraSpacePx;
public final int numShownHotseatIcons;
public int hotseatCellHeightPx;
- private final int hotseatExtraVerticalSize;
private final boolean areNavButtonsInline;
// In portrait: size = height, in landscape: size = width
public int hotseatBarSizePx;
- public int hotseatBarTopPaddingPx;
- public final int hotseatBarBottomPaddingPx;
+ public int hotseatBarBottomSpacePx;
+ public int hotseatQsbSpace;
public int springLoadedHotseatBarTopMarginPx;
// Start is the side next to the nav bar, end is the side next to the workspace
public final int hotseatBarSidePaddingStartPx;
public final int hotseatBarSidePaddingEndPx;
public final int hotseatQsbHeight;
+ public final int hotseatQsbVisualHeight;
+ private final int hotseatQsbShadowHeight;
public int hotseatBorderSpace;
- public final float qsbBottomMarginOriginalPx;
- public int qsbBottomMarginPx;
public int qsbWidth; // only used when isQsbInline
// All apps
@@ -222,7 +220,7 @@
// Insets
private final Rect mInsets = new Rect();
public final Rect workspacePadding = new Rect();
- private final Rect mHotseatPadding = new Rect();
+ private final Rect mHotseatBarPadding = new Rect();
// When true, nav bar is on the left side of the screen.
private boolean mIsSeascape;
@@ -275,7 +273,7 @@
widthPx = windowBounds.bounds.width();
heightPx = windowBounds.bounds.height();
availableWidthPx = windowBounds.availableSize.x;
- availableHeightPx = windowBounds.availableSize.y;
+ availableHeightPx = windowBounds.availableSize.y;
aspectRatio = ((float) Math.max(widthPx, heightPx)) / Math.min(widthPx, heightPx);
boolean isTallDevice = Float.compare(aspectRatio, TALL_DEVICE_ASPECT_RATIO_THRESHOLD) >= 0;
@@ -301,6 +299,7 @@
}
edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
+ workspaceContentScale = res.getFloat(R.dimen.workspace_content_scale);
desiredWorkspaceHorizontalMarginPx = getHorizontalMarginPx(inv, res);
desiredWorkspaceHorizontalMarginOriginalPx = desiredWorkspaceHorizontalMarginPx;
@@ -360,6 +359,9 @@
workspaceCellPaddingXPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_padding_x);
hotseatQsbHeight = res.getDimensionPixelSize(R.dimen.qsb_widget_height);
+ hotseatQsbShadowHeight = res.getDimensionPixelSize(R.dimen.qsb_shadow_height);
+ hotseatQsbVisualHeight = hotseatQsbHeight - 2 * hotseatQsbShadowHeight;
+
// Whether QSB might be inline in appropriate orientation (e.g. landscape).
boolean canQsbInline = (isTwoPanels ? inv.inlineQsb[INDEX_TWO_PANEL_PORTRAIT]
|| inv.inlineQsb[INDEX_TWO_PANEL_LANDSCAPE]
@@ -379,17 +381,28 @@
numShownAllAppsColumns =
isTwoPanels ? inv.numDatabaseAllAppsColumns : inv.numAllAppsColumns;
- hotseatBarSizeExtraSpacePx = 0;
- hotseatBarTopPaddingPx =
- res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_top_padding);
- if (isQsbInline) {
- hotseatBarBottomPaddingPx = res.getDimensionPixelSize(R.dimen.inline_qsb_bottom_margin);
+
+ int hotseatBarBottomSpace = pxFromDp(inv.hotseatBarBottomSpace[mTypeIndex], mMetrics);
+ int minQsbMargin = res.getDimensionPixelSize(R.dimen.min_qsb_margin);
+ hotseatQsbSpace = pxFromDp(inv.hotseatQsbSpace[mTypeIndex], mMetrics);
+ // Have a little space between the inset and the QSB
+ if (mInsets.bottom + minQsbMargin > hotseatBarBottomSpace) {
+ int availableSpace = hotseatQsbSpace - (mInsets.bottom - hotseatBarBottomSpace);
+
+ // Only change the spaces if there is space
+ if (availableSpace > 0) {
+ // Make sure there is enough space between hotseat/QSB and QSB/navBar
+ if (availableSpace < minQsbMargin * 2) {
+ minQsbMargin = availableSpace / 2;
+ hotseatQsbSpace = minQsbMargin;
+ } else {
+ hotseatQsbSpace -= minQsbMargin;
+ }
+ }
+ hotseatBarBottomSpacePx = mInsets.bottom + minQsbMargin;
+
} else {
- hotseatBarBottomPaddingPx = (isTallDevice ? res.getDimensionPixelSize(
- R.dimen.dynamic_grid_hotseat_bottom_tall_padding)
- : res.getDimensionPixelSize(
- R.dimen.dynamic_grid_hotseat_bottom_non_tall_padding))
- + res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_padding);
+ hotseatBarBottomSpacePx = hotseatBarBottomSpace;
}
springLoadedHotseatBarTopMarginPx = res.getDimensionPixelSize(
@@ -398,13 +411,7 @@
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_side_padding);
// Add a bit of space between nav bar and hotseat in vertical bar layout.
hotseatBarSidePaddingStartPx = isVerticalBarLayout() ? workspacePageIndicatorHeight : 0;
- hotseatExtraVerticalSize =
- res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_extra_vertical_size);
- updateHotseatIconSize(pxFromDp(inv.iconSize[INDEX_DEFAULT], mMetrics));
-
- qsbBottomMarginOriginalPx = isScalableGrid
- ? res.getDimensionPixelSize(R.dimen.scalable_grid_qsb_bottom_margin)
- : 0;
+ updateHotseatSizes(pxFromDp(inv.iconSize[INDEX_DEFAULT], mMetrics));
overviewTaskMarginPx = res.getDimensionPixelSize(R.dimen.overview_task_margin);
overviewTaskMarginGridPx = res.getDimensionPixelSize(R.dimen.overview_task_margin_grid);
@@ -443,42 +450,6 @@
workspaceTopPadding = Math.round(paddingWorkspaceTop * cellScaleToFit);
workspaceBottomPadding = Math.round(paddingWorkspaceBottom * cellScaleToFit);
- extraHotseatBottomPadding = Math.round(paddingHotseatBottom * cellScaleToFit);
-
- hotseatBarSizePx += extraHotseatBottomPadding;
-
- qsbBottomMarginPx = Math.round(qsbBottomMarginOriginalPx * cellScaleToFit);
- } else if (!isVerticalBarLayout() && isPhone && isTallDevice) {
- // We increase the hotseat size when there is extra space.
-
- if (Float.compare(aspectRatio, TALLER_DEVICE_ASPECT_RATIO_THRESHOLD) >= 0
- && extraSpace >= Utilities.dpToPx(TALL_DEVICE_EXTRA_SPACE_THRESHOLD_DP)) {
- // For taller devices, we will take a piece of the extra space from each row,
- // and add it to the space above and below the hotseat.
-
- // For devices with more extra space, we take a larger piece from each cell.
- int piece = extraSpace < Utilities.dpToPx(TALL_DEVICE_MORE_EXTRA_SPACE_THRESHOLD_DP)
- ? 7 : 5;
-
- int extraSpace = ((getCellSize().y - iconSizePx - iconDrawablePaddingPx * 2)
- * inv.numRows) / piece;
-
- workspaceTopPadding = extraSpace / 8;
- int halfLeftOver = (extraSpace - workspaceTopPadding) / 2;
- hotseatBarTopPaddingPx += halfLeftOver;
- hotseatBarSizeExtraSpacePx = halfLeftOver;
- } else {
- // ie. For a display with a large aspect ratio, we can keep the icons on the
- // workspace in portrait mode closer together by adding more height to the hotseat.
- // Note: This calculation was created after noticing a pattern in the design spec.
- hotseatBarSizeExtraSpacePx = getCellSize().y - iconSizePx
- - iconDrawablePaddingPx * 2 - workspacePageIndicatorHeight;
- }
-
- updateHotseatIconSize(iconSizePx);
-
- // Recalculate the available dimensions using the new hotseat size.
- updateAvailableDimensions(res);
}
int cellLayoutPadding =
@@ -534,22 +505,27 @@
: res.getDimensionPixelSize(R.dimen.dynamic_grid_left_right_margin);
}
- private void updateHotseatIconSize(int hotseatIconSizePx) {
+ /** Updates hotseatCellHeightPx and hotseatBarSizePx */
+ private void updateHotseatSizes(int hotseatIconSizePx) {
// Ensure there is enough space for folder icons, which have a slightly larger radius.
hotseatCellHeightPx = (int) Math.ceil(hotseatIconSizePx * ICON_OVERLAP_FACTOR);
+
if (isVerticalBarLayout()) {
hotseatBarSizePx = hotseatIconSizePx + hotseatBarSidePaddingStartPx
+ hotseatBarSidePaddingEndPx;
+ } else if (isQsbInline) {
+ hotseatBarSizePx = Math.max(hotseatIconSizePx, hotseatQsbVisualHeight)
+ + hotseatBarBottomSpacePx;
} else {
- hotseatBarSizePx = hotseatIconSizePx + hotseatBarTopPaddingPx
- + hotseatBarBottomPaddingPx + (isScalableGrid ? 0 : hotseatExtraVerticalSize)
- + hotseatBarSizeExtraSpacePx;
+ hotseatBarSizePx = hotseatIconSizePx
+ + hotseatQsbSpace
+ + hotseatQsbVisualHeight
+ + hotseatBarBottomSpacePx;
}
}
private Point getCellLayoutBorderSpace(InvariantDeviceProfile idp) {
return getCellLayoutBorderSpace(idp, 1f);
-
}
private Point getCellLayoutBorderSpace(InvariantDeviceProfile idp, float scale) {
@@ -761,7 +737,7 @@
// All apps
updateAllAppsIconSize(scale, res);
- updateHotseatIconSize(iconSizePx);
+ updateHotseatSizes(iconSizePx);
// Folder icon
folderIconSizePx = IconNormalizer.getNormalizedCircleSize(iconSizePx);
@@ -932,10 +908,10 @@
*/
private int getVerticalHotseatLastItemBottomOffset() {
int cellHeight = calculateCellHeight(
- heightPx - mHotseatPadding.top - mHotseatPadding.bottom, hotseatBorderSpace,
+ heightPx - mHotseatBarPadding.top - mHotseatBarPadding.bottom, hotseatBorderSpace,
numShownHotseatIcons);
int extraIconEndSpacing = (cellHeight - iconSizePx) / 2;
- return extraIconEndSpacing + mHotseatPadding.bottom;
+ return extraIconEndSpacing + mHotseatBarPadding.bottom;
}
/**
@@ -1017,10 +993,11 @@
padding.right = hotseatBarSizePx;
}
} else {
- // Pad the bottom of the workspace with search/hotseat bar sizes
- int hotseatTop = hotseatBarSizePx;
- int paddingBottom = hotseatTop + workspacePageIndicatorHeight
- + workspaceBottomPadding - mWorkspacePageIndicatorOverlapWorkspace;
+ // Pad the bottom of the workspace with hotseat bar
+ // and leave a bit of space in case a widget go all the way down
+ int paddingBottom = hotseatBarSizePx + workspaceBottomPadding
+ + workspacePageIndicatorHeight - mWorkspacePageIndicatorOverlapWorkspace
+ - mInsets.bottom;
int paddingTop = workspaceTopPadding + (isScalableGrid ? 0 : edgeMarginPx);
int paddingSide = desiredWorkspaceHorizontalMarginPx;
@@ -1060,17 +1037,17 @@
+ diffOverlapFactor), 0);
if (isSeascape()) {
- mHotseatPadding.set(mInsets.left + hotseatBarSidePaddingStartPx, paddingTop,
+ mHotseatBarPadding.set(mInsets.left + hotseatBarSidePaddingStartPx, paddingTop,
hotseatBarSidePaddingEndPx, paddingBottom);
} else {
- mHotseatPadding.set(hotseatBarSidePaddingEndPx, paddingTop,
+ mHotseatBarPadding.set(hotseatBarSidePaddingEndPx, paddingTop,
mInsets.right + hotseatBarSidePaddingStartPx, paddingBottom);
}
} else if (isTaskbarPresent) {
// Center the QSB vertically with hotseat
- int hotseatBottomPadding = getHotseatBottomPadding();
- int hotseatTopPadding =
- workspacePadding.bottom - hotseatBottomPadding - hotseatCellHeightPx;
+ int hotseatBarBottomPadding = getHotseatBarBottomPadding();
+ int hotseatBarTopPadding =
+ hotseatBarSizePx - hotseatBarBottomPadding - hotseatCellHeightPx;
// Push icons to the side
int additionalQsbSpace = isQsbInline ? qsbWidth + hotseatBorderSpace : 0;
@@ -1081,29 +1058,29 @@
int hotseatWidth = Math.min(requiredWidth, availableWidthPx - endOffset);
int sideSpacing = (availableWidthPx - hotseatWidth) / 2;
- mHotseatPadding.set(sideSpacing, hotseatTopPadding, sideSpacing, hotseatBottomPadding);
+ mHotseatBarPadding.set(sideSpacing, hotseatBarTopPadding, sideSpacing,
+ hotseatBarBottomPadding);
boolean isRtl = Utilities.isRtl(context.getResources());
if (isRtl) {
- mHotseatPadding.right += additionalQsbSpace;
+ mHotseatBarPadding.right += additionalQsbSpace;
} else {
- mHotseatPadding.left += additionalQsbSpace;
+ mHotseatBarPadding.left += additionalQsbSpace;
}
if (endOffset > sideSpacing) {
int diff = isRtl
? sideSpacing - endOffset
: endOffset - sideSpacing;
- mHotseatPadding.left -= diff;
- mHotseatPadding.right += diff;
+ mHotseatBarPadding.left -= diff;
+ mHotseatBarPadding.right += diff;
}
} else if (isScalableGrid) {
int sideSpacing = (availableWidthPx - qsbWidth) / 2;
- mHotseatPadding.set(sideSpacing,
- hotseatBarTopPaddingPx,
+ mHotseatBarPadding.set(sideSpacing,
+ 0,
sideSpacing,
- hotseatBarSizePx - hotseatCellHeightPx - hotseatBarTopPaddingPx
- + mInsets.bottom);
+ getHotseatBarBottomPadding());
} else {
// We want the edges of the hotseat to line up with the edges of the workspace, but the
// icons in the hotseat are a different size, and so don't line up perfectly. To account
@@ -1112,14 +1089,15 @@
float workspaceCellWidth = (float) widthPx / inv.numColumns;
float hotseatCellWidth = (float) widthPx / numShownHotseatIcons;
int hotseatAdjustment = Math.round((workspaceCellWidth - hotseatCellWidth) / 2);
- mHotseatPadding.set(hotseatAdjustment + workspacePadding.left + cellLayoutPaddingPx.left
- + mInsets.left, hotseatBarTopPaddingPx,
+ mHotseatBarPadding.set(
+ hotseatAdjustment + workspacePadding.left + cellLayoutPaddingPx.left
+ + mInsets.left,
+ 0,
hotseatAdjustment + workspacePadding.right + cellLayoutPaddingPx.right
+ mInsets.right,
- hotseatBarSizePx - hotseatCellHeightPx - hotseatBarTopPaddingPx
- + mInsets.bottom);
+ getHotseatBarBottomPadding());
}
- return mHotseatPadding;
+ return mHotseatBarPadding;
}
/**
@@ -1127,27 +1105,22 @@
*/
public int getQsbOffsetY() {
if (isQsbInline) {
- return hotseatBarBottomPaddingPx;
- }
-
- int freeSpace = isTaskbarPresent
- ? workspacePadding.bottom
- : hotseatBarSizePx - hotseatCellHeightPx - hotseatQsbHeight;
-
- if (isScalableGrid && qsbBottomMarginPx > mInsets.bottom) {
- // Note that taskbarSize = 0 unless isTaskbarPresent.
- return Math.min(qsbBottomMarginPx + taskbarSize, freeSpace);
+ return getHotseatBarBottomPadding() - ((hotseatQsbHeight - hotseatCellHeightPx) / 2);
+ } else if (isTaskbarPresent) { // QSB on top
+ return hotseatBarSizePx - hotseatQsbHeight + hotseatQsbShadowHeight;
} else {
- return (int) (freeSpace * mQsbCenterFactor)
- + (isTaskbarPresent ? taskbarSize : mInsets.bottom);
+ return hotseatBarBottomSpacePx - hotseatQsbShadowHeight;
}
}
- private int getHotseatBottomPadding() {
- if (isQsbInline) {
- return getQsbOffsetY() + ((hotseatQsbHeight - hotseatCellHeightPx) / 2);
+ /**
+ * Returns the number of pixels the hotseat is translated from the bottom of the screen.
+ */
+ private int getHotseatBarBottomPadding() {
+ if (isTaskbarPresent) { // QSB on top or inline
+ return hotseatBarBottomSpacePx - (Math.abs(hotseatCellHeightPx - iconSizePx) / 2);
} else {
- return (getQsbOffsetY() - taskbarSize) / 2;
+ return hotseatBarSizePx - hotseatCellHeightPx;
}
}
@@ -1158,7 +1131,7 @@
int taskbarIconBottomSpace = (taskbarSize - iconSizePx) / 2;
int launcherIconBottomSpace =
Math.min((hotseatCellHeightPx - iconSizePx) / 2, gridVisualizationPaddingY);
- return getHotseatBottomPadding() + launcherIconBottomSpace - taskbarIconBottomSpace;
+ return getHotseatBarBottomPadding() + launcherIconBottomSpace - taskbarIconBottomSpace;
}
/**
@@ -1167,7 +1140,7 @@
public int getOverviewActionsClaimedSpaceBelow() {
if (isTaskbarPresent && !isGestureMode) {
// Align vertically to where nav buttons are.
- return ((taskbarSize - overviewActionsHeight) / 2) + getTaskbarOffsetY();
+ return ((taskbarSize - overviewActionsHeight) / 2) + getTaskbarOffsetY();
}
return isTaskbarPresent ? stashedTaskbarSize : mInsets.bottom;
@@ -1349,18 +1322,19 @@
writer.println(prefix + pxToDpStr("hotseatBarSizePx", hotseatBarSizePx));
writer.println(prefix + "\tinv.hotseatColumnSpan: " + inv.hotseatColumnSpan[mTypeIndex]);
writer.println(prefix + pxToDpStr("hotseatCellHeightPx", hotseatCellHeightPx));
- writer.println(prefix + pxToDpStr("hotseatBarTopPaddingPx", hotseatBarTopPaddingPx));
- writer.println(prefix + pxToDpStr("hotseatBarBottomPaddingPx", hotseatBarBottomPaddingPx));
+ writer.println(prefix + pxToDpStr("hotseatBarBottomPaddingPx", hotseatBarBottomSpacePx));
writer.println(prefix + pxToDpStr("hotseatBarSidePaddingStartPx",
hotseatBarSidePaddingStartPx));
writer.println(prefix + pxToDpStr("hotseatBarSidePaddingEndPx",
hotseatBarSidePaddingEndPx));
+ writer.println(prefix + pxToDpStr("hotseatQsbSpace", hotseatQsbSpace));
+ writer.println(prefix + pxToDpStr("hotseatQsbHeight", hotseatQsbHeight));
writer.println(prefix + pxToDpStr("springLoadedHotseatBarTopMarginPx",
springLoadedHotseatBarTopMarginPx));
- writer.println(prefix + pxToDpStr("mHotseatPadding.top", mHotseatPadding.top));
- writer.println(prefix + pxToDpStr("mHotseatPadding.bottom", mHotseatPadding.bottom));
- writer.println(prefix + pxToDpStr("mHotseatPadding.left", mHotseatPadding.left));
- writer.println(prefix + pxToDpStr("mHotseatPadding.right", mHotseatPadding.right));
+ writer.println(prefix + pxToDpStr("mHotseatBarPadding.top", mHotseatBarPadding.top));
+ writer.println(prefix + pxToDpStr("mHotseatBarPadding.bottom", mHotseatBarPadding.bottom));
+ writer.println(prefix + pxToDpStr("mHotseatBarPadding.left", mHotseatBarPadding.left));
+ writer.println(prefix + pxToDpStr("mHotseatBarPadding.right", mHotseatBarPadding.right));
writer.println(prefix + "\tnumShownHotseatIcons: " + numShownHotseatIcons);
writer.println(prefix + pxToDpStr("hotseatBorderSpace", hotseatBorderSpace));
writer.println(prefix + "\tisQsbInline: " + isQsbInline);
@@ -1389,7 +1363,6 @@
}
writer.println(prefix + pxToDpStr("workspaceTopPadding", workspaceTopPadding));
writer.println(prefix + pxToDpStr("workspaceBottomPadding", workspaceBottomPadding));
- writer.println(prefix + pxToDpStr("extraHotseatBottomPadding", extraHotseatBottomPadding));
writer.println(prefix + pxToDpStr("overviewTaskMarginPx", overviewTaskMarginPx));
writer.println(prefix + pxToDpStr("overviewTaskMarginGridPx", overviewTaskMarginGridPx));
@@ -1425,6 +1398,8 @@
workspaceSpringLoadedMinNextPageVisiblePx));
writer.println(
prefix + pxToDpStr("getWorkspaceSpringLoadScale()", getWorkspaceSpringLoadScale()));
+ writer.println(prefix + pxToDpStr("getCellLayoutHeight()", getCellLayoutHeight()));
+ writer.println(prefix + pxToDpStr("getCellLayoutWidth()", getCellLayoutWidth()));
}
private static Context getContext(Context c, Info info, int orientation, WindowBounds bounds) {
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 8c4c662..05ed319 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -111,9 +111,7 @@
mQsb.setVisibility(View.VISIBLE);
lp.gravity = Gravity.BOTTOM;
lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
- lp.height = grid.isTaskbarPresent
- ? grid.workspacePadding.bottom
- : grid.hotseatBarSizePx + insets.bottom;
+ lp.height = grid.hotseatBarSizePx;
}
Rect padding = grid.getHotseatLayoutPadding(getContext());
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index dacbe92..2085b84 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -46,6 +46,7 @@
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
+import androidx.core.content.res.ResourcesCompat;
import com.android.launcher3.model.DeviceGridState;
import com.android.launcher3.provider.RestoreDbTask;
@@ -77,7 +78,8 @@
@Retention(RetentionPolicy.SOURCE)
@IntDef({TYPE_PHONE, TYPE_MULTI_DISPLAY, TYPE_TABLET})
- public @interface DeviceType{}
+ public @interface DeviceType {}
+
public static final int TYPE_PHONE = 0;
public static final int TYPE_MULTI_DISPLAY = 1;
public static final int TYPE_TABLET = 2;
@@ -153,6 +155,8 @@
public int numDatabaseHotseatIcons;
public int[] hotseatColumnSpan;
+ public float[] hotseatBarBottomSpace;
+ public float[] hotseatQsbSpace;
/**
* Number of columns in the all apps list.
@@ -360,6 +364,8 @@
? closestProfile.numDatabaseHotseatIcons : closestProfile.numHotseatIcons;
hotseatColumnSpan = closestProfile.hotseatColumnSpan;
hotseatBorderSpaces = displayOption.hotseatBorderSpaces;
+ hotseatBarBottomSpace = displayOption.hotseatBarBottomSpace;
+ hotseatQsbSpace = displayOption.hotseatQsbSpace;
numAllAppsColumns = closestProfile.numAllAppsColumns;
numDatabaseAllAppsColumns = deviceType == TYPE_MULTI_DISPLAY
@@ -726,6 +732,7 @@
private final int numHotseatIcons;
private final int numShrunkenHotseatIcons;
private final int numDatabaseHotseatIcons;
+
private final int[] hotseatColumnSpan = new int[COUNT_SIZES];
private final String dbFile;
@@ -766,6 +773,7 @@
R.styleable.GridDisplayOption_numShrunkenHotseatIcons, numHotseatIcons / 2);
numDatabaseHotseatIcons = a.getInt(
R.styleable.GridDisplayOption_numExtendedHotseatIcons, 2 * numHotseatIcons);
+
hotseatColumnSpan[INDEX_DEFAULT] = a.getInt(
R.styleable.GridDisplayOption_hotseatColumnSpan, numColumns);
hotseatColumnSpan[INDEX_LANDSCAPE] = a.getInt(
@@ -825,6 +833,8 @@
private final float[] horizontalMargin = new float[COUNT_SIZES];
//TODO(http://b/228998082) remove this when 3 button spaces are fixed
private final float[] hotseatBorderSpaces = new float[COUNT_SIZES];
+ private final float[] hotseatBarBottomSpace = new float[COUNT_SIZES];
+ private final float[] hotseatQsbSpace = new float[COUNT_SIZES];
private final float[] iconSizes = new float[COUNT_SIZES];
private final float[] textSizes = new float[COUNT_SIZES];
@@ -1050,6 +1060,34 @@
R.styleable.ProfileDisplayOption_hotseatBorderSpaceTwoPanelPortrait,
hotseatBorderSpaces[INDEX_DEFAULT]);
+ hotseatBarBottomSpace[INDEX_DEFAULT] = a.getFloat(
+ R.styleable.ProfileDisplayOption_hotseatBarBottomSpace,
+ ResourcesCompat.getFloat(context.getResources(),
+ R.dimen.hotseat_bar_bottom_space_default));
+ hotseatBarBottomSpace[INDEX_LANDSCAPE] = a.getFloat(
+ R.styleable.ProfileDisplayOption_hotseatBarBottomSpaceLandscape,
+ hotseatBarBottomSpace[INDEX_DEFAULT]);
+ hotseatBarBottomSpace[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
+ R.styleable.ProfileDisplayOption_hotseatBarBottomSpaceTwoPanelLandscape,
+ hotseatBarBottomSpace[INDEX_DEFAULT]);
+ hotseatBarBottomSpace[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat(
+ R.styleable.ProfileDisplayOption_hotseatBarBottomSpaceTwoPanelPortrait,
+ hotseatBarBottomSpace[INDEX_DEFAULT]);
+
+ hotseatQsbSpace[INDEX_DEFAULT] = a.getFloat(
+ R.styleable.ProfileDisplayOption_hotseatQsbSpace,
+ ResourcesCompat.getFloat(context.getResources(),
+ R.dimen.hotseat_qsb_space_default));
+ hotseatQsbSpace[INDEX_LANDSCAPE] = a.getFloat(
+ R.styleable.ProfileDisplayOption_hotseatQsbSpaceLandscape,
+ hotseatQsbSpace[INDEX_DEFAULT]);
+ hotseatQsbSpace[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
+ R.styleable.ProfileDisplayOption_hotseatQsbSpaceTwoPanelLandscape,
+ hotseatQsbSpace[INDEX_DEFAULT]);
+ hotseatQsbSpace[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat(
+ R.styleable.ProfileDisplayOption_hotseatQsbSpaceTwoPanelPortrait,
+ hotseatQsbSpace[INDEX_DEFAULT]);
+
a.recycle();
}
@@ -1085,6 +1123,8 @@
minCellSize[i].y *= w;
horizontalMargin[i] *= w;
hotseatBorderSpaces[i] *= w;
+ hotseatBarBottomSpace[i] *= w;
+ hotseatQsbSpace[i] *= w;
allAppsCellSize[i].x *= w;
allAppsCellSize[i].y *= w;
allAppsIconSizes[i] *= w;
@@ -1108,6 +1148,8 @@
minCellSize[i].y += p.minCellSize[i].y;
horizontalMargin[i] += p.horizontalMargin[i];
hotseatBorderSpaces[i] += p.hotseatBorderSpaces[i];
+ hotseatBarBottomSpace[i] += p.hotseatBarBottomSpace[i];
+ hotseatQsbSpace[i] += p.hotseatQsbSpace[i];
allAppsCellSize[i].x += p.allAppsCellSize[i].x;
allAppsCellSize[i].y += p.allAppsCellSize[i].y;
allAppsIconSizes[i] += p.allAppsIconSizes[i];
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 5081f4f..9c62251 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -30,7 +30,10 @@
import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE;
import static com.android.launcher3.AbstractFloatingView.TYPE_SNACKBAR;
import static com.android.launcher3.AbstractFloatingView.getTopOpenViewWithType;
+import static com.android.launcher3.LauncherAnimUtils.HOTSEAT_SCALE_PROPERTY_FACTORY;
+import static com.android.launcher3.LauncherAnimUtils.SCALE_INDEX_WIDGET_TRANSITION;
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
+import static com.android.launcher3.LauncherAnimUtils.WORKSPACE_SCALE_PROPERTY_FACTORY;
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.FLAG_MULTI_PAGE;
@@ -96,6 +99,7 @@
import android.os.UserHandle;
import android.text.TextUtils;
import android.text.method.TextKeyListener;
+import android.util.FloatProperty;
import android.util.Log;
import android.util.SparseArray;
import android.view.KeyEvent;
@@ -194,6 +198,7 @@
import com.android.launcher3.util.TouchController;
import com.android.launcher3.util.TraceHelper;
import com.android.launcher3.util.UiThreadHelper;
+import com.android.launcher3.util.ViewCapture;
import com.android.launcher3.util.ViewOnDrawExecutor;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.FloatingIconView;
@@ -301,6 +306,11 @@
public static final int DISPLAY_WORKSPACE_TRACE_COOKIE = 0;
public static final int DISPLAY_ALL_APPS_TRACE_COOKIE = 1;
+ private static final FloatProperty<Workspace<?>> WORKSPACE_WIDGET_SCALE =
+ WORKSPACE_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_WIDGET_TRANSITION);
+ private static final FloatProperty<Hotseat> HOTSEAT_WIDGET_SCALE =
+ HOTSEAT_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_WIDGET_TRANSITION);
+
private Configuration mOldConfig;
@Thunk
@@ -388,6 +398,7 @@
private LauncherState mPrevLauncherState;
private StringCache mStringCache;
+ private ViewCapture mViewCapture;
@Override
@TargetApi(Build.VERSION_CODES.S)
@@ -1478,6 +1489,14 @@
public void onAttachedToWindow() {
super.onAttachedToWindow();
mOverlayManager.onAttachedToWindow();
+ if (FeatureFlags.CONTINUOUS_VIEW_TREE_CAPTURE.get()) {
+ View root = getDragLayer().getRootView();
+ if (mViewCapture != null) {
+ root.getViewTreeObserver().removeOnDrawListener(mViewCapture);
+ }
+ mViewCapture = new ViewCapture(root);
+ root.getViewTreeObserver().addOnDrawListener(mViewCapture);
+ }
}
@Override
@@ -2997,6 +3016,10 @@
writer.println(prefix + "\tmRotationHelper: " + mRotationHelper);
writer.println(prefix + "\tmAppWidgetHost.isListening: " + mAppWidgetHost.isListening());
+ if (mViewCapture != null) {
+ writer.println(prefix + "\tmViewCapture: " + mViewCapture.dumpToString());
+ }
+
// Extra logging for general debugging
mDragLayer.dump(prefix, writer);
mStateManager.dump(prefix, writer);
@@ -3225,7 +3248,12 @@
* @param progress Transition progress from 0 to 1; where 0 => home and 1 => widgets.
*/
public void onWidgetsTransition(float progress) {
- // No-Op
+ if (mDeviceProfile.isTablet) {
+ float scale =
+ Utilities.comp(Utilities.comp(mDeviceProfile.workspaceContentScale) * progress);
+ WORKSPACE_WIDGET_SCALE.set(getWorkspace(), scale);
+ HOTSEAT_WIDGET_SCALE.set(getHotseat(), scale);
+ }
}
private static class NonConfigInstance {
diff --git a/src/com/android/launcher3/LauncherAnimUtils.java b/src/com/android/launcher3/LauncherAnimUtils.java
index 0c7c311..b858d1a 100644
--- a/src/com/android/launcher3/LauncherAnimUtils.java
+++ b/src/com/android/launcher3/LauncherAnimUtils.java
@@ -81,9 +81,9 @@
new MultiScalePropertyFactory<Hotseat>("hotseat_scale_property");
public static final int SCALE_INDEX_UNFOLD_ANIMATION = 1;
- public static final int SCALE_INDEX_UNLOCK_ANIMATION = 2;
- public static final int SCALE_INDEX_WORKSPACE_STATE = 3;
- public static final int SCALE_INDEX_REVEAL_ANIM = 4;
+ public static final int SCALE_INDEX_WORKSPACE_STATE = 2;
+ public static final int SCALE_INDEX_REVEAL_ANIM = 3;
+ public static final int SCALE_INDEX_WIDGET_TRANSITION = 4;
/** Increase the duration if we prevented the fling, as we are going against a high velocity. */
public static int blockedFlingDurationFactor(float velocity) {
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 5aa8a46..a20ff8c 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -162,7 +162,7 @@
private synchronized boolean prepForMigration(String dbFile, String targetTableName,
Supplier<DatabaseHelper> src, Supplier<DatabaseHelper> dst) {
if (TextUtils.equals(dbFile, mOpenHelper.getDatabaseName())) {
- Log.e("b/198965093", "prepForMigration - target db is same as current: " + dbFile);
+ Log.e(TAG, "prepForMigration - target db is same as current: " + dbFile);
return false;
}
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index cba0b7d..73be5be 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -1187,9 +1187,7 @@
}
public int getScrollForPage(int index) {
- // TODO(b/233112195): Use !pageScrollsInitialized() instead of mPageScrolls == null, once we
- // root cause where we should be using runOnPageScrollsInitialized().
- if (mPageScrolls == null || index >= mPageScrolls.length || index < 0) {
+ if (!pageScrollsInitialized() || index >= mPageScrolls.length || index < 0) {
return 0;
} else {
return mPageScrolls[index];
diff --git a/src/com/android/launcher3/allapps/FloatingHeaderRow.java b/src/com/android/launcher3/allapps/FloatingHeaderRow.java
index 6ff2132..75e527a 100644
--- a/src/com/android/launcher3/allapps/FloatingHeaderRow.java
+++ b/src/com/android/launcher3/allapps/FloatingHeaderRow.java
@@ -15,11 +15,8 @@
*/
package com.android.launcher3.allapps;
-import android.graphics.Rect;
import android.view.View;
-import com.android.launcher3.DeviceProfile;
-
/**
* A abstract representation of a row in all-apps view
*/
@@ -29,8 +26,6 @@
void setup(FloatingHeaderView parent, FloatingHeaderRow[] allRows, boolean tabsHidden);
- void setInsets(Rect insets, DeviceProfile grid);
-
int getExpectedHeight();
/**
diff --git a/src/com/android/launcher3/allapps/FloatingHeaderView.java b/src/com/android/launcher3/allapps/FloatingHeaderView.java
index 02655b7..c5bdb69 100644
--- a/src/com/android/launcher3/allapps/FloatingHeaderView.java
+++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java
@@ -31,7 +31,6 @@
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
-import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
import com.android.launcher3.R;
import com.android.launcher3.allapps.BaseAllAppsContainerView.AdapterHolder;
@@ -164,22 +163,6 @@
PluginManagerWrapper.INSTANCE.get(getContext()).removePluginListener(this);
}
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- mTabLayout.getLayoutParams().width = getTabWidth();
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- }
-
- /**
- * Returns distance between left and right app icons
- */
- public int getTabWidth() {
- DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile();
- int totalWidth = getMeasuredWidth() - getPaddingLeft() - getPaddingRight();
- int iconPadding = totalWidth / grid.numShownAllAppsColumns - grid.allAppsIconSizePx;
- return totalWidth - iconPadding - grid.allAppsIconDrawablePaddingPx;
- }
-
private void recreateAllRowsArray() {
int pluginCount = mPluginRows.size();
if (pluginCount == 0) {
@@ -429,15 +412,6 @@
p.y = getTop() - mCurrentRV.getTop() - ((ViewGroup) mCurrentRV.getParent()).getTop();
}
- public boolean hasVisibleContent() {
- for (FloatingHeaderRow row : mAllRows) {
- if (row.hasVisibleContent()) {
- return true;
- }
- }
- return false;
- }
-
public boolean isHeaderProtectionSupported() {
return mHeaderProtectionSupported;
}
@@ -449,10 +423,9 @@
@Override
public void setInsets(Rect insets) {
- DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile();
- for (FloatingHeaderRow row : mAllRows) {
- row.setInsets(insets, grid);
- }
+ int leftRightPadding = ActivityContext.lookupContext(getContext())
+ .getDeviceProfile().allAppsLeftRightPadding;
+ setPadding(leftRightPadding, getPaddingTop(), leftRightPadding, getPaddingBottom());
}
public <T extends FloatingHeaderRow> T findFixedRowByType(Class<T> type) {
diff --git a/src/com/android/launcher3/allapps/PluginHeaderRow.java b/src/com/android/launcher3/allapps/PluginHeaderRow.java
index 5b5fbb7..a9d36d1 100644
--- a/src/com/android/launcher3/allapps/PluginHeaderRow.java
+++ b/src/com/android/launcher3/allapps/PluginHeaderRow.java
@@ -18,10 +18,8 @@
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
-import android.graphics.Rect;
import android.view.View;
-import com.android.launcher3.DeviceProfile;
import com.android.systemui.plugins.AllAppsRow;
/**
@@ -43,9 +41,6 @@
boolean tabsHidden) { }
@Override
- public void setInsets(Rect insets, DeviceProfile grid) { }
-
- @Override
public int getExpectedHeight() {
return mPlugin.getExpectedHeight();
}
diff --git a/src/com/android/launcher3/allapps/WorkEduCard.java b/src/com/android/launcher3/allapps/WorkEduCard.java
index 836cd5a..539cff1 100644
--- a/src/com/android/launcher3/allapps/WorkEduCard.java
+++ b/src/com/android/launcher3/allapps/WorkEduCard.java
@@ -15,6 +15,8 @@
*/
package com.android.launcher3.allapps;
+import static com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip.getTabWidth;
+
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
@@ -70,8 +72,6 @@
protected void onFinishInflate() {
super.onFinishInflate();
findViewById(R.id.action_btn).setOnClickListener(this);
- MarginLayoutParams lp = ((MarginLayoutParams) findViewById(R.id.wrapper).getLayoutParams());
- lp.width = mActivityContext.getAppsView().getFloatingHeaderView().getTabWidth();
}
@Override
@@ -87,14 +87,10 @@
}
@Override
- public void onAnimationRepeat(Animation animation) {
-
- }
+ public void onAnimationRepeat(Animation animation) { }
@Override
- public void onAnimationStart(Animation animation) {
-
- }
+ public void onAnimationStart(Animation animation) { }
private void removeCard() {
if (mPosition == -1) {
@@ -107,8 +103,14 @@
}
}
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ int size = MeasureSpec.getSize(widthMeasureSpec);
+ findViewById(R.id.wrapper).getLayoutParams().width = getTabWidth(getContext(), size);
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+
public void setPosition(int position) {
mPosition = position;
}
-
}
diff --git a/src/com/android/launcher3/allapps/WorkModeSwitch.java b/src/com/android/launcher3/allapps/WorkModeSwitch.java
index 733577e..aee7c4c 100644
--- a/src/com/android/launcher3/allapps/WorkModeSwitch.java
+++ b/src/com/android/launcher3/allapps/WorkModeSwitch.java
@@ -16,20 +16,23 @@
package com.android.launcher3.allapps;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TURN_OFF_WORK_APPS_TAP;
+import static com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip.getTabWidth;
import android.content.Context;
import android.graphics.Insets;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
-import android.view.ViewGroup;
+import android.view.ViewGroup.MarginLayoutParams;
import android.view.WindowInsets;
import android.widget.Button;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
+import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.KeyboardInsetAnimationCallback;
+import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.StringCache;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip;
@@ -50,7 +53,6 @@
private boolean mWorkEnabled;
private boolean mOnWorkTab;
-
public WorkModeSwitch(Context context) {
this(context, null, 0);
}
@@ -85,15 +87,39 @@
@Override
public void setInsets(Rect insets) {
- int bottomInset = insets.bottom - mInsets.bottom;
mInsets.set(insets);
- ViewGroup.MarginLayoutParams marginLayoutParams =
- (ViewGroup.MarginLayoutParams) getLayoutParams();
- if (marginLayoutParams != null) {
- marginLayoutParams.bottomMargin = bottomInset + marginLayoutParams.bottomMargin;
+ MarginLayoutParams lp = (MarginLayoutParams) getLayoutParams();
+ if (lp != null) {
+ int bottomMargin = getResources().getDimensionPixelSize(R.dimen.work_fab_margin_bottom);
+ if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
+ bottomMargin <<= 1; // Double margin to add space above search bar.
+ bottomMargin += getResources().getDimensionPixelSize(R.dimen.qsb_widget_height);
+ }
+
+ DeviceProfile dp = ActivityContext.lookupContext(getContext()).getDeviceProfile();
+ if (!dp.isGestureMode) {
+ if (dp.isTaskbarPresent) {
+ bottomMargin += dp.taskbarSize;
+ } else {
+ bottomMargin += insets.bottom;
+ }
+ }
+
+ lp.bottomMargin = bottomMargin;
}
}
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+ DeviceProfile dp = ActivityContext.lookupContext(getContext()).getDeviceProfile();
+ View parent = (View) getParent();
+ int size = parent.getWidth() - parent.getPaddingLeft() - parent.getPaddingRight()
+ - 2 * dp.allAppsLeftRightPadding;
+ int tabWidth = getTabWidth(getContext(), size);
+ int shift = (size - tabWidth) / 2 + dp.allAppsLeftRightPadding;
+ setTranslationX(Utilities.isRtl(getResources()) ? shift : -shift);
+ }
@Override
public void onActivePageChanged(int page) {
diff --git a/src/com/android/launcher3/allapps/WorkProfileManager.java b/src/com/android/launcher3/allapps/WorkProfileManager.java
index 5edd431..2f5b7a2 100644
--- a/src/com/android/launcher3/allapps/WorkProfileManager.java
+++ b/src/com/android/launcher3/allapps/WorkProfileManager.java
@@ -26,7 +26,6 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
-import android.view.ViewGroup;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
@@ -34,7 +33,6 @@
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
-import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip;
@@ -144,29 +142,6 @@
mWorkModeSwitch = (WorkModeSwitch) mAllApps.getLayoutInflater().inflate(
R.layout.work_mode_fab, mAllApps, false);
}
- ViewGroup.MarginLayoutParams lp =
- (ViewGroup.MarginLayoutParams) mWorkModeSwitch.getLayoutParams();
- int workFabMarginBottom =
- mWorkModeSwitch.getResources().getDimensionPixelSize(
- R.dimen.work_fab_margin_bottom);
- if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
- workFabMarginBottom <<= 1; // Double margin to add space above search bar.
- workFabMarginBottom +=
- mWorkModeSwitch.getResources().getDimensionPixelSize(R.dimen.qsb_widget_height);
- }
- if (!mAllApps.mActivityContext.getDeviceProfile().isGestureMode){
- if (mDeviceProfile.isTaskbarPresent){
- workFabMarginBottom += mDeviceProfile.taskbarSize;
- } else {
- workFabMarginBottom +=
- mAllApps.mActivityContext.getDeviceProfile().getInsets().bottom;
- }
- }
- lp.bottomMargin = workFabMarginBottom;
- int allAppsContainerWidth = mAllApps.getVisibleContainerView().getWidth();
- int personalWorkTabWidth =
- mAllApps.mActivityContext.getAppsView().getFloatingHeaderView().getTabWidth();
- lp.rightMargin = lp.leftMargin = (allAppsContainerWidth - personalWorkTabWidth) / 2;
if (mWorkModeSwitch.getParent() != mAllApps) {
mAllApps.addView(mWorkModeSwitch);
}
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index da5c4c2..4fd13b2 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -281,6 +281,13 @@
"ENABLE_CACHED_WIDGET", true,
"Show previously cached widgets as opposed to deferred widget where available");
+ public static final BooleanFlag USE_SEARCH_REQUEST_TIMEOUT_OVERRIDES = getDebugFlag(
+ "USE_SEARCH_REQUEST_TIMEOUT_OVERRIDES", false,
+ "Use local overrides for search request timeout");
+
+ public static final BooleanFlag CONTINUOUS_VIEW_TREE_CAPTURE = getDebugFlag(
+ "CONTINUOUS_VIEW_TREE_CAPTURE", false, "Capture View tree every frame");
+
public static void initialize(Context context) {
synchronized (sDebugFlags) {
for (DebugFlag flag : sDebugFlags) {
diff --git a/src/com/android/launcher3/model/GridSizeMigrationTaskV2.java b/src/com/android/launcher3/model/GridSizeMigrationTaskV2.java
index a7b0b9d..c25929a 100644
--- a/src/com/android/launcher3/model/GridSizeMigrationTaskV2.java
+++ b/src/com/android/launcher3/model/GridSizeMigrationTaskV2.java
@@ -110,9 +110,8 @@
private static boolean needsToMigrate(
DeviceGridState srcDeviceState, DeviceGridState destDeviceState) {
boolean needsToMigrate = !destDeviceState.isCompatible(srcDeviceState);
- // TODO(b/198965093): Revert this change after bug is fixed
if (needsToMigrate) {
- Log.d("b/198965093", "Migration is needed. destDeviceState: " + destDeviceState
+ Log.i(TAG, "Migration is needed. destDeviceState: " + destDeviceState
+ ", srcDeviceState: " + srcDeviceState);
}
return needsToMigrate;
diff --git a/src/com/android/launcher3/pageindicators/WorkspacePageIndicator.java b/src/com/android/launcher3/pageindicators/WorkspacePageIndicator.java
index 1681ea5..87ae890 100644
--- a/src/com/android/launcher3/pageindicators/WorkspacePageIndicator.java
+++ b/src/com/android/launcher3/pageindicators/WorkspacePageIndicator.java
@@ -271,7 +271,7 @@
} else {
lp.leftMargin = lp.rightMargin = 0;
lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
- lp.bottomMargin = grid.hotseatBarSizePx + insets.bottom;
+ lp.bottomMargin = grid.hotseatBarSizePx;
}
setLayoutParams(lp);
}
diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java
index af4fb26..0334b96 100644
--- a/src/com/android/launcher3/testing/TestInformationHandler.java
+++ b/src/com/android/launcher3/testing/TestInformationHandler.java
@@ -154,10 +154,6 @@
mDeviceProfile.isTwoPanels);
return response;
- case TestProtocol.REQUEST_SET_FORCE_PAUSE_TIMEOUT:
- TestProtocol.sForcePauseTimeout = Long.parseLong(arg);
- return response;
-
case TestProtocol.REQUEST_GET_HAD_NONTEST_EVENTS:
response.putBoolean(
TestProtocol.TEST_INFO_RESPONSE_FIELD, TestLogging.sHadEventsNotFromTest);
@@ -210,7 +206,7 @@
/* spanX= */ 1, /* spanY= */ 1);
// TODO(b/234322284): return the real center point.
return new Point(cellRect.left + (cellRect.right - cellRect.left) / 3,
- cellRect.centerY());
+ cellRect.top + (cellRect.bottom - cellRect.top) / 3);
});
}
diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java
index ca824e3..9bc9067 100644
--- a/src/com/android/launcher3/testing/TestProtocol.java
+++ b/src/com/android/launcher3/testing/TestProtocol.java
@@ -124,9 +124,6 @@
public static final String REQUEST_GET_OVERVIEW_PAGE_SPACING = "get-overview-page-spacing";
public static final String REQUEST_ENABLE_ROTATION = "enable_rotation";
- public static Long sForcePauseTimeout;
- public static final String REQUEST_SET_FORCE_PAUSE_TIMEOUT = "set-force-pause-timeout";
-
public static boolean sDebugTracing = false;
public static final String REQUEST_ENABLE_DEBUG_TRACING = "enable-debug-tracing";
public static final String REQUEST_DISABLE_DEBUG_TRACING = "disable-debug-tracing";
diff --git a/src/com/android/launcher3/util/DisplayController.java b/src/com/android/launcher3/util/DisplayController.java
index 1a77674..15fe1d9 100644
--- a/src/com/android/launcher3/util/DisplayController.java
+++ b/src/com/android/launcher3/util/DisplayController.java
@@ -66,6 +66,7 @@
public class DisplayController implements ComponentCallbacks, SafeCloseable {
private static final String TAG = "DisplayController";
+ private static final boolean DEBUG = false;
public static final MainThreadInitializedObject<DisplayController> INSTANCE =
new MainThreadInitializedObject<>(DisplayController::new);
@@ -243,10 +244,9 @@
|| !newInfo.mPerDisplayBounds.equals(oldInfo.mPerDisplayBounds)) {
change |= CHANGE_SUPPORTED_BOUNDS;
}
- Log.d("b/198965093", "handleInfoChange"
- + "\n\tchange: 0b" + Integer.toBinaryString(change)
- + "\n\tConfiguration diff: 0x" + Integer.toHexString(
- newInfo.mConfiguration.diff(oldInfo.mConfiguration)));
+ if (DEBUG) {
+ Log.d(TAG, "handleInfoChange - change: 0b" + Integer.toBinaryString(change));
+ }
if (change != 0) {
mInfo = newInfo;
@@ -286,9 +286,6 @@
private final ArrayMap<CachedDisplayInfo, WindowBounds[]> mPerDisplayBounds =
new ArrayMap<>();
- // TODO(b/198965093): Remove after investigation
- private Configuration mConfiguration;
-
public Info(Context displayInfoContext) {
/* don't need system overrides for external displays */
this(displayInfoContext, new WindowManagerProxy(), new ArrayMap<>());
@@ -310,21 +307,18 @@
mScreenSizeDp = new PortraitSize(config.screenHeightDp, config.screenWidthDp);
navigationMode = parseNavigationMode(displayInfoContext);
- // TODO(b/198965093): Remove after investigation
- mConfiguration = config;
-
mPerDisplayBounds.putAll(perDisplayBoundsCache);
WindowBounds[] cachedValue = mPerDisplayBounds.get(normalizedDisplayInfo);
WindowBounds realBounds = wmProxy.getRealBounds(displayInfoContext, displayInfo);
if (cachedValue == null) {
// Unexpected normalizedDisplayInfo is found, recreate the cache
- Log.e("b/198965093", "Unexpected normalizedDisplayInfo found, invalidating cache");
+ Log.e(TAG, "Unexpected normalizedDisplayInfo found, invalidating cache");
mPerDisplayBounds.clear();
mPerDisplayBounds.putAll(wmProxy.estimateInternalDisplayBounds(displayInfoContext));
cachedValue = mPerDisplayBounds.get(normalizedDisplayInfo);
if (cachedValue == null) {
- Log.e("b/198965093", "normalizedDisplayInfo not found in estimation: "
+ Log.e(TAG, "normalizedDisplayInfo not found in estimation: "
+ normalizedDisplayInfo);
supportedBounds.add(realBounds);
}
@@ -342,12 +336,13 @@
}
mPerDisplayBounds.values().forEach(
windowBounds -> Collections.addAll(supportedBounds, windowBounds));
- Log.e("b/198965093", "mConfiguration: " + mConfiguration);
- Log.d("b/198965093", "displayInfo: " + displayInfo);
- Log.d("b/198965093", "realBounds: " + realBounds);
- Log.d("b/198965093", "normalizedDisplayInfo: " + normalizedDisplayInfo);
- mPerDisplayBounds.forEach((key, value) -> Log.d("b/198965093",
- "perDisplayBounds - " + key + ": " + Arrays.deepToString(value)));
+ if (DEBUG) {
+ Log.d(TAG, "displayInfo: " + displayInfo);
+ Log.d(TAG, "realBounds: " + realBounds);
+ Log.d(TAG, "normalizedDisplayInfo: " + normalizedDisplayInfo);
+ mPerDisplayBounds.forEach((key, value) -> Log.d(TAG,
+ "perDisplayBounds - " + key + ": " + Arrays.deepToString(value)));
+ }
}
/**
diff --git a/src/com/android/launcher3/util/ViewCapture.java b/src/com/android/launcher3/util/ViewCapture.java
new file mode 100644
index 0000000..140971b
--- /dev/null
+++ b/src/com/android/launcher3/util/ViewCapture.java
@@ -0,0 +1,212 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3.util;
+
+import android.content.res.Resources;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.SystemClock;
+import android.os.Trace;
+import android.util.Base64;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewTreeObserver.OnDrawListener;
+
+import androidx.annotation.UiThread;
+
+import com.android.launcher3.view.ViewCaptureData.ExportedData;
+import com.android.launcher3.view.ViewCaptureData.FrameData;
+import com.android.launcher3.view.ViewCaptureData.ViewNode;
+
+import java.util.concurrent.FutureTask;
+
+/**
+ * Utility class for capturing view data every frame
+ */
+public class ViewCapture implements OnDrawListener {
+
+ private static final String TAG = "ViewCapture";
+
+ private static final int MEMORY_SIZE = 2000;
+
+ private final View mRoot;
+ private final long[] mFrameTimes = new long[MEMORY_SIZE];
+ private final Node[] mNodes = new Node[MEMORY_SIZE];
+
+ private int mFrameIndex = -1;
+
+ /**
+ * @param root the root view for the capture data
+ */
+ public ViewCapture(View root) {
+ mRoot = root;
+ }
+
+ @Override
+ public void onDraw() {
+ Trace.beginSection("view_capture");
+ long now = SystemClock.elapsedRealtimeNanos();
+
+ mFrameIndex++;
+ if (mFrameIndex >= MEMORY_SIZE) {
+ mFrameIndex = 0;
+ }
+ mFrameTimes[mFrameIndex] = now;
+ mNodes[mFrameIndex] = captureView(mRoot, mNodes[mFrameIndex]);
+ Trace.endSection();
+ }
+
+ /**
+ * Creates a proto of all the data captured so far.
+ */
+ public String dumpToString() {
+ Handler handler = mRoot.getHandler();
+ if (handler == null) {
+ handler = Executors.MAIN_EXECUTOR.getHandler();
+ }
+ FutureTask<ExportedData> task = new FutureTask<>(this::dumpToProtoUI);
+ if (Looper.myLooper() == handler.getLooper()) {
+ task.run();
+ } else {
+ handler.post(task);
+ }
+ try {
+ return Base64.encodeToString(task.get().toByteArray(),
+ Base64.NO_CLOSE | Base64.NO_PADDING | Base64.NO_WRAP);
+ } catch (Exception e) {
+ Log.e(TAG, "Error capturing proto", e);
+ return "--error--";
+ }
+ }
+
+ @UiThread
+ private ExportedData dumpToProtoUI() {
+ ExportedData.Builder dataBuilder = ExportedData.newBuilder();
+ Resources res = mRoot.getResources();
+
+ int size = (mNodes[MEMORY_SIZE - 1] == null) ? mFrameIndex + 1 : MEMORY_SIZE;
+ for (int i = size - 1; i >= 0; i--) {
+ int index = (MEMORY_SIZE + mFrameIndex - i) % MEMORY_SIZE;
+ dataBuilder.addFrameData(FrameData.newBuilder()
+ .setNode(mNodes[index].toProto(res))
+ .setTimestamp(mFrameTimes[index]));
+ }
+ return dataBuilder.build();
+ }
+
+ private Node captureView(View view, Node recycle) {
+ Node result = recycle == null ? new Node() : recycle;
+
+ result.clazz = view.getClass();
+ result.hashCode = view.hashCode();
+ result.id = view.getId();
+ result.left = view.getLeft();
+ result.top = view.getTop();
+ result.right = view.getRight();
+ result.bottom = view.getBottom();
+ result.scrollX = view.getScrollX();
+ result.scrollY = view.getScrollY();
+
+ result.translateX = view.getTranslationX();
+ result.translateY = view.getTranslationY();
+ result.scaleX = view.getScaleX();
+ result.scaleY = view.getScaleY();
+ result.alpha = view.getAlpha();
+
+ result.visibility = view.getVisibility();
+ result.willNotDraw = view.willNotDraw();
+
+ if (view instanceof ViewGroup) {
+ ViewGroup parent = (ViewGroup) view;
+ result.clipChildren = parent.getClipChildren();
+ int childCount = parent.getChildCount();
+ if (childCount == 0) {
+ result.children = null;
+ } else {
+ result.children = captureView(parent.getChildAt(0), result.children);
+ Node lastChild = result.children;
+ for (int i = 1; i < childCount; i++) {
+ lastChild.sibling = captureView(parent.getChildAt(i), lastChild.sibling);
+ lastChild = lastChild.sibling;
+ }
+ lastChild.sibling = null;
+ }
+ } else {
+ result.clipChildren = false;
+ result.children = null;
+ }
+ return result;
+ }
+
+ private static class Node {
+
+ // We store reference in memory to avoid generating and storing too many strings
+ public Class clazz;
+ public int hashCode;
+
+ public int id;
+ public int left, top, right, bottom;
+ public int scrollX, scrollY;
+
+ public float translateX, translateY;
+ public float scaleX, scaleY;
+ public float alpha;
+
+ public int visibility;
+ public boolean willNotDraw;
+ public boolean clipChildren;
+
+ public Node sibling;
+ public Node children;
+
+ public ViewNode toProto(Resources res) {
+ String resolvedId;
+ if (id >= 0) {
+ try {
+ resolvedId = res.getResourceTypeName(id) + '/' + res.getResourceEntryName(id);
+ } catch (Resources.NotFoundException e) {
+ resolvedId = "id/" + "0x" + Integer.toHexString(id).toUpperCase();
+ }
+ } else {
+ resolvedId = "NO_ID";
+ }
+
+ ViewNode.Builder result = ViewNode.newBuilder()
+ .setClassname(clazz.getName() + "@" + hashCode)
+ .setId(resolvedId)
+ .setLeft(left)
+ .setTop(top)
+ .setWidth(right - left)
+ .setHeight(bottom - top)
+ .setTranslationX(translateX)
+ .setTranslationY(translateY)
+ .setScaleX(scaleX)
+ .setScaleY(scaleY)
+ .setAlpha(alpha)
+ .setVisibility(visibility)
+ .setWillNotDraw(willNotDraw)
+ .setClipChildren(clipChildren);
+ Node child = children;
+ while (child != null) {
+ result.addChildren(child.toProto(res));
+ child = child.sibling;
+ }
+ return result.build();
+ }
+
+ }
+}
diff --git a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
index 11185fb..49db2a0 100644
--- a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
+++ b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
@@ -23,7 +23,9 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import com.android.launcher3.DeviceProfile;
import com.android.launcher3.pageindicators.PageIndicator;
+import com.android.launcher3.views.ActivityContext;
/**
* Supports two indicator colors, dedicated for personal and work tabs.
@@ -72,6 +74,26 @@
return false;
}
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ if (getPaddingLeft() == 0 && getPaddingRight() == 0) {
+ // If any padding is not specified, restrict the width to emulate padding
+ int size = MeasureSpec.getSize(widthMeasureSpec);
+ size = getTabWidth(getContext(), size);
+ widthMeasureSpec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY);
+ }
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+
+ /**
+ * Returns distance between left and right app icons
+ */
+ public static int getTabWidth(Context context, int totalWidth) {
+ DeviceProfile grid = ActivityContext.lookupContext(context).getDeviceProfile();
+ int iconPadding = totalWidth / grid.numShownAllAppsColumns - grid.allAppsIconSizePx;
+ return totalWidth - iconPadding;
+ }
+
/**
* Interface definition for a callback to be invoked when an active page has been changed.
*/
diff --git a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
index 6a6c40f..0635d84 100644
--- a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
+++ b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
@@ -112,6 +112,8 @@
).toTypedArray()
hotseatBorderSpaces = FloatArray(4) { 16f }
hotseatColumnSpan = IntArray(4) { 4 }
+ hotseatBarBottomSpace = FloatArray(4) { 48f }
+ hotseatQsbSpace = FloatArray(4) { 36f }
iconSize = FloatArray(4) { 56f }
allAppsIconSize = FloatArray(4) { 56f }
iconTextSize = FloatArray(4) { 14f }
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index ae7c46a..a5f8cf2 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -84,7 +84,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -101,7 +100,6 @@
private static final String TAG = "Tapl";
private static final int ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME = 15;
private static final int GESTURE_STEP_MS = 16;
- private static final long FORCE_PAUSE_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(2);
static final Pattern EVENT_TOUCH_DOWN = getTouchEventPattern("ACTION_DOWN");
static final Pattern EVENT_TOUCH_UP = getTouchEventPattern("ACTION_UP");
@@ -362,10 +360,6 @@
return getRealDisplaySize().x / 2f;
}
- private void setForcePauseTimeout(long timeout) {
- getTestInfo(TestProtocol.REQUEST_SET_FORCE_PAUSE_TIMEOUT, Long.toString(timeout));
- }
-
public void setEnableRotation(boolean on) {
getTestInfo(TestProtocol.REQUEST_ENABLE_ROTATION, Boolean.toString(on));
}
@@ -886,7 +880,6 @@
final String action;
if (getNavigationModel() == NavigationModel.ZERO_BUTTON) {
checkForAnomaly(false, true);
- setForcePauseTimeout(FORCE_PAUSE_TIMEOUT_MS);
final Point displaySize = getRealDisplaySize();
// The swipe up to home gesture starts from inside the launcher when the user is