Merge "Import translations. DO NOT MERGE ANYWHERE" into tm-dev
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
index 6bc2a93..d5c399b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
@@ -75,4 +75,15 @@
public void hideAllApps() {
mControllers.taskbarAllAppsController.hide();
}
+
+ /**
+ * User expands PiP to full-screen (or split-screen) mode, try to hide the Taskbar.
+ */
+ public void onExpandPip() {
+ if (mControllers != null) {
+ final TaskbarStashController stashController = mControllers.taskbarStashController;
+ stashController.updateStateForFlag(TaskbarStashController.FLAG_IN_APP, true);
+ stashController.applyState();
+ }
+ }
}
diff --git a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
index d76484c..a62e9d1 100644
--- a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
@@ -186,6 +186,7 @@
} else {
recentsCallback = callback;
}
+ mRecentsView.cleanupRemoteTargets();
mRecentsAnimationController.finish(
mAppCanEnterPip /* toRecents */, recentsCallback, true /* sendUserLeaveHint */);
}
diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
index e9571e0..50d1244 100644
--- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
+++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
@@ -239,6 +239,7 @@
@Override
protected void finishRecentsControllerToHome(Runnable callback) {
+ mRecentsView.cleanupRemoteTargets();
mRecentsAnimationController.finish(
true /* toRecents */, callback, true /* sendUserLeaveHint */);
}
diff --git a/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java b/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
index d79b946..7556bf4 100644
--- a/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
+++ b/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
@@ -325,7 +325,7 @@
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
- if (mTutorialController != null) {
+ if (mTutorialController != null && !isGestureComplete()) {
mTutorialController.hideFeedback();
}
// Note: Using logical-or to ensure both functions get called.
diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
index f3ad0f6..ee69fc3 100644
--- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
+++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
@@ -111,7 +111,7 @@
if (mInitialTaskIntent != null) {
fillInIntent = new Intent();
if (TextUtils.equals(mInitialTaskIntent.getComponent().getPackageName(),
- task.topActivity.getPackageName())) {
+ task.getTopComponent().getPackageName())) {
fillInIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
}
} else {
diff --git a/quickstep/src/com/android/quickstep/views/FloatingTaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/FloatingTaskThumbnailView.java
index 98e50f6..d869fed 100644
--- a/quickstep/src/com/android/quickstep/views/FloatingTaskThumbnailView.java
+++ b/quickstep/src/com/android/quickstep/views/FloatingTaskThumbnailView.java
@@ -62,6 +62,7 @@
// Scale down the bitmap to fix x, and crop in y.
float scale = 1.0f * getMeasuredWidth() / mBitmap.getWidth();
+ mMatrix.reset();
mMatrix.postScale(scale, scale);
mBitmapShader.setLocalMatrix(mMatrix);
diff --git a/quickstep/src/com/android/quickstep/views/FloatingTaskView.java b/quickstep/src/com/android/quickstep/views/FloatingTaskView.java
index 93a3a9f..fe5e1d0 100644
--- a/quickstep/src/com/android/quickstep/views/FloatingTaskView.java
+++ b/quickstep/src/com/android/quickstep/views/FloatingTaskView.java
@@ -91,6 +91,8 @@
// Copy bounds of exiting thumbnail into ImageView
mThumbnailView.setThumbnail(thumbnail);
+ mThumbnailView.setVisibility(VISIBLE);
+
RecentsView recentsView = launcher.getOverviewPanel();
mOrientationHandler = recentsView.getPagedOrientationHandler();
mSplitPlaceholderView.setIcon(icon,
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 395bfb1..22491bc 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -4283,7 +4283,7 @@
}
mPendingAnimation.addEndListener(isSuccess -> {
if (isSuccess) {
- if (tv.getTaskIds()[1] != -1) {
+ if (tv.getTaskIds()[1] != -1 && mRemoteTargetHandles != null) {
// TODO(b/194414938): make this part of the animations instead.
TaskViewUtils.createSplitAuxiliarySurfacesAnimator(
mRemoteTargetHandles[0].getTransformParams().getTargetSet().nonApps,
@@ -5104,6 +5104,19 @@
mRecentsView.mPipCornerRadius = cornerRadius;
}
}
+
+ @Override
+ public void onExpandPip() {
+ MAIN_EXECUTOR.execute(() -> {
+ if (mRecentsView == null
+ || mRecentsView.mSizeStrategy.getTaskbarController() == null) {
+ return;
+ }
+ // Hide the task bar when leaving PiP to prevent it from flickering once
+ // the app settles in full-screen mode.
+ mRecentsView.mSizeStrategy.getTaskbarController().onExpandPip();
+ });
+ }
}
/** Get the color used for foreground scrimming the RecentsView for sharing. */
diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
index 11f9ddd..bff8651 100644
--- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -50,7 +50,6 @@
import com.android.launcher3.BaseActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Utilities;
-import com.android.launcher3.icons.BitmapRenderer;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.SystemUiController;
import com.android.quickstep.TaskOverlayFactory.TaskOverlay;
@@ -162,23 +161,6 @@
setThumbnail(task, thumbnailData, true /* refreshNow */);
}
- /**
- * By combining the two in a single bitmap then we only have to do a single draw
- * call in the onDraw function. Also, this fixes a bug where the background was
- * visible in the corners because of anti-aliasing.
- */
- public Bitmap combineThumbnailAndBackground(Bitmap bm) {
- return BitmapRenderer.createHardwareBitmap(bm.getWidth(), bm.getHeight(), c -> {
- final boolean drawBackgroundOnly = mTask == null || mTask.isLocked;
- if (drawBackgroundOnly) {
- c.drawPaint(mBackgroundPaint);
- } else {
- c.drawPaint(mBackgroundPaint);
- c.drawBitmap(bm, 0, 0, null);
- }
- });
- }
-
/** Updates the shader, paint, matrix to redraw. */
public void refresh() {
refresh(false);
@@ -191,7 +173,6 @@
private void refresh(boolean shouldRefreshOverlay) {
if (mThumbnailData != null && mThumbnailData.thumbnail != null) {
Bitmap bm = mThumbnailData.thumbnail;
- bm = combineThumbnailAndBackground(bm);
bm.prepareToDraw();
mBitmapShader = new BitmapShader(bm, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
mPaint.setShader(mBitmapShader);
@@ -213,6 +194,7 @@
* <p>
* If dimAlpha is 0, no dimming is applied; if dimAlpha is 1, the thumbnail will be the
* extracted background color.
+ *
*/
public void setDimAlpha(float dimAlpha) {
mDimAlpha = dimAlpha;
@@ -314,6 +296,19 @@
return;
}
}
+
+ // Always draw the background since the snapshots might be translucent or partially empty
+ // (For example, tasks been reparented out of dismissing split root when drag-to-dismiss
+ // split screen).
+ canvas.drawRoundRect(x, y + 1, width, height - 1, cornerRadius,
+ cornerRadius, mBackgroundPaint);
+
+ final boolean drawBackgroundOnly = mTask == null || mTask.isLocked || mBitmapShader == null
+ || mThumbnailData == null;
+ if (drawBackgroundOnly) {
+ return;
+ }
+
canvas.drawRoundRect(x, y, width, height, cornerRadius, cornerRadius, mPaint);
}
@@ -344,6 +339,7 @@
private void updateThumbnailPaintFilter() {
ColorFilter filter = getColorFilter(mDimAlpha);
+ mBackgroundPaint.setColorFilter(filter);
int alpha = (int) (mDimAlpha * 255);
mDimmingPaintAfterClearing.setAlpha(alpha);
if (mBitmapShader != null) {
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 009ee27..0c33bce 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -982,8 +982,17 @@
*/
public Rect getHotseatLayoutPadding(Context context) {
if (isVerticalBarLayout()) {
- int paddingTop = Math.max(mInsets.top - cellLayoutPaddingPx.top, 0);
- int paddingBottom = Math.max(mInsets.bottom - cellLayoutPaddingPx.bottom, 0);
+ // The hotseat icons will be placed in the middle of the hotseat cells.
+ // Changing the hotseatCellHeightPx is not affecting hotseat icon positions
+ // in vertical bar layout.
+ // Workspace icons are moved up by a small factor. The variable diffOverlapFactor
+ // is set to account for that difference.
+ float diffOverlapFactor = iconSizePx * (ICON_OVERLAP_FACTOR - 1) / 2;
+ int paddingTop = Math.max((int) (mInsets.top + cellLayoutPaddingPx.top
+ - diffOverlapFactor), 0);
+ int paddingBottom = Math.max((int) (mInsets.bottom + cellLayoutPaddingPx.bottom
+ + diffOverlapFactor), 0);
+
if (isSeascape()) {
mHotseatPadding.set(mInsets.left + hotseatBarSidePaddingStartPx, paddingTop,
hotseatBarSidePaddingEndPx, paddingBottom);
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 2f9b563..1cead11 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -651,7 +651,7 @@
mDragLayer.onOneHandedModeStateChanged(activated);
}
- private void initDeviceProfile(InvariantDeviceProfile idp) {
+ protected void initDeviceProfile(InvariantDeviceProfile idp) {
// Load configuration-specific DeviceProfile
mDeviceProfile = idp.getDeviceProfile(this);
if (isInMultiWindowMode()) {
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index be2cd88..baee49f 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -16,6 +16,7 @@
package com.android.launcher3;
import static com.android.launcher3.anim.Interpolators.ACCEL_2;
+import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_OVERVIEW;
import static com.android.launcher3.testing.TestProtocol.ALL_APPS_STATE_ORDINAL;
@@ -91,6 +92,14 @@
}
};
+ protected static final PageTranslationProvider DEFAULT_PAGE_TRANSLATION_PROVIDER =
+ new PageTranslationProvider(DEACCEL_2) {
+ @Override
+ public float getPageTranslation(int pageIndex) {
+ return 0;
+ }
+ };
+
private static final LauncherState[] sAllStates = new LauncherState[10];
/**
@@ -288,6 +297,25 @@
};
}
+ /**
+ * Gets the translation provider for workspace pages.
+ */
+ public PageTranslationProvider getWorkspacePageTranslationProvider(Launcher launcher) {
+ if (this != SPRING_LOADED || !launcher.getDeviceProfile().isTwoPanels) {
+ return DEFAULT_PAGE_TRANSLATION_PROVIDER;
+ }
+ final float quarterPageSpacing = launcher.getWorkspace().getPageSpacing() / 4f;
+ return new PageTranslationProvider(DEACCEL_2) {
+ @Override
+ public float getPageTranslation(int pageIndex) {
+ boolean isRtl = launcher.getWorkspace().mIsRtl;
+ boolean isFirstPage = pageIndex % 2 == 0;
+ return ((isFirstPage && !isRtl) || (!isFirstPage && isRtl)) ? -quarterPageSpacing
+ : quarterPageSpacing;
+ }
+ };
+ }
+
@Override
public LauncherState getHistoryForState(LauncherState previousState) {
// No history is supported
@@ -318,6 +346,23 @@
public abstract float getPageAlpha(int pageIndex);
}
+ /**
+ * Provider for the translation and animation interpolation of workspace pages.
+ */
+ public abstract static class PageTranslationProvider {
+
+ public final Interpolator interpolator;
+
+ public PageTranslationProvider(Interpolator interpolator) {
+ this.interpolator = interpolator;
+ }
+
+ /**
+ * Gets the translation of the workspace page at the provided page index.
+ */
+ public abstract float getPageTranslation(int pageIndex);
+ }
+
public static class ScaleAndTranslation {
public float scale;
public float translationX;
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index d94e84c..1e09b2d 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -39,6 +39,7 @@
import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_TRANSLATE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_SCRIM_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_FADE;
+import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_PAGE_TRANSLATE_X;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCALE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_TRANSLATE;
import static com.android.launcher3.states.StateAnimationConfig.SKIP_SCRIM;
@@ -49,6 +50,7 @@
import android.view.animation.Interpolator;
import com.android.launcher3.LauncherState.PageAlphaProvider;
+import com.android.launcher3.LauncherState.PageTranslationProvider;
import com.android.launcher3.LauncherState.ScaleAndTranslation;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.anim.PropertySetter;
@@ -155,6 +157,12 @@
scaleAndTranslation.translationX, translationInterpolator);
propertySetter.setFloat(mWorkspace, VIEW_TRANSLATE_Y,
scaleAndTranslation.translationY, translationInterpolator);
+ PageTranslationProvider pageTranslationProvider = state.getWorkspacePageTranslationProvider(
+ mLauncher);
+ for (int i = 0; i < childCount; i++) {
+ applyPageTranslation((CellLayout) mWorkspace.getChildAt(i), i, pageTranslationProvider,
+ propertySetter, config);
+ }
Interpolator hotseatTranslationInterpolator = config.getInterpolator(
ANIM_HOTSEAT_TRANSLATE, translationInterpolator);
@@ -202,6 +210,16 @@
pageAlpha, fadeInterpolator);
}
+ private void applyPageTranslation(CellLayout cellLayout, int childIndex,
+ PageTranslationProvider pageTranslationProvider, PropertySetter propertySetter,
+ StateAnimationConfig config) {
+ float pageTranslation = pageTranslationProvider.getPageTranslation(childIndex);
+ Interpolator translationInterpolator = config.getInterpolator(
+ ANIM_WORKSPACE_PAGE_TRANSLATE_X, pageTranslationProvider.interpolator);
+ propertySetter.setFloat(cellLayout, VIEW_TRANSLATE_X, pageTranslation,
+ translationInterpolator);
+ }
+
/**
* Returns a spring based animator for the scale property of {@param workspace}.
*/
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index 16264da..7687fea 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -84,7 +84,7 @@
private final ArrayList<AdapterItem> mSearchResults = new ArrayList<>();
private BaseAllAppsAdapter<T> mAdapter;
private AppInfoComparator mAppNameComparator;
- private final int mNumAppsPerRow;
+ private final int mNumAppsPerRowAllApps;
private int mNumAppRowsInAdapter;
private ItemInfoMatcher mItemFilter;
@@ -94,7 +94,7 @@
mActivityContext = ActivityContext.lookupContext(context);
mAppNameComparator = new AppInfoComparator(context);
mWorkAdapterProvider = adapterProvider;
- mNumAppsPerRow = mActivityContext.getDeviceProfile().inv.numColumns;
+ mNumAppsPerRowAllApps = mActivityContext.getDeviceProfile().inv.numAllAppsColumns;
mAllAppsStore.addUpdateListener(this);
}
@@ -336,7 +336,7 @@
}
}
- if (mNumAppsPerRow != 0) {
+ if (mNumAppsPerRowAllApps != 0) {
// Update the number of rows in the adapter after we do all the merging (otherwise, we
// would have to shift the values again)
int numAppsInSection = 0;
@@ -344,10 +344,10 @@
int rowIndex = -1;
for (AdapterItem item : mAdapterItems) {
item.rowIndex = 0;
- if (AllAppsGridAdapter.isDividerViewType(item.viewType)) {
+ if (BaseAllAppsAdapter.isDividerViewType(item.viewType)) {
numAppsInSection = 0;
- } else if (AllAppsGridAdapter.isIconViewType(item.viewType)) {
- if (numAppsInSection % mNumAppsPerRow == 0) {
+ } else if (BaseAllAppsAdapter.isIconViewType(item.viewType)) {
+ if (numAppsInSection % mNumAppsPerRowAllApps == 0) {
numAppsInRow = 0;
rowIndex++;
}
@@ -365,12 +365,13 @@
float rowFraction = 1f / mNumAppRowsInAdapter;
for (FastScrollSectionInfo info : mFastScrollerSections) {
AdapterItem item = info.fastScrollToItem;
- if (!AllAppsGridAdapter.isIconViewType(item.viewType)) {
+ if (!BaseAllAppsAdapter.isIconViewType(item.viewType)) {
info.touchFraction = 0f;
continue;
}
- float subRowFraction = item.rowAppIndex * (rowFraction / mNumAppsPerRow);
+ float subRowFraction =
+ item.rowAppIndex * (rowFraction / mNumAppsPerRowAllApps);
info.touchFraction = item.rowIndex * rowFraction + subRowFraction;
}
break;
@@ -379,7 +380,7 @@
float cumulativeTouchFraction = 0f;
for (FastScrollSectionInfo info : mFastScrollerSections) {
AdapterItem item = info.fastScrollToItem;
- if (!AllAppsGridAdapter.isIconViewType(item.viewType)) {
+ if (!BaseAllAppsAdapter.isIconViewType(item.viewType)) {
info.touchFraction = 0f;
continue;
}
diff --git a/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java b/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java
index 1d1960d..976284d 100644
--- a/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java
+++ b/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java
@@ -163,10 +163,10 @@
protected String mEmptySearchMessage;
protected int mAppsPerRow;
- private final LayoutInflater mLayoutInflater;
- private final OnClickListener mOnIconClickListener;
- private OnLongClickListener mOnIconLongClickListener = INSTANCE_ALL_APPS;
- private OnFocusChangeListener mIconFocusListener;
+ protected final LayoutInflater mLayoutInflater;
+ protected final OnClickListener mOnIconClickListener;
+ protected OnLongClickListener mOnIconLongClickListener = INSTANCE_ALL_APPS;
+ protected OnFocusChangeListener mIconFocusListener;
// The click listener to send off to the market app, updated each time the search query changes.
private OnClickListener mMarketSearchClickListener;
private final int mExtraHeight;
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index 8ba2070..7727fae 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -259,7 +259,7 @@
"Enable the new grid migration logic, keeping pages when src < dest");
public static final BooleanFlag ENABLE_ONE_SEARCH_MOTION = new DeviceFlag(
- "ENABLE_ONE_SEARCH_MOTION", false, "Enables animations in OneSearch.");
+ "ENABLE_ONE_SEARCH_MOTION", true, "Enables animations in OneSearch.");
public static void initialize(Context context) {
synchronized (sDebugFlags) {
diff --git a/src/com/android/launcher3/states/StateAnimationConfig.java b/src/com/android/launcher3/states/StateAnimationConfig.java
index bd6f7d3..f04e685 100644
--- a/src/com/android/launcher3/states/StateAnimationConfig.java
+++ b/src/com/android/launcher3/states/StateAnimationConfig.java
@@ -62,6 +62,7 @@
ANIM_OVERVIEW_MODAL,
ANIM_DEPTH,
ANIM_OVERVIEW_ACTIONS_FADE,
+ ANIM_WORKSPACE_PAGE_TRANSLATE_X,
})
@Retention(RetentionPolicy.SOURCE)
public @interface AnimType {}
@@ -80,8 +81,9 @@
public static final int ANIM_OVERVIEW_MODAL = 12;
public static final int ANIM_DEPTH = 13;
public static final int ANIM_OVERVIEW_ACTIONS_FADE = 14;
+ public static final int ANIM_WORKSPACE_PAGE_TRANSLATE_X = 15;
- private static final int ANIM_TYPES_COUNT = 15;
+ private static final int ANIM_TYPES_COUNT = 16;
protected final Interpolator[] mInterpolators = new Interpolator[ANIM_TYPES_COUNT];