summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r--src/com/android/launcher3/AppWidgetResizeFrame.java115
-rw-r--r--src/com/android/launcher3/CellLayout.java4
-rw-r--r--src/com/android/launcher3/DragLayer.java32
-rw-r--r--src/com/android/launcher3/Folder.java6
-rw-r--r--src/com/android/launcher3/FolderPagedView.java5
-rw-r--r--src/com/android/launcher3/HolographicOutlineHelper.java3
-rw-r--r--src/com/android/launcher3/IconCache.java70
-rw-r--r--src/com/android/launcher3/Launcher.java5
-rw-r--r--src/com/android/launcher3/LauncherAppState.java1
-rw-r--r--src/com/android/launcher3/LauncherModel.java4
-rw-r--r--src/com/android/launcher3/PagedView.java14
-rw-r--r--src/com/android/launcher3/SmoothPagedView.java2
-rw-r--r--src/com/android/launcher3/Workspace.java7
-rw-r--r--src/com/android/launcher3/accessibility/DragAndDropAccessibilityDelegate.java1
-rw-r--r--src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java (renamed from src/com/android/launcher3/LauncherAccessibilityDelegate.java)20
-rw-r--r--src/com/android/launcher3/accessibility/WorkspaceAccessibilityHelper.java3
-rw-r--r--src/com/android/launcher3/model/WidgetsAndShortcutNameComparator.java33
-rw-r--r--src/com/android/launcher3/widget/WidgetsContainerView.java2
-rw-r--r--src/com/android/launcher3/widget/WidgetsListAdapter.java1
19 files changed, 200 insertions, 128 deletions
diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java
index 3c698c014..e6bf52531 100644
--- a/src/com/android/launcher3/AppWidgetResizeFrame.java
+++ b/src/com/android/launcher3/AppWidgetResizeFrame.java
@@ -15,24 +15,36 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
public class AppWidgetResizeFrame extends FrameLayout {
- private LauncherAppWidgetHostView mWidgetView;
- private CellLayout mCellLayout;
- private DragLayer mDragLayer;
- private ImageView mLeftHandle;
- private ImageView mRightHandle;
- private ImageView mTopHandle;
- private ImageView mBottomHandle;
+ private static final int SNAP_DURATION = 150;
+ private static final float DIMMED_HANDLE_ALPHA = 0f;
+ private static final float RESIZE_THRESHOLD = 0.66f;
+
+ private static Rect sTmpRect = new Rect();
+
+ private final Launcher mLauncher;
+ private final LauncherAppWidgetHostView mWidgetView;
+ private final CellLayout mCellLayout;
+ private final DragLayer mDragLayer;
+
+ private final ImageView mLeftHandle;
+ private final ImageView mRightHandle;
+ private final ImageView mTopHandle;
+ private final ImageView mBottomHandle;
+
+ private final Rect mWidgetPadding;
+
+ private final int mBackgroundPadding;
+ private final int mTouchTargetWidth;
+
+ private final int[] mDirectionVector = new int[2];
+ private final int[] mLastDirectionVector = new int[2];
+ private final int[] mTmpPt = new int[2];
private boolean mLeftBorderActive;
private boolean mRightBorderActive;
private boolean mTopBorderActive;
private boolean mBottomBorderActive;
- private int mWidgetPaddingLeft;
- private int mWidgetPaddingRight;
- private int mWidgetPaddingTop;
- private int mWidgetPaddingBottom;
-
private int mBaselineWidth;
private int mBaselineHeight;
private int mBaselineX;
@@ -48,30 +60,9 @@ public class AppWidgetResizeFrame extends FrameLayout {
private int mDeltaXAddOn;
private int mDeltaYAddOn;
- private int mBackgroundPadding;
- private int mTouchTargetWidth;
-
private int mTopTouchRegionAdjustment = 0;
private int mBottomTouchRegionAdjustment = 0;
- int[] mDirectionVector = new int[2];
- int[] mLastDirectionVector = new int[2];
- int[] mTmpPt = new int[2];
-
- final int SNAP_DURATION = 150;
- final int BACKGROUND_PADDING = 24;
- final float DIMMED_HANDLE_ALPHA = 0f;
- final float RESIZE_THRESHOLD = 0.66f;
-
- private static Rect mTmpRect = new Rect();
-
- public static final int LEFT = 0;
- public static final int TOP = 1;
- public static final int RIGHT = 2;
- public static final int BOTTOM = 3;
-
- private Launcher mLauncher;
-
public AppWidgetResizeFrame(Context context,
LauncherAppWidgetHostView widgetView, CellLayout cellLayout, DragLayer dragLayer) {
@@ -87,49 +78,49 @@ public class AppWidgetResizeFrame extends FrameLayout {
mMinHSpan = info.minSpanX;
mMinVSpan = info.minSpanY;
- setBackgroundResource(R.drawable.widget_resize_frame_holo);
+ setBackgroundResource(R.drawable.widget_resize_shadow);
+ setForeground(getResources().getDrawable(R.drawable.widget_resize_frame));
setPadding(0, 0, 0, 0);
+ final int handleMargin = getResources().getDimensionPixelSize(R.dimen.widget_handle_margin);
LayoutParams lp;
mLeftHandle = new ImageView(context);
- mLeftHandle.setImageResource(R.drawable.widget_resize_handle_left);
- lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
+ mLeftHandle.setImageResource(R.drawable.ic_widget_resize_handle);
+ lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
Gravity.LEFT | Gravity.CENTER_VERTICAL);
+ lp.leftMargin = handleMargin;
addView(mLeftHandle, lp);
mRightHandle = new ImageView(context);
- mRightHandle.setImageResource(R.drawable.widget_resize_handle_right);
- lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
+ mRightHandle.setImageResource(R.drawable.ic_widget_resize_handle);
+ lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
Gravity.RIGHT | Gravity.CENTER_VERTICAL);
+ lp.rightMargin = handleMargin;
addView(mRightHandle, lp);
mTopHandle = new ImageView(context);
- mTopHandle.setImageResource(R.drawable.widget_resize_handle_top);
- lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
+ mTopHandle.setImageResource(R.drawable.ic_widget_resize_handle);
+ lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
Gravity.CENTER_HORIZONTAL | Gravity.TOP);
+ lp.topMargin = handleMargin;
addView(mTopHandle, lp);
mBottomHandle = new ImageView(context);
- mBottomHandle.setImageResource(R.drawable.widget_resize_handle_bottom);
- lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
+ mBottomHandle.setImageResource(R.drawable.ic_widget_resize_handle);
+ lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
+ lp.bottomMargin = handleMargin;
addView(mBottomHandle, lp);
- Rect p = new Rect(0, 0, 0, 0);
if (!info.isCustomWidget) {
- p = AppWidgetHostView.getDefaultPaddingForWidget(context,
+ mWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context,
widgetView.getAppWidgetInfo().provider, null);
} else {
Resources r = context.getResources();
int padding = r.getDimensionPixelSize(R.dimen.default_widget_padding);
- p.set(padding, padding, padding, padding);
+ mWidgetPadding = new Rect(padding, padding, padding, padding);
}
- mWidgetPaddingLeft = p.left;
- mWidgetPaddingTop = p.top;
- mWidgetPaddingRight = p.right;
- mWidgetPaddingBottom = p.bottom;
-
if (mResizeMode == AppWidgetProviderInfo.RESIZE_HORIZONTAL) {
mTopHandle.setVisibility(GONE);
mBottomHandle.setVisibility(GONE);
@@ -138,8 +129,8 @@ public class AppWidgetResizeFrame extends FrameLayout {
mRightHandle.setVisibility(GONE);
}
- final float density = mLauncher.getResources().getDisplayMetrics().density;
- mBackgroundPadding = (int) Math.ceil(density * BACKGROUND_PADDING);
+ mBackgroundPadding = getResources()
+ .getDimensionPixelSize(R.dimen.resize_frame_background_padding);
mTouchTargetWidth = 2 * mBackgroundPadding;
// When we create the resize frame, we first mark all cells as unoccupied. The appropriate
@@ -344,9 +335,9 @@ public class AppWidgetResizeFrame extends FrameLayout {
static void updateWidgetSizeRanges(AppWidgetHostView widgetView, Launcher launcher,
int spanX, int spanY) {
- getWidgetSizeRanges(launcher, spanX, spanY, mTmpRect);
- widgetView.updateAppWidgetSize(null, mTmpRect.left, mTmpRect.top,
- mTmpRect.right, mTmpRect.bottom);
+ getWidgetSizeRanges(launcher, spanX, spanY, sTmpRect);
+ widgetView.updateAppWidgetSize(null, sTmpRect.left, sTmpRect.top,
+ sTmpRect.right, sTmpRect.bottom);
}
public static Rect getWidgetSizeRanges(Launcher launcher, int spanX, int spanY, Rect rect) {
@@ -404,19 +395,19 @@ public class AppWidgetResizeFrame extends FrameLayout {
public void snapToWidget(boolean animate) {
final DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
- int newWidth = mWidgetView.getWidth() + 2 * mBackgroundPadding - mWidgetPaddingLeft -
- mWidgetPaddingRight;
- int newHeight = mWidgetView.getHeight() + 2 * mBackgroundPadding - mWidgetPaddingTop -
- mWidgetPaddingBottom;
+ int newWidth = mWidgetView.getWidth() + 2 * mBackgroundPadding
+ - mWidgetPadding.left - mWidgetPadding.right;
+ int newHeight = mWidgetView.getHeight() + 2 * mBackgroundPadding
+ - mWidgetPadding.top - mWidgetPadding.bottom;
mTmpPt[0] = mWidgetView.getLeft();
mTmpPt[1] = mWidgetView.getTop();
mDragLayer.getDescendantCoordRelativeToSelf(mCellLayout.getShortcutsAndWidgets(), mTmpPt);
- int newX = mTmpPt[0] - mBackgroundPadding + mWidgetPaddingLeft;
- int newY = mTmpPt[1] - mBackgroundPadding + mWidgetPaddingTop;
+ int newX = mTmpPt[0] - mBackgroundPadding + mWidgetPadding.left;
+ int newY = mTmpPt[1] - mBackgroundPadding + mWidgetPadding.top;
- // We need to make sure the frame's touchable regions lie fully within the bounds of the
+ // We need to make sure the frame's touchable regions lie fully within the bounds of the
// DragLayer. We allow the actual handles to be clipped, but we shift the touch regions
// down accordingly to provide a proper touch target.
if (newY < 0) {
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 48ddfe6bf..1d211bff1 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -2999,7 +2999,7 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
// 2. When long clicking on an empty cell in a CellLayout, we save information about the
// cellX and cellY coordinates and which page was clicked. We then set this as a tag on
// the CellLayout that was long clicked
- static final class CellInfo {
+ public static final class CellInfo {
View cell;
int cellX = -1;
int cellY = -1;
@@ -3008,7 +3008,7 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
long screenId;
long container;
- CellInfo(View v, ItemInfo info) {
+ public CellInfo(View v, ItemInfo info) {
cell = v;
cellX = info.cellX;
cellY = info.cellY;
diff --git a/src/com/android/launcher3/DragLayer.java b/src/com/android/launcher3/DragLayer.java
index e25e6152c..423a9a3d5 100644
--- a/src/com/android/launcher3/DragLayer.java
+++ b/src/com/android/launcher3/DragLayer.java
@@ -39,6 +39,7 @@ import android.view.animation.Interpolator;
import android.widget.FrameLayout;
import android.widget.TextView;
+import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.util.Thunk;
import java.util.ArrayList;
@@ -48,34 +49,35 @@ import java.util.ArrayList;
*/
public class DragLayer extends InsettableFrameLayout {
+ public static final int ANIMATION_END_DISAPPEAR = 0;
+ public static final int ANIMATION_END_FADE_OUT = 1;
+ public static final int ANIMATION_END_REMAIN_VISIBLE = 2;
+
// Scrim color without any alpha component.
private static final int SCRIM_COLOR = Color.BLACK & 0x00FFFFFF;
+ private final int[] mTmpXY = new int[2];
+
@Thunk DragController mDragController;
- private int[] mTmpXY = new int[2];
private int mXDown, mYDown;
private Launcher mLauncher;
// Variables relating to resizing widgets
- private final ArrayList<AppWidgetResizeFrame> mResizeFrames =
- new ArrayList<AppWidgetResizeFrame>();
+ private final ArrayList<AppWidgetResizeFrame> mResizeFrames = new ArrayList<>();
private final boolean mIsRtl;
private AppWidgetResizeFrame mCurrentResizeFrame;
// Variables relating to animation of views after drop
private ValueAnimator mDropAnim = null;
private ValueAnimator mFadeOutAnim = null;
- private TimeInterpolator mCubicEaseOutInterpolator = new DecelerateInterpolator(1.5f);
+ private final TimeInterpolator mCubicEaseOutInterpolator = new DecelerateInterpolator(1.5f);
@Thunk DragView mDropView = null;
@Thunk int mAnchorViewInitialScrollX = 0;
@Thunk View mAnchorView = null;
private boolean mHoverPointClosesFolder = false;
- private Rect mHitRect = new Rect();
- public static final int ANIMATION_END_DISAPPEAR = 0;
- public static final int ANIMATION_END_FADE_OUT = 1;
- public static final int ANIMATION_END_REMAIN_VISIBLE = 2;
+ private final Rect mHitRect = new Rect();
private TouchCompleteListener mTouchCompleteListener;
@@ -87,6 +89,7 @@ public class DragLayer extends InsettableFrameLayout {
private float mBackgroundAlpha = 0;
// Related to adjacent page hints
+ private final Rect mScrollChildPosition = new Rect();
private boolean mInScrollArea;
private boolean mShowPageHints;
private Drawable mLeftHoverDrawable;
@@ -914,6 +917,9 @@ public class DragLayer extends InsettableFrameLayout {
void showPageHints() {
mShowPageHints = true;
+ Workspace workspace = mLauncher.getWorkspace();
+ getDescendantRectRelativeToSelf(workspace.getChildAt(workspace.getChildCount() - 1),
+ mScrollChildPosition);
invalidate();
}
@@ -937,10 +943,6 @@ public class DragLayer extends InsettableFrameLayout {
if (mShowPageHints) {
Workspace workspace = mLauncher.getWorkspace();
int width = getMeasuredWidth();
- Rect childRect = new Rect();
- getDescendantRectRelativeToSelf(workspace.getChildAt(workspace.getChildCount() - 1),
- childRect);
-
int page = workspace.getNextPage();
CellLayout leftPage = (CellLayout) workspace.getChildAt(mIsRtl ? page + 1 : page - 1);
CellLayout rightPage = (CellLayout) workspace.getChildAt(mIsRtl ? page - 1 : page + 1);
@@ -948,15 +950,15 @@ public class DragLayer extends InsettableFrameLayout {
if (leftPage != null && leftPage.isDragTarget()) {
Drawable left = mInScrollArea && leftPage.getIsDragOverlapping() ?
mLeftHoverDrawableActive : mLeftHoverDrawable;
- left.setBounds(0, childRect.top,
- left.getIntrinsicWidth(), childRect.bottom);
+ left.setBounds(0, mScrollChildPosition.top,
+ left.getIntrinsicWidth(), mScrollChildPosition.bottom);
left.draw(canvas);
}
if (rightPage != null && rightPage.isDragTarget()) {
Drawable right = mInScrollArea && rightPage.getIsDragOverlapping() ?
mRightHoverDrawableActive : mRightHoverDrawable;
right.setBounds(width - right.getIntrinsicWidth(),
- childRect.top, width, childRect.bottom);
+ mScrollChildPosition.top, width, mScrollChildPosition.bottom);
right.draw(canvas);
}
}
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index 69b18374a..d0a7ba3f8 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -49,13 +49,15 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.LinearLayout;
import android.widget.TextView;
+
import com.android.launcher3.CellLayout.CellInfo;
import com.android.launcher3.DragController.DragListener;
import com.android.launcher3.FolderInfo.FolderListener;
-import com.android.launcher3.LauncherAccessibilityDelegate.AccessibilityDragSource;
import com.android.launcher3.UninstallDropTarget.UninstallSource;
import com.android.launcher3.Workspace.ItemOperator;
+import com.android.launcher3.accessibility.LauncherAccessibilityDelegate.AccessibilityDragSource;
import com.android.launcher3.util.Thunk;
+
import java.util.ArrayList;
import java.util.Collections;
@@ -352,7 +354,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
/**
* @return the FolderInfo object associated with this folder
*/
- FolderInfo getInfo() {
+ public FolderInfo getInfo() {
return mInfo;
}
diff --git a/src/com/android/launcher3/FolderPagedView.java b/src/com/android/launcher3/FolderPagedView.java
index de30b606a..06ed58895 100644
--- a/src/com/android/launcher3/FolderPagedView.java
+++ b/src/com/android/launcher3/FolderPagedView.java
@@ -241,6 +241,11 @@ public class FolderPagedView extends PagedView {
return page;
}
+ @Override
+ protected int getChildGap() {
+ return getPaddingLeft() + getPaddingRight();
+ }
+
public void setFixedSize(int width, int height) {
width -= (getPaddingLeft() + getPaddingRight());
height -= (getPaddingTop() + getPaddingBottom());
diff --git a/src/com/android/launcher3/HolographicOutlineHelper.java b/src/com/android/launcher3/HolographicOutlineHelper.java
index 4a04d038a..5ff85d664 100644
--- a/src/com/android/launcher3/HolographicOutlineHelper.java
+++ b/src/com/android/launcher3/HolographicOutlineHelper.java
@@ -157,6 +157,9 @@ public class HolographicOutlineHelper {
Bitmap createMediumDropShadow(BubbleTextView view) {
Drawable icon = view.getIcon();
+ if (icon == null) {
+ return null;
+ }
Rect rect = icon.getBounds();
int bitmapWidth = (int) (rect.width() * view.getScaleX());
diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java
index fff07c6ed..1fac5a1c2 100644
--- a/src/com/android/launcher3/IconCache.java
+++ b/src/com/android/launcher3/IconCache.java
@@ -46,12 +46,14 @@ import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.widget.PackageItemInfo;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map.Entry;
+import java.util.Stack;
/**
* Cache of application icons. Icons can be made from any thread.
@@ -281,7 +283,7 @@ public class IconCache {
itemsToRemove.add(c.getInt(rowIndex));
continue;
}
- ContentValues values = updateCacheAndGetContentValues(app);
+ ContentValues values = updateCacheAndGetContentValues(app, true);
mIconDb.getWritableDatabase().update(IconDB.TABLE_NAME, values,
IconDB.COLUMN_COMPONENT + " = ? AND " + IconDB.COLUMN_USER + " = ?",
new String[] {cn, Long.toString(userSerial)});
@@ -296,21 +298,19 @@ public class IconCache {
}
// Insert remaining apps.
- for (LauncherActivityInfoCompat app : componentMap.values()) {
- PackageInfo info = pkgInfoMap.get(app.getComponentName().getPackageName());
- if (info == null) {
- continue;
- }
- addIconToDBAndMemCache(app, info, userSerial);
+ if (!componentMap.isEmpty()) {
+ mWorkerHandler.post(new SerializedIconAdditionTask(userSerial, pkgInfoMap,
+ componentMap.values()));
}
return updatedPackages;
}
private void addIconToDBAndMemCache(LauncherActivityInfoCompat app, PackageInfo info,
long userSerial) {
- ContentValues values = updateCacheAndGetContentValues(app);
+ // Reuse the existing entry if it already exists in the DB. This ensures that we do not
+ // create bitmap if it was already created during loader.
+ ContentValues values = updateCacheAndGetContentValues(app, false);
addIconToDB(values, app.getComponentName(), info, userSerial);
- values.put(IconDB.COLUMN_COMPONENT, app.getComponentName().flattenToString());
}
/**
@@ -327,9 +327,21 @@ public class IconCache {
SQLiteDatabase.CONFLICT_REPLACE);
}
- private ContentValues updateCacheAndGetContentValues(LauncherActivityInfoCompat app) {
- CacheEntry entry = new CacheEntry();
- entry.icon = Utilities.createIconBitmap(app.getBadgedIcon(mIconDpi), mContext);
+ private ContentValues updateCacheAndGetContentValues(LauncherActivityInfoCompat app,
+ boolean replaceExisting) {
+ final ComponentKey key = new ComponentKey(app.getComponentName(), app.getUser());
+ CacheEntry entry = null;
+ if (!replaceExisting) {
+ entry = mCache.get(key);
+ // We can't reuse the entry if the high-res icon is not present.
+ if (entry == null || entry.isLowResIcon || entry.icon == null) {
+ entry = null;
+ }
+ }
+ if (entry == null) {
+ entry = new CacheEntry();
+ entry.icon = Utilities.createIconBitmap(app.getBadgedIcon(mIconDpi), mContext);
+ }
entry.title = app.getLabel();
entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, app.getUser());
mCache.put(new ComponentKey(app.getComponentName(), app.getUser()), entry);
@@ -671,6 +683,40 @@ public class IconCache {
}
}
+ /**
+ * A runnable that adds icons in the DB for the provided LauncherActivityInfoCompat list.
+ * Items are added one at a time, to that the worker thread does not get blocked.
+ */
+ private class SerializedIconAdditionTask implements Runnable {
+ private final long mUserSerial;
+ private final HashMap<String, PackageInfo> mPkgInfoMap;
+ private final Stack<LauncherActivityInfoCompat> mAppsToAdd;
+
+ private SerializedIconAdditionTask(long userSerial, HashMap<String, PackageInfo> pkgInfoMap,
+ Collection<LauncherActivityInfoCompat> appsToAdd) {
+ mUserSerial = userSerial;
+ mPkgInfoMap = pkgInfoMap;
+ mAppsToAdd = new Stack<LauncherActivityInfoCompat>();
+ mAppsToAdd.addAll(appsToAdd);
+ }
+
+ @Override
+ public void run() {
+ if (!mAppsToAdd.isEmpty()) {
+ LauncherActivityInfoCompat app = mAppsToAdd.pop();
+ PackageInfo info = mPkgInfoMap.get(app.getComponentName().getPackageName());
+ if (info != null) {
+ synchronized (IconCache.this) {
+ addIconToDBAndMemCache(app, info, mUserSerial);
+ }
+ }
+ }
+ if (!mAppsToAdd.isEmpty()) {
+ mWorkerHandler.post(this);
+ }
+ }
+ }
+
private static final class IconDB extends SQLiteOpenHelper {
private final static int DB_VERSION = 4;
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 51ba2dfc9..7b7b61795 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -96,6 +96,7 @@ import android.widget.Toast;
import com.android.launcher3.DropTarget.DragObject;
import com.android.launcher3.PagedView.PageSwitchListener;
+import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.compat.AppWidgetManagerCompat;
import com.android.launcher3.compat.LauncherActivityInfoCompat;
import com.android.launcher3.compat.LauncherAppsCompat;
@@ -3184,7 +3185,7 @@ public class Launcher extends Activity
}
}
- void closeFolder(Folder folder) {
+ public void closeFolder(Folder folder) {
folder.getInfo().opened = false;
ViewGroup parent = (ViewGroup) folder.getParent().getParent();
@@ -3337,7 +3338,7 @@ public class Launcher extends Activity
true);
}
- protected void showWorkspace(boolean animated, Runnable onCompleteRunnable) {
+ public void showWorkspace(boolean animated, Runnable onCompleteRunnable) {
showWorkspace(WorkspaceStateTransitionAnimation.SCROLL_TO_CURRENT_PAGE, animated,
onCompleteRunnable, true);
}
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index bde54c335..f540eb47d 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -31,6 +31,7 @@ import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
+import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.PackageInstallerCompat;
import com.android.launcher3.util.Thunk;
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 58e899aec..3e05f57b9 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -792,7 +792,7 @@ public class LauncherModel extends BroadcastReceiver
/**
* Move an item in the DB to a new <container, screen, cellX, cellY>
*/
- static void moveItemInDatabase(Context context, final ItemInfo item, final long container,
+ public static void moveItemInDatabase(Context context, final ItemInfo item, final long container,
final long screenId, final int cellX, final int cellY) {
item.container = container;
item.cellX = cellX;
@@ -888,7 +888,7 @@ public class LauncherModel extends BroadcastReceiver
/**
* Update an item to the database in a specified container.
*/
- static void updateItemInDatabase(Context context, final ItemInfo item) {
+ public static void updateItemInDatabase(Context context, final ItemInfo item) {
final ContentValues values = new ContentValues();
item.onAddToDatabase(context, values);
updateItemInDatabaseHelper(context, values, item, "updateItemInDatabase");
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 554a975e7..dda9a166c 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -407,7 +407,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
/**
* Returns the index of the currently displayed page.
*/
- int getCurrentPage() {
+ public int getCurrentPage() {
return mCurrentPage;
}
@@ -422,7 +422,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
return getChildCount();
}
- View getPageAt(int index) {
+ public View getPageAt(int index) {
return getChildAt(index);
}
@@ -633,9 +633,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
if (mCurrentPage != getNextPage()) {
AccessibilityEvent ev =
AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_SCROLLED);
- ev.setItemCount(getChildCount());
- ev.setFromIndex(getNextPage());
- ev.setToIndex(getNextPage());
sendAccessibilityEventUnchecked(ev);
}
@@ -912,8 +909,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
pageGap = getPaddingRight();
}
- childLeft += childWidth + pageGap
- + (lp.isFullScreenPage ? 0 : (getPaddingLeft() + getPaddingRight()));
+ childLeft += childWidth + pageGap + getChildGap();
}
}
@@ -961,6 +957,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
}
+ protected int getChildGap() {
+ return 0;
+ }
+
private void updateMaxScrollX() {
int childCount = getChildCount();
if (childCount > 0) {
diff --git a/src/com/android/launcher3/SmoothPagedView.java b/src/com/android/launcher3/SmoothPagedView.java
index 4e331aa2c..0f9b23cda 100644
--- a/src/com/android/launcher3/SmoothPagedView.java
+++ b/src/com/android/launcher3/SmoothPagedView.java
@@ -152,7 +152,7 @@ public abstract class SmoothPagedView extends PagedView {
}
@Override
- protected void snapToPage(int whichPage) {
+ public void snapToPage(int whichPage) {
if (mScrollMode == X_LARGE_MODE) {
super.snapToPage(whichPage);
} else {
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index e645b6570..55742f655 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -61,10 +61,11 @@ import android.widget.TextView;
import com.android.launcher3.FolderIcon.FolderRingAnimator;
import com.android.launcher3.Launcher.CustomContentCallbacks;
import com.android.launcher3.Launcher.LauncherOverlay;
-import com.android.launcher3.LauncherAccessibilityDelegate.AccessibilityDragSource;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.UninstallDropTarget.UninstallSource;
+import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.accessibility.OverviewScreenAccessibilityDelegate;
+import com.android.launcher3.accessibility.LauncherAccessibilityDelegate.AccessibilityDragSource;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.util.LongArrayMap;
import com.android.launcher3.util.Thunk;
@@ -486,7 +487,7 @@ public class Workspace extends SmoothPagedView
/**
* @return The open folder on the current screen, or null if there is none
*/
- Folder getOpenFolder() {
+ public Folder getOpenFolder() {
DragLayer dragLayer = mLauncher.getDragLayer();
int count = dragLayer.getChildCount();
for (int i = 0; i < count; i++) {
@@ -848,7 +849,7 @@ public class Workspace extends SmoothPagedView
return -1;
}
- ArrayList<Long> getScreenOrder() {
+ public ArrayList<Long> getScreenOrder() {
return mScreenOrder;
}
diff --git a/src/com/android/launcher3/accessibility/DragAndDropAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/DragAndDropAccessibilityDelegate.java
index 0f1724155..78accf720 100644
--- a/src/com/android/launcher3/accessibility/DragAndDropAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/DragAndDropAccessibilityDelegate.java
@@ -26,7 +26,6 @@ import android.view.View.OnClickListener;
import android.view.accessibility.AccessibilityEvent;
import com.android.launcher3.CellLayout;
-import com.android.launcher3.LauncherAccessibilityDelegate;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
diff --git a/src/com/android/launcher3/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
index 3992e6390..eeec8c580 100644
--- a/src/com/android/launcher3/LauncherAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
@@ -1,4 +1,4 @@
-package com.android.launcher3;
+package com.android.launcher3.accessibility;
import android.annotation.TargetApi;
import android.app.AlertDialog;
@@ -16,6 +16,24 @@ import android.view.View.AccessibilityDelegate;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
+import com.android.launcher3.AppInfo;
+import com.android.launcher3.AppWidgetResizeFrame;
+import com.android.launcher3.CellLayout;
+import com.android.launcher3.DeleteDropTarget;
+import com.android.launcher3.Folder;
+import com.android.launcher3.FolderInfo;
+import com.android.launcher3.InfoDropTarget;
+import com.android.launcher3.ItemInfo;
+import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherAppWidgetHostView;
+import com.android.launcher3.LauncherAppWidgetInfo;
+import com.android.launcher3.LauncherModel;
+import com.android.launcher3.LauncherSettings;
+import com.android.launcher3.PendingAddItemInfo;
+import com.android.launcher3.R;
+import com.android.launcher3.ShortcutInfo;
+import com.android.launcher3.UninstallDropTarget;
+import com.android.launcher3.Workspace;
import com.android.launcher3.util.Thunk;
import java.util.ArrayList;
diff --git a/src/com/android/launcher3/accessibility/WorkspaceAccessibilityHelper.java b/src/com/android/launcher3/accessibility/WorkspaceAccessibilityHelper.java
index 6f89d0eb0..80ddc13b7 100644
--- a/src/com/android/launcher3/accessibility/WorkspaceAccessibilityHelper.java
+++ b/src/com/android/launcher3/accessibility/WorkspaceAccessibilityHelper.java
@@ -23,8 +23,7 @@ import com.android.launcher3.AppInfo;
import com.android.launcher3.CellLayout;
import com.android.launcher3.FolderInfo;
import com.android.launcher3.ItemInfo;
-import com.android.launcher3.LauncherAccessibilityDelegate;
-import com.android.launcher3.LauncherAccessibilityDelegate.DragType;
+import com.android.launcher3.accessibility.LauncherAccessibilityDelegate.DragType;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
diff --git a/src/com/android/launcher3/model/WidgetsAndShortcutNameComparator.java b/src/com/android/launcher3/model/WidgetsAndShortcutNameComparator.java
index 7c4e80651..61e895283 100644
--- a/src/com/android/launcher3/model/WidgetsAndShortcutNameComparator.java
+++ b/src/com/android/launcher3/model/WidgetsAndShortcutNameComparator.java
@@ -1,6 +1,5 @@
package com.android.launcher3.model;
-import android.appwidget.AppWidgetProviderInfo;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
@@ -8,6 +7,7 @@ import android.content.pm.ResolveInfo;
import com.android.launcher3.LauncherAppWidgetProviderInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AppWidgetManagerCompat;
+import com.android.launcher3.compat.UserHandleCompat;
import java.text.Collator;
import java.util.Comparator;
@@ -18,12 +18,14 @@ public class WidgetsAndShortcutNameComparator implements Comparator<Object> {
private final PackageManager mPackageManager;
private final HashMap<Object, String> mLabelCache;
private final Collator mCollator;
+ private final UserHandleCompat mMainHandle;
public WidgetsAndShortcutNameComparator(Context context) {
mManager = AppWidgetManagerCompat.getInstance(context);
mPackageManager = context.getPackageManager();
mLabelCache = new HashMap<Object, String>();
mCollator = Collator.getInstance();
+ mMainHandle = UserHandleCompat.myUserHandle();
}
@Override
@@ -45,19 +47,22 @@ public class WidgetsAndShortcutNameComparator implements Comparator<Object> {
: Utilities.trim(((ResolveInfo) b).loadLabel(mPackageManager));
mLabelCache.put(b, labelB);
}
- int result = mCollator.compare(labelA, labelB);
- if (result == 0 && a instanceof AppWidgetProviderInfo &&
- b instanceof AppWidgetProviderInfo) {
- AppWidgetProviderInfo aInfo = (AppWidgetProviderInfo) a;
- AppWidgetProviderInfo bInfo = (AppWidgetProviderInfo) b;
-
- // prioritize main user's widgets against work profile widgets.
- if (aInfo.getProfile().equals(android.os.Process.myUserHandle())) {
- return -1;
- } else if (bInfo.getProfile().equals(android.os.Process.myUserHandle())) {
- return 1;
- }
+
+ // Currently, there is no work profile shortcuts, hence only considering the widget cases.
+
+ boolean aWorkProfile = (a instanceof LauncherAppWidgetProviderInfo) &&
+ !mMainHandle.equals(mManager.getUser((LauncherAppWidgetProviderInfo) a));
+ boolean bWorkProfile = (b instanceof LauncherAppWidgetProviderInfo) &&
+ !mMainHandle.equals(mManager.getUser((LauncherAppWidgetProviderInfo) b));
+
+ // Independent of how the labels compare, if only one of the two widget info belongs to
+ // work profile, put that one in the back.
+ if (aWorkProfile && !bWorkProfile) {
+ return 1;
+ }
+ if (!aWorkProfile && bWorkProfile) {
+ return -1;
}
- return result;
+ return mCollator.compare(labelA, labelB);
}
};
diff --git a/src/com/android/launcher3/widget/WidgetsContainerView.java b/src/com/android/launcher3/widget/WidgetsContainerView.java
index 181c08a40..7a7895ff8 100644
--- a/src/com/android/launcher3/widget/WidgetsContainerView.java
+++ b/src/com/android/launcher3/widget/WidgetsContainerView.java
@@ -135,7 +135,7 @@ public class WidgetsContainerView extends BaseContainerView
//
public View getContentView() {
- return findViewById(R.id.widgets_content);
+ return mView;
}
public View getRevealView() {
diff --git a/src/com/android/launcher3/widget/WidgetsListAdapter.java b/src/com/android/launcher3/widget/WidgetsListAdapter.java
index 2f733dcbc..3916c00d2 100644
--- a/src/com/android/launcher3/widget/WidgetsListAdapter.java
+++ b/src/com/android/launcher3/widget/WidgetsListAdapter.java
@@ -183,7 +183,6 @@ public class WidgetsListAdapter extends Adapter<WidgetsRowViewHolder> {
}
}
- @Override
public boolean onFailedToRecycleView(WidgetsRowViewHolder holder) {
// If child views are animating, then the RecyclerView may choose not to recycle the view,
// causing extraneous onCreateViewHolder() calls. It is safe in this case to continue