summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/AppInfo.java7
-rw-r--r--src/com/android/launcher3/BaseContainerView.java4
-rw-r--r--src/com/android/launcher3/BuildInfo.java25
-rw-r--r--src/com/android/launcher3/ButtonDropTarget.java7
-rw-r--r--src/com/android/launcher3/CellLayout.java44
-rw-r--r--src/com/android/launcher3/DeleteDropTarget.java6
-rw-r--r--src/com/android/launcher3/DeviceProfile.java10
-rw-r--r--src/com/android/launcher3/DragController.java8
-rw-r--r--src/com/android/launcher3/DropTarget.java2
-rw-r--r--src/com/android/launcher3/FocusHelper.java3
-rw-r--r--src/com/android/launcher3/Folder.java4
-rw-r--r--src/com/android/launcher3/FolderIcon.java10
-rw-r--r--src/com/android/launcher3/FolderInfo.java3
-rw-r--r--src/com/android/launcher3/InfoDropTarget.java17
-rw-r--r--src/com/android/launcher3/ItemInfo.java29
-rw-r--r--src/com/android/launcher3/Launcher.java77
-rw-r--r--src/com/android/launcher3/LauncherAppState.java6
-rw-r--r--src/com/android/launcher3/LauncherModel.java47
-rw-r--r--src/com/android/launcher3/LauncherStateTransitionAnimation.java39
-rw-r--r--src/com/android/launcher3/PagedView.java67
-rw-r--r--src/com/android/launcher3/SearchDropTargetBar.java2
-rw-r--r--src/com/android/launcher3/ShortcutInfo.java3
-rw-r--r--src/com/android/launcher3/Stats.java4
-rw-r--r--src/com/android/launcher3/UninstallDropTarget.java10
-rw-r--r--src/com/android/launcher3/Utilities.java4
-rw-r--r--src/com/android/launcher3/Workspace.java205
-rw-r--r--src/com/android/launcher3/WorkspaceStateTransitionAnimation.java19
-rw-r--r--src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java2
-rw-r--r--src/com/android/launcher3/allapps/AllAppsContainerView.java2
-rw-r--r--src/com/android/launcher3/allapps/AlphabeticalAppsList.java5
-rw-r--r--src/com/android/launcher3/config/ProviderConfig.java2
-rw-r--r--src/com/android/launcher3/model/PackageItemInfo.java5
-rw-r--r--src/com/android/launcher3/widget/WidgetHostViewLoader.java3
-rw-r--r--src/com/android/launcher3/widget/WidgetsContainerView.java2
34 files changed, 273 insertions, 410 deletions
diff --git a/src/com/android/launcher3/AppInfo.java b/src/com/android/launcher3/AppInfo.java
index c95d5585a..7249c6406 100644
--- a/src/com/android/launcher3/AppInfo.java
+++ b/src/com/android/launcher3/AppInfo.java
@@ -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());
}
diff --git a/src/com/android/launcher3/BaseContainerView.java b/src/com/android/launcher3/BaseContainerView.java
index c8de9df10..a049ec0f1 100644
--- a/src/com/android/launcher3/BaseContainerView.java
+++ b/src/com/android/launcher3/BaseContainerView.java
@@ -22,6 +22,8 @@ import android.util.AttributeSet;
import android.util.Log;
import android.widget.LinearLayout;
+import com.android.launcher3.config.ProviderConfig;
+
/**
* A base container view, which supports resizing.
*/
@@ -69,7 +71,7 @@ public abstract class BaseContainerView extends LinearLayout implements Insettab
* Sets the search bar bounds for this container view to match.
*/
final public void setSearchBarBounds(Rect bounds) {
- if (LauncherAppState.isDogfoodBuild() && !isValidSearchBarBounds(bounds)) {
+ if (ProviderConfig.IS_DOGFOOD_BUILD && !isValidSearchBarBounds(bounds)) {
Log.e(TAG, "Invalid search bar bounds: " + bounds);
}
diff --git a/src/com/android/launcher3/BuildInfo.java b/src/com/android/launcher3/BuildInfo.java
index b49ee0d9b..1392d7a43 100644
--- a/src/com/android/launcher3/BuildInfo.java
+++ b/src/com/android/launcher3/BuildInfo.java
@@ -1,32 +1,9 @@
package com.android.launcher3;
-import android.text.TextUtils;
-import android.util.Log;
-
+// TODO: Remove this class once all its references are gone.
public class BuildInfo {
- private static final boolean DBG = false;
- private static final String TAG = "BuildInfo";
public boolean isDogfoodBuild() {
return false;
}
-
- public static BuildInfo loadByName(String className) {
- if (TextUtils.isEmpty(className)) return new BuildInfo();
-
- if (DBG) Log.d(TAG, "Loading BuildInfo: " + className);
- try {
- Class<?> cls = Class.forName(className);
- return (BuildInfo) cls.newInstance();
- } catch (ClassNotFoundException e) {
- Log.e(TAG, "Bad BuildInfo class", e);
- } catch (InstantiationException e) {
- Log.e(TAG, "Bad BuildInfo class", e);
- } catch (IllegalAccessException e) {
- Log.e(TAG, "Bad BuildInfo class", e);
- } catch (ClassCastException e) {
- Log.e(TAG, "Bad BuildInfo class", e);
- }
- return new BuildInfo();
- }
}
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index b7f89d02a..574f229eb 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -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() {
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index b875d22e6..cad1a4fe9 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -50,9 +50,11 @@ 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;
+import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.widget.PendingAddWidgetInfo;
@@ -568,7 +570,7 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
try {
dispatchRestoreInstanceState(states);
} catch (IllegalArgumentException ex) {
- if (LauncherAppState.isDogfoodBuild()) {
+ if (ProviderConfig.IS_DOGFOOD_BUILD) {
throw ex;
}
// Mismatched viewId / viewType preventing restore. Skip restore on production builds.
@@ -1095,23 +1097,6 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
*
* @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.
- *
- * @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 minSpanX The minimum horizontal span required
* @param minSpanY The minimum vertical span required
* @param spanX Horizontal span of the object.
@@ -2203,6 +2188,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);
@@ -2211,17 +2205,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) {
diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java
index 9c8659c29..ae6e3ba0b 100644
--- a/src/com/android/launcher3/DeleteDropTarget.java
+++ b/src/com/android/launcher3/DeleteDropTarget.java
@@ -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);
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 6e90fc291..6cfdcf70b 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -340,13 +340,13 @@ public class DeviceProfile {
}
// The rect returned will be extended to below the system ui that covers the workspace
- Rect getHotseatRect() {
+ public boolean isInHotseatRect(int x, int y) {
if (isVerticalBarLayout()) {
- return new Rect(availableWidthPx - hotseatBarHeightPx, 0,
- Integer.MAX_VALUE, availableHeightPx);
+ return (x >= (availableWidthPx - hotseatBarHeightPx))
+ && (y >= 0) && (y <= availableHeightPx);
} else {
- return new Rect(0, availableHeightPx - hotseatBarHeightPx,
- availableWidthPx, Integer.MAX_VALUE);
+ return (x >= 0) && (x <= availableWidthPx)
+ && (y >= (availableHeightPx - hotseatBarHeightPx));
}
}
diff --git a/src/com/android/launcher3/DragController.java b/src/com/android/launcher3/DragController.java
index 2191455d5..410271d29 100644
--- a/src/com/android/launcher3/DragController.java
+++ b/src/com/android/launcher3/DragController.java
@@ -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");
diff --git a/src/com/android/launcher3/DropTarget.java b/src/com/android/launcher3/DropTarget.java
index c8fac5466..374846445 100644
--- a/src/com/android/launcher3/DropTarget.java
+++ b/src/com/android/launcher3/DropTarget.java
@@ -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;
diff --git a/src/com/android/launcher3/FocusHelper.java b/src/com/android/launcher3/FocusHelper.java
index 57aec3280..3751b881b 100644
--- a/src/com/android/launcher3/FocusHelper.java
+++ b/src/com/android/launcher3/FocusHelper.java
@@ -22,6 +22,7 @@ import android.view.SoundEffectConstants;
import android.view.View;
import android.view.ViewGroup;
+import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.util.FocusLogic;
import com.android.launcher3.util.Thunk;
@@ -74,7 +75,7 @@ public class FocusHelper {
if (!(v.getParent() instanceof ShortcutAndWidgetContainer)) {
- if (LauncherAppState.isDogfoodBuild()) {
+ if (ProviderConfig.IS_DOGFOOD_BUILD) {
throw new IllegalStateException("Parent of the focused item is not supported.");
} else {
return false;
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index 2e19f6eba..21f23b599 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -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) &&
diff --git a/src/com/android/launcher3/FolderIcon.java b/src/com/android/launcher3/FolderIcon.java
index 8d534d2fe..de0df0dee 100644
--- a/src/com/android/launcher3/FolderIcon.java
+++ b/src/com/android/launcher3/FolderIcon.java
@@ -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) {
diff --git a/src/com/android/launcher3/FolderInfo.java b/src/com/android/launcher3/FolderInfo.java
index aea21c95b..6e0dcd421 100644
--- a/src/com/android/launcher3/FolderInfo.java
+++ b/src/com/android/launcher3/FolderInfo.java
@@ -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) {
diff --git a/src/com/android/launcher3/InfoDropTarget.java b/src/com/android/launcher3/InfoDropTarget.java
index d93cdcc1b..b4a144526 100644
--- a/src/com/android/launcher3/InfoDropTarget.java
+++ b/src/com/android/launcher3/InfoDropTarget.java
@@ -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;
}
diff --git a/src/com/android/launcher3/ItemInfo.java b/src/com/android/launcher3/ItemInfo.java
index f7e0ea488..4bc501987 100644
--- a/src/com/android/launcher3/ItemInfo.java
+++ b/src/com/android/launcher3/ItemInfo.java
@@ -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.
*/
@@ -100,11 +98,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
*/
public CharSequence title;
@@ -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 + ")";
}
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 6648b6e74..e27e1837f 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -103,6 +103,7 @@ import com.android.launcher3.compat.LauncherActivityInfoCompat;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
+import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.LongArrayMap;
@@ -165,8 +166,6 @@ public class Launcher extends Activity
*/
protected static final int REQUEST_LAST = 100;
- static final int SCREEN_COUNT = 5;
-
// To turn on these properties, type
// adb shell setprop log.tag.PROPERTY_NAME [VERBOSE | SUPPRESS]
static final String DUMP_STATE_PROPERTY = "launcher_dump_state";
@@ -253,7 +252,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;
@@ -295,8 +294,6 @@ public class Launcher extends Activity
private ArrayList<Runnable> mBindOnResumeCallbacks = new ArrayList<Runnable>();
private ArrayList<Runnable> mOnResumeCallbacks = new ArrayList<Runnable>();
- private Bundle mSavedInstanceState;
-
private LauncherModel mModel;
private IconCache mIconCache;
@Thunk boolean mUserPresent = true;
@@ -840,24 +837,22 @@ public class Launcher extends Activity
return;
}
- // The pattern used here is that a user PICKs a specific application,
- // which, depending on the target, might need to CREATE the actual target.
-
- // For example, the user would PICK_SHORTCUT for "Music playlist", and we
- // launch over to the Music app to actually CREATE_SHORTCUT.
- if (resultCode == RESULT_OK && mPendingAddInfo.container != ItemInfo.NO_ID) {
- final PendingAddArguments args = preparePendingAddArgs(requestCode, data, -1,
- mPendingAddInfo);
- if (isWorkspaceLocked()) {
- sPendingAddItem = args;
- } else {
- completeAdd(args);
+ if (requestCode == REQUEST_CREATE_SHORTCUT) {
+ // Handle custom shortcuts created using ACTION_CREATE_SHORTCUT.
+ if (resultCode == RESULT_OK && mPendingAddInfo.container != ItemInfo.NO_ID) {
+ final PendingAddArguments args = preparePendingAddArgs(requestCode, data, -1,
+ mPendingAddInfo);
+ if (isWorkspaceLocked()) {
+ sPendingAddItem = args;
+ } else {
+ completeAdd(args);
+ mWorkspace.removeExtraEmptyScreenDelayed(true, exitSpringLoaded,
+ ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
+ }
+ } else if (resultCode == RESULT_CANCELED) {
mWorkspace.removeExtraEmptyScreenDelayed(true, exitSpringLoaded,
ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
}
- } else if (resultCode == RESULT_CANCELED) {
- mWorkspace.removeExtraEmptyScreenDelayed(true, exitSpringLoaded,
- ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
}
mDragLayer.clearAnimatedView();
@@ -1505,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);
@@ -1532,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);
}
@@ -2219,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
@@ -2291,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];
@@ -2315,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;
@@ -2475,8 +2462,10 @@ public class Launcher extends Activity
if (v instanceof CellLayout) {
if (mWorkspace.isInOverviewMode()) {
- showWorkspace(mWorkspace.indexOfChild(v), true);
+ mWorkspace.snapToPageFromOverView(mWorkspace.indexOfChild(v));
+ showWorkspace(true);
}
+ return;
}
Object tag = v.getTag();
@@ -3274,26 +3263,17 @@ public class Launcher extends Activity
}
public void showWorkspace(boolean animated) {
- showWorkspace(WorkspaceStateTransitionAnimation.SCROLL_TO_CURRENT_PAGE, animated, null);
+ showWorkspace(animated, null);
}
public void showWorkspace(boolean animated, Runnable onCompleteRunnable) {
- showWorkspace(WorkspaceStateTransitionAnimation.SCROLL_TO_CURRENT_PAGE, animated,
- onCompleteRunnable);
- }
-
- protected void showWorkspace(int snapToPage, boolean animated) {
- showWorkspace(snapToPage, animated, null);
- }
-
- void showWorkspace(int snapToPage, boolean animated, Runnable onCompleteRunnable) {
boolean changed = mState != State.WORKSPACE ||
mWorkspace.getState() != Workspace.State.NORMAL;
if (changed) {
boolean wasInSpringLoadedMode = (mState != State.WORKSPACE);
mWorkspace.setVisibility(View.VISIBLE);
mStateTransitionAnimation.startAnimationToWorkspace(mState, Workspace.State.NORMAL,
- snapToPage, animated, onCompleteRunnable);
+ animated, onCompleteRunnable);
// Show the search bar (only animate if we were showing the drop target bar in spring
// loaded mode)
@@ -3324,8 +3304,7 @@ public class Launcher extends Activity
void showOverviewMode(boolean animated) {
mWorkspace.setVisibility(View.VISIBLE);
mStateTransitionAnimation.startAnimationToWorkspace(mState, Workspace.State.OVERVIEW,
- WorkspaceStateTransitionAnimation.SCROLL_TO_CURRENT_PAGE, animated,
- null /* onCompleteRunnable */);
+ animated, null /* onCompleteRunnable */);
mState = State.WORKSPACE;
}
@@ -3401,11 +3380,11 @@ public class Launcher extends Activity
* Updates the workspace and interaction state on state change, and return the animation to this
* new state.
*/
- public Animator startWorkspaceStateChangeAnimation(Workspace.State toState, int toPage,
+ public Animator startWorkspaceStateChangeAnimation(Workspace.State toState,
boolean animated, boolean hasOverlaySearchBar, HashMap<View, Integer> layerViews) {
Workspace.State fromState = mWorkspace.getState();
- Animator anim = mWorkspace.setStateWithAnimation(toState, toPage, animated,
- hasOverlaySearchBar, layerViews);
+ Animator anim = mWorkspace.setStateWithAnimation(
+ toState, animated, hasOverlaySearchBar, layerViews);
updateInteraction(fromState, toState);
return anim;
}
@@ -3418,8 +3397,7 @@ public class Launcher extends Activity
}
mStateTransitionAnimation.startAnimationToWorkspace(mState, Workspace.State.SPRING_LOADED,
- WorkspaceStateTransitionAnimation.SCROLL_TO_CURRENT_PAGE, true /* animated */,
- null /* onCompleteRunnable */);
+ true /* animated */, null /* onCompleteRunnable */);
mState = isAppsViewVisible() ? State.APPS_SPRING_LOADED : State.WIDGETS_SPRING_LOADED;
}
@@ -3638,7 +3616,7 @@ public class Launcher extends Activity
if (mWorkspace != null) {
return mWorkspace.getCurrentPage();
} else {
- return SCREEN_COUNT / 2;
+ return 0;
}
}
@@ -3798,7 +3776,7 @@ public class Launcher extends Activity
Object tag = v.getTag();
String desc = "Collision while binding workspace item: " + item
+ ". Collides with " + tag;
- if (LauncherAppState.isDogfoodBuild()) {
+ if (ProviderConfig.IS_DOGFOOD_BUILD) {
throw (new RuntimeException(desc));
} else {
Log.d(TAG, desc);
@@ -4608,7 +4586,6 @@ public class Launcher extends Activity
Log.d(TAG, "mWorkspaceLoading=" + mWorkspaceLoading);
Log.d(TAG, "mRestoring=" + mRestoring);
Log.d(TAG, "mWaitingForResult=" + mWaitingForResult);
- Log.d(TAG, "mSavedInstanceState=" + mSavedInstanceState);
Log.d(TAG, "sFolders.size=" + sFolders.size());
mModel.dumpState();
// TODO(hyunyoungs): add mWidgetsView.dumpState(); or mWidgetsModel.dumpState();
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index ecaf8016e..e97080ca5 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -32,7 +32,6 @@ import java.lang.ref.WeakReference;
public class LauncherAppState {
private final AppFilter mAppFilter;
- private final BuildInfo mBuildInfo;
@Thunk final LauncherModel mModel;
private final IconCache mIconCache;
private final WidgetPreviewLoader mWidgetCache;
@@ -86,7 +85,6 @@ public class LauncherAppState {
mWidgetCache = new WidgetPreviewLoader(sContext, mIconCache);
mAppFilter = AppFilter.loadByName(sContext.getString(R.string.app_filter_class));
- mBuildInfo = BuildInfo.loadByName(sContext.getString(R.string.build_info_class));
mModel = new LauncherModel(this, mIconCache, mAppFilter);
LauncherAppsCompat.getInstance(sContext).addOnAppsChangedCallback(mModel);
@@ -171,8 +169,4 @@ public class LauncherAppState {
public InvariantDeviceProfile getInvariantDeviceProfile() {
return mInvariantDeviceProfile;
}
-
- public static boolean isDogfoodBuild() {
- return getInstance().mBuildInfo.isDogfoodBuild();
- }
}
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 7e75f9793..360e2ba25 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -56,6 +56,7 @@ import com.android.launcher3.compat.PackageInstallerCompat;
import com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
+import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.model.MigrateFromRestoreTask;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.util.ComponentKey;
@@ -662,12 +663,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;
}
@@ -894,7 +890,7 @@ public class LauncherModel extends BroadcastReceiver
}
private void assertWorkspaceLoaded() {
- if (LauncherAppState.isDogfoodBuild() && (isLoadingWorkspace() || !mHasLoaderCompletedOnce)) {
+ if (ProviderConfig.IS_DOGFOOD_BUILD && (isLoadingWorkspace() || !mHasLoaderCompletedOnce)) {
throw new RuntimeException("Trying to add shortcut while loader is running");
}
}
@@ -2464,19 +2460,36 @@ public class LauncherModel extends BroadcastReceiver
private void sortWorkspaceItemsSpatially(ArrayList<ItemInfo> workspaceItems) {
final LauncherAppState app = LauncherAppState.getInstance();
final InvariantDeviceProfile profile = app.getInvariantDeviceProfile();
- // XXX: review this
+ final int screenCols = profile.numColumns;
+ final int screenCellCount = profile.numColumns * profile.numRows;
Collections.sort(workspaceItems, new Comparator<ItemInfo>() {
@Override
public int compare(ItemInfo lhs, ItemInfo rhs) {
- int cellCountX = (int) profile.numColumns;
- int cellCountY = (int) profile.numRows;
- int screenOffset = cellCountX * cellCountY;
- int containerOffset = screenOffset * (Launcher.SCREEN_COUNT + 1); // +1 hotseat
- long lr = (lhs.container * containerOffset + lhs.screenId * screenOffset +
- lhs.cellY * cellCountX + lhs.cellX);
- long rr = (rhs.container * containerOffset + rhs.screenId * screenOffset +
- rhs.cellY * cellCountX + rhs.cellX);
- return (int) (lr - rr);
+ if (lhs.container == rhs.container) {
+ // Within containers, order by their spatial position in that container
+ switch ((int) lhs.container) {
+ case LauncherSettings.Favorites.CONTAINER_DESKTOP: {
+ long lr = (lhs.screenId * screenCellCount +
+ lhs.cellY * screenCols + lhs.cellX);
+ long rr = (rhs.screenId * screenCellCount +
+ rhs.cellY * screenCols + rhs.cellX);
+ return (int) (lr - rr);
+ }
+ case LauncherSettings.Favorites.CONTAINER_HOTSEAT: {
+ // We currently use the screen id as the rank
+ return (int) (lhs.screenId - rhs.screenId);
+ }
+ default:
+ if (ProviderConfig.IS_DOGFOOD_BUILD) {
+ throw new RuntimeException("Unexpected container type when " +
+ "sorting workspace items.");
+ }
+ return 0;
+ }
+ } else {
+ // Between containers, order by hotseat, desktop
+ return (int) (lhs.container - rhs.container);
+ }
}
});
}
diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
index d69b7432d..38ccfa798 100644
--- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java
+++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
@@ -170,7 +170,6 @@ public class LauncherStateTransitionAnimation {
public void startAnimationToWidgets(final boolean animated) {
final WidgetsContainerView toView = mLauncher.getWidgetsView();
final View buttonView = mLauncher.getWidgetsButton();
-
PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks() {
@Override
public float getMaterialRevealViewFinalAlpha(View revealView) {
@@ -186,7 +185,7 @@ public class LauncherStateTransitionAnimation {
* Starts and animation to the workspace from the current overlay view.
*/
public void startAnimationToWorkspace(final Launcher.State fromState,
- final Workspace.State toWorkspaceState, final int toWorkspacePage,
+ final Workspace.State toWorkspaceState,
final boolean animated, final Runnable onCompleteRunnable) {
if (toWorkspaceState != Workspace.State.NORMAL &&
toWorkspaceState != Workspace.State.SPRING_LOADED &&
@@ -195,11 +194,9 @@ public class LauncherStateTransitionAnimation {
}
if (fromState == Launcher.State.APPS || fromState == Launcher.State.APPS_SPRING_LOADED) {
- startAnimationToWorkspaceFromAllApps(toWorkspaceState, toWorkspacePage,
- animated, onCompleteRunnable);
+ startAnimationToWorkspaceFromAllApps(toWorkspaceState, animated, onCompleteRunnable);
} else {
- startAnimationToWorkspaceFromWidgets(toWorkspaceState, toWorkspacePage,
- animated, onCompleteRunnable);
+ startAnimationToWorkspaceFromWidgets(toWorkspaceState, animated, onCompleteRunnable);
}
}
@@ -229,7 +226,7 @@ public class LauncherStateTransitionAnimation {
// Create the workspace animation.
// NOTE: this call apparently also sets the state for the workspace if !animated
- Animator workspaceAnim = mLauncher.startWorkspaceStateChangeAnimation(toWorkspaceState, -1,
+ Animator workspaceAnim = mLauncher.startWorkspaceStateChangeAnimation(toWorkspaceState,
animated, overlaySearchBarView != null /* hasOverlaySearchBar */, layerViews);
if (animated && initialized) {
@@ -415,7 +412,7 @@ public class LauncherStateTransitionAnimation {
* Starts and animation to the workspace from the apps view.
*/
private void startAnimationToWorkspaceFromAllApps(final Workspace.State toWorkspaceState,
- final int toWorkspacePage, final boolean animated, final Runnable onCompleteRunnable) {
+ final boolean animated, final Runnable onCompleteRunnable) {
AllAppsContainerView appsView = mLauncher.getAppsView();
PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks() {
int[] mAllAppsToPanelDelta;
@@ -451,17 +448,16 @@ public class LauncherStateTransitionAnimation {
}
};
// Only animate the search bar if animating to spring loaded mode from all apps
- startAnimationToWorkspaceFromOverlay(toWorkspaceState, toWorkspacePage,
- mLauncher.getAllAppsButton(), appsView, appsView.getContentView(),
- appsView.getRevealView(), appsView.getSearchBarView(), animated,
- onCompleteRunnable, cb);
+ startAnimationToWorkspaceFromOverlay(toWorkspaceState, mLauncher.getAllAppsButton(),
+ appsView, appsView.getContentView(), appsView.getRevealView(),
+ appsView.getSearchBarView(), animated, onCompleteRunnable, cb);
}
/**
* Starts and animation to the workspace from the widgets view.
*/
private void startAnimationToWorkspaceFromWidgets(final Workspace.State toWorkspaceState,
- final int toWorkspacePage, final boolean animated, final Runnable onCompleteRunnable) {
+ final boolean animated, final Runnable onCompleteRunnable) {
final WidgetsContainerView widgetsView = mLauncher.getWidgetsView();
PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks() {
@Override
@@ -479,19 +475,18 @@ public class LauncherStateTransitionAnimation {
};
}
};
- startAnimationToWorkspaceFromOverlay(toWorkspaceState, toWorkspacePage,
- mLauncher.getWidgetsButton(), widgetsView, widgetsView.getContentView(),
- widgetsView.getRevealView(), null, animated, onCompleteRunnable, cb);
- }
+ startAnimationToWorkspaceFromOverlay(toWorkspaceState, mLauncher.getWidgetsButton(),
+ widgetsView, widgetsView.getContentView(), widgetsView.getRevealView(), null,
+ animated, onCompleteRunnable, cb);
+ }
/**
* Creates and starts a new animation to the workspace.
*/
private void startAnimationToWorkspaceFromOverlay(final Workspace.State toWorkspaceState,
- final int toWorkspacePage, final View buttonView, final View fromView,
- final View contentView, final View revealView, final View overlaySearchBarView,
- final boolean animated, final Runnable onCompleteRunnable,
- final PrivateTransitionCallbacks pCb) {
+ final View buttonView, final View fromView, final View contentView,
+ final View revealView, final View overlaySearchBarView, final boolean animated,
+ final Runnable onCompleteRunnable, final PrivateTransitionCallbacks pCb) {
final Resources res = mLauncher.getResources();
final boolean material = Utilities.isLmpOrAbove();
final int revealDuration = res.getInteger(R.integer.config_overlayRevealTime);
@@ -511,7 +506,7 @@ public class LauncherStateTransitionAnimation {
// Create the workspace animation.
// NOTE: this call apparently also sets the state for the workspace if !animated
Animator workspaceAnim = mLauncher.startWorkspaceStateChangeAnimation(toWorkspaceState,
- toWorkspacePage, animated, overlaySearchBarView != null /* hasOverlaySearchBar */,
+ animated, overlaySearchBarView != null /* hasOverlaySearchBar */,
layerViews);
if (animated && initialized) {
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 218c1a36f..c9bbe0a06 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -22,6 +22,7 @@ import android.animation.AnimatorSet;
import android.animation.LayoutTransition;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
+import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
@@ -47,10 +48,8 @@ import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.Interpolator;
-
import com.android.launcher3.util.LauncherEdgeEffect;
import com.android.launcher3.util.Thunk;
-
import java.util.ArrayList;
/**
@@ -67,7 +66,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
protected static final int PAGE_SNAP_ANIMATION_DURATION = 750;
protected static final int SLOW_PAGE_SNAP_ANIMATION_DURATION = 950;
- protected static final float NANOTIME_DIV = 1000000000.0f;
private static final float RETURN_TO_ORIGINAL_PAGE_THRESHOLD = 0.33f;
// The page is moved more than halfway, automatically move to the next page on touch up.
@@ -87,25 +85,19 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
private int mFreeScrollMinScrollX = -1;
private int mFreeScrollMaxScrollX = -1;
- static final int AUTOMATIC_PAGE_SPACING = -1;
-
protected int mFlingThresholdVelocity;
protected int mMinFlingVelocity;
protected int mMinSnapVelocity;
- protected float mDensity;
- protected float mSmoothingTime;
- protected float mTouchX;
-
protected boolean mFirstLayout = true;
private int mNormalChildHeight;
protected int mCurrentPage;
protected int mRestorePage = INVALID_RESTORE_PAGE;
- protected int mChildCountOnLastLayout;
+ private int mChildCountOnLastLayout;
protected int mNextPage = INVALID_PAGE;
- protected int mMaxScrollX;
+ private int mMaxScrollX;
protected LauncherScroller mScroller;
private Interpolator mDefaultInterpolator;
private VelocityTracker mVelocityTracker;
@@ -117,10 +109,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
private float mDownMotionY;
private float mDownScrollX;
private float mDragViewBaselineLeft;
- protected float mLastMotionX;
- protected float mLastMotionXRemainder;
- protected float mLastMotionY;
- protected float mTotalMotionX;
+ private float mLastMotionX;
+ private float mLastMotionXRemainder;
+ private float mLastMotionY;
+ private float mTotalMotionX;
private int mLastScreenCenter = -1;
private boolean mCancelTap;
@@ -133,23 +125,17 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
protected final static int TOUCH_STATE_NEXT_PAGE = 3;
protected final static int TOUCH_STATE_REORDERING = 4;
- protected final static float ALPHA_QUANTIZE_LEVEL = 0.0001f;
-
protected int mTouchState = TOUCH_STATE_REST;
- protected boolean mForceScreenScrolled = false;
+ private boolean mForceScreenScrolled = false;
protected OnLongClickListener mLongClickListener;
protected int mTouchSlop;
private int mMaximumVelocity;
- protected int mPageLayoutWidthGap;
- protected int mPageLayoutHeightGap;
protected int mCellCountX = 0;
protected int mCellCountY = 0;
- protected boolean mCenterPagesVertically;
protected boolean mAllowOverScroll = true;
protected int[] mTempVisiblePagesRange = new int[2];
- protected boolean mForceDrawAllChildrenNextFrame;
protected static final int INVALID_POINTER = -1;
@@ -180,7 +166,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
private float mMinScale = 1f;
private boolean mUseMinScale = false;
- protected View mDragView;
+ @Thunk View mDragView;
private Runnable mSidePageHoverRunnable;
@Thunk int mSidePageHoverIndex = -1;
// This variable's scope is only for the duration of startReordering() and endReordering()
@@ -189,12 +175,12 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// animation after endReordering()
private boolean mIsReordering;
// The runnable that settles the page after snapToPage and animateDragViewToOriginalPosition
- private int NUM_ANIMATIONS_RUNNING_BEFORE_ZOOM_OUT = 2;
+ private static final int NUM_ANIMATIONS_RUNNING_BEFORE_ZOOM_OUT = 2;
private int mPostReorderingPreZoomInRemainingAnimationCount;
private Runnable mPostReorderingPreZoomInRunnable;
// Convenience/caching
- private static final Matrix sTmpInvMatrix = new Matrix();
+ protected static final Matrix sTmpInvMatrix = new Matrix();
private static final float[] sTmpPoint = new float[2];
private static final int[] sTmpIntPoint = new int[2];
private static final Rect sTmpRect = new Rect();
@@ -223,11 +209,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.PagedView, defStyle, 0);
-
- mPageLayoutWidthGap = a.getDimensionPixelSize(
- R.styleable.PagedView_pageLayoutWidthGap, 0);
- mPageLayoutHeightGap = a.getDimensionPixelSize(
- R.styleable.PagedView_pageLayoutHeightGap, 0);
mPageIndicatorViewId = a.getResourceId(R.styleable.PagedView_pageIndicator, -1);
a.recycle();
@@ -243,16 +224,15 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
mScroller = new LauncherScroller(getContext());
setDefaultInterpolator(new ScrollInterpolator());
mCurrentPage = 0;
- mCenterPagesVertically = true;
final ViewConfiguration configuration = ViewConfiguration.get(getContext());
mTouchSlop = configuration.getScaledPagingTouchSlop();
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
- mDensity = getResources().getDisplayMetrics().density;
- mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * mDensity);
- mMinFlingVelocity = (int) (MIN_FLING_VELOCITY * mDensity);
- mMinSnapVelocity = (int) (MIN_SNAP_VELOCITY * mDensity);
+ float density = getResources().getDisplayMetrics().density;
+ mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * density);
+ mMinFlingVelocity = (int) (MIN_FLING_VELOCITY * density);
+ mMinSnapVelocity = (int) (MIN_SNAP_VELOCITY * density);
setOnHierarchyChangeListener(this);
setWillNotDraw(false);
}
@@ -606,9 +586,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
super.scrollTo(x, y);
}
- mTouchX = x;
- mSmoothingTime = System.nanoTime() / NANOTIME_DIV;
-
// Update the last motion events when scrolling
if (isReordering(true)) {
float[] p = mapPointFromParentToView(this, mParentDownMotionX, mParentDownMotionY);
@@ -836,6 +813,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
setMeasuredDimension(scaledWidthSize, scaledHeightSize);
}
+ @SuppressLint("DrawAllocation")
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
if (getChildCount() == 0) {
@@ -874,9 +852,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
childTop = offsetY;
} else {
childTop = offsetY + getPaddingTop() + mInsets.top;
- if (mCenterPagesVertically) {
- childTop += (getViewportHeight() - mInsets.top - mInsets.bottom - verticalPadding - child.getMeasuredHeight()) / 2;
- }
+ childTop += (getViewportHeight() - mInsets.top - mInsets.bottom - verticalPadding - child.getMeasuredHeight()) / 2;
}
final int childWidth = child.getMeasuredWidth();
@@ -1136,8 +1112,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
for (int i = pageCount - 1; i >= 0; i--) {
final View v = getPageAt(i);
if (v == mDragView) continue;
- if (mForceDrawAllChildrenNextFrame ||
- (leftScreen <= i && i <= rightScreen && shouldDrawChild(v))) {
+ if (leftScreen <= i && i <= rightScreen && shouldDrawChild(v)) {
drawChild(canvas, v, drawingTime);
}
}
@@ -1146,7 +1121,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
drawChild(canvas, mDragView, drawingTime);
}
- mForceDrawAllChildrenNextFrame = false;
canvas.restore();
}
}
@@ -1450,8 +1424,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
mTotalMotionX += Math.abs(mLastMotionX - x);
mLastMotionX = x;
mLastMotionXRemainder = 0;
- mTouchX = getViewportOffsetX() + getScrollX();
- mSmoothingTime = System.nanoTime() / NANOTIME_DIV;
onScrollInteractionBegin();
pageBeginMoving();
}
@@ -1650,8 +1622,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// keep the remainder because we are actually testing if we've moved from the last
// scrolled position (which is discrete).
if (Math.abs(deltaX) >= 1.0f) {
- mTouchX += deltaX;
- mSmoothingTime = System.nanoTime() / NANOTIME_DIV;
scrollBy((int) deltaX, 0);
mLastMotionX = x;
mLastMotionXRemainder = deltaX - (int) deltaX;
@@ -2276,6 +2246,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
private static final int ANIM_TAG_KEY = 100;
/* Accessibility */
+ @SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
diff --git a/src/com/android/launcher3/SearchDropTargetBar.java b/src/com/android/launcher3/SearchDropTargetBar.java
index 4cdf1cac9..7c8f4415a 100644
--- a/src/com/android/launcher3/SearchDropTargetBar.java
+++ b/src/com/android/launcher3/SearchDropTargetBar.java
@@ -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();
}
diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java
index 56c0b9d2f..fe76634b3 100644
--- a/src/com/android/launcher3/ShortcutInfo.java
+++ b/src/com/android/launcher3/ShortcutInfo.java
@@ -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,
diff --git a/src/com/android/launcher3/Stats.java b/src/com/android/launcher3/Stats.java
index cb0e252b2..4aba1503b 100644
--- a/src/com/android/launcher3/Stats.java
+++ b/src/com/android/launcher3/Stats.java
@@ -25,6 +25,8 @@ import android.util.Log;
import android.view.View;
import android.view.ViewParent;
+import com.android.launcher3.config.ProviderConfig;
+
public class Stats {
/**
@@ -71,7 +73,7 @@ public class Stats {
if (provider != null) {
provider.fillInLaunchSourceData(sourceData);
- } else if (LauncherAppState.isDogfoodBuild()) {
+ } else if (ProviderConfig.IS_DOGFOOD_BUILD) {
throw new RuntimeException("Expected LaunchSourceProvider");
}
}
diff --git a/src/com/android/launcher3/UninstallDropTarget.java b/src/com/android/launcher3/UninstallDropTarget.java
index 0819f8ce0..7c548a5f8 100644
--- a/src/com/android/launcher3/UninstallDropTarget.java
+++ b/src/com/android/launcher3/UninstallDropTarget.java
@@ -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);
}
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 8fd298df7..096edc546 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -56,6 +56,8 @@ import android.util.TypedValue;
import android.view.View;
import android.widget.Toast;
+import com.android.launcher3.config.ProviderConfig;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
@@ -660,7 +662,7 @@ public final class Utilities {
}
public static void assertWorkerThread() {
- if (LauncherAppState.isDogfoodBuild() &&
+ if (ProviderConfig.IS_DOGFOOD_BUILD &&
(LauncherModel.sWorkerThread.getThreadId() != Process.myTid())) {
throw new IllegalStateException();
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 267787be8..3ab8d79a5 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -68,6 +68,7 @@ import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate.AccessibilityDragSource;
import com.android.launcher3.accessibility.OverviewScreenAccessibilityDelegate;
import com.android.launcher3.compat.UserHandleCompat;
+import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.util.LongArrayMap;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.WallpaperUtils;
@@ -92,13 +93,17 @@ public class Workspace extends PagedView
private static boolean ENFORCE_DRAG_EVENT_ORDER = false;
- protected static final int SNAP_OFF_EMPTY_SCREEN_DURATION = 400;
- protected static final int FADE_EMPTY_SCREEN_DURATION = 150;
+ private static final int SNAP_OFF_EMPTY_SCREEN_DURATION = 400;
+ private static final int FADE_EMPTY_SCREEN_DURATION = 150;
private static final int ADJACENT_SCREEN_DROP_DURATION = 300;
- static final boolean MAP_NO_RECURSE = false;
- static final boolean MAP_RECURSE = true;
+ private static final boolean MAP_NO_RECURSE = false;
+ private static final boolean MAP_RECURSE = true;
+
+ // The screen id used for the empty screen always present to the right.
+ public final static long EXTRA_EMPTY_SCREEN_ID = -201;
+ private final static long CUSTOM_CONTENT_SCREEN_ID = -301;
private static final long CUSTOM_CONTENT_GESTURE_DELAY = 200;
private long mTouchDownTime = -1;
@@ -113,10 +118,6 @@ public class Workspace extends PagedView
private ShortcutAndWidgetContainer mDragSourceInternal;
- // The screen id used for the empty screen always present to the right.
- final static long EXTRA_EMPTY_SCREEN_ID = -201;
- private final static long CUSTOM_CONTENT_SCREEN_ID = -301;
-
@Thunk LongArrayMap<CellLayout> mWorkspaceScreens = new LongArrayMap<>();
@Thunk ArrayList<Long> mScreenOrder = new ArrayList<Long>();
@@ -136,8 +137,8 @@ public class Workspace extends PagedView
private int mDragOverX = -1;
private int mDragOverY = -1;
- static Rect mLandscapeCellLayoutMetrics = null;
- static Rect mPortraitCellLayoutMetrics = null;
+ private static Rect mLandscapeCellLayoutMetrics = null;
+ private static Rect mPortraitCellLayoutMetrics = null;
CustomContentCallbacks mCustomContentCallbacks;
boolean mCustomContentShowing;
@@ -164,12 +165,11 @@ public class Workspace extends PagedView
// These are temporary variables to prevent having to allocate a new object just to
// 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];
+ private static final Rect sTempRect = new Rect();
+ private final int[] mTempXY = new int[2];
@Thunk float[] mDragViewVisualCenter = new float[2];
private float[] mTempCellLayoutCenterCoordinates = new float[2];
- private Matrix mTempInverseMatrix = new Matrix();
+ private int[] mTempVisiblePagesRange = new int[2];
private SpringLoadedDragController mSpringLoadedDragController;
private float mSpringLoadedShrinkFactor;
@@ -183,7 +183,6 @@ public class Workspace extends PagedView
private boolean mIsSwitchingState = false;
boolean mAnimatingViewIntoPlace = false;
- boolean mIsDragOccuring = false;
boolean mChildrenLayersEnabled = true;
private boolean mStripScreensOnPageStopMoving = false;
@@ -193,9 +192,6 @@ public class Workspace extends PagedView
private HolographicOutlineHelper mOutlineHelper;
@Thunk Bitmap mDragOutline = null;
- private static final Rect sTempRect = new Rect();
- private final int[] mTempXY = new int[2];
- private int[] mTempVisiblePagesRange = new int[2];
public static final int DRAG_BITMAP_PADDING = 2;
private boolean mWorkspaceFadeInAdjacentScreens;
@@ -206,7 +202,6 @@ public class Workspace extends PagedView
@Thunk Runnable mDelayedResizeRunnable;
private Runnable mDelayedSnapToPageRunnable;
- private Point mDisplaySize = new Point();
// Variables relating to the creation of user folders by hovering shortcuts over shortcuts
private static final int FOLDER_CREATION_TIMEOUT = 0;
@@ -364,12 +359,11 @@ 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);
}
- mIsDragOccuring = true;
updateChildrenLayersEnabled(false);
mLauncher.lockScreenOrientation();
mLauncher.onInteractionBegin();
@@ -400,7 +394,6 @@ public class Workspace extends PagedView
removeExtraEmptyScreen(true, mDragSourceInternal != null);
}
- mIsDragOccuring = false;
updateChildrenLayersEnabled(false);
mLauncher.unlockScreenOrientation(false);
@@ -428,8 +421,6 @@ public class Workspace extends PagedView
setupLayoutTransition();
mWallpaperOffset = new WallpaperOffsetInterpolator();
- Display display = mLauncher.getWindowManager().getDefaultDisplay();
- display.getSize(mDisplaySize);
mMaxDistanceForFolderCreation = (0.55f * grid.iconSizePx);
@@ -1831,8 +1822,18 @@ public class Workspace extends PagedView
updateChildrenLayersEnabled(false);
}
+ @Override
+ protected void getVisiblePages(int[] range) {
+ super.getVisiblePages(range);
+ if (mState == State.OVERVIEW || mState == State.SPRING_LOADED) {
+ // In overview mode, make sure that the two side pages are visible.
+ range[0] = Math.min(range[0], Math.max(getCurrentPage() - 1, numCustomPages()));
+ range[1] = Math.max(range[0], Math.min(getCurrentPage() + 1, getPageCount() - 1));
+ }
+ }
+
protected void onWallpaperTap(MotionEvent ev) {
- final int[] position = mTempCell;
+ final int[] position = mTempXY;
getLocationOnScreen(position);
int pointerIndex = ev.getActionIndex();
@@ -1951,6 +1952,10 @@ public class Workspace extends PagedView
return mState == State.OVERVIEW;
}
+ public void snapToPageFromOverView(int whichPage) {
+ mStateTransitionAnimation.snapToPageFromOverView(whichPage);
+ }
+
int getOverviewModeTranslationY() {
DeviceProfile grid = mLauncher.getDeviceProfile();
Rect workspacePadding = grid.getWorkspacePadding(Utilities.isRtl(getResources()));
@@ -1970,15 +1975,19 @@ public class Workspace extends PagedView
* Sets the current workspace {@link State}, returning an animation transitioning the workspace
* to that new state.
*/
- public Animator setStateWithAnimation(State toState, int toPage, boolean animated,
+ public Animator setStateWithAnimation(State toState, boolean animated,
boolean hasOverlaySearchBar, HashMap<View, Integer> layerViews) {
// Create the animation to the new state
Animator workspaceAnim = mStateTransitionAnimation.getAnimationToState(mState,
- toState, toPage, animated, hasOverlaySearchBar, layerViews);
+ toState, animated, hasOverlaySearchBar, layerViews);
// Update the current state
mState = toState;
updateAccessibilityFlags();
+ if (mState == State.OVERVIEW || mState == State.SPRING_LOADED) {
+ // Redraw pages, as we might want to draw pages which were not visible.
+ invalidate();
+ }
return workspaceAnim;
}
@@ -2276,6 +2285,8 @@ public class Workspace extends PagedView
dragRect = new Rect(left, top, right, bottom);
} else if (child instanceof FolderIcon) {
int previewSize = grid.folderIconSizePx;
+ dragVisualizeOffset = new Point(-padding.get() / 2,
+ padding.get() / 2 - child.getPaddingTop());
dragRect = new Rect(0, child.getPaddingTop(), child.getWidth(), previewSize);
}
@@ -2285,15 +2296,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) {
@@ -2333,7 +2346,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();
@@ -2341,8 +2355,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
@@ -2383,9 +2398,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;
@@ -2400,12 +2414,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;
}
@@ -2471,7 +2485,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]);
@@ -2584,7 +2598,7 @@ public class Workspace extends PagedView
}
}
- int snapScreen = WorkspaceStateTransitionAnimation.SCROLL_TO_CURRENT_PAGE;
+ int snapScreen = -1;
boolean resizeOnDrop = false;
if (d.dragSource != this) {
final int[] touchXY = new int[] { (int) mDragViewVisualCenter[0],
@@ -2627,7 +2641,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) {
@@ -2665,7 +2679,7 @@ public class Workspace extends PagedView
CellLayout parentCell = getParentCellLayoutForView(cell);
if (parentCell != null) {
parentCell.removeView(cell);
- } else if (LauncherAppState.isDogfoodBuild()) {
+ } else if (ProviderConfig.IS_DOGFOOD_BUILD) {
throw new NullPointerException("mDragInfo.cell has null parent");
}
addInScreen(cell, container, screenId, mTargetCell[0], mTargetCell[1],
@@ -2745,9 +2759,7 @@ public class Workspace extends PagedView
animateWidgetDrop(info, parent, d.dragView,
onCompleteRunnable, animationType, cell, false);
} else {
- int duration = snapScreen < 0 ?
- WorkspaceStateTransitionAnimation.SCROLL_TO_CURRENT_PAGE :
- ADJACENT_SCREEN_DROP_DURATION;
+ int duration = snapScreen < 0 ? -1 : ADJACENT_SCREEN_DROP_DURATION;
mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, cell, duration,
onCompleteRunnable, this);
}
@@ -3001,30 +3013,21 @@ public class Workspace extends PagedView
xy[1] = xy[1] - v.getTop();
}
- boolean isPointInSelfOverHotseat(int x, int y, Rect r) {
- if (r == null) {
- r = new Rect();
- }
- mTempPt[0] = x;
- mTempPt[1] = y;
- mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempPt, true);
-
- DeviceProfile grid = mLauncher.getDeviceProfile();
- r = grid.getHotseatRect();
- if (r.contains(mTempPt[0], mTempPt[1])) {
- return true;
- }
- return false;
+ boolean isPointInSelfOverHotseat(int x, int y) {
+ mTempXY[0] = x;
+ mTempXY[1] = y;
+ mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempXY, true);
+ return mLauncher.getDeviceProfile().isInHotseatRect(mTempXY[0], mTempXY[1]);
}
void mapPointFromSelfToHotseatLayout(Hotseat hotseat, float[] xy) {
- mTempPt[0] = (int) xy[0];
- mTempPt[1] = (int) xy[1];
- mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempPt, true);
- mLauncher.getDragLayer().mapCoordInSelfToDescendent(hotseat.getLayout(), mTempPt);
+ mTempXY[0] = (int) xy[0];
+ mTempXY[1] = (int) xy[1];
+ mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempXY, true);
+ mLauncher.getDragLayer().mapCoordInSelfToDescendent(hotseat.getLayout(), mTempXY);
- xy[0] = mTempPt[0];
- xy[1] = mTempPt[1];
+ xy[0] = mTempXY[0];
+ xy[1] = mTempXY[1];
}
/*
@@ -3072,8 +3075,8 @@ public class Workspace extends PagedView
final float[] touchXy = {originX, originY};
// Transform the touch coordinates to the CellLayout's local coordinates
// If the touch point is within the bounds of the cell layout, we can return immediately
- cl.getMatrix().invert(mTempInverseMatrix);
- mapPointFromSelfToChild(cl, touchXy, mTempInverseMatrix);
+ cl.getMatrix().invert(sTmpInvMatrix);
+ mapPointFromSelfToChild(cl, touchXy, sTmpInvMatrix);
if (touchXy[0] >= 0 && touchXy[0] <= cl.getWidth() &&
touchXy[1] >= 0 && touchXy[1] <= cl.getHeight()) {
@@ -3115,11 +3118,10 @@ public class Workspace extends PagedView
// Skip drag over events while we are dragging over side pages
if (mInScrollArea || !transitionStateShouldAllowDrop()) return;
- Rect r = new Rect();
CellLayout layout = null;
- ItemInfo item = (ItemInfo) d.dragInfo;
+ ItemInfo item = d.dragInfo;
if (item == null) {
- if (LauncherAppState.isDogfoodBuild()) {
+ if (ProviderConfig.IS_DOGFOOD_BUILD) {
throw new NullPointerException("DragObject has null info");
}
return;
@@ -3133,7 +3135,7 @@ public class Workspace extends PagedView
// Identify whether we have dragged over a side page
if (workspaceInModalState()) {
if (mLauncher.getHotseat() != null && !isExternalDragWidget(d)) {
- if (isPointInSelfOverHotseat(d.x, d.y, r)) {
+ if (isPointInSelfOverHotseat(d.x, d.y)) {
layout = mLauncher.getHotseat().getLayout();
}
}
@@ -3156,7 +3158,7 @@ public class Workspace extends PagedView
} else {
// Test to see if we are over the hotseat otherwise just use the current page
if (mLauncher.getHotseat() != null && !isDragWidget(d)) {
- if (isPointInSelfOverHotseat(d.x, d.y, r)) {
+ if (isPointInSelfOverHotseat(d.x, d.y)) {
layout = mLauncher.getHotseat().getLayout();
}
}
@@ -3178,7 +3180,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;
@@ -3358,24 +3360,6 @@ public class Workspace extends PagedView
}
/**
- * 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
* come from another app altogether.
@@ -3383,7 +3367,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
@@ -3393,7 +3377,7 @@ public class Workspace extends PagedView
}
};
- ItemInfo info = (ItemInfo) dragInfo;
+ ItemInfo info = dragInfo;
int spanX = info.spanX;
int spanY = info.spanY;
if (mDragInfo != null) {
@@ -3420,14 +3404,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;
@@ -3745,7 +3729,7 @@ public class Workspace extends PagedView
mDragInfo.container, mDragInfo.screenId);
if (cellLayout != null) {
cellLayout.onDropChild(mDragInfo.cell);
- } else if (LauncherAppState.isDogfoodBuild()) {
+ } else if (ProviderConfig.IS_DOGFOOD_BUILD) {
throw new RuntimeException("Invalid state: cellLayout == null in "
+ "Workspace#onDropCompleted. Please file a bug. ");
};
@@ -3765,7 +3749,7 @@ public class Workspace extends PagedView
CellLayout parentCell = getParentCellLayoutForView(v);
if (parentCell != null) {
parentCell.removeView(v);
- } else if (LauncherAppState.isDogfoodBuild()) {
+ } else if (ProviderConfig.IS_DOGFOOD_BUILD) {
throw new NullPointerException("mDragInfo.cell has null parent");
}
if (v instanceof DropTarget) {
@@ -3788,29 +3772,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();
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index e908ccd81..f5a1cc4b6 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -174,7 +174,6 @@ public class WorkspaceStateTransitionAnimation {
public static final String TAG = "WorkspaceStateTransitionAnimation";
- public static final int SCROLL_TO_CURRENT_PAGE = -1;
@Thunk static final int BACKGROUND_FADE_OUT_DURATION = 350;
final @Thunk Launcher mLauncher;
@@ -217,16 +216,18 @@ public class WorkspaceStateTransitionAnimation {
mWorkspaceFadeInAdjacentScreens = grid.shouldFadeAdjacentWorkspaceScreens();
}
+ public void snapToPageFromOverView(int whichPage) {
+ mWorkspace.snapToPage(whichPage, mOverviewTransitionTime, mZoomInInterpolator);
+ }
+
public AnimatorSet getAnimationToState(Workspace.State fromState, Workspace.State toState,
- int toPage, boolean animated, boolean hasOverlaySearchBar,
- HashMap<View, Integer> layerViews) {
+ boolean animated, boolean hasOverlaySearchBar, HashMap<View, Integer> layerViews) {
AccessibilityManager am = (AccessibilityManager)
mLauncher.getSystemService(Context.ACCESSIBILITY_SERVICE);
final boolean accessibilityEnabled = am.isEnabled();
TransitionStates states = new TransitionStates(fromState, toState);
int duration = getAnimationDuration(states);
- animateWorkspace(states, toPage, animated, duration, layerViews,
- accessibilityEnabled);
+ animateWorkspace(states, animated, duration, layerViews, accessibilityEnabled);
animateSearchBar(states, animated, duration, hasOverlaySearchBar, layerViews,
accessibilityEnabled);
animateBackgroundGradient(states, animated, BACKGROUND_FADE_OUT_DURATION);
@@ -266,7 +267,7 @@ public class WorkspaceStateTransitionAnimation {
/**
* Starts a transition animation for the workspace.
*/
- private void animateWorkspace(final TransitionStates states, int toPage, final boolean animated,
+ private void animateWorkspace(final TransitionStates states, final boolean animated,
final int duration, final HashMap<View, Integer> layerViews,
final boolean accessibilityEnabled) {
// Reinitialize animation arrays for the current workspace state
@@ -306,11 +307,7 @@ public class WorkspaceStateTransitionAnimation {
}
}
- if (toPage == SCROLL_TO_CURRENT_PAGE) {
- toPage = mWorkspace.getPageNearestToCenterOfScreen();
- }
- mWorkspace.snapToPage(toPage, duration, mZoomInInterpolator);
-
+ int toPage = mWorkspace.getPageNearestToCenterOfScreen();
for (int i = 0; i < childCount; i++) {
final CellLayout cl = (CellLayout) mWorkspace.getChildAt(i);
boolean isCurrentPage = (i == toPage);
diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
index fe7b25edd..c11aab995 100644
--- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
@@ -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
}
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 67d572819..32c9012d5 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -526,7 +526,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 =
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index 47241ce5d..01e0f0cb9 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -18,11 +18,12 @@ package com.android.launcher3.allapps;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
+
import com.android.launcher3.AppInfo;
import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherAppState;
import com.android.launcher3.compat.AlphabeticIndexCompat;
import com.android.launcher3.compat.UserHandleCompat;
+import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.model.AppNameComparator;
import com.android.launcher3.util.ComponentKey;
@@ -393,7 +394,7 @@ public class AlphabeticalAppsList {
if (info != null) {
mPredictedApps.add(info);
} else {
- if (LauncherAppState.isDogfoodBuild()) {
+ if (ProviderConfig.IS_DOGFOOD_BUILD) {
Log.e(TAG, "Predicted app not found: " + ck.flattenToString(mLauncher));
}
}
diff --git a/src/com/android/launcher3/config/ProviderConfig.java b/src/com/android/launcher3/config/ProviderConfig.java
index e8930d063..825b43422 100644
--- a/src/com/android/launcher3/config/ProviderConfig.java
+++ b/src/com/android/launcher3/config/ProviderConfig.java
@@ -19,4 +19,6 @@ package com.android.launcher3.config;
public class ProviderConfig {
public static final String AUTHORITY = "com.android.launcher3.settings".intern();
+
+ public static boolean IS_DOGFOOD_BUILD = false;
}
diff --git a/src/com/android/launcher3/model/PackageItemInfo.java b/src/com/android/launcher3/model/PackageItemInfo.java
index 30f228c68..ddc9cbfd9 100644
--- a/src/com/android/launcher3/model/PackageItemInfo.java
+++ b/src/com/android/launcher3/model/PackageItemInfo.java
@@ -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 + ")";
}
}
diff --git a/src/com/android/launcher3/widget/WidgetHostViewLoader.java b/src/com/android/launcher3/widget/WidgetHostViewLoader.java
index 30b3d581a..bdd117c73 100644
--- a/src/com/android/launcher3/widget/WidgetHostViewLoader.java
+++ b/src/com/android/launcher3/widget/WidgetHostViewLoader.java
@@ -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() {
diff --git a/src/com/android/launcher3/widget/WidgetsContainerView.java b/src/com/android/launcher3/widget/WidgetsContainerView.java
index 5afd7c493..0f43a34e2 100644
--- a/src/com/android/launcher3/widget/WidgetsContainerView.java
+++ b/src/com/android/launcher3/widget/WidgetsContainerView.java
@@ -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 =