Loading src/com/android/launcher3/Launcher.java +39 −2 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; Loading Loading @@ -113,6 +112,7 @@ import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; /** * Default launcher application. Loading Loading @@ -183,6 +183,8 @@ public class Launcher extends Activity private static final String RUNTIME_STATE_PENDING_ADD_WIDGET_INFO = "launcher.add_widget_info"; // Type: parcelable private static final String RUNTIME_STATE_PENDING_ADD_WIDGET_ID = "launcher.add_widget_id"; // Type: int[] private static final String RUNTIME_STATE_VIEW_IDS = "launcher.view_ids"; private static final String TOOLBAR_ICON_METADATA_NAME = "com.android.launcher.toolbar_icon"; private static final String TOOLBAR_SEARCH_ICON_METADATA_NAME = Loading @@ -207,6 +209,9 @@ public class Launcher extends Activity private static final Object sLock = new Object(); private static int sScreen = DEFAULT_SCREEN; private HashMap<Integer, Integer> mItemIdToViewId = new HashMap<Integer, Integer>(); private static final AtomicInteger sNextGeneratedId = new AtomicInteger(1); // How long to wait before the new-shortcut animation automatically pans the workspace private static int NEW_APPS_PAGE_MOVE_DELAY = 500; private static int NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS = 5; Loading Loading @@ -670,6 +675,34 @@ public class Launcher extends Activity } } /** * Copied from View -- the View version of the method isn't called * anywhere else in our process and only exists for API level 17+, * so it's ok to keep our own version with no API requirement. */ public static int generateViewId() { for (;;) { final int result = sNextGeneratedId.get(); // aapt-generated IDs have the high byte nonzero; clamp to the range under that. int newValue = result + 1; if (newValue > 0x00FFFFFF) newValue = 1; // Roll over to 1, not 0. if (sNextGeneratedId.compareAndSet(result, newValue)) { return result; } } } public int getViewIdForItem(ItemInfo info) { // This cast is safe given the > 2B range for int. int itemId = (int) info.id; if (mItemIdToViewId.containsKey(itemId)) { return mItemIdToViewId.get(itemId); } int viewId = generateViewId(); mItemIdToViewId.put(itemId, viewId); return viewId; } /** * 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. Loading Loading @@ -1108,6 +1141,7 @@ public class Launcher extends Activity * * @param savedState The previous state. */ @SuppressWarnings("unchecked") private void restoreState(Bundle savedState) { if (savedState == null) { return; Loading Loading @@ -1160,6 +1194,8 @@ public class Launcher extends Activity int currentIndex = savedState.getInt("apps_customize_currentIndex"); mAppsCustomizeContent.restorePageForIndex(currentIndex); } mItemIdToViewId = (HashMap<Integer, Integer>) savedState.getSerializable(RUNTIME_STATE_VIEW_IDS); } /** Loading Loading @@ -1801,6 +1837,7 @@ public class Launcher extends Activity int currentIndex = mAppsCustomizeContent.getSaveInstanceStateIndex(); outState.putInt("apps_customize_currentIndex", currentIndex); } outState.putSerializable(RUNTIME_STATE_VIEW_IDS, mItemIdToViewId); } @Override Loading src/com/android/launcher3/Workspace.java +3 −3 Original line number Diff line number Diff line Loading @@ -949,7 +949,9 @@ public class Workspace extends SmoothPagedView } // Get the canonical child id to uniquely represent this view in this screen int childId = LauncherModel.getCellLayoutChildId(container, screenId, x, y, spanX, spanY); ItemInfo info = (ItemInfo) child.getTag(); int childId = mLauncher.getViewIdForItem(info); boolean markCellsAsOccupied = !(child instanceof Folder); if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) { // TODO: This branch occurs when the workspace is adding views Loading Loading @@ -2890,8 +2892,6 @@ public class Workspace extends SmoothPagedView lp.cellHSpan = item.spanX; lp.cellVSpan = item.spanY; lp.isLockedToGrid = true; cell.setId(LauncherModel.getCellLayoutChildId(container, mDragInfo.screenId, mTargetCell[0], mTargetCell[1], mDragInfo.spanX, mDragInfo.spanY)); if (container != LauncherSettings.Favorites.CONTAINER_HOTSEAT && cell instanceof LauncherAppWidgetHostView) { Loading Loading
src/com/android/launcher3/Launcher.java +39 −2 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; Loading Loading @@ -113,6 +112,7 @@ import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; /** * Default launcher application. Loading Loading @@ -183,6 +183,8 @@ public class Launcher extends Activity private static final String RUNTIME_STATE_PENDING_ADD_WIDGET_INFO = "launcher.add_widget_info"; // Type: parcelable private static final String RUNTIME_STATE_PENDING_ADD_WIDGET_ID = "launcher.add_widget_id"; // Type: int[] private static final String RUNTIME_STATE_VIEW_IDS = "launcher.view_ids"; private static final String TOOLBAR_ICON_METADATA_NAME = "com.android.launcher.toolbar_icon"; private static final String TOOLBAR_SEARCH_ICON_METADATA_NAME = Loading @@ -207,6 +209,9 @@ public class Launcher extends Activity private static final Object sLock = new Object(); private static int sScreen = DEFAULT_SCREEN; private HashMap<Integer, Integer> mItemIdToViewId = new HashMap<Integer, Integer>(); private static final AtomicInteger sNextGeneratedId = new AtomicInteger(1); // How long to wait before the new-shortcut animation automatically pans the workspace private static int NEW_APPS_PAGE_MOVE_DELAY = 500; private static int NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS = 5; Loading Loading @@ -670,6 +675,34 @@ public class Launcher extends Activity } } /** * Copied from View -- the View version of the method isn't called * anywhere else in our process and only exists for API level 17+, * so it's ok to keep our own version with no API requirement. */ public static int generateViewId() { for (;;) { final int result = sNextGeneratedId.get(); // aapt-generated IDs have the high byte nonzero; clamp to the range under that. int newValue = result + 1; if (newValue > 0x00FFFFFF) newValue = 1; // Roll over to 1, not 0. if (sNextGeneratedId.compareAndSet(result, newValue)) { return result; } } } public int getViewIdForItem(ItemInfo info) { // This cast is safe given the > 2B range for int. int itemId = (int) info.id; if (mItemIdToViewId.containsKey(itemId)) { return mItemIdToViewId.get(itemId); } int viewId = generateViewId(); mItemIdToViewId.put(itemId, viewId); return viewId; } /** * 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. Loading Loading @@ -1108,6 +1141,7 @@ public class Launcher extends Activity * * @param savedState The previous state. */ @SuppressWarnings("unchecked") private void restoreState(Bundle savedState) { if (savedState == null) { return; Loading Loading @@ -1160,6 +1194,8 @@ public class Launcher extends Activity int currentIndex = savedState.getInt("apps_customize_currentIndex"); mAppsCustomizeContent.restorePageForIndex(currentIndex); } mItemIdToViewId = (HashMap<Integer, Integer>) savedState.getSerializable(RUNTIME_STATE_VIEW_IDS); } /** Loading Loading @@ -1801,6 +1837,7 @@ public class Launcher extends Activity int currentIndex = mAppsCustomizeContent.getSaveInstanceStateIndex(); outState.putInt("apps_customize_currentIndex", currentIndex); } outState.putSerializable(RUNTIME_STATE_VIEW_IDS, mItemIdToViewId); } @Override Loading
src/com/android/launcher3/Workspace.java +3 −3 Original line number Diff line number Diff line Loading @@ -949,7 +949,9 @@ public class Workspace extends SmoothPagedView } // Get the canonical child id to uniquely represent this view in this screen int childId = LauncherModel.getCellLayoutChildId(container, screenId, x, y, spanX, spanY); ItemInfo info = (ItemInfo) child.getTag(); int childId = mLauncher.getViewIdForItem(info); boolean markCellsAsOccupied = !(child instanceof Folder); if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) { // TODO: This branch occurs when the workspace is adding views Loading Loading @@ -2890,8 +2892,6 @@ public class Workspace extends SmoothPagedView lp.cellHSpan = item.spanX; lp.cellVSpan = item.spanY; lp.isLockedToGrid = true; cell.setId(LauncherModel.getCellLayoutChildId(container, mDragInfo.screenId, mTargetCell[0], mTargetCell[1], mDragInfo.spanX, mDragInfo.spanY)); if (container != LauncherSettings.Favorites.CONTAINER_HOTSEAT && cell instanceof LauncherAppWidgetHostView) { Loading