Loading src/com/android/launcher3/AutoInstallsLayout.java +28 −29 Original line number Original line Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.util.Patterns; import com.android.launcher3.LauncherProvider.SqlArguments; import com.android.launcher3.LauncherProvider.SqlArguments; import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.icons.LauncherIcons; import com.android.launcher3.icons.LauncherIcons; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.Thunk; import com.android.launcher3.util.Thunk; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser; Loading Loading @@ -163,7 +164,7 @@ public class AutoInstallsLayout { private final int mRowCount; private final int mRowCount; private final int mColumnCount; private final int mColumnCount; private final long[] mTemp = new long[2]; private final int[] mTemp = new int[2]; @Thunk final ContentValues mValues; @Thunk final ContentValues mValues; protected final String mRootTag; protected final String mRootTag; Loading Loading @@ -191,7 +192,7 @@ public class AutoInstallsLayout { /** /** * Loads the layout in the db and returns the number of entries added on the desktop. * Loads the layout in the db and returns the number of entries added on the desktop. */ */ public int loadLayout(SQLiteDatabase db, ArrayList<Long> screenIds) { public int loadLayout(SQLiteDatabase db, IntArray screenIds) { mDb = db; mDb = db; try { try { return parseLayout(mLayoutId, screenIds); return parseLayout(mLayoutId, screenIds); Loading @@ -204,7 +205,7 @@ public class AutoInstallsLayout { /** /** * Parses the layout and returns the number of elements added on the homescreen. * Parses the layout and returns the number of elements added on the homescreen. */ */ protected int parseLayout(int layoutId, ArrayList<Long> screenIds) protected int parseLayout(int layoutId, IntArray screenIds) throws XmlPullParserException, IOException { throws XmlPullParserException, IOException { XmlResourceParser parser = mSourceRes.getXml(layoutId); XmlResourceParser parser = mSourceRes.getXml(layoutId); beginDocument(parser, mRootTag); beginDocument(parser, mRootTag); Loading @@ -227,14 +228,14 @@ public class AutoInstallsLayout { * Parses container and screenId attribute from the current tag, and puts it in the out. * Parses container and screenId attribute from the current tag, and puts it in the out. * @param out array of size 2. * @param out array of size 2. */ */ protected void parseContainerAndScreen(XmlResourceParser parser, long[] out) { protected void parseContainerAndScreen(XmlResourceParser parser, int[] out) { if (HOTSEAT_CONTAINER_NAME.equals(getAttributeValue(parser, ATTR_CONTAINER))) { if (HOTSEAT_CONTAINER_NAME.equals(getAttributeValue(parser, ATTR_CONTAINER))) { out[0] = Favorites.CONTAINER_HOTSEAT; out[0] = Favorites.CONTAINER_HOTSEAT; // Hack: hotseat items are stored using screen ids // Hack: hotseat items are stored using screen ids out[1] = Long.parseLong(getAttributeValue(parser, ATTR_RANK)); out[1] = Integer.parseInt(getAttributeValue(parser, ATTR_RANK)); } else { } else { out[0] = Favorites.CONTAINER_DESKTOP; out[0] = Favorites.CONTAINER_DESKTOP; out[1] = Long.parseLong(getAttributeValue(parser, ATTR_SCREEN)); out[1] = Integer.parseInt(getAttributeValue(parser, ATTR_SCREEN)); } } } } Loading @@ -242,9 +243,7 @@ public class AutoInstallsLayout { * Parses the current node and returns the number of elements added. * Parses the current node and returns the number of elements added. */ */ protected int parseAndAddNode( protected int parseAndAddNode( XmlResourceParser parser, XmlResourceParser parser, ArrayMap<String, TagParser> tagParserMap, IntArray screenIds) ArrayMap<String, TagParser> tagParserMap, ArrayList<Long> screenIds) throws XmlPullParserException, IOException { throws XmlPullParserException, IOException { if (TAG_INCLUDE.equals(parser.getName())) { if (TAG_INCLUDE.equals(parser.getName())) { Loading @@ -259,8 +258,8 @@ public class AutoInstallsLayout { mValues.clear(); mValues.clear(); parseContainerAndScreen(parser, mTemp); parseContainerAndScreen(parser, mTemp); final long container = mTemp[0]; final int container = mTemp[0]; final long screenId = mTemp[1]; final int screenId = mTemp[1]; mValues.put(Favorites.CONTAINER, container); mValues.put(Favorites.CONTAINER, container); mValues.put(Favorites.SCREEN, screenId); mValues.put(Favorites.SCREEN, screenId); Loading @@ -275,7 +274,7 @@ public class AutoInstallsLayout { if (LOGD) Log.d(TAG, "Ignoring unknown element tag: " + parser.getName()); if (LOGD) Log.d(TAG, "Ignoring unknown element tag: " + parser.getName()); return 0; return 0; } } long newElementId = tagParser.parseAndAdd(parser); int newElementId = tagParser.parseAndAdd(parser); if (newElementId >= 0) { if (newElementId >= 0) { // Keep track of the set of screens which need to be added to the db. // Keep track of the set of screens which need to be added to the db. if (!screenIds.contains(screenId) && if (!screenIds.contains(screenId) && Loading @@ -287,8 +286,8 @@ public class AutoInstallsLayout { return 0; return 0; } } protected long addShortcut(String title, Intent intent, int type) { protected int addShortcut(String title, Intent intent, int type) { long id = mCallback.generateNewItemId(); int id = mCallback.generateNewItemId(); mValues.put(Favorites.INTENT, intent.toUri(0)); mValues.put(Favorites.INTENT, intent.toUri(0)); mValues.put(Favorites.TITLE, title); mValues.put(Favorites.TITLE, title); mValues.put(Favorites.ITEM_TYPE, type); mValues.put(Favorites.ITEM_TYPE, type); Loading Loading @@ -325,7 +324,7 @@ public class AutoInstallsLayout { * Parses the tag and adds to the db * Parses the tag and adds to the db * @return the id of the row added or -1; * @return the id of the row added or -1; */ */ long parseAndAdd(XmlResourceParser parser) int parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, IOException; throws XmlPullParserException, IOException; } } Loading @@ -335,7 +334,7 @@ public class AutoInstallsLayout { protected class AppShortcutParser implements TagParser { protected class AppShortcutParser implements TagParser { @Override @Override public long parseAndAdd(XmlResourceParser parser) { public int parseAndAdd(XmlResourceParser parser) { final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME); final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME); final String className = getAttributeValue(parser, ATTR_CLASS_NAME); final String className = getAttributeValue(parser, ATTR_CLASS_NAME); Loading Loading @@ -372,7 +371,7 @@ public class AutoInstallsLayout { /** /** * Helper method to allow extending the parser capabilities * Helper method to allow extending the parser capabilities */ */ protected long invalidPackageOrClass(XmlResourceParser parser) { protected int invalidPackageOrClass(XmlResourceParser parser) { Log.w(TAG, "Skipping invalid <favorite> with no component"); Log.w(TAG, "Skipping invalid <favorite> with no component"); return -1; return -1; } } Loading @@ -384,7 +383,7 @@ public class AutoInstallsLayout { protected class AutoInstallParser implements TagParser { protected class AutoInstallParser implements TagParser { @Override @Override public long parseAndAdd(XmlResourceParser parser) { public int parseAndAdd(XmlResourceParser parser) { final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME); final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME); final String className = getAttributeValue(parser, ATTR_CLASS_NAME); final String className = getAttributeValue(parser, ATTR_CLASS_NAME); if (TextUtils.isEmpty(packageName) || TextUtils.isEmpty(className)) { if (TextUtils.isEmpty(packageName) || TextUtils.isEmpty(className)) { Loading Loading @@ -415,7 +414,7 @@ public class AutoInstallsLayout { } } @Override @Override public long parseAndAdd(XmlResourceParser parser) { public int parseAndAdd(XmlResourceParser parser) { final int titleResId = getAttributeResourceValue(parser, ATTR_TITLE, 0); final int titleResId = getAttributeResourceValue(parser, ATTR_TITLE, 0); final int iconId = getAttributeResourceValue(parser, ATTR_ICON, 0); final int iconId = getAttributeResourceValue(parser, ATTR_ICON, 0); Loading Loading @@ -471,7 +470,7 @@ public class AutoInstallsLayout { protected class PendingWidgetParser implements TagParser { protected class PendingWidgetParser implements TagParser { @Override @Override public long parseAndAdd(XmlResourceParser parser) public int parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, IOException { throws XmlPullParserException, IOException { final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME); final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME); final String className = getAttributeValue(parser, ATTR_CLASS_NAME); final String className = getAttributeValue(parser, ATTR_CLASS_NAME); Loading Loading @@ -510,7 +509,7 @@ public class AutoInstallsLayout { return verifyAndInsert(new ComponentName(packageName, className), extras); return verifyAndInsert(new ComponentName(packageName, className), extras); } } protected long verifyAndInsert(ComponentName cn, Bundle extras) { protected int verifyAndInsert(ComponentName cn, Bundle extras) { mValues.put(Favorites.APPWIDGET_PROVIDER, cn.flattenToString()); mValues.put(Favorites.APPWIDGET_PROVIDER, cn.flattenToString()); mValues.put(Favorites.RESTORED, mValues.put(Favorites.RESTORED, LauncherAppWidgetInfo.FLAG_ID_NOT_VALID | LauncherAppWidgetInfo.FLAG_ID_NOT_VALID | Loading @@ -521,7 +520,7 @@ public class AutoInstallsLayout { mValues.put(Favorites.INTENT, new Intent().putExtras(extras).toUri(0)); mValues.put(Favorites.INTENT, new Intent().putExtras(extras).toUri(0)); } } long insertedId = mCallback.insertAndCheck(mDb, mValues); int insertedId = mCallback.insertAndCheck(mDb, mValues); if (insertedId < 0) { if (insertedId < 0) { return -1; return -1; } else { } else { Loading @@ -542,7 +541,7 @@ public class AutoInstallsLayout { } } @Override @Override public long parseAndAdd(XmlResourceParser parser) public int parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, IOException { throws XmlPullParserException, IOException { final String title; final String title; final int titleResId = getAttributeResourceValue(parser, ATTR_TITLE, 0); final int titleResId = getAttributeResourceValue(parser, ATTR_TITLE, 0); Loading @@ -557,14 +556,14 @@ public class AutoInstallsLayout { mValues.put(Favorites.SPANX, 1); mValues.put(Favorites.SPANX, 1); mValues.put(Favorites.SPANY, 1); mValues.put(Favorites.SPANY, 1); mValues.put(Favorites._ID, mCallback.generateNewItemId()); mValues.put(Favorites._ID, mCallback.generateNewItemId()); long folderId = mCallback.insertAndCheck(mDb, mValues); int folderId = mCallback.insertAndCheck(mDb, mValues); if (folderId < 0) { if (folderId < 0) { if (LOGD) Log.e(TAG, "Unable to add folder"); if (LOGD) Log.e(TAG, "Unable to add folder"); return -1; return -1; } } final ContentValues myValues = new ContentValues(mValues); final ContentValues myValues = new ContentValues(mValues); ArrayList<Long> folderItems = new ArrayList<>(); IntArray folderItems = new IntArray(); int type; int type; int folderDepth = parser.getDepth(); int folderDepth = parser.getDepth(); Loading @@ -580,7 +579,7 @@ public class AutoInstallsLayout { TagParser tagParser = mFolderElements.get(parser.getName()); TagParser tagParser = mFolderElements.get(parser.getName()); if (tagParser != null) { if (tagParser != null) { final long id = tagParser.parseAndAdd(parser); final int id = tagParser.parseAndAdd(parser); if (id >= 0) { if (id >= 0) { folderItems.add(id); folderItems.add(id); rank++; rank++; Loading @@ -590,7 +589,7 @@ public class AutoInstallsLayout { } } } } long addedId = folderId; int addedId = folderId; // We can only have folders with >= 2 items, so we need to remove the // We can only have folders with >= 2 items, so we need to remove the // folder and clean up if less than 2 items were included, or some // folder and clean up if less than 2 items were included, or some Loading Loading @@ -675,9 +674,9 @@ public class AutoInstallsLayout { } } public interface LayoutParserCallback { public interface LayoutParserCallback { long generateNewItemId(); int generateNewItemId(); long insertAndCheck(SQLiteDatabase db, ContentValues values); int insertAndCheck(SQLiteDatabase db, ContentValues values); } } @Thunk static void copyInteger(ContentValues from, ContentValues to, String key) { @Thunk static void copyInteger(ContentValues from, ContentValues to, String key) { Loading src/com/android/launcher3/CellLayout.java +3 −3 Original line number Original line Diff line number Diff line Loading @@ -2063,7 +2063,7 @@ public class CellLayout extends ViewGroup { private void commitTempPlacement() { private void commitTempPlacement() { mTmpOccupied.copyTo(mOccupied); mTmpOccupied.copyTo(mOccupied); long screenId = mLauncher.getWorkspace().getIdForScreen(this); int screenId = mLauncher.getWorkspace().getIdForScreen(this); int container = Favorites.CONTAINER_DESKTOP; int container = Favorites.CONTAINER_DESKTOP; if (mContainerType == HOTSEAT) { if (mContainerType == HOTSEAT) { Loading Loading @@ -2688,8 +2688,8 @@ public class CellLayout extends ViewGroup { // the CellLayout that was long clicked // the CellLayout that was long clicked public static final class CellInfo extends CellAndSpan { public static final class CellInfo extends CellAndSpan { public final View cell; public final View cell; final long screenId; final int screenId; final long container; final int container; public CellInfo(View v, ItemInfo info) { public CellInfo(View v, ItemInfo info) { cellX = info.cellX; cellX = info.cellX; Loading src/com/android/launcher3/DefaultLayoutParser.java +10 −10 Original line number Original line Diff line number Diff line Loading @@ -76,13 +76,13 @@ public class DefaultLayoutParser extends AutoInstallsLayout { } } @Override @Override protected void parseContainerAndScreen(XmlResourceParser parser, long[] out) { protected void parseContainerAndScreen(XmlResourceParser parser, int[] out) { out[0] = LauncherSettings.Favorites.CONTAINER_DESKTOP; out[0] = LauncherSettings.Favorites.CONTAINER_DESKTOP; String strContainer = getAttributeValue(parser, ATTR_CONTAINER); String strContainer = getAttributeValue(parser, ATTR_CONTAINER); if (strContainer != null) { if (strContainer != null) { out[0] = Long.valueOf(strContainer); out[0] = Integer.parseInt(strContainer); } } out[1] = Long.parseLong(getAttributeValue(parser, ATTR_SCREEN)); out[1] = Integer.parseInt(getAttributeValue(parser, ATTR_SCREEN)); } } /** /** Loading @@ -91,7 +91,7 @@ public class DefaultLayoutParser extends AutoInstallsLayout { public class AppShortcutWithUriParser extends AppShortcutParser { public class AppShortcutWithUriParser extends AppShortcutParser { @Override @Override protected long invalidPackageOrClass(XmlResourceParser parser) { protected int invalidPackageOrClass(XmlResourceParser parser) { final String uri = getAttributeValue(parser, ATTR_URI); final String uri = getAttributeValue(parser, ATTR_URI); if (TextUtils.isEmpty(uri)) { if (TextUtils.isEmpty(uri)) { Log.e(TAG, "Skipping invalid <favorite> with no component or uri"); Log.e(TAG, "Skipping invalid <favorite> with no component or uri"); Loading Loading @@ -205,11 +205,11 @@ public class DefaultLayoutParser extends AutoInstallsLayout { private final AppShortcutWithUriParser mChildParser = new AppShortcutWithUriParser(); private final AppShortcutWithUriParser mChildParser = new AppShortcutWithUriParser(); @Override @Override public long parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, public int parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, IOException { IOException { final int groupDepth = parser.getDepth(); final int groupDepth = parser.getDepth(); int type; int type; long addedId = -1; int addedId = -1; while ((type = parser.next()) != XmlPullParser.END_TAG || while ((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > groupDepth) { parser.getDepth() > groupDepth) { if (type != XmlPullParser.START_TAG || addedId > -1) { if (type != XmlPullParser.START_TAG || addedId > -1) { Loading @@ -233,7 +233,7 @@ public class DefaultLayoutParser extends AutoInstallsLayout { @Thunk class PartnerFolderParser implements TagParser { @Thunk class PartnerFolderParser implements TagParser { @Override @Override public long parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, public int parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, IOException { IOException { // Folder contents come from an external XML resource // Folder contents come from an external XML resource final Partner partner = Partner.get(mPackageManager); final Partner partner = Partner.get(mPackageManager); Loading @@ -259,7 +259,7 @@ public class DefaultLayoutParser extends AutoInstallsLayout { @Thunk class MyFolderParser extends FolderParser { @Thunk class MyFolderParser extends FolderParser { @Override @Override public long parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, public int parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, IOException { IOException { final int resId = getAttributeResourceValue(parser, ATTR_FOLDER_ITEMS, 0); final int resId = getAttributeResourceValue(parser, ATTR_FOLDER_ITEMS, 0); if (resId != 0) { if (resId != 0) { Loading @@ -277,7 +277,7 @@ public class DefaultLayoutParser extends AutoInstallsLayout { protected class AppWidgetParser extends PendingWidgetParser { protected class AppWidgetParser extends PendingWidgetParser { @Override @Override protected long verifyAndInsert(ComponentName cn, Bundle extras) { protected int verifyAndInsert(ComponentName cn, Bundle extras) { try { try { mPackageManager.getReceiverInfo(cn, 0); mPackageManager.getReceiverInfo(cn, 0); } catch (Exception e) { } catch (Exception e) { Loading @@ -293,7 +293,7 @@ public class DefaultLayoutParser extends AutoInstallsLayout { } } final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext); final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext); long insertedId = -1; int insertedId = -1; try { try { int appWidgetId = mAppWidgetHost.allocateAppWidgetId(); int appWidgetId = mAppWidgetHost.allocateAppWidgetId(); Loading src/com/android/launcher3/ItemInfo.java +5 −5 Original line number Original line Diff line number Diff line Loading @@ -34,7 +34,7 @@ public class ItemInfo { /** /** * The id in the settings database for this item * The id in the settings database for this item */ */ public long id = NO_ID; public int id = NO_ID; /** /** * One of {@link LauncherSettings.Favorites#ITEM_TYPE_APPLICATION}, * One of {@link LauncherSettings.Favorites#ITEM_TYPE_APPLICATION}, Loading @@ -52,14 +52,14 @@ public class ItemInfo { * will be {@link #NO_ID} (since it is not stored in the settings DB). For user folders * 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. * it will be the id of the folder. */ */ public long container = NO_ID; public int container = NO_ID; /** /** * Indicates the screen in which the shortcut appears if the container types is * Indicates the screen in which the shortcut appears if the container types is * {@link LauncherSettings.Favorites#CONTAINER_DESKTOP}. (i.e., ignore if the container type is * {@link LauncherSettings.Favorites#CONTAINER_DESKTOP}. (i.e., ignore if the container type is * {@link LauncherSettings.Favorites#CONTAINER_HOTSEAT}) * {@link LauncherSettings.Favorites#CONTAINER_HOTSEAT}) */ */ public long screenId = -1; public int screenId = -1; /** /** * Indicates the X position of the associated cell. * Indicates the X position of the associated cell. Loading Loading @@ -158,8 +158,8 @@ public class ItemInfo { public void readFromValues(ContentValues values) { public void readFromValues(ContentValues values) { itemType = values.getAsInteger(LauncherSettings.Favorites.ITEM_TYPE); itemType = values.getAsInteger(LauncherSettings.Favorites.ITEM_TYPE); container = values.getAsLong(LauncherSettings.Favorites.CONTAINER); container = values.getAsInteger(LauncherSettings.Favorites.CONTAINER); screenId = values.getAsLong(LauncherSettings.Favorites.SCREEN); screenId = values.getAsInteger(LauncherSettings.Favorites.SCREEN); cellX = values.getAsInteger(LauncherSettings.Favorites.CELLX); cellX = values.getAsInteger(LauncherSettings.Favorites.CELLX); cellY = values.getAsInteger(LauncherSettings.Favorites.CELLY); cellY = values.getAsInteger(LauncherSettings.Favorites.CELLY); spanX = values.getAsInteger(LauncherSettings.Favorites.SPANX); spanX = values.getAsInteger(LauncherSettings.Favorites.SPANX); Loading src/com/android/launcher3/Launcher.java +16 −15 Original line number Original line Diff line number Diff line Loading @@ -108,6 +108,7 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; import com.android.launcher3.util.ActivityResultInfo; import com.android.launcher3.util.ActivityResultInfo; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.MultiHashMap; import com.android.launcher3.util.MultiHashMap; import com.android.launcher3.util.MultiValueAlpha; import com.android.launcher3.util.MultiValueAlpha; Loading Loading @@ -490,9 +491,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, * Returns whether we should delay spring loaded mode -- for shortcuts and widgets that have * Returns whether we should delay spring loaded mode -- for shortcuts and widgets that have * a configuration step, this allows the proper animations to run after other transitions. * a configuration step, this allows the proper animations to run after other transitions. */ */ private long completeAdd( private int completeAdd( int requestCode, Intent intent, int appWidgetId, PendingRequestArgs info) { int requestCode, Intent intent, int appWidgetId, PendingRequestArgs info) { long screenId = info.screenId; int screenId = info.screenId; if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) { if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) { // When the screen id represents an actual screen (as opposed to a rank) we make sure // When the screen id represents an actual screen (as opposed to a rank) we make sure // that the drop page actually exists. // that the drop page actually exists. Loading Loading @@ -694,7 +695,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, * @param screenId the screen id to check * @param screenId the screen id to check * @return the new screen, or screenId if it exists * @return the new screen, or screenId if it exists */ */ private long ensurePendingDropLayoutExists(long screenId) { private int ensurePendingDropLayoutExists(int screenId) { CellLayout dropLayout = mWorkspace.getScreenWithId(screenId); CellLayout dropLayout = mWorkspace.getScreenWithId(screenId); if (dropLayout == null) { if (dropLayout == null) { // it's possible that the add screen was removed because it was // it's possible that the add screen was removed because it was Loading Loading @@ -974,7 +975,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, * * * @param data The intent describing the shortcut. * @param data The intent describing the shortcut. */ */ private void completeAddShortcut(Intent data, long container, long screenId, int cellX, private void completeAddShortcut(Intent data, int container, int screenId, int cellX, int cellY, PendingRequestArgs args) { int cellY, PendingRequestArgs args) { if (args.getRequestCode() != REQUEST_CREATE_SHORTCUT if (args.getRequestCode() != REQUEST_CREATE_SHORTCUT || args.getPendingIntent().getComponent() == null) { || args.getPendingIntent().getComponent() == null) { Loading Loading @@ -1050,7 +1051,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, } } } } public FolderIcon findFolderIcon(final long folderIconId) { public FolderIcon findFolderIcon(final int folderIconId) { return (FolderIcon) mWorkspace.getHomescreenIconByItemId(folderIconId); return (FolderIcon) mWorkspace.getHomescreenIconByItemId(folderIconId); } } Loading Loading @@ -1413,7 +1414,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, } } } } public void addPendingItem(PendingAddItemInfo info, long container, long screenId, public void addPendingItem(PendingAddItemInfo info, int container, int screenId, int[] cell, int spanX, int spanY) { int[] cell, int spanX, int spanY) { info.container = container; info.container = container; info.screenId = screenId; info.screenId = screenId; Loading Loading @@ -1489,7 +1490,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, } } } } FolderIcon addFolder(CellLayout layout, long container, final long screenId, int cellX, FolderIcon addFolder(CellLayout layout, int container, final int screenId, int cellX, int cellY) { int cellY) { final FolderInfo folderInfo = new FolderInfo(); final FolderInfo folderInfo = new FolderInfo(); folderInfo.title = getText(R.string.folder_name); folderInfo.title = getText(R.string.folder_name); Loading Loading @@ -1650,7 +1651,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, /** /** * Returns the CellLayout of the specified container at the specified screen. * Returns the CellLayout of the specified container at the specified screen. */ */ public CellLayout getCellLayout(long container, long screenId) { public CellLayout getCellLayout(int container, int screenId) { if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { if (mHotseat != null) { if (mHotseat != null) { return mHotseat.getLayout(); return mHotseat.getLayout(); Loading Loading @@ -1750,11 +1751,11 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, } } @Override @Override public void bindScreens(ArrayList<Long> orderedScreenIds) { public void bindScreens(IntArray orderedScreenIds) { // Make sure the first screen is always at the start. // Make sure the first screen is always at the start. if (FeatureFlags.getInstance(this).isQsbOnFirstScreenEnabled() && if (FeatureFlags.getInstance(this).isQsbOnFirstScreenEnabled() && orderedScreenIds.indexOf(Workspace.FIRST_SCREEN_ID) != 0) { orderedScreenIds.indexOf(Workspace.FIRST_SCREEN_ID) != 0) { orderedScreenIds.remove(Workspace.FIRST_SCREEN_ID); orderedScreenIds.removeValue(Workspace.FIRST_SCREEN_ID); orderedScreenIds.add(0, Workspace.FIRST_SCREEN_ID); orderedScreenIds.add(0, Workspace.FIRST_SCREEN_ID); LauncherModel.updateWorkspaceScreenOrder(this, orderedScreenIds); LauncherModel.updateWorkspaceScreenOrder(this, orderedScreenIds); } else if (!FeatureFlags.getInstance(this).isQsbOnFirstScreenEnabled() } else if (!FeatureFlags.getInstance(this).isQsbOnFirstScreenEnabled() Loading @@ -1770,10 +1771,10 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, mWorkspace.unlockWallpaperFromDefaultPageOnNextLayout(); mWorkspace.unlockWallpaperFromDefaultPageOnNextLayout(); } } private void bindAddScreens(ArrayList<Long> orderedScreenIds) { private void bindAddScreens(IntArray orderedScreenIds) { int count = orderedScreenIds.size(); int count = orderedScreenIds.size(); for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) { long screenId = orderedScreenIds.get(i); int screenId = orderedScreenIds.get(i); if (!FeatureFlags.getInstance(this).isQsbOnFirstScreenEnabled() if (!FeatureFlags.getInstance(this).isQsbOnFirstScreenEnabled() || screenId != Workspace.FIRST_SCREEN_ID) { || screenId != Workspace.FIRST_SCREEN_ID) { // No need to bind the first screen, as its always bound. // No need to bind the first screen, as its always bound. Loading @@ -1794,7 +1795,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, } } @Override @Override public void bindAppsAdded(ArrayList<Long> newScreens, ArrayList<ItemInfo> addNotAnimated, public void bindAppsAdded(IntArray newScreens, ArrayList<ItemInfo> addNotAnimated, ArrayList<ItemInfo> addAnimated) { ArrayList<ItemInfo> addAnimated) { // Add the new screens // Add the new screens if (newScreens != null) { if (newScreens != null) { Loading Loading @@ -1825,7 +1826,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, final Collection<Animator> bounceAnims = new ArrayList<>(); final Collection<Animator> bounceAnims = new ArrayList<>(); final boolean animateIcons = forceAnimateIcons && canRunNewAppsAnimation(); final boolean animateIcons = forceAnimateIcons && canRunNewAppsAnimation(); Workspace workspace = mWorkspace; Workspace workspace = mWorkspace; long newItemsScreenId = -1; int newItemsScreenId = -1; int end = items.size(); int end = items.size(); for (int i = 0; i < end; i++) { for (int i = 0; i < end; i++) { final ItemInfo item = items.get(i); final ItemInfo item = items.get(i); Loading Loading @@ -1898,7 +1899,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, AnimatorSet anim = new AnimatorSet(); AnimatorSet anim = new AnimatorSet(); anim.playTogether(bounceAnims); anim.playTogether(bounceAnims); long currentScreenId = mWorkspace.getScreenIdForPageIndex(mWorkspace.getNextPage()); int currentScreenId = mWorkspace.getScreenIdForPageIndex(mWorkspace.getNextPage()); final int newScreenIndex = mWorkspace.getPageIndexForScreenId(newItemsScreenId); final int newScreenIndex = mWorkspace.getPageIndexForScreenId(newItemsScreenId); final Runnable startBounceAnimRunnable = anim::start; final Runnable startBounceAnimRunnable = anim::start; Loading Loading
src/com/android/launcher3/AutoInstallsLayout.java +28 −29 Original line number Original line Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.util.Patterns; import com.android.launcher3.LauncherProvider.SqlArguments; import com.android.launcher3.LauncherProvider.SqlArguments; import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.icons.LauncherIcons; import com.android.launcher3.icons.LauncherIcons; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.Thunk; import com.android.launcher3.util.Thunk; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser; Loading Loading @@ -163,7 +164,7 @@ public class AutoInstallsLayout { private final int mRowCount; private final int mRowCount; private final int mColumnCount; private final int mColumnCount; private final long[] mTemp = new long[2]; private final int[] mTemp = new int[2]; @Thunk final ContentValues mValues; @Thunk final ContentValues mValues; protected final String mRootTag; protected final String mRootTag; Loading Loading @@ -191,7 +192,7 @@ public class AutoInstallsLayout { /** /** * Loads the layout in the db and returns the number of entries added on the desktop. * Loads the layout in the db and returns the number of entries added on the desktop. */ */ public int loadLayout(SQLiteDatabase db, ArrayList<Long> screenIds) { public int loadLayout(SQLiteDatabase db, IntArray screenIds) { mDb = db; mDb = db; try { try { return parseLayout(mLayoutId, screenIds); return parseLayout(mLayoutId, screenIds); Loading @@ -204,7 +205,7 @@ public class AutoInstallsLayout { /** /** * Parses the layout and returns the number of elements added on the homescreen. * Parses the layout and returns the number of elements added on the homescreen. */ */ protected int parseLayout(int layoutId, ArrayList<Long> screenIds) protected int parseLayout(int layoutId, IntArray screenIds) throws XmlPullParserException, IOException { throws XmlPullParserException, IOException { XmlResourceParser parser = mSourceRes.getXml(layoutId); XmlResourceParser parser = mSourceRes.getXml(layoutId); beginDocument(parser, mRootTag); beginDocument(parser, mRootTag); Loading @@ -227,14 +228,14 @@ public class AutoInstallsLayout { * Parses container and screenId attribute from the current tag, and puts it in the out. * Parses container and screenId attribute from the current tag, and puts it in the out. * @param out array of size 2. * @param out array of size 2. */ */ protected void parseContainerAndScreen(XmlResourceParser parser, long[] out) { protected void parseContainerAndScreen(XmlResourceParser parser, int[] out) { if (HOTSEAT_CONTAINER_NAME.equals(getAttributeValue(parser, ATTR_CONTAINER))) { if (HOTSEAT_CONTAINER_NAME.equals(getAttributeValue(parser, ATTR_CONTAINER))) { out[0] = Favorites.CONTAINER_HOTSEAT; out[0] = Favorites.CONTAINER_HOTSEAT; // Hack: hotseat items are stored using screen ids // Hack: hotseat items are stored using screen ids out[1] = Long.parseLong(getAttributeValue(parser, ATTR_RANK)); out[1] = Integer.parseInt(getAttributeValue(parser, ATTR_RANK)); } else { } else { out[0] = Favorites.CONTAINER_DESKTOP; out[0] = Favorites.CONTAINER_DESKTOP; out[1] = Long.parseLong(getAttributeValue(parser, ATTR_SCREEN)); out[1] = Integer.parseInt(getAttributeValue(parser, ATTR_SCREEN)); } } } } Loading @@ -242,9 +243,7 @@ public class AutoInstallsLayout { * Parses the current node and returns the number of elements added. * Parses the current node and returns the number of elements added. */ */ protected int parseAndAddNode( protected int parseAndAddNode( XmlResourceParser parser, XmlResourceParser parser, ArrayMap<String, TagParser> tagParserMap, IntArray screenIds) ArrayMap<String, TagParser> tagParserMap, ArrayList<Long> screenIds) throws XmlPullParserException, IOException { throws XmlPullParserException, IOException { if (TAG_INCLUDE.equals(parser.getName())) { if (TAG_INCLUDE.equals(parser.getName())) { Loading @@ -259,8 +258,8 @@ public class AutoInstallsLayout { mValues.clear(); mValues.clear(); parseContainerAndScreen(parser, mTemp); parseContainerAndScreen(parser, mTemp); final long container = mTemp[0]; final int container = mTemp[0]; final long screenId = mTemp[1]; final int screenId = mTemp[1]; mValues.put(Favorites.CONTAINER, container); mValues.put(Favorites.CONTAINER, container); mValues.put(Favorites.SCREEN, screenId); mValues.put(Favorites.SCREEN, screenId); Loading @@ -275,7 +274,7 @@ public class AutoInstallsLayout { if (LOGD) Log.d(TAG, "Ignoring unknown element tag: " + parser.getName()); if (LOGD) Log.d(TAG, "Ignoring unknown element tag: " + parser.getName()); return 0; return 0; } } long newElementId = tagParser.parseAndAdd(parser); int newElementId = tagParser.parseAndAdd(parser); if (newElementId >= 0) { if (newElementId >= 0) { // Keep track of the set of screens which need to be added to the db. // Keep track of the set of screens which need to be added to the db. if (!screenIds.contains(screenId) && if (!screenIds.contains(screenId) && Loading @@ -287,8 +286,8 @@ public class AutoInstallsLayout { return 0; return 0; } } protected long addShortcut(String title, Intent intent, int type) { protected int addShortcut(String title, Intent intent, int type) { long id = mCallback.generateNewItemId(); int id = mCallback.generateNewItemId(); mValues.put(Favorites.INTENT, intent.toUri(0)); mValues.put(Favorites.INTENT, intent.toUri(0)); mValues.put(Favorites.TITLE, title); mValues.put(Favorites.TITLE, title); mValues.put(Favorites.ITEM_TYPE, type); mValues.put(Favorites.ITEM_TYPE, type); Loading Loading @@ -325,7 +324,7 @@ public class AutoInstallsLayout { * Parses the tag and adds to the db * Parses the tag and adds to the db * @return the id of the row added or -1; * @return the id of the row added or -1; */ */ long parseAndAdd(XmlResourceParser parser) int parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, IOException; throws XmlPullParserException, IOException; } } Loading @@ -335,7 +334,7 @@ public class AutoInstallsLayout { protected class AppShortcutParser implements TagParser { protected class AppShortcutParser implements TagParser { @Override @Override public long parseAndAdd(XmlResourceParser parser) { public int parseAndAdd(XmlResourceParser parser) { final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME); final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME); final String className = getAttributeValue(parser, ATTR_CLASS_NAME); final String className = getAttributeValue(parser, ATTR_CLASS_NAME); Loading Loading @@ -372,7 +371,7 @@ public class AutoInstallsLayout { /** /** * Helper method to allow extending the parser capabilities * Helper method to allow extending the parser capabilities */ */ protected long invalidPackageOrClass(XmlResourceParser parser) { protected int invalidPackageOrClass(XmlResourceParser parser) { Log.w(TAG, "Skipping invalid <favorite> with no component"); Log.w(TAG, "Skipping invalid <favorite> with no component"); return -1; return -1; } } Loading @@ -384,7 +383,7 @@ public class AutoInstallsLayout { protected class AutoInstallParser implements TagParser { protected class AutoInstallParser implements TagParser { @Override @Override public long parseAndAdd(XmlResourceParser parser) { public int parseAndAdd(XmlResourceParser parser) { final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME); final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME); final String className = getAttributeValue(parser, ATTR_CLASS_NAME); final String className = getAttributeValue(parser, ATTR_CLASS_NAME); if (TextUtils.isEmpty(packageName) || TextUtils.isEmpty(className)) { if (TextUtils.isEmpty(packageName) || TextUtils.isEmpty(className)) { Loading Loading @@ -415,7 +414,7 @@ public class AutoInstallsLayout { } } @Override @Override public long parseAndAdd(XmlResourceParser parser) { public int parseAndAdd(XmlResourceParser parser) { final int titleResId = getAttributeResourceValue(parser, ATTR_TITLE, 0); final int titleResId = getAttributeResourceValue(parser, ATTR_TITLE, 0); final int iconId = getAttributeResourceValue(parser, ATTR_ICON, 0); final int iconId = getAttributeResourceValue(parser, ATTR_ICON, 0); Loading Loading @@ -471,7 +470,7 @@ public class AutoInstallsLayout { protected class PendingWidgetParser implements TagParser { protected class PendingWidgetParser implements TagParser { @Override @Override public long parseAndAdd(XmlResourceParser parser) public int parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, IOException { throws XmlPullParserException, IOException { final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME); final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME); final String className = getAttributeValue(parser, ATTR_CLASS_NAME); final String className = getAttributeValue(parser, ATTR_CLASS_NAME); Loading Loading @@ -510,7 +509,7 @@ public class AutoInstallsLayout { return verifyAndInsert(new ComponentName(packageName, className), extras); return verifyAndInsert(new ComponentName(packageName, className), extras); } } protected long verifyAndInsert(ComponentName cn, Bundle extras) { protected int verifyAndInsert(ComponentName cn, Bundle extras) { mValues.put(Favorites.APPWIDGET_PROVIDER, cn.flattenToString()); mValues.put(Favorites.APPWIDGET_PROVIDER, cn.flattenToString()); mValues.put(Favorites.RESTORED, mValues.put(Favorites.RESTORED, LauncherAppWidgetInfo.FLAG_ID_NOT_VALID | LauncherAppWidgetInfo.FLAG_ID_NOT_VALID | Loading @@ -521,7 +520,7 @@ public class AutoInstallsLayout { mValues.put(Favorites.INTENT, new Intent().putExtras(extras).toUri(0)); mValues.put(Favorites.INTENT, new Intent().putExtras(extras).toUri(0)); } } long insertedId = mCallback.insertAndCheck(mDb, mValues); int insertedId = mCallback.insertAndCheck(mDb, mValues); if (insertedId < 0) { if (insertedId < 0) { return -1; return -1; } else { } else { Loading @@ -542,7 +541,7 @@ public class AutoInstallsLayout { } } @Override @Override public long parseAndAdd(XmlResourceParser parser) public int parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, IOException { throws XmlPullParserException, IOException { final String title; final String title; final int titleResId = getAttributeResourceValue(parser, ATTR_TITLE, 0); final int titleResId = getAttributeResourceValue(parser, ATTR_TITLE, 0); Loading @@ -557,14 +556,14 @@ public class AutoInstallsLayout { mValues.put(Favorites.SPANX, 1); mValues.put(Favorites.SPANX, 1); mValues.put(Favorites.SPANY, 1); mValues.put(Favorites.SPANY, 1); mValues.put(Favorites._ID, mCallback.generateNewItemId()); mValues.put(Favorites._ID, mCallback.generateNewItemId()); long folderId = mCallback.insertAndCheck(mDb, mValues); int folderId = mCallback.insertAndCheck(mDb, mValues); if (folderId < 0) { if (folderId < 0) { if (LOGD) Log.e(TAG, "Unable to add folder"); if (LOGD) Log.e(TAG, "Unable to add folder"); return -1; return -1; } } final ContentValues myValues = new ContentValues(mValues); final ContentValues myValues = new ContentValues(mValues); ArrayList<Long> folderItems = new ArrayList<>(); IntArray folderItems = new IntArray(); int type; int type; int folderDepth = parser.getDepth(); int folderDepth = parser.getDepth(); Loading @@ -580,7 +579,7 @@ public class AutoInstallsLayout { TagParser tagParser = mFolderElements.get(parser.getName()); TagParser tagParser = mFolderElements.get(parser.getName()); if (tagParser != null) { if (tagParser != null) { final long id = tagParser.parseAndAdd(parser); final int id = tagParser.parseAndAdd(parser); if (id >= 0) { if (id >= 0) { folderItems.add(id); folderItems.add(id); rank++; rank++; Loading @@ -590,7 +589,7 @@ public class AutoInstallsLayout { } } } } long addedId = folderId; int addedId = folderId; // We can only have folders with >= 2 items, so we need to remove the // We can only have folders with >= 2 items, so we need to remove the // folder and clean up if less than 2 items were included, or some // folder and clean up if less than 2 items were included, or some Loading Loading @@ -675,9 +674,9 @@ public class AutoInstallsLayout { } } public interface LayoutParserCallback { public interface LayoutParserCallback { long generateNewItemId(); int generateNewItemId(); long insertAndCheck(SQLiteDatabase db, ContentValues values); int insertAndCheck(SQLiteDatabase db, ContentValues values); } } @Thunk static void copyInteger(ContentValues from, ContentValues to, String key) { @Thunk static void copyInteger(ContentValues from, ContentValues to, String key) { Loading
src/com/android/launcher3/CellLayout.java +3 −3 Original line number Original line Diff line number Diff line Loading @@ -2063,7 +2063,7 @@ public class CellLayout extends ViewGroup { private void commitTempPlacement() { private void commitTempPlacement() { mTmpOccupied.copyTo(mOccupied); mTmpOccupied.copyTo(mOccupied); long screenId = mLauncher.getWorkspace().getIdForScreen(this); int screenId = mLauncher.getWorkspace().getIdForScreen(this); int container = Favorites.CONTAINER_DESKTOP; int container = Favorites.CONTAINER_DESKTOP; if (mContainerType == HOTSEAT) { if (mContainerType == HOTSEAT) { Loading Loading @@ -2688,8 +2688,8 @@ public class CellLayout extends ViewGroup { // the CellLayout that was long clicked // the CellLayout that was long clicked public static final class CellInfo extends CellAndSpan { public static final class CellInfo extends CellAndSpan { public final View cell; public final View cell; final long screenId; final int screenId; final long container; final int container; public CellInfo(View v, ItemInfo info) { public CellInfo(View v, ItemInfo info) { cellX = info.cellX; cellX = info.cellX; Loading
src/com/android/launcher3/DefaultLayoutParser.java +10 −10 Original line number Original line Diff line number Diff line Loading @@ -76,13 +76,13 @@ public class DefaultLayoutParser extends AutoInstallsLayout { } } @Override @Override protected void parseContainerAndScreen(XmlResourceParser parser, long[] out) { protected void parseContainerAndScreen(XmlResourceParser parser, int[] out) { out[0] = LauncherSettings.Favorites.CONTAINER_DESKTOP; out[0] = LauncherSettings.Favorites.CONTAINER_DESKTOP; String strContainer = getAttributeValue(parser, ATTR_CONTAINER); String strContainer = getAttributeValue(parser, ATTR_CONTAINER); if (strContainer != null) { if (strContainer != null) { out[0] = Long.valueOf(strContainer); out[0] = Integer.parseInt(strContainer); } } out[1] = Long.parseLong(getAttributeValue(parser, ATTR_SCREEN)); out[1] = Integer.parseInt(getAttributeValue(parser, ATTR_SCREEN)); } } /** /** Loading @@ -91,7 +91,7 @@ public class DefaultLayoutParser extends AutoInstallsLayout { public class AppShortcutWithUriParser extends AppShortcutParser { public class AppShortcutWithUriParser extends AppShortcutParser { @Override @Override protected long invalidPackageOrClass(XmlResourceParser parser) { protected int invalidPackageOrClass(XmlResourceParser parser) { final String uri = getAttributeValue(parser, ATTR_URI); final String uri = getAttributeValue(parser, ATTR_URI); if (TextUtils.isEmpty(uri)) { if (TextUtils.isEmpty(uri)) { Log.e(TAG, "Skipping invalid <favorite> with no component or uri"); Log.e(TAG, "Skipping invalid <favorite> with no component or uri"); Loading Loading @@ -205,11 +205,11 @@ public class DefaultLayoutParser extends AutoInstallsLayout { private final AppShortcutWithUriParser mChildParser = new AppShortcutWithUriParser(); private final AppShortcutWithUriParser mChildParser = new AppShortcutWithUriParser(); @Override @Override public long parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, public int parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, IOException { IOException { final int groupDepth = parser.getDepth(); final int groupDepth = parser.getDepth(); int type; int type; long addedId = -1; int addedId = -1; while ((type = parser.next()) != XmlPullParser.END_TAG || while ((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > groupDepth) { parser.getDepth() > groupDepth) { if (type != XmlPullParser.START_TAG || addedId > -1) { if (type != XmlPullParser.START_TAG || addedId > -1) { Loading @@ -233,7 +233,7 @@ public class DefaultLayoutParser extends AutoInstallsLayout { @Thunk class PartnerFolderParser implements TagParser { @Thunk class PartnerFolderParser implements TagParser { @Override @Override public long parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, public int parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, IOException { IOException { // Folder contents come from an external XML resource // Folder contents come from an external XML resource final Partner partner = Partner.get(mPackageManager); final Partner partner = Partner.get(mPackageManager); Loading @@ -259,7 +259,7 @@ public class DefaultLayoutParser extends AutoInstallsLayout { @Thunk class MyFolderParser extends FolderParser { @Thunk class MyFolderParser extends FolderParser { @Override @Override public long parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, public int parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, IOException { IOException { final int resId = getAttributeResourceValue(parser, ATTR_FOLDER_ITEMS, 0); final int resId = getAttributeResourceValue(parser, ATTR_FOLDER_ITEMS, 0); if (resId != 0) { if (resId != 0) { Loading @@ -277,7 +277,7 @@ public class DefaultLayoutParser extends AutoInstallsLayout { protected class AppWidgetParser extends PendingWidgetParser { protected class AppWidgetParser extends PendingWidgetParser { @Override @Override protected long verifyAndInsert(ComponentName cn, Bundle extras) { protected int verifyAndInsert(ComponentName cn, Bundle extras) { try { try { mPackageManager.getReceiverInfo(cn, 0); mPackageManager.getReceiverInfo(cn, 0); } catch (Exception e) { } catch (Exception e) { Loading @@ -293,7 +293,7 @@ public class DefaultLayoutParser extends AutoInstallsLayout { } } final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext); final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext); long insertedId = -1; int insertedId = -1; try { try { int appWidgetId = mAppWidgetHost.allocateAppWidgetId(); int appWidgetId = mAppWidgetHost.allocateAppWidgetId(); Loading
src/com/android/launcher3/ItemInfo.java +5 −5 Original line number Original line Diff line number Diff line Loading @@ -34,7 +34,7 @@ public class ItemInfo { /** /** * The id in the settings database for this item * The id in the settings database for this item */ */ public long id = NO_ID; public int id = NO_ID; /** /** * One of {@link LauncherSettings.Favorites#ITEM_TYPE_APPLICATION}, * One of {@link LauncherSettings.Favorites#ITEM_TYPE_APPLICATION}, Loading @@ -52,14 +52,14 @@ public class ItemInfo { * will be {@link #NO_ID} (since it is not stored in the settings DB). For user folders * 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. * it will be the id of the folder. */ */ public long container = NO_ID; public int container = NO_ID; /** /** * Indicates the screen in which the shortcut appears if the container types is * Indicates the screen in which the shortcut appears if the container types is * {@link LauncherSettings.Favorites#CONTAINER_DESKTOP}. (i.e., ignore if the container type is * {@link LauncherSettings.Favorites#CONTAINER_DESKTOP}. (i.e., ignore if the container type is * {@link LauncherSettings.Favorites#CONTAINER_HOTSEAT}) * {@link LauncherSettings.Favorites#CONTAINER_HOTSEAT}) */ */ public long screenId = -1; public int screenId = -1; /** /** * Indicates the X position of the associated cell. * Indicates the X position of the associated cell. Loading Loading @@ -158,8 +158,8 @@ public class ItemInfo { public void readFromValues(ContentValues values) { public void readFromValues(ContentValues values) { itemType = values.getAsInteger(LauncherSettings.Favorites.ITEM_TYPE); itemType = values.getAsInteger(LauncherSettings.Favorites.ITEM_TYPE); container = values.getAsLong(LauncherSettings.Favorites.CONTAINER); container = values.getAsInteger(LauncherSettings.Favorites.CONTAINER); screenId = values.getAsLong(LauncherSettings.Favorites.SCREEN); screenId = values.getAsInteger(LauncherSettings.Favorites.SCREEN); cellX = values.getAsInteger(LauncherSettings.Favorites.CELLX); cellX = values.getAsInteger(LauncherSettings.Favorites.CELLX); cellY = values.getAsInteger(LauncherSettings.Favorites.CELLY); cellY = values.getAsInteger(LauncherSettings.Favorites.CELLY); spanX = values.getAsInteger(LauncherSettings.Favorites.SPANX); spanX = values.getAsInteger(LauncherSettings.Favorites.SPANX); Loading
src/com/android/launcher3/Launcher.java +16 −15 Original line number Original line Diff line number Diff line Loading @@ -108,6 +108,7 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; import com.android.launcher3.util.ActivityResultInfo; import com.android.launcher3.util.ActivityResultInfo; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.MultiHashMap; import com.android.launcher3.util.MultiHashMap; import com.android.launcher3.util.MultiValueAlpha; import com.android.launcher3.util.MultiValueAlpha; Loading Loading @@ -490,9 +491,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, * Returns whether we should delay spring loaded mode -- for shortcuts and widgets that have * Returns whether we should delay spring loaded mode -- for shortcuts and widgets that have * a configuration step, this allows the proper animations to run after other transitions. * a configuration step, this allows the proper animations to run after other transitions. */ */ private long completeAdd( private int completeAdd( int requestCode, Intent intent, int appWidgetId, PendingRequestArgs info) { int requestCode, Intent intent, int appWidgetId, PendingRequestArgs info) { long screenId = info.screenId; int screenId = info.screenId; if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) { if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) { // When the screen id represents an actual screen (as opposed to a rank) we make sure // When the screen id represents an actual screen (as opposed to a rank) we make sure // that the drop page actually exists. // that the drop page actually exists. Loading Loading @@ -694,7 +695,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, * @param screenId the screen id to check * @param screenId the screen id to check * @return the new screen, or screenId if it exists * @return the new screen, or screenId if it exists */ */ private long ensurePendingDropLayoutExists(long screenId) { private int ensurePendingDropLayoutExists(int screenId) { CellLayout dropLayout = mWorkspace.getScreenWithId(screenId); CellLayout dropLayout = mWorkspace.getScreenWithId(screenId); if (dropLayout == null) { if (dropLayout == null) { // it's possible that the add screen was removed because it was // it's possible that the add screen was removed because it was Loading Loading @@ -974,7 +975,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, * * * @param data The intent describing the shortcut. * @param data The intent describing the shortcut. */ */ private void completeAddShortcut(Intent data, long container, long screenId, int cellX, private void completeAddShortcut(Intent data, int container, int screenId, int cellX, int cellY, PendingRequestArgs args) { int cellY, PendingRequestArgs args) { if (args.getRequestCode() != REQUEST_CREATE_SHORTCUT if (args.getRequestCode() != REQUEST_CREATE_SHORTCUT || args.getPendingIntent().getComponent() == null) { || args.getPendingIntent().getComponent() == null) { Loading Loading @@ -1050,7 +1051,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, } } } } public FolderIcon findFolderIcon(final long folderIconId) { public FolderIcon findFolderIcon(final int folderIconId) { return (FolderIcon) mWorkspace.getHomescreenIconByItemId(folderIconId); return (FolderIcon) mWorkspace.getHomescreenIconByItemId(folderIconId); } } Loading Loading @@ -1413,7 +1414,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, } } } } public void addPendingItem(PendingAddItemInfo info, long container, long screenId, public void addPendingItem(PendingAddItemInfo info, int container, int screenId, int[] cell, int spanX, int spanY) { int[] cell, int spanX, int spanY) { info.container = container; info.container = container; info.screenId = screenId; info.screenId = screenId; Loading Loading @@ -1489,7 +1490,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, } } } } FolderIcon addFolder(CellLayout layout, long container, final long screenId, int cellX, FolderIcon addFolder(CellLayout layout, int container, final int screenId, int cellX, int cellY) { int cellY) { final FolderInfo folderInfo = new FolderInfo(); final FolderInfo folderInfo = new FolderInfo(); folderInfo.title = getText(R.string.folder_name); folderInfo.title = getText(R.string.folder_name); Loading Loading @@ -1650,7 +1651,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, /** /** * Returns the CellLayout of the specified container at the specified screen. * Returns the CellLayout of the specified container at the specified screen. */ */ public CellLayout getCellLayout(long container, long screenId) { public CellLayout getCellLayout(int container, int screenId) { if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { if (mHotseat != null) { if (mHotseat != null) { return mHotseat.getLayout(); return mHotseat.getLayout(); Loading Loading @@ -1750,11 +1751,11 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, } } @Override @Override public void bindScreens(ArrayList<Long> orderedScreenIds) { public void bindScreens(IntArray orderedScreenIds) { // Make sure the first screen is always at the start. // Make sure the first screen is always at the start. if (FeatureFlags.getInstance(this).isQsbOnFirstScreenEnabled() && if (FeatureFlags.getInstance(this).isQsbOnFirstScreenEnabled() && orderedScreenIds.indexOf(Workspace.FIRST_SCREEN_ID) != 0) { orderedScreenIds.indexOf(Workspace.FIRST_SCREEN_ID) != 0) { orderedScreenIds.remove(Workspace.FIRST_SCREEN_ID); orderedScreenIds.removeValue(Workspace.FIRST_SCREEN_ID); orderedScreenIds.add(0, Workspace.FIRST_SCREEN_ID); orderedScreenIds.add(0, Workspace.FIRST_SCREEN_ID); LauncherModel.updateWorkspaceScreenOrder(this, orderedScreenIds); LauncherModel.updateWorkspaceScreenOrder(this, orderedScreenIds); } else if (!FeatureFlags.getInstance(this).isQsbOnFirstScreenEnabled() } else if (!FeatureFlags.getInstance(this).isQsbOnFirstScreenEnabled() Loading @@ -1770,10 +1771,10 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, mWorkspace.unlockWallpaperFromDefaultPageOnNextLayout(); mWorkspace.unlockWallpaperFromDefaultPageOnNextLayout(); } } private void bindAddScreens(ArrayList<Long> orderedScreenIds) { private void bindAddScreens(IntArray orderedScreenIds) { int count = orderedScreenIds.size(); int count = orderedScreenIds.size(); for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) { long screenId = orderedScreenIds.get(i); int screenId = orderedScreenIds.get(i); if (!FeatureFlags.getInstance(this).isQsbOnFirstScreenEnabled() if (!FeatureFlags.getInstance(this).isQsbOnFirstScreenEnabled() || screenId != Workspace.FIRST_SCREEN_ID) { || screenId != Workspace.FIRST_SCREEN_ID) { // No need to bind the first screen, as its always bound. // No need to bind the first screen, as its always bound. Loading @@ -1794,7 +1795,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, } } @Override @Override public void bindAppsAdded(ArrayList<Long> newScreens, ArrayList<ItemInfo> addNotAnimated, public void bindAppsAdded(IntArray newScreens, ArrayList<ItemInfo> addNotAnimated, ArrayList<ItemInfo> addAnimated) { ArrayList<ItemInfo> addAnimated) { // Add the new screens // Add the new screens if (newScreens != null) { if (newScreens != null) { Loading Loading @@ -1825,7 +1826,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, final Collection<Animator> bounceAnims = new ArrayList<>(); final Collection<Animator> bounceAnims = new ArrayList<>(); final boolean animateIcons = forceAnimateIcons && canRunNewAppsAnimation(); final boolean animateIcons = forceAnimateIcons && canRunNewAppsAnimation(); Workspace workspace = mWorkspace; Workspace workspace = mWorkspace; long newItemsScreenId = -1; int newItemsScreenId = -1; int end = items.size(); int end = items.size(); for (int i = 0; i < end; i++) { for (int i = 0; i < end; i++) { final ItemInfo item = items.get(i); final ItemInfo item = items.get(i); Loading Loading @@ -1898,7 +1899,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, AnimatorSet anim = new AnimatorSet(); AnimatorSet anim = new AnimatorSet(); anim.playTogether(bounceAnims); anim.playTogether(bounceAnims); long currentScreenId = mWorkspace.getScreenIdForPageIndex(mWorkspace.getNextPage()); int currentScreenId = mWorkspace.getScreenIdForPageIndex(mWorkspace.getNextPage()); final int newScreenIndex = mWorkspace.getPageIndexForScreenId(newItemsScreenId); final int newScreenIndex = mWorkspace.getPageIndexForScreenId(newItemsScreenId); final Runnable startBounceAnimRunnable = anim::start; final Runnable startBounceAnimRunnable = anim::start; Loading