diff --git a/src/com/android/launcher2/AllAppsView.java b/src/com/android/launcher2/AllAppsView.java index 4cd017b0bb..732bce33c9 100644 --- a/src/com/android/launcher2/AllAppsView.java +++ b/src/com/android/launcher2/AllAppsView.java @@ -20,6 +20,8 @@ import java.io.Writer; import java.util.ArrayList; import java.util.concurrent.Semaphore; import java.lang.Float; +import java.util.Collections; +import java.util.Comparator; import android.renderscript.RSSurfaceView; import android.renderscript.RenderScript; @@ -307,7 +309,7 @@ public class AllAppsView extends RSSurfaceView return true; } int index = mRollo.mState.selectedIconIndex; - Log.d(TAG, "long click! velocity=" + mRollo.mMessageProc.mVelocity + " index=" + index); + if (mRollo.checkClickOK() && index >= 0 && index < mAllAppsList.size()) { ApplicationInfo app = mAllAppsList.get(index); @@ -381,14 +383,77 @@ public class AllAppsView extends RSSurfaceView mRollo.setApps(list); } mPageCount = countPages(list.size()); - Log.d(TAG, "setApps mRollo=" + mRollo + " list=" + list); mLocks &= ~LOCK_ICONS_PENDING; } - private void invokeIcon(int index) { - Log.d(TAG, "launch it!!!! index=" + index); + public void addApps(ArrayList list) { + final int N = list.size(); + if (mRollo != null) { + mRollo.reallocAppsList(mRollo.mState.iconCount + N); + } + + for (int i=0; i list) { + final int N = list.size(); + for (int i=0; i= 0) { + mAllAppsList.remove(index); + if (mRollo != null) { + mRollo.removeApp(index); + mRollo.mState.iconCount--; + } + } else { + Log.e(TAG, "couldn't find a match for item \"" + item + "\""); + // Try to recover. This should keep us from crashing for now. + } + } + + if (mRollo != null) { + mRollo.saveAppsList(); + } + } + + public void updateApps(String packageName, ArrayList list) { + // Just remove and add, because they may need to be re-sorted. + removeApps(list); + addApps(list); + } + + private Comparator mAppNameComp = new Comparator() { + public int compare(ApplicationInfo a, ApplicationInfo b) { + int result = a.title.toString().compareTo(b.toString()); + if (result != 0) { + return result; + } + return a.intent.getComponent().compareTo(b.intent.getComponent()); + } + }; + + private Comparator mAppIntentComp = new Comparator() { + public int compare(ApplicationInfo a, ApplicationInfo b) { + return a.intent.getComponent().compareTo(b.intent.getComponent()); + } + }; + private static int countPages(int iconCount) { int iconsPerPage = Defines.COLUMNS_PER_PAGE * Defines.ROWS_PER_PAGE; int pages = iconCount / iconsPerPage; @@ -425,11 +490,11 @@ public class AllAppsView extends RSSurfaceView private Allocation[] mIcons; private int[] mIconIds; - private Allocation mAllocIconID; + private Allocation mAllocIconIds; private Allocation[] mLabels; private int[] mLabelIds; - private Allocation mAllocLabelID; + private Allocation mAllocLabelIds; private Allocation mSelectedIcon; private int[] mTouchYBorders; @@ -678,7 +743,6 @@ public class AllAppsView extends RSSurfaceView Defines.ICON_TEXTURE_HEIGHT_PX, Bitmap.Config.ARGB_8888); mSelectionCanvas = new Canvas(mSelectionBitmap); - Log.d(TAG, "initData calling mRollo.setApps"); setApps(null); } @@ -698,8 +762,8 @@ public class AllAppsView extends RSSurfaceView mScript.bindAllocation(mParams.mAlloc, Defines.ALLOC_PARAMS); mScript.bindAllocation(mState.mAlloc, Defines.ALLOC_STATE); - mScript.bindAllocation(mAllocIconID, Defines.ALLOC_ICON_IDS); - mScript.bindAllocation(mAllocLabelID, Defines.ALLOC_LABEL_IDS); + mScript.bindAllocation(mAllocIconIds, Defines.ALLOC_ICON_IDS); + mScript.bindAllocation(mAllocLabelIds, Defines.ALLOC_LABEL_IDS); mScript.bindAllocation(mAllocTouchXBorders, Defines.ALLOC_X_BORDERS); mScript.bindAllocation(mAllocTouchYBorders, Defines.ALLOC_Y_BORDERS); @@ -711,48 +775,123 @@ public class AllAppsView extends RSSurfaceView private void setApps(ArrayList list) { final int count = list != null ? list.size() : 0; int allocCount = count; - if(allocCount < 1) { + if (allocCount < 1) { allocCount = 1; } mIcons = new Allocation[count]; mIconIds = new int[allocCount]; - mAllocIconID = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount); + mAllocIconIds = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount); mLabels = new Allocation[count]; mLabelIds = new int[allocCount]; - mAllocLabelID = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount); + mAllocLabelIds = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount); Element ie8888 = Element.RGBA_8888(mRS); Utilities.BubbleText bubble = new Utilities.BubbleText(getContext()); for (int i=0; i