summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2009-12-07 17:48:02 -0800
committerRomain Guy <romainguy@android.com>2009-12-07 18:01:15 -0800
commitf8e6a80acd4e5558fdf7e0559f1043a2b183a8fa (patch)
tree76dda2c024f4138ccccb8a5805c5772e2e17812c /src
parentb8139ab650b7b3661401bc0a175a148ca34eb4fa (diff)
downloadandroid_packages_apps_Trebuchet-f8e6a80acd4e5558fdf7e0559f1043a2b183a8fa.tar.gz
android_packages_apps_Trebuchet-f8e6a80acd4e5558fdf7e0559f1043a2b183a8fa.tar.bz2
android_packages_apps_Trebuchet-f8e6a80acd4e5558fdf7e0559f1043a2b183a8fa.zip
Let the user click the dots during a scroll on Home.
This allows faster scroll across Home. Also remove dead code.
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/Launcher.java62
-rw-r--r--src/com/android/launcher2/Workspace.java152
2 files changed, 30 insertions, 184 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index acfccb17a..aa6b7cedf 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -19,7 +19,6 @@ package com.android.launcher2;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
-import android.app.ISearchManager;
import android.app.SearchManager;
import android.app.StatusBarManager;
import android.app.WallpaperManager;
@@ -46,8 +45,6 @@ import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Parcelable;
-import android.os.RemoteException;
-import android.os.ServiceManager;
import android.os.SystemProperties;
import android.provider.LiveFolders;
import android.text.Selection;
@@ -552,6 +549,7 @@ public final class Launcher extends Activity
mHandleView = (HandleView) findViewById(R.id.all_apps_button);
mHandleView.setLauncher(this);
mHandleView.setOnClickListener(this);
+ mHandleView.setOnLongClickListener(this);
mPreviousView = (ImageView) dragLayer.findViewById(R.id.previous_screen);
mNextView = (ImageView) dragLayer.findViewById(R.id.next_screen);
@@ -1482,14 +1480,21 @@ public final class Launcher extends Activity
if (!isAllAppsVisible()) {
mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
- showPreviousPreview(v);
+ showPreviews(v);
}
return true;
case R.id.next_screen:
if (!isAllAppsVisible()) {
mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
- showNextPreview(v);
+ showPreviews(v);
+ }
+ return true;
+ case R.id.all_apps_button:
+ if (!isAllAppsVisible()) {
+ mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
+ HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
+ showPreviews(v);
}
return true;
}
@@ -1552,29 +1557,19 @@ public final class Launcher extends Activity
v.setTag(null);
}
- private void showPreviousPreview(View anchor) {
- int current = mWorkspace.getCurrentScreen();
- if (current <= 0) return;
-
+ private void showPreviews(View anchor) {
showPreviews(anchor, 0, mWorkspace.getChildCount());
}
- private void showNextPreview(View anchor) {
- int current = mWorkspace.getCurrentScreen();
- if (current >= mWorkspace.getChildCount() - 1) return;
-
- showPreviews(anchor, 0, mWorkspace.getChildCount());
- }
-
private void showPreviews(final View anchor, int start, int end) {
- Resources resources = getResources();
+ final Resources resources = getResources();
+ final Workspace workspace = mWorkspace;
- Workspace workspace = mWorkspace;
CellLayout cell = ((CellLayout) workspace.getChildAt(start));
float max = workspace.getChildCount();
- Rect r = new Rect();
+ final Rect r = new Rect();
resources.getDrawable(R.drawable.preview_background).getPadding(r);
int extraW = (int) ((r.left + r.right) * max);
int extraH = r.top + r.bottom;
@@ -1605,10 +1600,10 @@ public final class Launcher extends Activity
ImageView image = new ImageView(this);
cell = (CellLayout) workspace.getChildAt(i);
- Bitmap bitmap = Bitmap.createBitmap((int) sWidth, (int) sHeight,
+ final Bitmap bitmap = Bitmap.createBitmap((int) sWidth, (int) sHeight,
Bitmap.Config.ARGB_8888);
-
- Canvas c = new Canvas(bitmap);
+
+ final Canvas c = new Canvas(bitmap);
c.scale(scale, scale);
c.translate(-cell.getLeftPadding(), -cell.getTopPadding());
cell.dispatchDraw(c);
@@ -1626,8 +1621,8 @@ public final class Launcher extends Activity
bitmaps.add(bitmap);
}
-
- PopupWindow p = new PopupWindow(this);
+
+ final PopupWindow p = new PopupWindow(this);
p.setContentView(preview);
p.setWidth((int) (sWidth * count + extraW));
p.setHeight((int) (sHeight + extraH));
@@ -1671,10 +1666,6 @@ public final class Launcher extends Activity
}
}
- View getDrawerHandle() {
- return mHandleView;
- }
-
Workspace getWorkspace() {
return mWorkspace;
}
@@ -1825,22 +1816,14 @@ public final class Launcher extends Activity
return mAllAppsGrid.isVisible();
}
- boolean isAllAppsOpaque() {
- return mAllAppsGrid.isOpaque();
- }
-
void showAllApps(boolean animated) {
mAllAppsGrid.zoom(1.0f, animated);
- //mWorkspace.hide();
-
- mWorkspace.startFading(false);
mAllAppsGrid.setFocusable(true);
mAllAppsGrid.requestFocus();
// TODO: fade these two too
mDeleteZone.setVisibility(View.GONE);
- //mHandleView.setVisibility(View.GONE);
}
/**
@@ -1879,13 +1862,6 @@ public final class Launcher extends Activity
mAllAppsGrid.zoom(0.0f, animated);
mAllAppsGrid.setFocusable(false);
mWorkspace.getChildAt(mWorkspace.getCurrentScreen()).requestFocus();
- mWorkspace.startFading(true);
-
- // TODO: fade these two too
- /*
- mDeleteZone.setVisibility(View.VISIBLE);
- mHandleView.setVisibility(View.VISIBLE);
- */
}
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index ac94ccae8..89d2ebdcf 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -23,7 +23,6 @@ import android.content.ComponentName;
import android.content.res.TypedArray;
import android.content.pm.PackageManager;
import android.graphics.Canvas;
-import android.graphics.RectF;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Parcelable;
@@ -103,16 +102,9 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
private int mTouchSlop;
private int mMaximumVelocity;
- final Rect mDrawerBounds = new Rect();
- final Rect mClipBounds = new Rect();
- int mDrawerContentHeight;
- int mDrawerContentWidth;
-
private Drawable mPreviousIndicator;
private Drawable mNextIndicator;
- private boolean mFading = true;
-
/**
* Used to inflate the Workspace from XML.
*
@@ -246,27 +238,6 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
}
/**
- * Returns how many screens there are.
- */
- int getScreenCount() {
- return getChildCount();
- }
-
- /**
- * Computes a bounding rectangle for a range of cells
- *
- * @param cellX X coordinate of upper left corner expressed as a cell position
- * @param cellY Y coordinate of upper left corner expressed as a cell position
- * @param cellHSpan Width in cells
- * @param cellVSpan Height in cells
- * @param rect Rectnagle into which to put the results
- */
- public void cellToRect(int cellX, int cellY, int cellHSpan, int cellVSpan, RectF rect) {
- ((CellLayout)getChildAt(mCurrentScreen)).cellToRect(cellX, cellY,
- cellHSpan, cellVSpan, rect);
- }
-
- /**
* Sets the current screen.
*
* @param currentScreen
@@ -385,56 +356,6 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
mVacantCache = null;
}
}
-
- /**
- * Returns the coordinate of a vacant cell for the current screen.
- */
- boolean getVacantCell(int[] vacant, int spanX, int spanY) {
- CellLayout group = (CellLayout) getChildAt(mCurrentScreen);
- if (group != null) {
- return group.getVacantCell(vacant, spanX, spanY);
- }
- return false;
- }
-
- /**
- * Adds the specified child in the current screen. The position and dimension of
- * the child are defined by x, y, spanX and spanY.
- *
- * @param child The child to add in one of the workspace's screens.
- * @param spanX The number of cells spanned horizontally by the child.
- * @param spanY The number of cells spanned vertically by the child.
- */
- void fitInCurrentScreen(View child, int spanX, int spanY) {
- fitInScreen(child, mCurrentScreen, spanX, spanY);
- }
-
- /**
- * Adds the specified child in the specified screen. The position and dimension of
- * the child are defined by x, y, spanX and spanY.
- *
- * @param child The child to add in one of the workspace's screens.
- * @param screen The screen in which to add the child.
- * @param spanX The number of cells spanned horizontally by the child.
- * @param spanY The number of cells spanned vertically by the child.
- */
- void fitInScreen(View child, int screen, int spanX, int spanY) {
- if (screen < 0 || screen >= getChildCount()) {
- throw new IllegalStateException("The screen must be >= 0 and < " + getChildCount());
- }
-
- final CellLayout group = (CellLayout) getChildAt(screen);
- boolean vacant = group.getVacantCell(mTempCell, spanX, spanY);
- if (vacant) {
- group.addView(child,
- new CellLayout.LayoutParams(mTempCell[0], mTempCell[1], spanX, spanY));
- child.setHapticFeedbackEnabled(false);
- child.setOnLongClickListener(mLongClickListener);
- if (child instanceof DropTarget) {
- mDragController.addDropTarget((DropTarget)child);
- }
- }
- }
/**
* Registers the specified listener on each screen contained in this workspace.
@@ -476,60 +397,17 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
}
}
- public void startFading(boolean dest) {
- mFading = dest;
- invalidate();
- }
-
@Override
protected void dispatchDraw(Canvas canvas) {
- /*
- final boolean allAppsOpaque = mLauncher.isAllAppsOpaque();
- if (mFading == allAppsOpaque) {
- invalidate();
- } else {
- mFading = !allAppsOpaque;
- }
- if (allAppsOpaque) {
- // If the launcher is up, draw black.
- canvas.drawARGB(0xff, 0, 0, 0);
- return;
- }
- */
-
boolean restore = false;
int restoreCount = 0;
- // For the fade. If view gets setAlpha(), use that instead.
- float scale = mScale;
- if (scale < 0.999f) {
- int sx = mScrollX;
-
- int alpha = (scale < 0.5f) ? (int)(255 * 2 * scale) : 255;
-
- restoreCount = canvas.saveLayerAlpha(sx, 0, sx+getWidth(), getHeight(), alpha,
- Canvas.HAS_ALPHA_LAYER_SAVE_FLAG | Canvas.CLIP_TO_LAYER_SAVE_FLAG);
- restore = true;
-
- if (scale < 0.999f) {
- int w = getWidth();
- w += 2 * mCurrentScreen * w;
- int dx = w/2;
- int h = getHeight();
- int dy = (h/2) - (h/4);
- canvas.translate(dx, dy);
- canvas.scale(scale, scale);
- canvas.translate(-dx, -dy);
- }
- }
-
// ViewGroup.dispatchDraw() supports many features we don't need:
// clip to padding, layout animation, animation listener, disappearing
// children, etc. The following implementation attempts to fast-track
// the drawing dispatch by drawing only what we know needs to be drawn.
- boolean fastDraw = mTouchState != TOUCH_STATE_SCROLLING && mNextScreen == INVALID_SCREEN
- && scale > 0.999f;
+ boolean fastDraw = mTouchState != TOUCH_STATE_SCROLLING && mNextScreen == INVALID_SCREEN;
// If we are not scrolling or flinging, draw only the current screen
if (fastDraw) {
drawChild(canvas, getChildAt(mCurrentScreen), getDrawingTime());
@@ -554,12 +432,6 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
}
}
- private float mScale = 1.0f;
- public void setScale(float scale) {
- mScale = scale;
- invalidate();
- }
-
protected void onAttachedToWindow() {
super.onAttachedToWindow();
mDragController.setWindowToken(getWindowToken());
@@ -974,7 +846,9 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
final int delta = newX - mScrollX;
final int duration = screenDelta * 300;
awakenScrollBars(duration);
+
// 1ms is close to don't animate
+ if (!mScroller.isFinished()) mScroller.abortAnimation();
mScroller.startScroll(mScrollX, 0, delta, 0, animate ? duration : 1);
invalidate();
}
@@ -1220,16 +1094,19 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
public void scrollLeft() {
clearVacantCache();
- if (mNextScreen == INVALID_SCREEN && mCurrentScreen > 0 && mScroller.isFinished()) {
- snapToScreen(mCurrentScreen - 1);
+ if (mScroller.isFinished()) {
+ if (mCurrentScreen > 0) snapToScreen(mCurrentScreen - 1);
+ } else {
+ if (mNextScreen > 0) snapToScreen(mNextScreen - 1);
}
}
public void scrollRight() {
clearVacantCache();
- if (mNextScreen == INVALID_SCREEN && mCurrentScreen < getChildCount() -1 &&
- mScroller.isFinished()) {
- snapToScreen(mCurrentScreen + 1);
+ if (mScroller.isFinished()) {
+ if (mCurrentScreen < getChildCount() -1) snapToScreen(mCurrentScreen + 1);
+ } else {
+ if (mNextScreen < getChildCount() -1) snapToScreen(mNextScreen + 1);
}
}
@@ -1466,11 +1343,4 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
}
};
}
-
- void show() {
- setVisibility(VISIBLE);
- }
-
- void hide() {
- }
}