checkpoint 3d all apps entrance / exit animations
This commit is contained in:
parent
e498ab9986
commit
fb0ca67aea
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
|
@ -39,6 +39,16 @@
|
|||
// Drawing constants, should be parameters ======
|
||||
#define VIEW_ANGLE 1.28700222f
|
||||
|
||||
int g_lastFrameTime = 0;
|
||||
void print_frame_rate()
|
||||
{
|
||||
int now = uptimeMillis();
|
||||
if (g_lastFrameTime != 0) {
|
||||
debugI32("frame_rate", 1000/(now-g_lastFrameTime));
|
||||
}
|
||||
g_lastFrameTime = now;
|
||||
}
|
||||
|
||||
int
|
||||
count_pages(int iconCount)
|
||||
{
|
||||
|
@ -138,7 +148,7 @@ draw_page(int icon, int lastIcon, float centerAngle)
|
|||
iconLeftX, iconTextureBottom, iconLeftZ, 0.0f, 1.0f);
|
||||
|
||||
// label
|
||||
if (scale <= 1.04f) {
|
||||
if (scale <= 0.1f) {
|
||||
float labelLeftX = centerX - farLabelWidth * 0.5f;
|
||||
float labelRightX = centerX + farLabelWidth * 0.5f;
|
||||
|
||||
|
@ -343,6 +353,8 @@ main(int launchID)
|
|||
drawRect(handleLeft, handleTop, handleLeft+handleWidth, handleTop+handleHeight, 0.0f);
|
||||
*/
|
||||
|
||||
print_frame_rate();
|
||||
|
||||
return !done;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public class AllAppsGridView extends GridView implements AdapterView.OnItemClick
|
|||
app = new ApplicationInfo(app);
|
||||
|
||||
mDragController.startDrag(view, this, app, DragController.DRAG_ACTION_COPY);
|
||||
mLauncher.closeAllAppsDialog(true);
|
||||
mLauncher.closeAllApps(true);
|
||||
mDraw = false;
|
||||
invalidate();
|
||||
return true;
|
||||
|
@ -84,7 +84,7 @@ public class AllAppsGridView extends GridView implements AdapterView.OnItemClick
|
|||
}
|
||||
|
||||
public void onDropCompleted(View target, boolean success) {
|
||||
mLauncher.closeAllAppsDialog(false);
|
||||
mLauncher.closeAllApps(false);
|
||||
}
|
||||
|
||||
void setLauncher(Launcher launcher) {
|
||||
|
|
|
@ -64,9 +64,18 @@ public class AllAppsView extends RSSurfaceView
|
|||
implements View.OnClickListener, View.OnLongClickListener, DragSource {
|
||||
private static final String TAG = "Launcher.AllAppsView";
|
||||
|
||||
/** Bit for mLocks for when there are icons being loaded. */
|
||||
private static final int LOCK_ICONS_PENDING = 1;
|
||||
|
||||
/** Bit for mLocks for when the enter/exit is going. */
|
||||
private static final int LOCK_ZOOMING = 2;
|
||||
|
||||
private Launcher mLauncher;
|
||||
private DragController mDragController;
|
||||
private boolean mLocked = true;
|
||||
|
||||
/** When this is 0, modifications are allowed, when it's not, they're not.
|
||||
* TODO: What about scrolling? */
|
||||
private int mLocks = LOCK_ICONS_PENDING;
|
||||
|
||||
private RenderScript mRS;
|
||||
private RolloRS mRollo;
|
||||
|
@ -80,7 +89,6 @@ public class AllAppsView extends RSSurfaceView
|
|||
private int mLastMotionX;
|
||||
private int mMotionDownRawX;
|
||||
private int mMotionDownRawY;
|
||||
private TouchHandler mTouchHandler;
|
||||
private int mScrollHandleTop;
|
||||
|
||||
static class Defines {
|
||||
|
@ -168,36 +176,12 @@ public class AllAppsView extends RSSurfaceView
|
|||
return true;
|
||||
}
|
||||
|
||||
if (mLocked) {
|
||||
if (mLocks != 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
super.onTouchEvent(ev);
|
||||
|
||||
mTouchHandler = mFlingHandler;
|
||||
/*
|
||||
int action = ev.getAction();
|
||||
if (action == MotionEvent.ACTION_DOWN) {
|
||||
if (ev.getY() > mScrollHandleTop) {
|
||||
mTouchHandler = mScrollHandler;
|
||||
} else {
|
||||
mTouchHandler = mFlingHandler;
|
||||
}
|
||||
}
|
||||
*/
|
||||
mTouchHandler.onTouchEvent(ev);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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()) {
|
||||
|
@ -252,11 +236,14 @@ public class AllAppsView extends RSSurfaceView
|
|||
mVelocity = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
public void onClick(View v) {
|
||||
if (mLocks != 0) {
|
||||
return;
|
||||
}
|
||||
int index = mRollo.mState.selectedIconIndex;
|
||||
if (mRollo.mState.flingVelocityX == 0 && index >= 0 && index < mAllAppsList.size()) {
|
||||
ApplicationInfo app = mAllAppsList.get(index);
|
||||
|
@ -265,6 +252,9 @@ public class AllAppsView extends RSSurfaceView
|
|||
}
|
||||
|
||||
public boolean onLongClick(View v) {
|
||||
if (mLocks != 0) {
|
||||
return true;
|
||||
}
|
||||
int index = mRollo.mState.selectedIconIndex;
|
||||
Log.d(TAG, "long click! velocity=" + mRollo.mState.flingVelocityX + " index=" + index);
|
||||
if (mRollo.mState.flingVelocityX == 0 && index >= 0 && index < mAllAppsList.size()) {
|
||||
|
@ -280,7 +270,7 @@ public class AllAppsView extends RSSurfaceView
|
|||
left, top, Defines.ICON_WIDTH_PX, Defines.ICON_HEIGHT_PX,
|
||||
this, app, DragController.DRAG_ACTION_COPY);
|
||||
|
||||
mLauncher.closeAllAppsDialog(true);
|
||||
mLauncher.closeAllApps(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -294,15 +284,10 @@ public class AllAppsView extends RSSurfaceView
|
|||
|
||||
private static final int SCALE_SCALE = 100000;
|
||||
|
||||
public void show() {
|
||||
mRollo.mState.read();
|
||||
mRollo.mState.visible = 1;
|
||||
mRollo.mState.zoom = SCALE_SCALE;
|
||||
mRollo.mState.save();
|
||||
}
|
||||
|
||||
public void setScale(float amount) {
|
||||
cancelLongPress();
|
||||
mRollo.mState.read();
|
||||
mRollo.clearSelectedIcon();
|
||||
if (amount > 0.001f) {
|
||||
mRollo.mState.visible = 1;
|
||||
mRollo.mState.zoom = (int)(SCALE_SCALE*amount);
|
||||
|
@ -310,37 +295,21 @@ public class AllAppsView extends RSSurfaceView
|
|||
mRollo.mState.visible = 0;
|
||||
mRollo.mState.zoom = 0;
|
||||
}
|
||||
if (amount > 0.001f && amount < 0.999f) {
|
||||
mLocks |= LOCK_ZOOMING;
|
||||
} else {
|
||||
mLocks &= ~LOCK_ZOOMING;
|
||||
}
|
||||
mRollo.mState.save();
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
mRollo.mState.read();
|
||||
mRollo.mState.visible = 0;
|
||||
mRollo.mState.zoom = 0;
|
||||
mRollo.mState.save();
|
||||
public boolean isZooming() {
|
||||
return (mLocks & LOCK_ZOOMING) != 0;
|
||||
}
|
||||
|
||||
/*
|
||||
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;
|
||||
public boolean isVisible() {
|
||||
return mRollo != null && mRollo.mState.visible != 0;
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean onTrackballEvent(MotionEvent ev)
|
||||
|
@ -362,7 +331,7 @@ public class AllAppsView extends RSSurfaceView
|
|||
}
|
||||
mPageCount = countPages(list.size());
|
||||
Log.d(TAG, "setApps mRollo=" + mRollo + " list=" + list);
|
||||
mLocked = false;
|
||||
mLocks &= ~LOCK_ICONS_PENDING;
|
||||
}
|
||||
|
||||
private void invokeIcon(int index) {
|
||||
|
|
|
@ -49,7 +49,7 @@ public class HandleView extends ImageView {
|
|||
@Override
|
||||
public View focusSearch(int direction) {
|
||||
View newFocus = super.focusSearch(direction);
|
||||
if (newFocus == null && mLauncher.isDrawerDown()) {
|
||||
if (newFocus == null && mLauncher.isAllAppsVisible()) {
|
||||
final Workspace workspace = mLauncher.getWorkspace();
|
||||
workspace.dispatchUnhandledMove(null, direction);
|
||||
return (mOrientation == ORIENTATION_HORIZONTAL && direction == FOCUS_DOWN) ?
|
||||
|
|
|
@ -177,7 +177,6 @@ public final class Launcher extends Activity
|
|||
private DeleteZone mDeleteZone;
|
||||
private HandleView mHandleView;
|
||||
private AllAppsView mAllAppsGrid;
|
||||
private boolean mAllAppsVisible; // if it's visible at all
|
||||
private int mMode = MODE_WORKSPACE;
|
||||
|
||||
private Bundle mSavedState;
|
||||
|
@ -424,7 +423,7 @@ public final class Launcher extends Activity
|
|||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
closeAllAppsDialog(false);
|
||||
closeAllApps(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -812,7 +811,7 @@ public final class Launcher extends Activity
|
|||
mWorkspace.moveToDefaultScreen();
|
||||
}
|
||||
|
||||
closeAllAppsDialog(true);
|
||||
closeAllApps(true);
|
||||
|
||||
final View v = getWindow().peekDecorView();
|
||||
if (v != null && v.getWindowToken() != null) {
|
||||
|
@ -821,7 +820,7 @@ public final class Launcher extends Activity
|
|||
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
|
||||
}
|
||||
} else {
|
||||
closeAllAppsDialog(false);
|
||||
closeAllApps(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -853,7 +852,8 @@ public final class Launcher extends Activity
|
|||
|
||||
// When the drawer is opened and we are saving the state because of a
|
||||
// configuration change
|
||||
if (mAllAppsVisible && isConfigurationChange) {
|
||||
// TODO should not do this if the drawer is currently closing.
|
||||
if (isAllAppsVisible() && isConfigurationChange) {
|
||||
outState.putBoolean(RUNTIME_STATE_ALL_APPS_FOLDER, true);
|
||||
}
|
||||
|
||||
|
@ -906,7 +906,7 @@ public final class Launcher extends Activity
|
|||
public void startSearch(String initialQuery, boolean selectInitialQuery,
|
||||
Bundle appSearchData, boolean globalSearch) {
|
||||
|
||||
closeAllAppsDialog(false);
|
||||
closeAllApps(false);
|
||||
|
||||
// Slide the search widget to the top, if it's on the current screen,
|
||||
// otherwise show the search dialog immediately.
|
||||
|
@ -1282,8 +1282,8 @@ public final class Launcher extends Activity
|
|||
case KeyEvent.KEYCODE_BACK:
|
||||
if (!event.isCanceled()) {
|
||||
mWorkspace.dispatchKeyEvent(event);
|
||||
if (mAllAppsVisible) {
|
||||
closeAllAppsDialog(true);
|
||||
if (isAllAppsVisible()) {
|
||||
closeAllApps(true);
|
||||
} else {
|
||||
closeFolder();
|
||||
}
|
||||
|
@ -1341,10 +1341,11 @@ public final class Launcher extends Activity
|
|||
} else if (tag instanceof FolderInfo) {
|
||||
handleFolderClick((FolderInfo) tag);
|
||||
} else if (v == mHandleView) {
|
||||
if (mAllAppsVisible) {
|
||||
// TODO how can we be here?
|
||||
Log.d(TAG, "onClick");
|
||||
if (isAllAppsVisible()) {
|
||||
closeAllApps(true);
|
||||
} else {
|
||||
showAllAppsDialog();
|
||||
showAllApps(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1453,10 +1454,6 @@ public final class Launcher extends Activity
|
|||
return mHandleView;
|
||||
}
|
||||
|
||||
boolean isDrawerDown() { // TODO rename to isAllAppsVisible()
|
||||
return /* TODO !mDrawer.isMoving() && */ !mAllAppsVisible;
|
||||
}
|
||||
|
||||
Workspace getWorkspace() {
|
||||
return mWorkspace;
|
||||
}
|
||||
|
@ -1605,26 +1602,44 @@ public final class Launcher extends Activity
|
|||
}
|
||||
}
|
||||
|
||||
void showAllAppsDialog() {
|
||||
mAllAppsVisible = true;
|
||||
mAllAppsGrid.show();
|
||||
boolean isAllAppsVisible() {
|
||||
return mAllAppsGrid.isZooming() || mAllAppsGrid.isVisible();
|
||||
}
|
||||
|
||||
void showAllApps(boolean animated) {
|
||||
if (mMode == MODE_ALL_APPS) {
|
||||
return;
|
||||
}
|
||||
|
||||
mSwipeController.setRange(-1, 0);
|
||||
if (animated) {
|
||||
mSwipeController.animate(-1);
|
||||
} else {
|
||||
mSwipeController.setImmediate(-1);
|
||||
}
|
||||
|
||||
mWorkspace.hide();
|
||||
|
||||
// TODO: fade these two too
|
||||
mDeleteZone.setVisibility(View.GONE);
|
||||
mHandleView.setVisibility(View.GONE);
|
||||
//mHandleView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
void closeAllAppsDialog(boolean animated) {
|
||||
if (mAllAppsVisible) {
|
||||
mAllAppsGrid.hide();
|
||||
mAllAppsVisible = false;
|
||||
void closeAllApps(boolean animated) {
|
||||
if (mAllAppsGrid.isVisible()) {
|
||||
mSwipeController.setRange(0, 1);
|
||||
if (animated) {
|
||||
mSwipeController.animate(1);
|
||||
} else {
|
||||
mSwipeController.setImmediate(1);
|
||||
}
|
||||
mWorkspace.getChildAt(mWorkspace.getCurrentScreen()).requestFocus();
|
||||
mWorkspace.show();
|
||||
|
||||
// TODO: fade these two too
|
||||
/*
|
||||
mDeleteZone.setVisibility(View.VISIBLE);
|
||||
mHandleView.setVisibility(View.VISIBLE);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1777,6 +1792,7 @@ public final class Launcher extends Activity
|
|||
switch (mMode) {
|
||||
case MODE_WORKSPACE:
|
||||
if (amount == -1) {
|
||||
setWorkspaceAndAllAppsScale(-amount);
|
||||
mWorkspace.clearChildrenCache();
|
||||
mMode = MODE_ALL_APPS;
|
||||
mSwipeController.setRange(0, 1);
|
||||
|
@ -1784,6 +1800,7 @@ public final class Launcher extends Activity
|
|||
break;
|
||||
case MODE_ALL_APPS:
|
||||
if (amount == 1) {
|
||||
setWorkspaceAndAllAppsScale(1-amount);
|
||||
mWorkspace.clearChildrenCache();
|
||||
mMode = MODE_WORKSPACE;
|
||||
mSwipeController.setRange(-1, 0);
|
||||
|
@ -1983,7 +2000,7 @@ public final class Launcher extends Activity
|
|||
|
||||
final boolean allApps = mSavedState.getBoolean(RUNTIME_STATE_ALL_APPS_FOLDER, false);
|
||||
if (allApps) {
|
||||
showAllAppsDialog();
|
||||
showAllApps(false);
|
||||
}
|
||||
|
||||
mSavedState = null;
|
||||
|
|
|
@ -143,6 +143,41 @@ public class SwipeController {
|
|||
return mTracking || mCanceled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value, performing an animation. Make sure that you have set the
|
||||
* range properly first, otherwise the value may be clamped.
|
||||
*/
|
||||
public void animate(float dest) {
|
||||
go(dest, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value, but don't perform an animation. Make sure that you have set the
|
||||
* range properly first, otherwise the value may be clamped.
|
||||
*/
|
||||
public void setImmediate(float dest) {
|
||||
go(dest, dest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Externally start a swipe. If dest == amount, this will end up just immediately
|
||||
* setting the value, but it will perform the proper start and finish callbacks.
|
||||
*/
|
||||
private void go(float dest, float amount) {
|
||||
mListener.onStartSwipe();
|
||||
|
||||
dest = clamp(dest);
|
||||
mDirection = dest > amount ? 1 : -1; // if they're equal it doesn't matter
|
||||
mVelocity = mDirection * 0.002f; // TODO: density.
|
||||
mAmount = amount;
|
||||
mDest = dest;
|
||||
|
||||
mFlingTime = SystemClock.uptimeMillis();
|
||||
mLastTime = 0;
|
||||
|
||||
scheduleAnim();
|
||||
}
|
||||
|
||||
private float clamp(float v) {
|
||||
if (v < mMinDest) {
|
||||
return mMinDest;
|
||||
|
@ -165,6 +200,7 @@ public class SwipeController {
|
|||
mVelocityTracker.computeCurrentVelocity(1);
|
||||
|
||||
mVelocity = mVelocityTracker.getYVelocity() / mSwipeDistance;
|
||||
Log.d(TAG, "mVelocity=" + mVelocity);
|
||||
mDirection = mVelocity >= 0.0f ? 1 : -1;
|
||||
mAmount = clamp((screenY-mDownY)/mSwipeDistance);
|
||||
if (mAmount < 0) {
|
||||
|
|
|
@ -600,7 +600,7 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
|
|||
|
||||
@Override
|
||||
protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) {
|
||||
if (mLauncher.isDrawerDown()) {
|
||||
if (mLauncher.isAllAppsVisible()) {
|
||||
final Folder openFolder = getOpenFolder();
|
||||
if (openFolder != null) {
|
||||
return openFolder.requestFocus(direction, previouslyFocusedRect);
|
||||
|
@ -635,7 +635,7 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
|
|||
|
||||
@Override
|
||||
public void addFocusables(ArrayList<View> views, int direction, int focusableMode) {
|
||||
if (mLauncher.isDrawerDown()) {
|
||||
if (mLauncher.isAllAppsVisible()) {
|
||||
final Folder openFolder = getOpenFolder();
|
||||
if (openFolder == null) {
|
||||
getChildAt(mCurrentScreen).addFocusables(views, direction);
|
||||
|
@ -656,7 +656,7 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
|
|||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
if (mLauncher.isWorkspaceLocked() || !mLauncher.isDrawerDown()) {
|
||||
if (mLauncher.isWorkspaceLocked() || !mLauncher.isAllAppsVisible()) {
|
||||
return false; // We don't want the events. Let them fall through to the all apps view.
|
||||
}
|
||||
|
||||
|
@ -766,7 +766,7 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
|
|||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
|
||||
if (mLauncher.isWorkspaceLocked() || !mLauncher.isDrawerDown()) {
|
||||
if (mLauncher.isWorkspaceLocked() || !mLauncher.isAllAppsVisible()) {
|
||||
return false; // We don't want the events. Let them fall through to the all apps view.
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue