Merge "Refactoring ItemInfo" into ub-launcher3-master

This commit is contained in:
Sunny Goyal
2015-07-07 06:06:58 +00:00
committed by Android (Google) Code Review
22 changed files with 92 additions and 178 deletions
+2 -5
View File
@@ -28,13 +28,11 @@ import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.util.ComponentKey;
import java.util.ArrayList;
import java.util.Arrays;
/**
* Represents an app in AllAppsView.
*/
public class AppInfo extends ItemInfo {
private static final String TAG = "Launcher3.AppInfo";
/**
* The intent used to start the application.
@@ -118,8 +116,7 @@ public class AppInfo extends ItemInfo {
return "ApplicationInfo(title=" + title + " id=" + this.id
+ " type=" + this.itemType + " container=" + this.container
+ " screen=" + screenId + " cellX=" + cellX + " cellY=" + cellY
+ " spanX=" + spanX + " spanY=" + spanY + " dropPos=" + Arrays.toString(dropPos)
+ " user=" + user + ")";
+ " spanX=" + spanX + " spanY=" + spanY + " user=" + user + ")";
}
/**
@@ -128,7 +125,7 @@ public class AppInfo extends ItemInfo {
public static void dumpApplicationInfoList(String tag, String label, ArrayList<AppInfo> list) {
Log.d(tag, label + " size=" + list.size());
for (AppInfo info: list) {
Log.d(tag, " title=\"" + info.title + "\" iconBitmap=" + info.iconBitmap
Log.d(tag, " title=\"" + info.title + "\" iconBitmap=" + info.iconBitmap
+ " firstInstallTime=" + info.firstInstallTime
+ " componentName=" + info.componentName.getPackageName());
}
@@ -24,7 +24,6 @@ import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.PointF;
@@ -185,8 +184,8 @@ public abstract class ButtonDropTarget extends TextView
}
}
@Override
public final void onDragStart(DragSource source, Object info, int dragAction) {
@Override
public final void onDragStart(DragSource source, ItemInfo info, int dragAction) {
mActive = supportsDrop(source, info);
mDrawable.setColorFilter(null);
if (mCurrentColorAnim != null) {
@@ -202,7 +201,7 @@ public abstract class ButtonDropTarget extends TextView
return supportsDrop(dragObject.dragSource, dragObject.dragInfo);
}
protected abstract boolean supportsDrop(DragSource source, Object info);
protected abstract boolean supportsDrop(DragSource source, ItemInfo info);
@Override
public boolean isDropEnabled() {
+19 -22
View File
@@ -50,6 +50,7 @@ import android.view.animation.DecelerateInterpolator;
import com.android.launcher3.BubbleTextView.BubbleTextShadowHandler;
import com.android.launcher3.FolderIcon.FolderRingAnimator;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.accessibility.DragAndDropAccessibilityDelegate;
import com.android.launcher3.accessibility.FolderAccessibilityHelper;
import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper;
@@ -1084,23 +1085,6 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
mDragCell[0] = mDragCell[1] = -1;
}
/**
* Find a vacant area that will fit the given bounds nearest the requested
* cell location. Uses Euclidean distance to score multiple vacant areas.
*
* @param pixelX The X location at which you want to search for a vacant area.
* @param pixelY The Y location at which you want to search for a vacant area.
* @param spanX Horizontal span of the object.
* @param spanY Vertical span of the object.
* @param result Array in which to place the result, or null (in which case a new array will
* be allocated)
* @return The X, Y cell of a vacant area that can contain this object,
* nearest the requested location.
*/
int[] findNearestVacantArea(int pixelX, int pixelY, int spanX, int spanY, int[] result) {
return findNearestVacantArea(pixelX, pixelY, spanX, spanY, spanX, spanY, result, null);
}
/**
* Find a vacant area that will fit the given bounds nearest the requested
* cell location. Uses Euclidean distance to score multiple vacant areas.
@@ -2198,6 +2182,15 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
mOccupied[i][j] = mTmpOccupied[i][j];
}
}
long screenId = mLauncher.getWorkspace().getIdForScreen(this);
int container = Favorites.CONTAINER_DESKTOP;
if (mLauncher.isHotseatLayout(this)) {
screenId = -1;
container = Favorites.CONTAINER_HOTSEAT;
}
int childCount = mShortcutsAndWidgets.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = mShortcutsAndWidgets.getChildAt(i);
@@ -2206,17 +2199,21 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
// We do a null check here because the item info can be null in the case of the
// AllApps button in the hotseat.
if (info != null) {
if (info.cellX != lp.tmpCellX || info.cellY != lp.tmpCellY ||
info.spanX != lp.cellHSpan || info.spanY != lp.cellVSpan) {
info.requiresDbUpdate = true;
}
final boolean requiresDbUpdate = (info.cellX != lp.tmpCellX
|| info.cellY != lp.tmpCellY || info.spanX != lp.cellHSpan
|| info.spanY != lp.cellVSpan);
info.cellX = lp.cellX = lp.tmpCellX;
info.cellY = lp.cellY = lp.tmpCellY;
info.spanX = lp.cellHSpan;
info.spanY = lp.cellVSpan;
if (requiresDbUpdate) {
LauncherModel.modifyItemInDatabase(mLauncher, info, container, screenId,
info.cellX, info.cellY, info.spanX, info.spanY);
}
}
}
mLauncher.getWorkspace().updateItemLocationsInDatabase(this);
}
private void setUseTempCoords(boolean useTempCoords) {
@@ -46,20 +46,20 @@ public class DeleteDropTarget extends ButtonDropTarget {
setDrawable(R.drawable.ic_remove_launcher);
}
public static boolean supportsDrop(Object info) {
public static boolean supportsDrop(ItemInfo info) {
return (info instanceof ShortcutInfo)
|| (info instanceof LauncherAppWidgetInfo)
|| (info instanceof FolderInfo);
}
@Override
protected boolean supportsDrop(DragSource source, Object info) {
protected boolean supportsDrop(DragSource source, ItemInfo info) {
return source.supportsDeleteDropTarget() && supportsDrop(info);
}
@Override
@Thunk void completeDrop(DragObject d) {
ItemInfo item = (ItemInfo) d.dragInfo;
ItemInfo item = d.dragInfo;
if ((d.dragSource instanceof Workspace) || (d.dragSource instanceof Folder)) {
removeWorkspaceOrFolderItem(mLauncher, item, null);
}
@@ -135,14 +135,14 @@ public class DragController {
* @param dragAction The drag action: either {@link DragController#DRAG_ACTION_MOVE}
* or {@link DragController#DRAG_ACTION_COPY}
*/
void onDragStart(DragSource source, Object info, int dragAction);
void onDragStart(DragSource source, ItemInfo info, int dragAction);
/**
* The drag has ended
*/
void onDragEnd();
}
/**
* Used to create a new DragLayer from XML.
*
@@ -178,7 +178,7 @@ public class DragController {
* @param dragRegion Coordinates within the bitmap b for the position of item being dragged.
* Makes dragging feel more precise, e.g. you can clip out a transparent border
*/
public void startDrag(View v, Bitmap bmp, DragSource source, Object dragInfo,
public void startDrag(View v, Bitmap bmp, DragSource source, ItemInfo dragInfo,
Rect viewImageBounds, int dragAction, float initialDragViewScale) {
int[] loc = mCoordinatesTemp;
mLauncher.getDragLayer().getLocationInDragLayer(v, loc);
@@ -211,7 +211,7 @@ public class DragController {
* @param accessible whether this drag should occur in accessibility mode
*/
public DragView startDrag(Bitmap b, int dragLayerX, int dragLayerY,
DragSource source, Object dragInfo, int dragAction, Point dragOffset, Rect dragRegion,
DragSource source, ItemInfo dragInfo, int dragAction, Point dragOffset, Rect dragRegion,
float initialDragViewScale, boolean accessible) {
if (PROFILE_DRAWING_DURING_DRAG) {
android.os.Debug.startMethodTracing("Launcher");
+1 -1
View File
@@ -47,7 +47,7 @@ public interface DropTarget {
public DragView dragView = null;
/** The data associated with the object being dragged */
public Object dragInfo = null;
public ItemInfo dragInfo = null;
/** Where the drag originated */
public DragSource dragSource = null;
+2 -2
View File
@@ -600,7 +600,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
}
@Override
public void onDragStart(DragSource source, Object info, int dragAction) { }
public void onDragStart(DragSource source, ItemInfo info, int dragAction) { }
@Override
public void onDragEnd() {
@@ -649,7 +649,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
}
public boolean acceptDrop(DragObject d) {
final ItemInfo item = (ItemInfo) d.dragInfo;
final ItemInfo item = d.dragInfo;
final int itemType = item.itemType;
return ((itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION ||
itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) &&
+5 -5
View File
@@ -330,8 +330,8 @@ public class FolderIcon extends FrameLayout implements FolderListener {
!mFolder.isFull() && item != mInfo && !mInfo.opened);
}
public boolean acceptDrop(Object dragInfo) {
final ItemInfo item = (ItemInfo) dragInfo;
public boolean acceptDrop(ItemInfo dragInfo) {
final ItemInfo item = dragInfo;
return !mFolder.isDestroyed() && willAcceptItem(item);
}
@@ -339,8 +339,8 @@ public class FolderIcon extends FrameLayout implements FolderListener {
mInfo.add(item);
}
public void onDragEnter(Object dragInfo) {
if (mFolder.isDestroyed() || !willAcceptItem((ItemInfo) dragInfo)) return;
public void onDragEnter(ItemInfo dragInfo) {
if (mFolder.isDestroyed() || !willAcceptItem(dragInfo)) return;
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) getLayoutParams();
CellLayout layout = (CellLayout) getParent().getParent();
mFolderRingAnimator.setCell(lp.cellX, lp.cellY);
@@ -356,7 +356,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
// Workspace#onDropExternal.
mOpenAlarm.setAlarm(ON_OPEN_DELAY);
}
mDragInfo = (ItemInfo) dragInfo;
mDragInfo = dragInfo;
}
public void onDragOver(Object dragInfo) {
+1 -2
View File
@@ -22,7 +22,6 @@ import android.content.Context;
import com.android.launcher3.compat.UserHandleCompat;
import java.util.ArrayList;
import java.util.Arrays;
/**
* Represents a folder containing shortcuts or apps.
@@ -140,7 +139,7 @@ public class FolderInfo extends ItemInfo {
return "FolderInfo(id=" + this.id + " type=" + this.itemType
+ " container=" + this.container + " screen=" + screenId
+ " cellX=" + cellX + " cellY=" + cellY + " spanX=" + spanX
+ " spanY=" + spanY + " dropPos=" + Arrays.toString(dropPos) + ")";
+ " spanY=" + spanY + ")";
}
public boolean hasOption(int optionFlag) {
+4 -13
View File
@@ -20,8 +20,6 @@ import android.content.ComponentName;
import android.content.Context;
import android.util.AttributeSet;
import com.android.launcher3.compat.UserHandleCompat;
public class InfoDropTarget extends ButtonDropTarget {
public InfoDropTarget(Context context, AttributeSet attrs) {
@@ -41,7 +39,7 @@ public class InfoDropTarget extends ButtonDropTarget {
setDrawable(R.drawable.ic_info_launcher);
}
public static void startDetailsActivityForInfo(Object info, Launcher launcher) {
public static void startDetailsActivityForInfo(ItemInfo info, Launcher launcher) {
ComponentName componentName = null;
if (info instanceof AppInfo) {
componentName = ((AppInfo) info).componentName;
@@ -50,24 +48,17 @@ public class InfoDropTarget extends ButtonDropTarget {
} else if (info instanceof PendingAddItemInfo) {
componentName = ((PendingAddItemInfo) info).componentName;
}
final UserHandleCompat user;
if (info instanceof ItemInfo) {
user = ((ItemInfo) info).user;
} else {
user = UserHandleCompat.myUserHandle();
}
if (componentName != null) {
launcher.startApplicationDetailsActivity(componentName, user);
launcher.startApplicationDetailsActivity(componentName, info.user);
}
}
@Override
protected boolean supportsDrop(DragSource source, Object info) {
protected boolean supportsDrop(DragSource source, ItemInfo info) {
return source.supportsAppInfoDropTarget() && supportsDrop(getContext(), info);
}
public static boolean supportsDrop(Context context, Object info) {
public static boolean supportsDrop(Context context, ItemInfo info) {
return info instanceof AppInfo || info instanceof PendingAddItemInfo;
}
+8 -21
View File
@@ -24,8 +24,6 @@ import android.graphics.Bitmap;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import java.util.Arrays;
/**
* Represents an item in the launcher.
*/
@@ -35,14 +33,14 @@ public class ItemInfo {
* Intent extra to store the profile. Format: UserHandle
*/
static final String EXTRA_PROFILE = "profile";
public static final int NO_ID = -1;
/**
* The id in the settings database for this item
*/
public long id = NO_ID;
/**
* One of {@link LauncherSettings.Favorites#ITEM_TYPE_APPLICATION},
* {@link LauncherSettings.Favorites#ITEM_TYPE_SHORTCUT},
@@ -50,20 +48,20 @@ public class ItemInfo {
* {@link LauncherSettings.Favorites#ITEM_TYPE_APPWIDGET}.
*/
public int itemType;
/**
* The id of the container that holds this item. For the desktop, this will be
* The id of the container that holds this item. For the desktop, this will be
* {@link LauncherSettings.Favorites#CONTAINER_DESKTOP}. For the all applications folder it
* will be {@link #NO_ID} (since it is not stored in the settings DB). For user folders
* it will be the id of the folder.
*/
public long container = NO_ID;
/**
* Iindicates the screen in which the shortcut appears.
*/
public long screenId = -1;
/**
* Indicates the X position of the associated cell.
*/
@@ -99,11 +97,6 @@ public class ItemInfo {
*/
public int rank = 0;
/**
* Indicates that this item needs to be updated in the db
*/
public boolean requiresDbUpdate = false;
/**
* Title of the item
*/
@@ -114,11 +107,6 @@ public class ItemInfo {
*/
public CharSequence contentDescription;
/**
* The position of the item in a drag-and-drop operation.
*/
public int[] dropPos = null;
public UserHandleCompat user;
public ItemInfo() {
@@ -194,7 +182,6 @@ public class ItemInfo {
public String toString() {
return "Item(id=" + this.id + " type=" + this.itemType + " container=" + this.container
+ " screen=" + screenId + " cellX=" + cellX + " cellY=" + cellY + " spanX=" + spanX
+ " spanY=" + spanY + " dropPos=" + Arrays.toString(dropPos)
+ " user=" + user + ")";
+ " spanY=" + spanY + " user=" + user + ")";
}
}
+1 -9
View File
@@ -253,7 +253,7 @@ public class Launcher extends Activity
private AppWidgetManagerCompat mAppWidgetManager;
private LauncherAppWidgetHost mAppWidgetHost;
@Thunk ItemInfo mPendingAddInfo = new ItemInfo();
@Thunk final ItemInfo mPendingAddInfo = new ItemInfo();
private LauncherAppWidgetProviderInfo mPendingAddWidgetInfo;
private int mPendingAddWidgetId = -1;
@@ -1500,7 +1500,6 @@ public class Launcher extends Activity
private void completeAddShortcut(Intent data, long container, long screenId, int cellX,
int cellY) {
int[] cellXY = mTmpAddItemCellCoordinates;
int[] touchXY = mPendingAddInfo.dropPos;
CellLayout layout = getCellLayout(container, screenId);
ShortcutInfo info = InstallShortcutReceiver.fromShortcutIntent(this, data);
@@ -1527,10 +1526,6 @@ public class Launcher extends Activity
true)) {
return;
}
} else if (touchXY != null) {
// when dragging and dropping, just find the closest free spot
int[] result = layout.findNearestVacantArea(touchXY[0], touchXY[1], 1, 1, cellXY);
foundCellSpan = (result != null);
} else {
foundCellSpan = layout.findCellForSpan(cellXY, 1, 1);
}
@@ -2214,7 +2209,6 @@ public class Launcher extends Activity
mPendingAddInfo.cellX = mPendingAddInfo.cellY = -1;
mPendingAddInfo.spanX = mPendingAddInfo.spanY = -1;
mPendingAddInfo.minSpanX = mPendingAddInfo.minSpanY = -1;
mPendingAddInfo.dropPos = null;
}
void addAppWidgetImpl(final int appWidgetId, final ItemInfo info, final
@@ -2286,7 +2280,6 @@ public class Launcher extends Activity
resetAddInfo();
mPendingAddInfo.container = container;
mPendingAddInfo.screenId = screenId;
mPendingAddInfo.dropPos = null;
if (cell != null) {
mPendingAddInfo.cellX = cell[0];
@@ -2310,7 +2303,6 @@ public class Launcher extends Activity
resetAddInfo();
mPendingAddInfo.container = info.container = container;
mPendingAddInfo.screenId = info.screenId = screenId;
mPendingAddInfo.dropPos = null;
mPendingAddInfo.minSpanX = info.minSpanX;
mPendingAddInfo.minSpanY = info.minSpanY;
+1 -6
View File
@@ -660,12 +660,7 @@ public class LauncherModel extends BroadcastReceiver
modelShortcut.cellX == shortcut.cellX &&
modelShortcut.cellY == shortcut.cellY &&
modelShortcut.spanX == shortcut.spanX &&
modelShortcut.spanY == shortcut.spanY &&
((modelShortcut.dropPos == null && shortcut.dropPos == null) ||
(modelShortcut.dropPos != null &&
shortcut.dropPos != null &&
modelShortcut.dropPos[0] == shortcut.dropPos[0] &&
modelShortcut.dropPos[1] == shortcut.dropPos[1]))) {
modelShortcut.spanY == shortcut.spanY) {
// For all intents and purposes, this is the same object
return;
}
@@ -196,7 +196,7 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
* DragController.DragListener implementation
*/
@Override
public void onDragStart(DragSource source, Object info, int dragAction) {
public void onDragStart(DragSource source, ItemInfo info, int dragAction) {
showDeleteTarget();
}
+1 -2
View File
@@ -29,7 +29,6 @@ import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import java.util.ArrayList;
import java.util.Arrays;
/**
* Represents a launchable icon on the workspaces and in folders.
@@ -241,7 +240,7 @@ public class ShortcutInfo extends ItemInfo {
return "ShortcutInfo(title=" + title + "intent=" + intent + "id=" + this.id
+ " type=" + this.itemType + " container=" + this.container + " screen=" + screenId
+ " cellX=" + cellX + " cellY=" + cellY + " spanX=" + spanX + " spanY=" + spanY
+ " dropPos=" + Arrays.toString(dropPos) + " user=" + user + ")";
+ " user=" + user + ")";
}
public static void dumpShortcutInfoList(String tag, String label,
@@ -8,7 +8,7 @@ import android.os.Bundle;
import android.os.UserManager;
import android.util.AttributeSet;
import android.util.Pair;
import com.android.launcher3.R;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.util.Thunk;
@@ -32,7 +32,7 @@ public class UninstallDropTarget extends ButtonDropTarget {
}
@Override
protected boolean supportsDrop(DragSource source, Object info) {
protected boolean supportsDrop(DragSource source, ItemInfo info) {
return supportsDrop(getContext(), info);
}
@@ -81,7 +81,7 @@ public class UninstallDropTarget extends ButtonDropTarget {
@Override
void completeDrop(final DragObject d) {
final Pair<ComponentName, Integer> componentInfo = getAppInfoFlags(d.dragInfo);
final UserHandleCompat user = ((ItemInfo) d.dragInfo).user;
final UserHandleCompat user = d.dragInfo.user;
if (startUninstallActivity(mLauncher, d.dragInfo)) {
final Runnable checkIfUninstallWasSuccess = new Runnable() {
@@ -99,9 +99,9 @@ public class UninstallDropTarget extends ButtonDropTarget {
}
}
public static boolean startUninstallActivity(Launcher launcher, Object info) {
public static boolean startUninstallActivity(Launcher launcher, ItemInfo info) {
final Pair<ComponentName, Integer> componentInfo = getAppInfoFlags(info);
final UserHandleCompat user = ((ItemInfo) info).user;
final UserHandleCompat user = info.user;
return launcher.startApplicationUninstallActivity(
componentInfo.first, componentInfo.second, user);
}
+25 -65
View File
@@ -28,7 +28,6 @@ import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetProviderInfo;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -167,7 +166,6 @@ public class Workspace extends PagedView
// return an (x, y) value from helper functions. Do NOT use them to maintain other state.
private int[] mTempCell = new int[2];
private int[] mTempPt = new int[2];
private int[] mTempEstimate = new int[2];
@Thunk float[] mDragViewVisualCenter = new float[2];
private float[] mTempCellLayoutCenterCoordinates = new float[2];
private Matrix mTempInverseMatrix = new Matrix();
@@ -369,7 +367,7 @@ public class Workspace extends PagedView
}
@Override
public void onDragStart(final DragSource source, Object info, int dragAction) {
public void onDragStart(final DragSource source, ItemInfo info, int dragAction) {
if (ENFORCE_DRAG_EVENT_ORDER) {
enfoceDragParity("onDragStart", 0, 0);
}
@@ -2288,15 +2286,17 @@ public class Workspace extends PagedView
icon.clearPressedBackground();
}
if (child.getTag() == null || !(child.getTag() instanceof ItemInfo)) {
Object dragObject = child.getTag();
if (!(dragObject instanceof ItemInfo)) {
String msg = "Drag started with a view that has no tag set. This "
+ "will cause a crash (issue 11627249) down the line. "
+ "View: " + child + " tag: " + child.getTag();
throw new IllegalStateException(msg);
}
DragView dv = mDragController.startDrag(b, dragLayerX, dragLayerY, source, child.getTag(),
DragController.DRAG_ACTION_MOVE, dragVisualizeOffset, dragRect, scale, accessible);
DragView dv = mDragController.startDrag(b, dragLayerX, dragLayerY, source,
(ItemInfo) dragObject, DragController.DRAG_ACTION_MOVE, dragVisualizeOffset,
dragRect, scale, accessible);
dv.setIntrinsicIconScaleFactor(source.getIntrinsicIconScaleFactor());
if (child.getParent() instanceof ShortcutAndWidgetContainer) {
@@ -2336,7 +2336,8 @@ public class Workspace extends PagedView
Point dragVisualizeOffset = new Point(-padding.get() / 2, padding.get() / 2);
Rect dragRect = new Rect(0, 0, iconSize, iconSize);
if (child.getTag() == null || !(child.getTag() instanceof ItemInfo)) {
Object dragObject = child.getTag();
if (!(dragObject instanceof ItemInfo)) {
String msg = "Drag started with a view that has no tag set. This "
+ "will cause a crash (issue 11627249) down the line. "
+ "View: " + child + " tag: " + child.getTag();
@@ -2344,8 +2345,9 @@ public class Workspace extends PagedView
}
// Start the drag
DragView dv = mDragController.startDrag(b, dragLayerX, dragLayerY, source, child.getTag(),
DragController.DRAG_ACTION_MOVE, dragVisualizeOffset, dragRect, scale, false);
DragView dv = mDragController.startDrag(b, dragLayerX, dragLayerY, source,
(ItemInfo) dragObject, DragController.DRAG_ACTION_MOVE, dragVisualizeOffset,
dragRect, scale, false);
dv.setIntrinsicIconScaleFactor(source.getIntrinsicIconScaleFactor());
// Recycle temporary bitmaps
@@ -2386,9 +2388,8 @@ public class Workspace extends PagedView
spanX = dragCellInfo.spanX;
spanY = dragCellInfo.spanY;
} else {
final ItemInfo dragInfo = (ItemInfo) d.dragInfo;
spanX = dragInfo.spanX;
spanY = dragInfo.spanY;
spanX = d.dragInfo.spanX;
spanY = d.dragInfo.spanY;
}
int minSpanX = spanX;
@@ -2403,12 +2404,12 @@ public class Workspace extends PagedView
mTargetCell);
float distance = dropTargetLayout.getDistanceFromCell(mDragViewVisualCenter[0],
mDragViewVisualCenter[1], mTargetCell);
if (mCreateUserFolderOnDrop && willCreateUserFolder((ItemInfo) d.dragInfo,
if (mCreateUserFolderOnDrop && willCreateUserFolder(d.dragInfo,
dropTargetLayout, mTargetCell, distance, true)) {
return true;
}
if (mAddToExistingFolderOnDrop && willAddToExistingUserFolder((ItemInfo) d.dragInfo,
if (mAddToExistingFolderOnDrop && willAddToExistingUserFolder(d.dragInfo,
dropTargetLayout, mTargetCell, distance)) {
return true;
}
@@ -2474,7 +2475,7 @@ public class Workspace extends PagedView
return (aboveShortcut && willBecomeShortcut);
}
boolean willAddToExistingUserFolder(Object dragInfo, CellLayout target, int[] targetCell,
boolean willAddToExistingUserFolder(ItemInfo dragInfo, CellLayout target, int[] targetCell,
float distance) {
if (distance > mMaxDistanceForFolderCreation) return false;
View dropOverView = target.getChildAt(targetCell[0], targetCell[1]);
@@ -2630,7 +2631,7 @@ public class Workspace extends PagedView
// Aside from the special case where we're dropping a shortcut onto a shortcut,
// we need to find the nearest cell location that is vacant
ItemInfo item = (ItemInfo) d.dragInfo;
ItemInfo item = d.dragInfo;
int minSpanX = item.spanX;
int minSpanY = item.spanY;
if (item.minSpanX > 0 && item.minSpanY > 0) {
@@ -3120,7 +3121,7 @@ public class Workspace extends PagedView
Rect r = new Rect();
CellLayout layout = null;
ItemInfo item = (ItemInfo) d.dragInfo;
ItemInfo item = d.dragInfo;
if (item == null) {
if (LauncherAppState.isDogfoodBuild()) {
throw new NullPointerException("DragObject has null info");
@@ -3181,7 +3182,7 @@ public class Workspace extends PagedView
mapPointFromSelfToChild(mDragTargetLayout, mDragViewVisualCenter, null);
}
ItemInfo info = (ItemInfo) d.dragInfo;
ItemInfo info = d.dragInfo;
int minSpanX = item.spanX;
int minSpanY = item.spanY;
@@ -3360,24 +3361,6 @@ public class Workspace extends PagedView
mLauncher.getDragLayer().getDescendantRectRelativeToSelf(this, outRect);
}
/**
* Add the item specified by dragInfo to the given layout.
* @return true if successful
*/
public boolean addExternalItemToScreen(ItemInfo dragInfo, CellLayout layout) {
if (layout.findCellForSpan(mTempEstimate, dragInfo.spanX, dragInfo.spanY)) {
onDropExternal(dragInfo.dropPos, (ItemInfo) dragInfo, (CellLayout) layout, false);
return true;
}
mLauncher.showOutOfSpaceMessage(mLauncher.isHotseatLayout(layout));
return false;
}
private void onDropExternal(int[] touchXY, Object dragInfo,
CellLayout cellLayout, boolean insertAtFirst) {
onDropExternal(touchXY, dragInfo, cellLayout, insertAtFirst, null);
}
/**
* 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
@@ -3386,7 +3369,7 @@ public class Workspace extends PagedView
* 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.
*/
private void onDropExternal(final int[] touchXY, final Object dragInfo,
private void onDropExternal(final int[] touchXY, final ItemInfo dragInfo,
final CellLayout cellLayout, boolean insertAtFirst, DragObject d) {
final Runnable exitSpringLoadedRunnable = new Runnable() {
@Override
@@ -3396,7 +3379,7 @@ public class Workspace extends PagedView
}
};
ItemInfo info = (ItemInfo) dragInfo;
ItemInfo info = dragInfo;
int spanX = info.spanX;
int spanY = info.spanY;
if (mDragInfo != null) {
@@ -3423,14 +3406,14 @@ public class Workspace extends PagedView
cellLayout, mTargetCell);
float distance = cellLayout.getDistanceFromCell(mDragViewVisualCenter[0],
mDragViewVisualCenter[1], mTargetCell);
if (willCreateUserFolder((ItemInfo) d.dragInfo, cellLayout, mTargetCell,
distance, true) || willAddToExistingUserFolder((ItemInfo) d.dragInfo,
cellLayout, mTargetCell, distance)) {
if (willCreateUserFolder(d.dragInfo, cellLayout, mTargetCell, distance, true)
|| willAddToExistingUserFolder(
d.dragInfo, cellLayout, mTargetCell, distance)) {
findNearestVacantCell = false;
}
}
final ItemInfo item = (ItemInfo) d.dragInfo;
final ItemInfo item = d.dragInfo;
boolean updateWidgetSize = false;
if (findNearestVacantCell) {
int minSpanX = item.spanX;
@@ -3791,29 +3774,6 @@ public class Workspace extends PagedView
}
}
void updateItemLocationsInDatabase(CellLayout cl) {
int count = cl.getShortcutsAndWidgets().getChildCount();
long screenId = getIdForScreen(cl);
int container = Favorites.CONTAINER_DESKTOP;
if (mLauncher.isHotseatLayout(cl)) {
screenId = -1;
container = Favorites.CONTAINER_HOTSEAT;
}
for (int i = 0; i < count; i++) {
View v = cl.getShortcutsAndWidgets().getChildAt(i);
ItemInfo info = (ItemInfo) v.getTag();
// Null check required as the AllApps button doesn't have an item info
if (info != null && info.requiresDbUpdate) {
info.requiresDbUpdate = false;
LauncherModel.modifyItemInDatabase(mLauncher, info, container, screenId, info.cellX,
info.cellY, info.spanX, info.spanY);
}
}
}
void saveWorkspaceToDb() {
saveWorkspaceScreenToDb((CellLayout) mLauncher.getHotseat().getLayout());
int count = getChildCount();
@@ -375,7 +375,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
@Override
public void onDragStart(DragSource source, Object info, int dragAction) {
public void onDragStart(DragSource source, ItemInfo info, int dragAction) {
// No-op
}
@@ -517,7 +517,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
int currentScreen = mLauncher.getCurrentWorkspaceScreen();
Workspace workspace = (Workspace) target;
CellLayout layout = (CellLayout) workspace.getChildAt(currentScreen);
ItemInfo itemInfo = (ItemInfo) d.dragInfo;
ItemInfo itemInfo = d.dragInfo;
if (layout != null) {
layout.calculateSpans(itemInfo);
showOutOfSpaceMessage =
@@ -20,8 +20,6 @@ import android.graphics.Bitmap;
import com.android.launcher3.ItemInfo;
import java.util.Arrays;
/**
* Represents a {@link Package} in the widget tray section.
*/
@@ -59,7 +57,6 @@ public class PackageItemInfo extends ItemInfo {
return "PackageItemInfo(title=" + title + " id=" + this.id
+ " type=" + this.itemType + " container=" + this.container
+ " screen=" + screenId + " cellX=" + cellX + " cellY=" + cellY
+ " spanX=" + spanX + " spanY=" + spanY + " dropPos=" + Arrays.toString(dropPos)
+ " user=" + user + ")";
+ " spanX=" + spanX + " spanY=" + spanY + " user=" + user + ")";
}
}
@@ -13,6 +13,7 @@ import com.android.launcher3.AppWidgetResizeFrame;
import com.android.launcher3.DragController.DragListener;
import com.android.launcher3.DragLayer;
import com.android.launcher3.DragSource;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppWidgetProviderInfo;
import com.android.launcher3.compat.AppWidgetManagerCompat;
@@ -43,7 +44,7 @@ public class WidgetHostViewLoader implements DragListener {
}
@Override
public void onDragStart(DragSource source, Object info, int dragAction) { }
public void onDragStart(DragSource source, ItemInfo info, int dragAction) { }
@Override
public void onDragEnd() {
@@ -317,7 +317,7 @@ public class WidgetsContainerView extends BaseContainerView
int currentScreen = mLauncher.getCurrentWorkspaceScreen();
Workspace workspace = (Workspace) target;
CellLayout layout = (CellLayout) workspace.getChildAt(currentScreen);
ItemInfo itemInfo = (ItemInfo) d.dragInfo;
ItemInfo itemInfo = d.dragInfo;
if (layout != null) {
layout.calculateSpans(itemInfo);
showOutOfSpaceMessage =