Merge "Review comments followup" into tm-dev

This commit is contained in:
Shikha Malhotra
2022-04-13 08:00:31 +00:00
committed by Android (Google) Code Review
25 changed files with 118 additions and 94 deletions
@@ -526,7 +526,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
endListener = composeViewContentAnimator(launcherAnimator, alphas, scales);
} else {
List<View> viewsToAnimate = new ArrayList<>();
Workspace workspace = mLauncher.getWorkspace();
Workspace<?> workspace = mLauncher.getWorkspace();
workspace.forEachVisiblePage(
view -> viewsToAnimate.add(((CellLayout) view).getShortcutsAndWidgets()));
@@ -131,7 +131,7 @@ public class HotseatEduController {
private int placeFoldersInWorkspace(ArrayDeque<FolderInfo> folders) {
if (folders.isEmpty()) return 0;
Workspace workspace = mLauncher.getWorkspace();
Workspace<?> workspace = mLauncher.getWorkspace();
InvariantDeviceProfile idp = mLauncher.getDeviceProfile().inv;
GridOccupancy[] occupancyList = new GridOccupancy[workspace.getChildCount()];
@@ -176,7 +176,7 @@ public class HotseatEduController {
* @return pageId where items are migrated
*/
private int migrateHotseatWhole() {
Workspace workspace = mLauncher.getWorkspace();
Workspace<?> workspace = mLauncher.getWorkspace();
int pageId = -1;
int toRow = 0;
@@ -263,7 +263,7 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
switch (state.ordinal) {
case HINT_STATE_ORDINAL: {
Workspace workspace = getWorkspace();
Workspace<?> workspace = getWorkspace();
getStateManager().goToState(NORMAL);
if (workspace.getNextPage() != Workspace.DEFAULT_PAGE) {
workspace.post(workspace::moveToDefaultScreen);
@@ -118,7 +118,7 @@ public class QuickstepAtomicAnimationFactory extends
config.duration = Math.max(config.duration, scrollDuration);
overview.snapToPage(DEFAULT_PAGE, Math.toIntExact(config.duration));
Workspace workspace = mActivity.getWorkspace();
Workspace<?> workspace = mActivity.getWorkspace();
// Start from a higher workspace scale, but only if we're invisible so we don't jump.
boolean isWorkspaceVisible = workspace.getVisibility() == VISIBLE;
if (isWorkspaceVisible) {
@@ -45,7 +45,7 @@ public class LauncherUnfoldAnimationController {
// Percentage of the width of the quick search bar that will be reduced
// from the both sides of the bar when progress is 0
private static final float MAX_WIDTH_INSET_FRACTION = 0.15f;
private static final FloatProperty<Workspace> WORKSPACE_SCALE_PROPERTY =
private static final FloatProperty<Workspace<?>> WORKSPACE_SCALE_PROPERTY =
WORKSPACE_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_UNFOLD_ANIMATION);
private static final FloatProperty<Hotseat> HOTSEAT_SCALE_PROPERTY =
HOTSEAT_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_UNFOLD_ANIMATION);
@@ -92,7 +92,7 @@ public class StaggeredWorkspaceAnim {
if (staggerWorkspace) {
DeviceProfile grid = launcher.getDeviceProfile();
Workspace workspace = launcher.getWorkspace();
Workspace<?> workspace = launcher.getWorkspace();
Hotseat hotseat = launcher.getHotseat();
// Hotseat and QSB takes up two additional rows.
@@ -37,7 +37,7 @@ public class UnfoldMoveFromCenterWorkspaceAnimator extends BaseUnfoldMoveFromCen
@Override
protected void onPrepareViewsForAnimation() {
Workspace workspace = mLauncher.getWorkspace();
Workspace<?> workspace = mLauncher.getWorkspace();
// App icons and widgets
workspace
@@ -53,7 +53,7 @@ public class WorkspaceRevealAnim {
// Should be used for animations running alongside this WorkspaceRevealAnim.
public static final int DURATION_MS = 350;
private static final FloatProperty<Workspace> WORKSPACE_SCALE_PROPERTY =
private static final FloatProperty<Workspace<?>> WORKSPACE_SCALE_PROPERTY =
WORKSPACE_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_REVEAL_ANIM);
private static final FloatProperty<Hotseat> HOTSEAT_SCALE_PROPERTY =
@@ -68,7 +68,7 @@ public class WorkspaceRevealAnim {
ResourceProvider rp = DynamicResource.provider(launcher);
mScaleStart = rp.getFloat(R.dimen.swipe_up_scale_start);
Workspace workspace = launcher.getWorkspace();
Workspace<?> workspace = launcher.getWorkspace();
workspace.setPivotToScaleWithSelf(launcher.getHotseat());
// Add reveal animations.
@@ -383,7 +383,7 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
// Handle invalid resize across CellLayouts in the two panel UI.
if (mCellLayout.getParent() instanceof Workspace) {
Workspace workspace = (Workspace) mCellLayout.getParent();
Workspace<?> workspace = (Workspace<?>) mCellLayout.getParent();
CellLayout pairedCellLayout = workspace.getScreenPair(mCellLayout);
if (pairedCellLayout != null) {
Rect focusedCellLayoutBound = sTmpRect;
@@ -570,7 +570,7 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
final DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
final CellLayout pairedCellLayout;
if (mCellLayout.getParent() instanceof Workspace) {
Workspace workspace = (Workspace) mCellLayout.getParent();
Workspace<?> workspace = (Workspace<?>) mCellLayout.getParent();
pairedCellLayout = workspace.getScreenPair(mCellLayout);
} else {
pairedCellLayout = null;
+2 -2
View File
@@ -1203,7 +1203,7 @@ public class CellLayout extends ViewGroup {
return getContext().getString(R.string.move_to_hotseat_position,
Math.max(cellX, cellY) + 1);
} else {
Workspace workspace = getWorkspace();
Workspace<?> workspace = getWorkspace();
int row = cellY + 1;
int col = workspace.mIsRtl ? mCountX - cellX : cellX + 1;
int panelCount = workspace.getPanelCount();
@@ -1217,7 +1217,7 @@ public class CellLayout extends ViewGroup {
}
}
private Workspace getWorkspace() {
private Workspace<?> getWorkspace() {
return Launcher.cast(mActivity).getWorkspace();
}
+1 -1
View File
@@ -179,7 +179,7 @@ public class DropTargetBar extends FrameLayout
}
Launcher launcher = Launcher.getLauncher(getContext());
Workspace workspace = launcher.getWorkspace();
Workspace<?> workspace = launcher.getWorkspace();
DeviceProfile dp = launcher.getDeviceProfile();
int buttonHorizontalPadding = dp.dropTargetHorizontalPaddingPx;
int buttonVerticalPadding = dp.dropTargetVerticalPaddingPx;
+2 -2
View File
@@ -41,7 +41,7 @@ public class Hotseat extends CellLayout implements Insettable {
@ViewDebug.ExportedProperty(category = "launcher")
private boolean mHasVerticalHotseat;
private Workspace mWorkspace;
private Workspace<?> mWorkspace;
private boolean mSendTouchToWorkspace;
@Nullable
private Consumer<Boolean> mOnVisibilityAggregatedCallback;
@@ -122,7 +122,7 @@ public class Hotseat extends CellLayout implements Insettable {
InsettableFrameLayout.dispatchInsets(this, insets);
}
public void setWorkspace(Workspace w) {
public void setWorkspace(Workspace<?> w) {
mWorkspace = w;
}
+1 -1
View File
@@ -2360,7 +2360,7 @@ public class Launcher extends StatefulActivity<LauncherState>
// Get the list of added items and intersect them with the set of items here
final Collection<Animator> bounceAnims = new ArrayList<>();
boolean canAnimatePageChange = canAnimatePageChange();
Workspace workspace = mWorkspace;
Workspace<?> workspace = mWorkspace;
int newItemsScreenId = -1;
int end = items.size();
View newView = null;
@@ -72,8 +72,8 @@ public class LauncherAnimUtils {
* of all the ones set, to have a smooth experience even in the case of overlapping scaling
* animation.
*/
public static final MultiScalePropertyFactory<Workspace> WORKSPACE_SCALE_PROPERTY_FACTORY =
new MultiScalePropertyFactory<Workspace>("workspace_scale_property");
public static final MultiScalePropertyFactory<Workspace<?>> WORKSPACE_SCALE_PROPERTY_FACTORY =
new MultiScalePropertyFactory<Workspace<?>>("workspace_scale_property");
/** Property to set the scale of hotseat. */
public static final MultiScalePropertyFactory<Hotseat> HOTSEAT_SCALE_PROPERTY_FACTORY =
@@ -67,18 +67,18 @@ import com.android.systemui.plugins.ResourceProvider;
*/
public class WorkspaceStateTransitionAnimation {
private static final FloatProperty<Workspace> WORKSPACE_SCALE_PROPERTY =
private static final FloatProperty<Workspace<?>> WORKSPACE_SCALE_PROPERTY =
WORKSPACE_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_WORKSPACE_STATE);
private static final FloatProperty<Hotseat> HOTSEAT_SCALE_PROPERTY =
HOTSEAT_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_WORKSPACE_STATE);
private final Launcher mLauncher;
private final Workspace mWorkspace;
private final Workspace<?> mWorkspace;
private float mNewScale;
public WorkspaceStateTransitionAnimation(Launcher launcher, Workspace workspace) {
public WorkspaceStateTransitionAnimation(Launcher launcher, Workspace<?> workspace) {
mLauncher = launcher;
mWorkspace = workspace;
}
@@ -224,7 +224,7 @@ public class WorkspaceStateTransitionAnimation {
* Returns a spring based animator for the scale property of {@param workspace}.
*/
public static ValueAnimator getWorkspaceSpringScaleAnimator(Launcher launcher,
Workspace workspace, float scale) {
Workspace<?> workspace, float scale) {
return getSpringScaleAnimator(launcher, workspace, scale, WORKSPACE_SCALE_PROPERTY);
}
@@ -19,7 +19,7 @@ import com.android.launcher3.BubbleTextView;
import com.android.launcher3.ButtonDropTarget;
import com.android.launcher3.CellLayout;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.PendingAddItemInfo;
import com.android.launcher3.R;
import com.android.launcher3.Workspace;
@@ -153,61 +153,9 @@ public class LauncherAccessibilityDelegate extends BaseAccessibilityDelegate<Lau
} else if (action == MOVE) {
return beginAccessibleDrag(host, item, fromKeyboard);
} else if (action == ADD_TO_WORKSPACE) {
final int[] coordinates = new int[2];
final int screenId = findSpaceOnWorkspace(item, coordinates);
if (screenId == -1) {
return false;
}
mContext.getStateManager().goToState(NORMAL, true, forSuccessCallback(() -> {
if (item instanceof AppInfo) {
WorkspaceItemInfo info = ((AppInfo) item).makeWorkspaceItem();
mContext.getModelWriter().addItemToDatabase(info,
Favorites.CONTAINER_DESKTOP,
screenId, coordinates[0], coordinates[1]);
mContext.bindItems(
Collections.singletonList(info),
/* forceAnimateIcons= */ true,
/* focusFirstItemForAccessibility= */ true);
announceConfirmation(R.string.item_added_to_workspace);
} else if (item instanceof PendingAddItemInfo) {
PendingAddItemInfo info = (PendingAddItemInfo) item;
Workspace workspace = mContext.getWorkspace();
workspace.snapToPage(workspace.getPageIndexForScreenId(screenId));
mContext.addPendingItem(info, Favorites.CONTAINER_DESKTOP,
screenId, coordinates, info.spanX, info.spanY);
}
else if (item instanceof WorkspaceItemInfo) {
WorkspaceItemInfo info = ((WorkspaceItemInfo) item).clone();
mContext.getModelWriter().addItemToDatabase(info,
Favorites.CONTAINER_DESKTOP,
screenId, coordinates[0], coordinates[1]);
mContext.bindItems(Collections.singletonList(info), true, true);
}
}));
return true;
return addToWorkspace(item, true);
} else if (action == MOVE_TO_WORKSPACE) {
Folder folder = Folder.getOpen(mContext);
folder.close(true);
WorkspaceItemInfo info = (WorkspaceItemInfo) item;
folder.getInfo().remove(info, false);
final int[] coordinates = new int[2];
final int screenId = findSpaceOnWorkspace(item, coordinates);
if (screenId == -1) {
return false;
}
mContext.getModelWriter().moveItemInDatabase(info,
Favorites.CONTAINER_DESKTOP,
screenId, coordinates[0], coordinates[1]);
// Bind the item in next frame so that if a new workspace page was created,
// it will get laid out.
new Handler().post(() -> {
mContext.bindItems(Collections.singletonList(item), true);
announceConfirmation(R.string.item_moved);
});
return true;
return moveToWorkspace(item);
} else if (action == RESIZE) {
final LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) item;
List<OptionItem> actions = getSupportedResizeActions(host, info);
@@ -403,4 +351,76 @@ public class LauncherAccessibilityDelegate extends BaseAccessibilityDelegate<Lau
}
return screenId;
}
/**
* Functionality to add the item {@link ItemInfo} to the workspace
* @param item item to be added
* @param accessibility true if the first item to be added to the workspace
* should be focused for accessibility.
*
* @return true if the item could be successfully added
*/
public boolean addToWorkspace(ItemInfo item, boolean accessibility) {
final int[] coordinates = new int[2];
final int screenId = findSpaceOnWorkspace(item, coordinates);
if (screenId == -1) {
return false;
}
mContext.getStateManager().goToState(NORMAL, true, forSuccessCallback(() -> {
if (item instanceof AppInfo) {
WorkspaceItemInfo info = ((AppInfo) item).makeWorkspaceItem();
mContext.getModelWriter().addItemToDatabase(info,
LauncherSettings.Favorites.CONTAINER_DESKTOP,
screenId, coordinates[0], coordinates[1]);
mContext.bindItems(
Collections.singletonList(info),
/* forceAnimateIcons= */ true,
/* focusFirstItemForAccessibility= */ accessibility);
announceConfirmation(R.string.item_added_to_workspace);
} else if (item instanceof PendingAddItemInfo) {
PendingAddItemInfo info = (PendingAddItemInfo) item;
Workspace<?> workspace = mContext.getWorkspace();
workspace.snapToPage(workspace.getPageIndexForScreenId(screenId));
mContext.addPendingItem(info, LauncherSettings.Favorites.CONTAINER_DESKTOP,
screenId, coordinates, info.spanX, info.spanY);
} else if (item instanceof WorkspaceItemInfo) {
WorkspaceItemInfo info = ((WorkspaceItemInfo) item).clone();
mContext.getModelWriter().addItemToDatabase(info,
LauncherSettings.Favorites.CONTAINER_DESKTOP,
screenId, coordinates[0], coordinates[1]);
mContext.bindItems(Collections.singletonList(info), true, accessibility);
}
}));
return true;
}
/**
* Functionality to move the item {@link ItemInfo} to the workspace
* @param item item to be moved
*
* @return true if the item could be successfully added
*/
public boolean moveToWorkspace(ItemInfo item) {
Folder folder = Folder.getOpen(mContext);
folder.close(true);
WorkspaceItemInfo info = (WorkspaceItemInfo) item;
folder.getInfo().remove(info, false);
final int[] coordinates = new int[2];
final int screenId = findSpaceOnWorkspace(item, coordinates);
if (screenId == -1) {
return false;
}
mContext.getModelWriter().moveItemInDatabase(info,
LauncherSettings.Favorites.CONTAINER_DESKTOP,
screenId, coordinates[0], coordinates[1]);
// Bind the item in next frame so that if a new workspace page was created,
// it will get laid out.
new Handler().post(() -> {
mContext.bindItems(Collections.singletonList(item), true);
announceConfirmation(R.string.item_moved);
});
return true;
}
}
@@ -104,7 +104,10 @@ public class DragLayer extends BaseDragLayer<Launcher> {
mFocusIndicatorHelper = new ViewGroupFocusHelper(this);
}
public void setup(DragController dragController, Workspace workspace) {
/**
* Set up the drag layer with the parameters.
*/
public void setup(DragController dragController, Workspace<?> workspace) {
mDragController = dragController;
recreateControllers();
mWorkspaceDragScrim = new Scrim(this);
@@ -55,7 +55,7 @@ public class SpringLoadedDragController implements OnAlarmListener {
public void onAlarm(Alarm alarm) {
if (mScreen != null) {
// Snap to the screen that we are hovering over now
Workspace w = mLauncher.getWorkspace();
Workspace<?> w = mLauncher.getWorkspace();
if (!w.isVisible(mScreen)) {
w.snapToPage(w.indexOfChild(mScreen));
}
@@ -342,7 +342,7 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
Rect to = finalRect;
if (to == null) {
to = new Rect();
Workspace workspace = launcher.getWorkspace();
Workspace<?> workspace = launcher.getWorkspace();
// Set cellLayout and this to it's final state to compute final animation locations
workspace.setFinalTransitionTransform();
float scaleX = getScaleX();
@@ -28,21 +28,22 @@ public interface PageIndicator {
/**
* Sets the flag if the Page Indicator should autohide.
* @param shouldAutoHide
*/
default void setShouldAutoHide(boolean shouldAutoHide) {
//No-op by default
// No-op by default
}
/**
* Pauses all currently running animations.
*/
default void pauseAnimations() {
//No-op by default
// No-op by default
}
/**
* Force-ends all currently running or paused animations.
*/
default void skipAnimationsToEnd() {
//No-op by default
// No-op by default
}
}
@@ -351,7 +351,7 @@ public abstract class ArrowPopup<T extends Context & ActivityContext>
if (mColorExtractors == null) {
return;
}
Workspace workspace = launcher.getWorkspace();
Workspace<?> workspace = launcher.getWorkspace();
if (workspace == null) {
return;
}
@@ -46,7 +46,7 @@ public class SpringLoadedState extends LauncherState {
@Override
public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
DeviceProfile grid = launcher.getDeviceProfile();
Workspace ws = launcher.getWorkspace();
Workspace<?> ws = launcher.getWorkspace();
if (ws.getChildCount() == 0) {
return super.getWorkspaceScaleAndTranslation(launcher);
}
@@ -178,7 +178,7 @@ public class TestInformationHandler implements ResourceBasedOverride {
case TestProtocol.REQUEST_WORKSPACE_CELL_LAYOUT_SIZE:
return getLauncherUIProperty(Bundle::putIntArray, launcher -> {
final Workspace workspace = launcher.getWorkspace();
final Workspace<?> workspace = launcher.getWorkspace();
final int screenId = workspace.getScreenIdForPageIndex(
workspace.getCurrentPage());
final CellLayout cellLayout = workspace.getScreenWithId(screenId);
@@ -189,7 +189,7 @@ public class TestInformationHandler implements ResourceBasedOverride {
final WorkspaceCellCenterRequest request = extra.getParcelable(
TestProtocol.TEST_INFO_REQUEST_FIELD);
return getLauncherUIProperty(Bundle::putParcelable, launcher -> {
final Workspace workspace = launcher.getWorkspace();
final Workspace<?> workspace = launcher.getWorkspace();
// TODO(b/216387249): allow caller selecting different pages.
CellLayout cellLayout = (CellLayout) workspace.getPageAt(
workspace.getCurrentPage());
@@ -64,7 +64,7 @@ public class WorkspaceTouchListener extends GestureDetector.SimpleOnGestureListe
private final Rect mTempRect = new Rect();
private final Launcher mLauncher;
private final Workspace mWorkspace;
private final Workspace<?> mWorkspace;
private final PointF mTouchDownPoint = new PointF();
private final float mTouchSlop;
@@ -72,7 +72,7 @@ public class WorkspaceTouchListener extends GestureDetector.SimpleOnGestureListe
private final GestureDetector mGestureDetector;
public WorkspaceTouchListener(Launcher launcher, Workspace workspace) {
public WorkspaceTouchListener(Launcher launcher, Workspace<?> workspace) {
mLauncher = launcher;
mWorkspace = workspace;
// Use twice the touch slop as we are looking for long press which is more
@@ -32,7 +32,7 @@ public class WallpaperOffsetInterpolator extends BroadcastReceiver {
// Don't use all the wallpaper for parallax until you have at least this many pages
private static final int MIN_PARALLAX_PAGE_SPAN = 4;
private final Workspace mWorkspace;
private final Workspace<?> mWorkspace;
private final boolean mIsRtl;
private final Handler mHandler;
@@ -43,7 +43,7 @@ public class WallpaperOffsetInterpolator extends BroadcastReceiver {
private boolean mLockedToDefaultPage;
private int mNumScreens;
public WallpaperOffsetInterpolator(Workspace workspace) {
public WallpaperOffsetInterpolator(Workspace<?> workspace) {
mWorkspace = workspace;
mIsRtl = Utilities.isRtl(workspace.getResources());
mHandler = new OffsetHandler(workspace.getContext());