Snap for 9581790 from fcb6a5fc064ccfc97caeb7fff7a05c823167f4cd to tm-qpr3-release
Change-Id: Ie90b017e9167e00fc6755ce00ea4adb52b4db0a8
diff --git a/build.gradle b/build.gradle
index 68ed73d..090bafe 100644
--- a/build.gradle
+++ b/build.gradle
@@ -147,6 +147,7 @@
implementation "androidx.recyclerview:recyclerview:${ANDROID_X_VERSION}"
implementation "androidx.preference:preference:${ANDROID_X_VERSION}"
implementation project(':IconLoader')
+ implementation project(':UiTestsLibLauncher')
withQuickstepImplementation project(':SharedLibWrapper')
// Recents lib dependency
diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java
index 2200b35..139e923 100644
--- a/quickstep/src/com/android/quickstep/SystemUiProxy.java
+++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java
@@ -628,14 +628,20 @@
}
}
- public void startIntentsWithLegacyTransition(PendingIntent pendingIntent1, Bundle options1,
- PendingIntent pendingIntent2, Bundle options2,
- @SplitConfigurationOptions.StagePosition int sidePosition, float splitRatio,
- RemoteAnimationAdapter adapter, InstanceId instanceId) {
+ /**
+ * Starts a pair of intents or shortcuts in split-screen using legacy transition. Passing a
+ * non-null shortcut info means to start the app as a shortcut.
+ */
+ public void startIntentsWithLegacyTransition(PendingIntent pendingIntent1,
+ @Nullable ShortcutInfo shortcutInfo1, @Nullable Bundle options1,
+ PendingIntent pendingIntent2, @Nullable ShortcutInfo shortcutInfo2,
+ @Nullable Bundle options2, @SplitConfigurationOptions.StagePosition int sidePosition,
+ float splitRatio, RemoteAnimationAdapter adapter, InstanceId instanceId) {
if (mSystemUiProxy != null) {
try {
- mSplitScreen.startIntentsWithLegacyTransition(pendingIntent1, options1,
- pendingIntent2, options2, sidePosition, splitRatio, adapter, instanceId);
+ mSplitScreen.startIntentsWithLegacyTransition(pendingIntent1, shortcutInfo1,
+ options1, pendingIntent2, shortcutInfo2, options2, sidePosition, splitRatio,
+ adapter, instanceId);
} catch (RemoteException e) {
Log.w(TAG, "Failed call startIntentsWithLegacyTransition");
}
diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
index e5d54d7..1b2bfc9 100644
--- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
+++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
@@ -261,8 +261,9 @@
getOppositeStagePosition(stagePosition), splitRatio, adapter,
shellInstanceId);
} else {
- mSystemUiProxy.startIntentsWithLegacyTransition(getPendingIntent(intent1),
- options1.toBundle(), getPendingIntent(intent2), null /* options2 */,
+ mSystemUiProxy.startIntentsWithLegacyTransition(
+ getPendingIntent(intent1), getShortcutInfo(intent1), options1.toBundle(),
+ getPendingIntent(intent2), getShortcutInfo(intent2), null /* options2 */,
stagePosition, splitRatio, adapter, shellInstanceId);
}
}
@@ -271,15 +272,13 @@
private void launchIntentOrShortcut(Intent intent, ActivityOptions options1, int taskId,
@StagePosition int stagePosition, float splitRatio, RemoteTransition remoteTransition,
@Nullable InstanceId shellInstanceId) {
- PendingIntent pendingIntent = getPendingIntent(intent);
- final ShortcutInfo shortcutInfo = getShortcutInfo(intent,
- pendingIntent.getCreatorUserHandle());
+ final ShortcutInfo shortcutInfo = getShortcutInfo(intent);
if (shortcutInfo != null) {
mSystemUiProxy.startShortcutAndTask(shortcutInfo,
options1.toBundle(), taskId, null /* options2 */, stagePosition,
splitRatio, remoteTransition, shellInstanceId);
} else {
- mSystemUiProxy.startIntentAndTask(pendingIntent, options1.toBundle(), taskId,
+ mSystemUiProxy.startIntentAndTask(getPendingIntent(intent), options1.toBundle(), taskId,
null /* options2 */, stagePosition, splitRatio, remoteTransition,
shellInstanceId);
}
@@ -288,15 +287,13 @@
private void launchIntentOrShortcutLegacy(Intent intent, ActivityOptions options1, int taskId,
@StagePosition int stagePosition, float splitRatio, RemoteAnimationAdapter adapter,
@Nullable InstanceId shellInstanceId) {
- PendingIntent pendingIntent = getPendingIntent(intent);
- final ShortcutInfo shortcutInfo = getShortcutInfo(intent,
- pendingIntent.getCreatorUserHandle());
+ final ShortcutInfo shortcutInfo = getShortcutInfo(intent);
if (shortcutInfo != null) {
mSystemUiProxy.startShortcutAndTaskWithLegacyTransition(shortcutInfo,
options1.toBundle(), taskId, null /* options2 */, stagePosition,
splitRatio, adapter, shellInstanceId);
} else {
- mSystemUiProxy.startIntentAndTaskWithLegacyTransition(pendingIntent,
+ mSystemUiProxy.startIntentAndTaskWithLegacyTransition(getPendingIntent(intent),
options1.toBundle(), taskId, null /* options2 */, stagePosition, splitRatio,
adapter, shellInstanceId);
}
@@ -322,7 +319,7 @@
}
@Nullable
- private ShortcutInfo getShortcutInfo(Intent intent, UserHandle userHandle) {
+ private ShortcutInfo getShortcutInfo(Intent intent) {
if (intent == null || intent.getPackage() == null) {
return null;
}
@@ -334,7 +331,7 @@
try {
final Context context = mContext.createPackageContextAsUser(
- intent.getPackage(), 0 /* flags */, userHandle);
+ intent.getPackage(), 0 /* flags */, mUser);
return new ShortcutInfo.Builder(context, shortcutId).build();
} catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, "Failed to create a ShortcutInfo for " + intent.getPackage());
diff --git a/res/layout/workspace_screen_foldable.xml b/res/layout/workspace_screen_foldable.xml
new file mode 100644
index 0000000..1e01250
--- /dev/null
+++ b/res/layout/workspace_screen_foldable.xml
@@ -0,0 +1,23 @@
+<?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.
+-->
+
+<com.android.launcher3.MultipageCellLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:launcher="http://schemas.android.com/apk/res-auto"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:hapticFeedbackEnabled="false"
+ launcher:containerType="workspace" />
\ No newline at end of file
diff --git a/res/values-sw600dp-land/dimens.xml b/res/values-sw600dp-land/dimens.xml
index 63970cd..92f6881 100644
--- a/res/values-sw600dp-land/dimens.xml
+++ b/res/values-sw600dp-land/dimens.xml
@@ -30,6 +30,4 @@
<dimen name="dynamic_grid_edge_margin">11.33dp</dimen>
<dimen name="cell_layout_padding">11.33dp</dimen>
-<!-- AllApps -->
- <dimen name="all_apps_bottom_sheet_horizontal_padding">52dp</dimen>
</resources>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index d69e777..0af0603 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -26,7 +26,6 @@
<!-- AllApps -->
<dimen name="all_apps_search_bar_content_overlap">0dp</dimen>
- <dimen name="all_apps_bottom_sheet_horizontal_padding">48dp</dimen>
<!-- Fast scroll -->
<dimen name="fastscroll_popup_width">75dp</dimen>
diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml
index 235631d..6362960 100644
--- a/res/values-sw720dp-land/dimens.xml
+++ b/res/values-sw720dp-land/dimens.xml
@@ -22,9 +22,6 @@
<dimen name="dynamic_grid_edge_margin">21.93dp</dimen>
<dimen name="cell_layout_padding">29.33dp</dimen>
-<!-- AllApps -->
- <dimen name="all_apps_bottom_sheet_horizontal_padding">32dp</dimen>
-
<!-- Dragging-->
<dimen name="drop_target_top_margin">0dp</dimen>
<dimen name="drop_target_bottom_margin">32dp</dimen>
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index 09b2d6f..d7a5881 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -18,9 +18,6 @@
<!-- PagedView -->
<dimen name="min_page_snap_velocity">3400dp</dimen>
-<!-- AllApps -->
- <dimen name="all_apps_bottom_sheet_horizontal_padding">28dp</dimen>
-
<!-- Dynamic grid -->
<dimen name="dynamic_grid_edge_margin">27.59dp</dimen>
<dimen name="cell_layout_padding">36dp</dimen>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index e6f285c..26180f3 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -151,6 +151,9 @@
<!-- Support attributes in FolderStyle -->
<attr name="folderStyle" format="reference" />
+ <!-- Support attributes in AllAppsStyle. Defaults to AllAppsStyleDefault -->
+ <attr name="allAppsStyle" format="reference" />
+
<!-- numAllAppsColumns defaults to numColumns, if not specified -->
<attr name="numAllAppsColumns" format="integer" />
<!-- Number of columns to use when extending the all-apps size,
@@ -418,6 +421,10 @@
<attr name="iconDrawablePadding" format="dimension" />
</declare-styleable>
+ <declare-styleable name="AllAppsStyle">
+ <attr name="horizontalPadding" format="dimension" />
+ </declare-styleable>
+
<declare-styleable name="ShadowDrawable">
<attr name="android:src" />
<attr name="android:shadowColor" />
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 321aef5..a9638f9 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -131,7 +131,6 @@
<dimen name="all_apps_content_fade_in_offset">150dp</dimen>
<dimen name="all_apps_tip_bottom_margin">8dp</dimen>
<dimen name="all_apps_height_extra">6dp</dimen>
- <dimen name="all_apps_bottom_sheet_horizontal_padding">0dp</dimen>
<dimen name="all_apps_paged_view_top_padding">40dp</dimen>
<dimen name="all_apps_icon_drawable_padding">8dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 6b57532..a0b5570 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -304,4 +304,8 @@
<item name="iconDrawablePadding">7dp</item>
</style>
+ <style name="AllAppsStyleDefault">
+ <item name="horizontalPadding">16dp</item>
+ </style>
+
</resources>
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index d388ebc..b96e4df 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -99,9 +99,9 @@
private Point mBorderSpace;
@ViewDebug.ExportedProperty(category = "launcher")
- private int mCountX;
+ protected int mCountX;
@ViewDebug.ExportedProperty(category = "launcher")
- private int mCountY;
+ protected int mCountY;
private boolean mDropPending = false;
@@ -111,8 +111,8 @@
@Thunk final int[] mTempLocation = new int[2];
final PointF mTmpPointF = new PointF();
- private GridOccupancy mOccupied;
- private GridOccupancy mTmpOccupied;
+ protected GridOccupancy mOccupied;
+ protected GridOccupancy mTmpOccupied;
private OnTouchListener mInterceptTouchListener;
@@ -121,7 +121,7 @@
private static final int[] BACKGROUND_STATE_ACTIVE = new int[] { android.R.attr.state_active };
private static final int[] BACKGROUND_STATE_DEFAULT = EMPTY_STATE_SET;
- private final Drawable mBackground;
+ protected final Drawable mBackground;
// These values allow a fixed measurement to be set on the CellLayout.
private int mFixedWidth = -1;
@@ -154,7 +154,7 @@
private int mGridVisualizationRoundingRadius;
private float mGridAlpha = 0f;
private int mGridColor = 0;
- private float mSpringLoadedProgress = 0f;
+ protected float mSpringLoadedProgress = 0f;
private float mScrollProgress = 0f;
// When a drag operation is in progress, holds the nearest cell to the touch point
@@ -164,7 +164,7 @@
private boolean mDragging = false;
private final TimeInterpolator mEaseOutInterpolator;
- private final ShortcutAndWidgetContainer mShortcutsAndWidgets;
+ protected final ShortcutAndWidgetContainer mShortcutsAndWidgets;
@Retention(RetentionPolicy.SOURCE)
@IntDef({WORKSPACE, HOTSEAT, FOLDER})
@@ -565,7 +565,7 @@
return mSpringLoadedProgress;
}
- private void updateBgAlpha() {
+ protected void updateBgAlpha() {
mBackground.setAlpha((int) (mSpringLoadedProgress * 255));
}
@@ -1662,7 +1662,7 @@
* @param spanY vertical cell span
* @return the configuration that represents the found reorder
*/
- private ItemConfiguration closestEmptySpaceReorder(int pixelX, int pixelY, int minSpanX,
+ ItemConfiguration closestEmptySpaceReorder(int pixelX, int pixelY, int minSpanX,
int minSpanY, int spanX, int spanY) {
ItemConfiguration solution = new ItemConfiguration();
int[] result = new int[2];
@@ -2402,8 +2402,15 @@
return true;
}
- private ItemConfiguration findReorderSolution(int pixelX, int pixelY, int minSpanX, int minSpanY,
- int spanX, int spanY, int[] direction, View dragView, boolean decX,
+ protected ItemConfiguration findReorderSolution(int pixelX, int pixelY, int minSpanX,
+ int minSpanY, int spanX, int spanY, int[] direction, View dragView, boolean decX,
+ ItemConfiguration solution) {
+ return findReorderSolutionRecursive(pixelX, pixelY, minSpanX, minSpanY, spanX, spanY,
+ direction, dragView, decX, solution);
+ }
+
+ protected ItemConfiguration findReorderSolutionRecursive(int pixelX, int pixelY, int minSpanX,
+ int minSpanY, int spanX, int spanY, int[] direction, View dragView, boolean decX,
ItemConfiguration solution) {
// Copy the current state into the solution. This solution will be manipulated as necessary.
copyCurrentStateToSolution(solution, false);
@@ -2426,11 +2433,11 @@
// We try shrinking the widget down to size in an alternating pattern, shrink 1 in
// x, then 1 in y etc.
if (spanX > minSpanX && (minSpanY == spanY || decX)) {
- return findReorderSolution(pixelX, pixelY, minSpanX, minSpanY, spanX - 1, spanY,
- direction, dragView, false, solution);
+ return findReorderSolutionRecursive(pixelX, pixelY, minSpanX, minSpanY, spanX - 1,
+ spanY, direction, dragView, false, solution);
} else if (spanY > minSpanY) {
- return findReorderSolution(pixelX, pixelY, minSpanX, minSpanY, spanX, spanY - 1,
- direction, dragView, true, solution);
+ return findReorderSolutionRecursive(pixelX, pixelY, minSpanX, minSpanY, spanX,
+ spanY - 1, direction, dragView, true, solution);
}
solution.isSolution = false;
} else {
@@ -2443,7 +2450,7 @@
return solution;
}
- private void copyCurrentStateToSolution(ItemConfiguration solution, boolean temp) {
+ protected void copyCurrentStateToSolution(ItemConfiguration solution, boolean temp) {
int childCount = mShortcutsAndWidgets.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = mShortcutsAndWidgets.getChildAt(i);
@@ -2624,7 +2631,7 @@
return mItemPlacementDirty;
}
- private static class ItemConfiguration extends CellAndSpan {
+ static class ItemConfiguration extends CellAndSpan {
final ArrayMap<View, CellAndSpan> map = new ArrayMap<>();
private final ArrayMap<View, CellAndSpan> savedMap = new ArrayMap<>();
final ArrayList<View> sortedViews = new ArrayList<>();
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 0070f95..086cf05 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -404,6 +404,7 @@
allAppsBorderSpacePx = new Point(
pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].x, mMetrics),
pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].y, mMetrics));
+ setupAllAppsStyle(context);
workspacePageIndicatorHeight = res.getDimensionPixelSize(
R.dimen.workspace_page_indicator_height);
@@ -810,9 +811,6 @@
int cellLayoutHorizontalPadding =
(cellLayoutPaddingPx.left + cellLayoutPaddingPx.right) / 2;
if (isTablet) {
- allAppsLeftRightPadding =
- res.getDimensionPixelSize(R.dimen.all_apps_bottom_sheet_horizontal_padding);
-
int usedWidth = (allAppsCellWidthPx * numShownAllAppsColumns)
+ (allAppsBorderSpacePx.x * (numShownAllAppsColumns - 1))
+ allAppsLeftRightPadding * 2;
@@ -823,6 +821,20 @@
}
}
+ private void setupAllAppsStyle(Context context) {
+ TypedArray allAppsStyle;
+ if (inv.allAppsStyle != INVALID_RESOURCE_HANDLE) {
+ allAppsStyle = context.obtainStyledAttributes(inv.allAppsStyle,
+ R.styleable.AllAppsStyle);
+ } else {
+ allAppsStyle = context.obtainStyledAttributes(R.style.AllAppsStyleDefault,
+ R.styleable.AllAppsStyle);
+ }
+ allAppsLeftRightPadding = allAppsStyle.getDimensionPixelSize(
+ R.styleable.AllAppsStyle_horizontalPadding, 0);
+ allAppsStyle.recycle();
+ }
+
/**
* Returns the amount of extra (or unused) vertical space.
*/
@@ -1806,7 +1818,7 @@
* Set the viewScaleProvider for the builder
*
* @param viewScaleProvider The viewScaleProvider to be set for the
- * DeviceProfile
+ * DeviceProfile
* @return This builder
*/
@NonNull
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index d97eac9..604c1b8 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -175,6 +175,7 @@
*/
public int numAllAppsColumns;
public int numDatabaseAllAppsColumns;
+ public @StyleRes int allAppsStyle;
/**
* Do not query directly. see {@link DeviceProfile#isScalableGrid}.
@@ -384,6 +385,8 @@
hotseatBarBottomSpace = displayOption.hotseatBarBottomSpace;
hotseatQsbSpace = displayOption.hotseatQsbSpace;
+ allAppsStyle = closestProfile.allAppsStyle;
+
numAllAppsColumns = closestProfile.numAllAppsColumns;
numDatabaseAllAppsColumns = deviceType == TYPE_MULTI_DISPLAY
? closestProfile.numDatabaseAllAppsColumns : closestProfile.numAllAppsColumns;
@@ -789,6 +792,7 @@
private final @StyleRes int folderStyle;
private final @StyleRes int cellStyle;
+ private final @StyleRes int allAppsStyle;
private final int numAllAppsColumns;
private final int numDatabaseAllAppsColumns;
private final int numHotseatIcons;
@@ -824,6 +828,8 @@
demoModeLayoutId = a.getResourceId(
R.styleable.GridDisplayOption_demoModeLayoutId, defaultLayoutId);
+ allAppsStyle = a.getResourceId(R.styleable.GridDisplayOption_allAppsStyle,
+ R.style.AllAppsStyleDefault);
numAllAppsColumns = a.getInt(
R.styleable.GridDisplayOption_numAllAppsColumns, numColumns);
numDatabaseAllAppsColumns = a.getInt(
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 2f1f59c..41632f7 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -44,6 +44,7 @@
import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.getSupportedActions;
import static com.android.launcher3.anim.Interpolators.EMPHASIZED;
+import static com.android.launcher3.config.FeatureFlags.FOLDABLE_SINGLE_PAGE;
import static com.android.launcher3.config.FeatureFlags.SHOW_DOT_PAGINATION;
import static com.android.launcher3.logging.StatsLogManager.EventEnum;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND;
@@ -138,6 +139,7 @@
import com.android.launcher3.anim.PropertyListBuilder;
import com.android.launcher3.celllayout.CellPosMapper;
import com.android.launcher3.celllayout.CellPosMapper.CellPos;
+import com.android.launcher3.celllayout.CellPosMapper.TwoPanelCellPosMapper;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dot.DotInfo;
@@ -730,7 +732,11 @@
}
onDeviceProfileInitiated();
- mCellPosMapper = CellPosMapper.DEFAULT;
+ if (FOLDABLE_SINGLE_PAGE.get() && mDeviceProfile.isTwoPanels) {
+ mCellPosMapper = new TwoPanelCellPosMapper(mDeviceProfile.inv.numColumns);
+ } else {
+ mCellPosMapper = CellPosMapper.DEFAULT;
+ }
mModelWriter = mModel.getWriter(getDeviceProfile().isVerticalBarLayout(), true,
mCellPosMapper, this);
return true;
@@ -1342,6 +1348,7 @@
// Setup Apps
mAppsView = findViewById(R.id.apps_view);
+ mAppsView.setAllAppsTransitionController(mAllAppsController);
// Setup Scrim
mScrimView = findViewById(R.id.scrim_view);
diff --git a/src/com/android/launcher3/MultipageCellLayout.java b/src/com/android/launcher3/MultipageCellLayout.java
new file mode 100644
index 0000000..d671c7d
--- /dev/null
+++ b/src/com/android/launcher3/MultipageCellLayout.java
@@ -0,0 +1,168 @@
+/*
+ * 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;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+import android.util.AttributeSet;
+import android.view.View;
+
+import com.android.launcher3.celllayout.CellLayoutLayoutParams;
+import com.android.launcher3.util.CellAndSpan;
+import com.android.launcher3.util.GridOccupancy;
+
+import java.util.function.Supplier;
+
+/**
+ * CellLayout that simulates a split in the middle for use in foldable devices.
+ */
+public class MultipageCellLayout extends CellLayout {
+
+ private final Drawable mLeftBackground;
+ private final Drawable mRightBackground;
+
+ private View mSeam;
+
+ public MultipageCellLayout(Context context) {
+ this(context, null);
+ }
+
+ public MultipageCellLayout(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public MultipageCellLayout(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ mLeftBackground = getContext().getDrawable(R.drawable.bg_celllayout);
+ mLeftBackground.setCallback(this);
+ mLeftBackground.setAlpha(0);
+
+ mRightBackground = getContext().getDrawable(R.drawable.bg_celllayout);
+ mRightBackground.setCallback(this);
+ mRightBackground.setAlpha(0);
+
+ DeviceProfile deviceProfile = mActivity.getDeviceProfile();
+
+ mCountX = deviceProfile.inv.numColumns * 2;
+ mCountY = deviceProfile.inv.numRows;
+ mSeam = new View(getContext());
+ setGridSize(mCountX, mCountY);
+ }
+
+ @Override
+ ItemConfiguration closestEmptySpaceReorder(int pixelX, int pixelY, int minSpanX, int minSpanY,
+ int spanX, int spanY) {
+ return simulateSeam(
+ () -> super.closestEmptySpaceReorder(pixelX, pixelY, minSpanX, minSpanY, spanX,
+ spanY));
+ }
+
+ @Override
+ protected ItemConfiguration findReorderSolution(int pixelX, int pixelY, int minSpanX,
+ int minSpanY, int spanX, int spanY, int[] direction, View dragView, boolean decX,
+ ItemConfiguration solution) {
+ return simulateSeam(
+ () -> super.findReorderSolution(pixelX, pixelY, minSpanX, minSpanY, spanX, spanY,
+ direction, dragView, decX, solution));
+ }
+
+ @Override
+ public ItemConfiguration dropInPlaceSolution(int pixelX, int pixelY, int spanX, int spanY,
+ View dragView) {
+ return simulateSeam(
+ () -> super.dropInPlaceSolution(pixelX, pixelY, spanX, spanY, dragView));
+ }
+
+ protected ItemConfiguration simulateSeam(Supplier<ItemConfiguration> f) {
+ CellLayoutLayoutParams lp = new CellLayoutLayoutParams(mCountX / 2, 0, 1, mCountY);
+ lp.canReorder = false;
+ mCountX++;
+ mShortcutsAndWidgets.addViewInLayout(mSeam, lp);
+ GridOccupancy auxGrid = mOccupied;
+ mOccupied = createGridOccupancy();
+ mTmpOccupied = new GridOccupancy(mCountX, mCountY);
+
+ ItemConfiguration res = removeSeamFromSolution(f.get());
+
+ mCountX--;
+ mShortcutsAndWidgets.removeViewInLayout(mSeam);
+ mOccupied = auxGrid;
+ mTmpOccupied = new GridOccupancy(mCountX, mCountY);
+ return res;
+ }
+
+ private ItemConfiguration removeSeamFromSolution(ItemConfiguration solution) {
+ solution.map.forEach((view, cell) -> cell.cellX = cell.cellX > mCountX / 2
+ ? cell.cellX - 1 : cell.cellX);
+ solution.cellX = solution.cellX > mCountX / 2 ? solution.cellX - 1 : solution.cellX;
+ return solution;
+ }
+
+ GridOccupancy createGridOccupancy() {
+ GridOccupancy grid = new GridOccupancy(mCountX, mCountY);
+ for (int i = 0; i < mShortcutsAndWidgets.getChildCount(); i++) {
+ View view = mShortcutsAndWidgets.getChildAt(i);
+ CellLayoutLayoutParams lp = (CellLayoutLayoutParams) view.getLayoutParams();
+ int seamOffset = lp.getCellX() >= mCountX / 2 && lp.canReorder ? 1 : 0;
+ grid.markCells(lp.getCellX() + seamOffset, lp.getCellY(), lp.cellHSpan, lp.cellVSpan,
+ true);
+ }
+ return grid;
+ }
+
+ @Override
+ protected void copyCurrentStateToSolution(ItemConfiguration solution, boolean temp) {
+ int childCount = mShortcutsAndWidgets.getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ View child = mShortcutsAndWidgets.getChildAt(i);
+ CellLayoutLayoutParams lp = (CellLayoutLayoutParams) child.getLayoutParams();
+ int seamOffset = lp.getCellX() >= mCountX / 2 && lp.canReorder ? 1 : 0;
+ CellAndSpan c = new CellAndSpan(lp.getCellX() + seamOffset, lp.getCellY(), lp.cellHSpan,
+ lp.cellVSpan);
+ solution.add(child, c);
+ }
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ if (mLeftBackground.getAlpha() > 0) {
+ mLeftBackground.setState(mBackground.getState());
+ mLeftBackground.draw(canvas);
+ }
+ if (mRightBackground.getAlpha() > 0) {
+ mRightBackground.setState(mBackground.getState());
+ mRightBackground.draw(canvas);
+ }
+
+ super.onDraw(canvas);
+ }
+
+ @Override
+ protected void updateBgAlpha() {
+ mLeftBackground.setAlpha((int) (mSpringLoadedProgress * 255));
+ mRightBackground.setAlpha((int) (mSpringLoadedProgress * 255));
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ super.onLayout(changed, l, t, r, b);
+ Rect rect = mBackground.getBounds();
+ mLeftBackground.setBounds(rect.left, rect.top, rect.right / 2 - 20, rect.bottom);
+ mRightBackground.setBounds(rect.right / 2 + 20, rect.top, rect.right, rect.bottom);
+ }
+}
diff --git a/src/com/android/launcher3/ShortcutAndWidgetContainer.java b/src/com/android/launcher3/ShortcutAndWidgetContainer.java
index 5f39f7e..55b745b 100644
--- a/src/com/android/launcher3/ShortcutAndWidgetContainer.java
+++ b/src/com/android/launcher3/ShortcutAndWidgetContainer.java
@@ -107,6 +107,18 @@
}
}
+ /**
+ * Adds view to Layout a new position and it does not trigger a layout request.
+ * For more information check documentation for
+ * {@code ViewGroup#addViewInLayout(View, int, LayoutParams, boolean)}
+ *
+ * @param child view to be added
+ * @return true if the child was added, false otherwise
+ */
+ public boolean addViewInLayout(View child, LayoutParams layoutParams) {
+ return super.addViewInLayout(child, -1, layoutParams, true);
+ }
+
public void setupLp(View child) {
CellLayoutLayoutParams lp = (CellLayoutLayoutParams) child.getLayoutParams();
if (child instanceof NavigableAppWidgetHostView) {
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index df829f1..fa54dcf 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -135,6 +135,7 @@
* The workspace is a wide area with a wallpaper and a finite number of pages.
* Each page contains a number of icons, folders or widgets the user can
* interact with. A workspace is meant to be used with a fixed width only.
+ *
* @param <T> Class that extends View and PageIndicator
*/
public class Workspace<T extends View & PageIndicator> extends PagedView<T>
@@ -142,12 +143,16 @@
DragController.DragListener, Insettable, StateHandler<LauncherState>,
WorkspaceLayoutManager, LauncherBindableItemsContainer, LauncherOverlayCallbacks {
- /** The value that {@link #mTransitionProgress} must be greater than for
- * {@link #transitionStateShouldAllowDrop()} to return true. */
+ /**
+ * The value that {@link #mTransitionProgress} must be greater than for
+ * {@link #transitionStateShouldAllowDrop()} to return true.
+ */
private static final float ALLOW_DROP_TRANSITION_PROGRESS = 0.25f;
- /** The value that {@link #mTransitionProgress} must be greater than for
- * {@link #isFinishedSwitchingState()} ()} to return true. */
+ /**
+ * The value that {@link #mTransitionProgress} must be greater than for
+ * {@link #isFinishedSwitchingState()} ()} to return true.
+ */
private static final float FINISHED_SWITCHING_STATE_TRANSITION_PROGRESS = 0.5f;
private static final float SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE = 0.15f;
@@ -161,16 +166,20 @@
private final int mAllAppsIconSize;
private LayoutTransition mLayoutTransition;
- @Thunk final WallpaperManager mWallpaperManager;
+ @Thunk
+ final WallpaperManager mWallpaperManager;
protected ShortcutAndWidgetContainer mDragSourceInternal;
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
- @Thunk public final IntSparseArrayMap<CellLayout> mWorkspaceScreens = new IntSparseArrayMap<>();
+ @Thunk
+ public final IntSparseArrayMap<CellLayout> mWorkspaceScreens = new IntSparseArrayMap<>();
- @Thunk final IntArray mScreenOrder = new IntArray();
+ @Thunk
+ final IntArray mScreenOrder = new IntArray();
- @Thunk boolean mDeferRemoveExtraEmptyScreen = false;
+ @Thunk
+ boolean mDeferRemoveExtraEmptyScreen = false;
/**
* CellInfo for the cell that is currently being dragged
@@ -180,14 +189,16 @@
/**
* Target drop area calculated during last acceptDrop call.
*/
- @Thunk int[] mTargetCell = new int[2];
+ @Thunk
+ int[] mTargetCell = new int[2];
private int mDragOverX = -1;
private int mDragOverY = -1;
/**
* The CellLayout that is currently being dragged over
*/
- @Thunk CellLayout mDragTargetLayout = null;
+ @Thunk
+ CellLayout mDragTargetLayout = null;
/**
* The CellLayout that we will show as highlighted
*/
@@ -198,13 +209,16 @@
*/
private CellLayout mDropToLayout = null;
- @Thunk final Launcher mLauncher;
- @Thunk DragController mDragController;
+ @Thunk
+ final Launcher mLauncher;
+ @Thunk
+ DragController mDragController;
protected final int[] mTempXY = new int[2];
private final float[] mTempFXY = new float[2];
private final Rect mTempRect = new Rect();
- @Thunk float[] mDragViewVisualCenter = new float[2];
+ @Thunk
+ float[] mDragViewVisualCenter = new float[2];
private SpringLoadedDragController mSpringLoadedDragController;
@@ -249,8 +263,10 @@
private static final int DRAG_MODE_ADD_TO_FOLDER = 2;
private static final int DRAG_MODE_REORDER = 3;
protected int mDragMode = DRAG_MODE_NONE;
- @Thunk int mLastReorderX = -1;
- @Thunk int mLastReorderY = -1;
+ @Thunk
+ int mLastReorderX = -1;
+ @Thunk
+ int mLastReorderY = -1;
private SparseArray<Parcelable> mSavedStates;
private final IntArray mRestoredPages = new IntArray();
@@ -275,7 +291,7 @@
* Used to inflate the Workspace from XML.
*
* @param context The application's context.
- * @param attrs The attributes set containing the Workspace's customization values.
+ * @param attrs The attributes set containing the Workspace's customization values.
*/
public Workspace(Context context, AttributeSet attrs) {
this(context, attrs, 0);
@@ -284,8 +300,8 @@
/**
* Used to inflate the Workspace from XML.
*
- * @param context The application's context.
- * @param attrs The attributes set containing the Workspace's customization values.
+ * @param context The application's context.
+ * @param attrs The attributes set containing the Workspace's customization values.
* @param defStyle Unused.
*/
public Workspace(Context context, AttributeSet attrs, int defStyle) {
@@ -421,7 +437,9 @@
return mWallpaperOffset.wallpaperOffsetForScroll(pageScroll);
}
- /** Returns the number of pages used for the wallpaper parallax. */
+ /**
+ * Returns the number of pages used for the wallpaper parallax.
+ */
public int getNumPagesForWallpaperParallax() {
return mWallpaperOffset.getNumPagesForWallpaperParallax();
}
@@ -553,6 +571,7 @@
void enableLayoutTransitions() {
setLayoutTransition(mLayoutTransition);
}
+
void disableLayoutTransitions() {
setLayoutTransition(null);
}
@@ -644,8 +663,14 @@
// Inflate the cell layout, but do not add it automatically so that we can get the newly
// created CellLayout.
- CellLayout newScreen = (CellLayout) LayoutInflater.from(getContext()).inflate(
+ CellLayout newScreen;
+ if (FOLDABLE_SINGLE_PAGE.get() && isTwoPanelEnabled()) {
+ newScreen = (CellLayout) LayoutInflater.from(getContext()).inflate(
+ R.layout.workspace_screen_foldable, this, false /* attachToRoot */);
+ } else {
+ newScreen = (CellLayout) LayoutInflater.from(getContext()).inflate(
R.layout.workspace_screen, this, false /* attachToRoot */);
+ }
mWorkspaceScreens.put(screenId, newScreen);
mScreenOrder.add(insertIndex, screenId);
@@ -783,17 +808,17 @@
* Empty page(s) from the end of mWorkspaceScreens will always be removed. The pages with
* ID = Workspace.EXTRA_EMPTY_SCREEN_IDS will be removed if there are other non-empty pages.
* If there are no more non-empty pages left, extra empty page(s) will either stay or get added.
- *
+ * <p>
* If stripEmptyScreens is true, all empty pages (not just the ones on the end) will be removed
* from the Workspace, and if there are no more pages left then extra empty page(s) will be
* added.
- *
+ * <p>
* The number of extra empty pages is equal to what getPanelCount() returns.
- *
+ * <p>
* After the method returns the possible pages are:
* stripEmptyScreens = true : [non-empty pages, extra empty page(s) alone]
* stripEmptyScreens = false : [non-empty pages, empty pages (not in the end),
- * extra empty page(s) alone]
+ * extra empty page(s) alone]
*/
public void removeExtraEmptyScreenDelayed(
int delay, boolean stripEmptyScreens, Runnable onComplete) {
@@ -844,11 +869,11 @@
}
/**
- * Commits the extra empty pages then returns the screen ids of those new screens.
- * Usually there's only one extra empty screen, but when two panel home is enabled we commit
- * two extra screens.
- *
- * Returns an empty IntSet in case we cannot commit any new screens.
+ * Commits the extra empty pages then returns the screen ids of those new screens.
+ * Usually there's only one extra empty screen, but when two panel home is enabled we commit
+ * two extra screens.
+ * <p>
+ * Returns an empty IntSet in case we cannot commit any new screens.
*/
public IntSet commitExtraEmptyScreens() {
if (mLauncher.isWorkspaceLoading()) {
@@ -869,7 +894,7 @@
mScreenOrder.removeValue(emptyScreenId);
int newScreenId = LauncherSettings.Settings.call(getContext().getContentResolver(),
- LauncherSettings.Settings.METHOD_NEW_SCREEN_ID)
+ LauncherSettings.Settings.METHOD_NEW_SCREEN_ID)
.getInt(LauncherSettings.Settings.EXTRA_VALUE);
// Launcher database isn't aware of empty pages that are already bound, so we need to
// skip those IDs manually.
@@ -1058,8 +1083,10 @@
return mIsSwitchingState;
}
- /** This differs from isSwitchingState in that we take into account how far the transition
- * has completed. */
+ /**
+ * This differs from isSwitchingState in that we take into account how far the transition
+ * has completed.
+ */
public boolean isFinishedSwitchingState() {
return !mIsSwitchingState
|| (mTransitionProgress > FINISHED_SWITCHING_STATE_TRANSITION_PROGRESS);
@@ -1387,7 +1414,9 @@
return mLauncher.isInState(SPRING_LOADED) || !workspaceInModalState();
}
- /** Returns whether a drag should be allowed to be started from the current workspace state. */
+ /**
+ * Returns whether a drag should be allowed to be started from the current workspace state.
+ */
public boolean workspaceIconsCanBeDragged() {
return mLauncher.getStateManager().getState().hasFlag(FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED);
}
@@ -1419,7 +1448,7 @@
// In overview mode, make sure that the two side pages are visible.
leftScreen = Utilities.boundToRange(getCurrentPage() - 1, 0, rightScreen);
rightScreen = Utilities.boundToRange(getCurrentPage() + 1,
- leftScreen, getPageCount() - 1);
+ leftScreen, getPageCount() - 1);
}
if (leftScreen == rightScreen) {
@@ -1621,7 +1650,7 @@
if (draggableView != null) {
draggableView.getSourceVisualDragBounds(dragRect);
dragLayerY += dragRect.top;
- dragVisualizeOffset = new Point(- halfPadding, halfPadding);
+ dragVisualizeOffset = new Point(-halfPadding, halfPadding);
}
@@ -1752,7 +1781,7 @@
}
boolean willCreateUserFolder(ItemInfo info, CellLayout target, int[] targetCell,
- float distance, boolean considerTimeout) {
+ float distance, boolean considerTimeout) {
if (distance > target.getFolderCreationRadius(targetCell)) return false;
View dropOverView = target.getChildAt(targetCell[0], targetCell[1]);
return willCreateUserFolder(info, dropOverView, considerTimeout);
@@ -1788,12 +1817,13 @@
}
boolean willAddToExistingUserFolder(ItemInfo dragInfo, CellLayout target, int[] targetCell,
- float distance) {
+ float distance) {
if (distance > target.getFolderCreationRadius(targetCell)) return false;
View dropOverView = target.getChildAt(targetCell[0], targetCell[1]);
return willAddToExistingUserFolder(dragInfo, dropOverView);
}
+
boolean willAddToExistingUserFolder(ItemInfo dragInfo, View dropOverView) {
if (dropOverView != null) {
CellLayoutLayoutParams lp = (CellLayoutLayoutParams) dropOverView.getLayoutParams();
@@ -1894,7 +1924,7 @@
}
@Override
- public void prepareAccessibilityDrop() { }
+ public void prepareAccessibilityDrop() {}
@Override
public void onDrop(final DragObject d, DragOptions options) {
@@ -1912,8 +1942,8 @@
boolean resizeOnDrop = false;
Runnable onCompleteRunnable = null;
if (d.dragSource != this || mDragInfo == null) {
- final int[] touchXY = new int[] { (int) mDragViewVisualCenter[0],
- (int) mDragViewVisualCenter[1] };
+ final int[] touchXY = new int[]{(int) mDragViewVisualCenter[0],
+ (int) mDragViewVisualCenter[1]};
onDropExternal(touchXY, dropTargetLayout, d);
} else {
final View cell = mDragInfo.cell;
@@ -2311,8 +2341,9 @@
/**
* Updates the point in {@param xy} to point to the co-ordinate space of {@param layout}
+ *
* @param layout either hotseat of a page in workspace
- * @param xy the point location in workspace co-ordinate space
+ * @param xy the point location in workspace co-ordinate space
*/
private void mapPointFromDropLayout(CellLayout layout, float[] xy) {
if (mLauncher.isHotseatLayout(layout)) {
@@ -2379,7 +2410,7 @@
manageFolderFeedback(targetCellDistance, d);
boolean nearestDropOccupied = mDragTargetLayout.isNearestDropLocationOccupied((int)
- mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1], item.spanX,
+ mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1], item.spanX,
item.spanY, child, mTargetCell);
manageReorderOnDragOver(d, targetCellDistance, nearestDropOccupied, minSpanX, minSpanY,
@@ -2400,11 +2431,15 @@
ItemInfo item = d.dragInfo;
final View child = (mDragInfo == null) ? null : mDragInfo.cell;
if (!nearestDropOccupied) {
+ int[] span = new int[2];
mDragTargetLayout.performReorder((int) mDragViewVisualCenter[0],
(int) mDragViewVisualCenter[1], minSpanX, minSpanY, item.spanX, item.spanY,
- child, mTargetCell, new int[2], CellLayout.MODE_SHOW_REORDER_HINT);
- mDragTargetLayout.visualizeDropLocation(mTargetCell[0], mTargetCell[1],
- item.spanX, item.spanY, d);
+ child, mTargetCell, span, CellLayout.MODE_SHOW_REORDER_HINT);
+ mDragTargetLayout.visualizeDropLocation(mTargetCell[0], mTargetCell[1], span[0],
+ span[1], d);
+ nearestDropOccupied = mDragTargetLayout.isNearestDropLocationOccupied((int)
+ mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1], item.spanX,
+ item.spanY, child, mTargetCell);
} else if ((mDragMode == DRAG_MODE_NONE || mDragMode == DRAG_MODE_REORDER)
&& (mLastReorderX != reorderX || mLastReorderY != reorderY)
&& targetCellDistance < mDragTargetLayout.getReorderRadius(mTargetCell, item.spanX,
@@ -2423,6 +2458,7 @@
mReorderAlarm.setAlarm(REORDER_TIMEOUT);
}
}
+
/**
* Updates {@link #mDragTargetLayout} and {@link #mDragOverlappingLayout}
* based on the DragObject's position.
@@ -2604,7 +2640,7 @@
final View child;
public ReorderAlarmListener(float[] dragViewCenter, int minSpanX, int minSpanY, int spanX,
- int spanY, DragObject dragObject, View child) {
+ int spanY, DragObject dragObject, View child) {
this.dragViewCenter = dragViewCenter;
this.minSpanX = minSpanX;
this.minSpanY = minSpanY;
@@ -2621,8 +2657,8 @@
mTargetCell);
mTargetCell = mDragTargetLayout.performReorder((int) mDragViewVisualCenter[0],
- (int) mDragViewVisualCenter[1], minSpanX, minSpanY, spanX, spanY,
- child, mTargetCell, resultSpan, CellLayout.MODE_DRAG_OVER);
+ (int) mDragViewVisualCenter[1], minSpanX, minSpanY, spanX, spanY,
+ child, mTargetCell, resultSpan, CellLayout.MODE_DRAG_OVER);
if (mTargetCell[0] < 0 || mTargetCell[1] < 0) {
mDragTargetLayout.revertTempState();
@@ -2646,7 +2682,7 @@
* Drop an item that didn't originate on one of the workspace screens.
* It may have come from Launcher (e.g. from all apps or customize), or it may have
* come from another app altogether.
- *
+ * <p>
* NOTE: This can also be called when we are outside of a drag event, when we want
* to add an item to one of the workspace screens.
*/
@@ -2688,7 +2724,7 @@
mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
if (willCreateUserFolder(d.dragInfo, cellLayout, mTargetCell, distance, true)
|| willAddToExistingUserFolder(
- d.dragInfo, cellLayout, mTargetCell, distance)) {
+ d.dragInfo, cellLayout, mTargetCell, distance)) {
findNearestVacantCell = false;
}
}
@@ -2923,7 +2959,7 @@
Drawable crossFadeDrawable = createWidgetDrawable(info, finalView);
dragView.crossFadeContent(crossFadeDrawable, (int) (duration * 0.8f));
} else if (isWidget && external) {
- scaleXY[0] = scaleXY[1] = Math.min(scaleXY[0], scaleXY[1]);
+ scaleXY[0] = scaleXY[1] = Math.min(scaleXY[0], scaleXY[1]);
}
DragLayer dragLayer = mLauncher.getDragLayer();
@@ -2962,6 +2998,7 @@
setScaleY(mStateTransitionAnimation.getFinalScale());
}
}
+
public void resetTransitionTransform() {
if (isSwitchingState()) {
setScaleX(mCurrentScale);
@@ -2973,7 +3010,6 @@
* Return the current CellInfo describing our current drag; this method exists
* so that Launcher can sync this object with the correct info when the activity is created/
* destroyed
- *
*/
public CellLayout.CellInfo getDragInfo() {
return mDragInfo;
@@ -2981,11 +3017,12 @@
/**
* Calculate the nearest cell where the given object would be dropped.
- *
+ * <p>
* pixelX and pixelY should be in the coordinate system of layout
*/
- @Thunk int[] findNearestArea(int pixelX, int pixelY,
- int spanX, int spanY, CellLayout layout, int[] recycle) {
+ @Thunk
+ int[] findNearestArea(int pixelX, int pixelY,
+ int spanX, int spanY, CellLayout layout, int[] recycle) {
return layout.findNearestAreaIgnoreOccupied(
pixelX, pixelY, spanX, spanY, recycle);
}
@@ -3003,7 +3040,7 @@
* Called at the end of a drag which originated on the workspace.
*/
public void onDropCompleted(final View target, final DragObject d,
- final boolean success) {
+ final boolean success) {
if (success) {
if (target != this && mDragInfo != null) {
removeWorkspaceItem(mDragInfo.cell);
@@ -3050,6 +3087,7 @@
/**
* Removed widget from workspace by appWidgetId
+ *
* @param appWidgetId
*/
public void removeWidget(int appWidgetId) {
@@ -3256,6 +3294,7 @@
/**
* Perform {param operator} over all the items in a given {param layout}.
+ *
* @return The first item that satisfies the operator or null.
*/
public View mapOverCellLayout(CellLayout layout, ItemOperator operator) {
@@ -3310,10 +3349,10 @@
/**
* Remove workspace icons & widget information related to items in matcher.
*
- * @param matcher the matcher generated by the caller.
+ * @param matcher the matcher generated by the caller.
*/
public void persistRemoveItemsByMatcher(Predicate<ItemInfo> matcher,
- @Nullable final String reason) {
+ @Nullable final String reason) {
mLauncher.getModelWriter().deleteItemsFromDatabase(matcher, reason);
removeItemsByMatcher(matcher);
}
@@ -3358,7 +3397,9 @@
return mOverlayShown;
}
- /** Calls {@link #snapToPage(int)} on the {@link #DEFAULT_PAGE}, then requests focus on it. */
+ /**
+ * Calls {@link #snapToPage(int)} on the {@link #DEFAULT_PAGE}, then requests focus on it.
+ */
public void moveToDefaultScreen() {
int page = DEFAULT_PAGE;
if (!workspaceInModalState() && getNextPage() != page) {
@@ -3458,7 +3499,7 @@
private boolean mRefreshPending;
DeferredWidgetRefresh(ArrayList<LauncherAppWidgetInfo> infos,
- LauncherWidgetHolder holder) {
+ LauncherWidgetHolder holder) {
mInfos = infos;
mWidgetHolder = holder;
mHandler = mLauncher.mHandler;
diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
index 9fb0e71..c3d24f9 100644
--- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
@@ -155,6 +155,7 @@
private int mHeaderColor;
private int mBottomSheetBackgroundColor;
private int mTabsProtectionAlpha;
+ @Nullable private AllAppsTransitionController mAllAppsTransitionController;
public ActivityAllAppsContainerView(Context context) {
this(context, null);
@@ -292,6 +293,11 @@
animateToSearchState(goingToSearch, DEFAULT_SEARCH_TRANSITION_DURATION_MS);
}
+ public void setAllAppsTransitionController(
+ AllAppsTransitionController allAppsTransitionController) {
+ mAllAppsTransitionController = allAppsTransitionController;
+ }
+
private void animateToSearchState(boolean goingToSearch, long durationMs) {
if (!mSearchTransitionController.isRunning() && goingToSearch == isSearching()) {
return;
@@ -299,6 +305,9 @@
if (goingToSearch) {
// Fade out the button to pause work apps.
mWorkManager.onActivePageChanged(SEARCH);
+ } else if (mAllAppsTransitionController != null) {
+ // If exiting search, revert predictive back scale on all apps
+ mAllAppsTransitionController.animateAllAppsToNoScale();
}
mSearchTransitionController.animateToSearchState(goingToSearch, durationMs,
/* onEndRunnable = */ () -> {
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 394a7d7..4a1c334 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -301,6 +301,13 @@
}
}
+ /** Animate all apps view to 1f scale. */
+ public void animateAllAppsToNoScale() {
+ mAllAppScale.animateToValue(1f)
+ .setDuration(REVERT_SWIPE_ALL_APPS_TO_HOME_ANIMATION_DURATION_MS)
+ .start();
+ }
+
/**
* Creates an animation which updates the vertical transition progress and updates all the
* dependent UI using various animation events
diff --git a/src/com/android/launcher3/util/GridOccupancy.java b/src/com/android/launcher3/util/GridOccupancy.java
index 1301460..43e486c 100644
--- a/src/com/android/launcher3/util/GridOccupancy.java
+++ b/src/com/android/launcher3/util/GridOccupancy.java
@@ -81,4 +81,16 @@
public void clear() {
markCells(0, 0, mCountX, mCountY, false);
}
+
+ @Override
+ public String toString() {
+ StringBuilder s = new StringBuilder("Grid: \n");
+ for (int y = 0; y < mCountY; y++) {
+ for (int x = 0; x < mCountX; x++) {
+ s.append(cells[x][y] ? 1 : 0).append(" ");
+ }
+ s.append("\n");
+ }
+ return s.toString();
+ }
}
diff --git a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
index 0aecfb2..daf4608 100644
--- a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
+++ b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
@@ -120,6 +120,7 @@
horizontalMargin = FloatArray(4) { 22f }
+ allAppsStyle = R.style.AllAppsStyleDefault
allAppsCellSize =
listOf(
PointF(80f, 104f),
@@ -198,6 +199,7 @@
horizontalMargin = floatArrayOf(54f, 120f, 54f, 54f)
+ allAppsStyle = R.style.AllAppsStyleDefault
allAppsCellSize =
listOf(
PointF(96f, 142f),
@@ -277,6 +279,7 @@
horizontalMargin = floatArrayOf(21.5f, 21.5f, 22.5f, 30.5f)
+ allAppsStyle = R.style.AllAppsStyleDefault
allAppsCellSize =
listOf(PointF(0f, 0f), PointF(0f, 0f), PointF(68f, 104f), PointF(80f, 104f))
.toTypedArray()