summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoe Onorato <joeo@android.com>2009-08-31 14:34:43 -0700
committerJoe Onorato <joeo@android.com>2009-08-31 14:34:43 -0700
commitc567acb6c32cdc3a9cf40b30c6716ab8bc5dd614 (patch)
treebbda44727cc0e0304573dd0f5af441434692874f /src
parent0d1c563125290a58a75f6476887942a62a79d136 (diff)
downloadandroid_packages_apps_Trebuchet-c567acb6c32cdc3a9cf40b30c6716ab8bc5dd614.tar.gz
android_packages_apps_Trebuchet-c567acb6c32cdc3a9cf40b30c6716ab8bc5dd614.tar.bz2
android_packages_apps_Trebuchet-c567acb6c32cdc3a9cf40b30c6716ab8bc5dd614.zip
Add the all apps button.
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/AllAppsView.java176
-rw-r--r--src/com/android/launcher2/Launcher.java4
-rw-r--r--src/com/android/launcher2/Utilities.java1
3 files changed, 128 insertions, 53 deletions
diff --git a/src/com/android/launcher2/AllAppsView.java b/src/com/android/launcher2/AllAppsView.java
index cd66b4ffd..d8ac50b48 100644
--- a/src/com/android/launcher2/AllAppsView.java
+++ b/src/com/android/launcher2/AllAppsView.java
@@ -66,11 +66,25 @@ public class AllAppsView extends RSSurfaceView {
private ArrayList<ApplicationInfo> mAllAppsList;
private ViewConfiguration mConfig;
+ private int mPageCount;
private VelocityTracker mVelocity;
private int mLastScrollX;
private int mLastMotionX;
private ApplicationsAdapter mAdapter;
-
+ private TouchHandler mTouchHandler;
+ private int mScrollHandleTop;
+
+ class Defines {
+ public static final int ALLOC_PARAMS = 0;
+ public static final int ALLOC_STATE = 1;
+ public static final int ALLOC_SCRATCH = 2;
+ public static final int ALLOC_ICON_IDS = 3;
+ public static final int ALLOC_LABEL_IDS = 4;
+
+ public static final int COLUMNS_PER_PAGE = 4;
+ public static final int ROWS_PER_PAGE = 4;
+
+ }
public AllAppsView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -103,6 +117,10 @@ public class AllAppsView extends RSSurfaceView {
if (mAllAppsList != null) {
mRollo.setApps(mAllAppsList);
}
+
+ Resources res = getContext().getResources();
+ int barHeight = (int)res.getDimension(R.dimen.button_bar_height);
+ mScrollHandleTop = h - barHeight;
}
@Override
@@ -115,44 +133,89 @@ public class AllAppsView extends RSSurfaceView {
@Override
public boolean onTouchEvent(MotionEvent ev)
{
- int x = (int)ev.getX();
- int deltaX;
- switch (ev.getAction()) {
- case MotionEvent.ACTION_DOWN:
- mLastMotionX = x;
- mRollo.mState.read();
- mRollo.mState.scrollX = mLastScrollX = mRollo.mState.currentScrollX;
- mRollo.mState.flingVelocityX = 0;
- mRollo.mState.adjustedDeceleration = 0;
- mRollo.mState.save();
- mVelocity = VelocityTracker.obtain();
- mVelocity.addMovement(ev);
- break;
- case MotionEvent.ACTION_MOVE:
- case MotionEvent.ACTION_OUTSIDE:
- deltaX = x - mLastMotionX;
- mVelocity.addMovement(ev);
- mRollo.mState.currentScrollX = mLastScrollX;
- mLastScrollX += deltaX;
- mRollo.mState.scrollX = mLastScrollX;
- mRollo.mState.save();
- mLastMotionX = x;
- break;
- case MotionEvent.ACTION_UP:
- case MotionEvent.ACTION_CANCEL:
- mVelocity.computeCurrentVelocity(1000 /* px/sec */,
- mConfig.getScaledMaximumFlingVelocity());
- mRollo.mState.flingTimeMs = (int)SystemClock.uptimeMillis(); // TODO: use long
- mRollo.mState.flingVelocityX = (int)mVelocity.getXVelocity();
- mRollo.mState.save();
- mLastMotionX = -10000;
- mVelocity.recycle();
- mVelocity = null;
- break;
+ mTouchHandler = mFlingHandler;
+ /*
+ int action = ev.getAction();
+ if (action == MotionEvent.ACTION_DOWN) {
+ if (ev.getY() > mScrollHandleTop) {
+ mTouchHandler = mScrollHandler;
+ } else {
+ mTouchHandler = mFlingHandler;
+ }
}
- return true;
+ */
+ return mTouchHandler.onTouchEvent(ev);
}
+ private abstract class TouchHandler {
+ abstract boolean onTouchEvent(MotionEvent ev);
+ };
+
+ private TouchHandler mFlingHandler = new TouchHandler() {
+ @Override
+ public boolean onTouchEvent(MotionEvent ev)
+ {
+ int x = (int)ev.getX();
+ int deltaX;
+ switch (ev.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ mLastMotionX = x;
+ mRollo.mState.read();
+ mRollo.mState.scrollX = mLastScrollX = mRollo.mState.currentScrollX;
+ mRollo.mState.flingVelocityX = 0;
+ mRollo.mState.adjustedDeceleration = 0;
+ mRollo.mState.save();
+ mVelocity = VelocityTracker.obtain();
+ mVelocity.addMovement(ev);
+ break;
+ case MotionEvent.ACTION_MOVE:
+ case MotionEvent.ACTION_OUTSIDE:
+ deltaX = x - mLastMotionX;
+ mVelocity.addMovement(ev);
+ mRollo.mState.currentScrollX = mLastScrollX;
+ mLastScrollX += deltaX;
+ mRollo.mState.scrollX = mLastScrollX;
+ mRollo.mState.save();
+ mLastMotionX = x;
+ break;
+ case MotionEvent.ACTION_UP:
+ case MotionEvent.ACTION_CANCEL:
+ mVelocity.computeCurrentVelocity(1000 /* px/sec */,
+ mConfig.getScaledMaximumFlingVelocity());
+ mRollo.mState.flingTimeMs = (int)SystemClock.uptimeMillis(); // TODO: use long
+ mRollo.mState.flingVelocityX = (int)mVelocity.getXVelocity();
+ mRollo.mState.save();
+ mLastMotionX = -10000;
+ mVelocity.recycle();
+ mVelocity = null;
+ break;
+ }
+ return true;
+ }
+ };
+
+ /*
+ private TouchHandler mScrollHandler = new TouchHandler() {
+ @Override
+ public boolean onTouchEvent(MotionEvent ev)
+ {
+ int x = (int)ev.getX();
+ int w = getWidth();
+
+ float percent = x / (float)w;
+
+ mRollo.mState.read();
+
+ mRollo.mState.scrollX = mLastScrollX = -(int)(mPageCount * w * percent);
+ mRollo.mState.flingVelocityX = 0;
+ mRollo.mState.adjustedDeceleration = 0;
+ mRollo.mState.save();
+
+ return true;
+ }
+ };
+ */
+
@Override
public boolean onTrackballEvent(MotionEvent ev)
{
@@ -177,6 +240,16 @@ public class AllAppsView extends RSSurfaceView {
if (mRollo != null) {
mRollo.setApps(list);
}
+ mPageCount = countPages(list.size());
+ }
+
+ private static int countPages(int iconCount) {
+ int iconsPerPage = Defines.COLUMNS_PER_PAGE * Defines.ROWS_PER_PAGE;
+ int pages = iconCount / iconsPerPage;
+ if (pages*iconsPerPage != iconCount) {
+ pages++;
+ }
+ return pages;
}
public class RolloRS {
@@ -200,6 +273,8 @@ public class AllAppsView extends RSSurfaceView {
private ProgramVertex mPVOrtho;
private ProgramVertex.MatrixAllocation mPVOrthoAlloc;
+ private Allocation mScrollHandle;
+
private Allocation[] mIcons;
private int[] mAllocIconIDBuf;
private Allocation mAllocIconID;
@@ -214,14 +289,6 @@ public class AllAppsView extends RSSurfaceView {
Params mParams;
State mState;
- class Defines {
- public static final int ALLOC_PARAMS = 0;
- public static final int ALLOC_STATE = 1;
- public static final int ALLOC_SCRATCH = 2;
- public static final int ALLOC_ICON_IDS = 3;
- public static final int ALLOC_LABEL_IDS = 4;
- }
-
class Params extends IntAllocation {
Params(RenderScript rs) {
super(rs);
@@ -230,6 +297,9 @@ public class AllAppsView extends RSSurfaceView {
@AllocationIndex(1) public int bubbleHeight;
@AllocationIndex(2) public int bubbleBitmapWidth;
@AllocationIndex(3) public int bubbleBitmapHeight;
+ @AllocationIndex(4) public int scrollHandleId;
+ @AllocationIndex(5) public int scrollHandleTextureWidth;
+ @AllocationIndex(6) public int scrollHandleTextureHeight;
}
class State extends IntAllocation {
@@ -244,6 +314,7 @@ public class AllAppsView extends RSSurfaceView {
@AllocationIndex(5) public int currentScrollX;
@AllocationIndex(6) public int flingDuration;
@AllocationIndex(7) public int flingEndPos;
+ @AllocationIndex(8) public int scrollHandlePos;
}
public RolloRS() {
@@ -338,19 +409,21 @@ public class AllAppsView extends RSSurfaceView {
mParams.bubbleBitmapWidth = bubble.getBitmapWidth();
mParams.bubbleBitmapHeight = bubble.getBitmapHeight();
+ mScrollHandle = Allocation.createFromBitmapResource(mRS, mRes,
+ R.drawable.all_apps_button_pow2, Element.RGBA_8888, true);
+ mScrollHandle.uploadToTexture(0);
+ mParams.scrollHandleId = mScrollHandle.getID();
+ Log.d(TAG, "mParams.scrollHandleId=" + mParams.scrollHandleId);
+ mParams.scrollHandleTextureWidth = 128;
+ mParams.scrollHandleTextureHeight = 128;
+ mState.scrollHandlePos = 0;
+
mParams.save();
mState.save();
setApps(null);
}
- Allocation makeTextBitmap(Utilities.BubbleText bubble, String label) {
- Bitmap b = bubble.createTextBitmap(label);
- Allocation a = Allocation.createFromBitmap(mRS, b, Element.RGBA_8888, true);
- b.recycle();
- return a;
- }
-
private void initRs() {
ScriptC.Builder sb = new ScriptC.Builder(mRS);
sb.setScript(mRes, R.raw.rollo);
@@ -415,4 +488,3 @@ public class AllAppsView extends RSSurfaceView {
}
-
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 40f4b3995..e1b213e90 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -528,8 +528,10 @@ public final class Launcher extends Activity
mHandleView = (HandleView) findViewById(R.id.all_apps_button);
mHandleView.setLauncher(this);
mHandleView.setOnClickListener(this);
+ /* TODO
TransitionDrawable handleIcon = (TransitionDrawable) mHandleView.getDrawable();
- handleIcon.setCrossFadeEnabled(true);
+ handleIocon.setCrossFadeEnabled(true);
+ */
workspace.setOnLongClickListener(this);
workspace.setDragController(dragController);
diff --git a/src/com/android/launcher2/Utilities.java b/src/com/android/launcher2/Utilities.java
index 0c5dbbdf0..ca12a4d29 100644
--- a/src/com/android/launcher2/Utilities.java
+++ b/src/com/android/launcher2/Utilities.java
@@ -274,6 +274,7 @@ final class Utilities {
textPaint.setTextSize(13*scale);
textPaint.setColor(0xffffffff);
textPaint.setAntiAlias(true);
+ //textPaint.setShadowLayer(8, 0, 0, 0xff000000);
float ascent = -textPaint.ascent();
float descent = textPaint.descent();