summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/Launcher.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher2/Launcher.java')
-rw-r--r--src/com/android/launcher2/Launcher.java126
1 files changed, 14 insertions, 112 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 3813afe95..7075b5f67 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -82,8 +82,7 @@ import java.io.DataInputStream;
* Default launcher application.
*/
public final class Launcher extends Activity
- implements View.OnClickListener, OnLongClickListener, LauncherModel.Callbacks,
- SwipeController.SwipeListener {
+ implements View.OnClickListener, OnLongClickListener, LauncherModel.Callbacks {
static final String LOG_TAG = "Launcher";
static final String TAG = LOG_TAG;
static final boolean LOGD = false;
@@ -109,10 +108,6 @@ public final class Launcher extends Activity
private static final int REQUEST_PICK_LIVE_FOLDER = 8;
private static final int REQUEST_PICK_APPWIDGET = 9;
- private static final int MODE_WORKSPACE = 0;
- private static final int MODE_ALL_APPS = 1;
- private static final int MODE_ALL_APPS_ZOOMED = 2;
-
static final String EXTRA_SHORTCUT_DUPLICATE = "duplicate";
static final String EXTRA_CUSTOM_WIDGET = "custom_widget";
@@ -177,7 +172,6 @@ public final class Launcher extends Activity
private DeleteZone mDeleteZone;
private HandleView mHandleView;
private AllAppsView mAllAppsGrid;
- private int mMode = MODE_WORKSPACE;
private Bundle mSavedState;
@@ -423,7 +417,7 @@ public final class Launcher extends Activity
@Override
protected void onPause() {
super.onPause();
- closeAllApps();
+ closeAllApps(false);
}
@Override
@@ -519,9 +513,8 @@ public final class Launcher extends Activity
private void setupViews() {
mDragController = new DragController(this);
DragController dragController = mDragController;
- mSwipeController = new SwipeController(this, this);
+ mSwipeController = new SwipeController(this);
SwipeController swipeController = mSwipeController;
- swipeController.setRange(-1, 0);
DragLayer dragLayer = (DragLayer) findViewById(R.id.drag_layer);
dragLayer.setDragController(dragController);
@@ -531,6 +524,7 @@ public final class Launcher extends Activity
mAllAppsGrid.setLauncher(this);
mAllAppsGrid.setDragController(dragController);
mAllAppsGrid.setWillNotDraw(false); // We don't want a hole punched in our window.
+ swipeController.setAllAppsView(mAllAppsGrid);
mWorkspace = (Workspace) dragLayer.findViewById(R.id.workspace);
final Workspace workspace = mWorkspace;
@@ -811,7 +805,7 @@ public final class Launcher extends Activity
mWorkspace.moveToDefaultScreen();
}
- closeAllApps();
+ closeAllApps(true);
final View v = getWindow().peekDecorView();
if (v != null && v.getWindowToken() != null) {
@@ -820,7 +814,7 @@ public final class Launcher extends Activity
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
} else {
- closeAllApps();
+ closeAllApps(false);
}
}
}
@@ -906,7 +900,7 @@ public final class Launcher extends Activity
public void startSearch(String initialQuery, boolean selectInitialQuery,
Bundle appSearchData, boolean globalSearch) {
- closeAllApps();
+ closeAllApps(true);
// Slide the search widget to the top, if it's on the current screen,
// otherwise show the search dialog immediately.
@@ -1283,7 +1277,7 @@ public final class Launcher extends Activity
if (!event.isCanceled()) {
mWorkspace.dispatchKeyEvent(event);
if (isAllAppsVisible()) {
- closeAllApps();
+ closeAllApps(true);
} else {
closeFolder();
}
@@ -1343,7 +1337,7 @@ public final class Launcher extends Activity
} else if (v == mHandleView) {
Log.d(TAG, "onClick");
if (isAllAppsVisible()) {
- closeAllApps();
+ closeAllApps(true);
} else {
showAllApps();
}
@@ -1433,7 +1427,6 @@ public final class Launcher extends Activity
}
if (mWorkspace.allowLongPress()) {
- Log.d(TAG, "there");
mSwipeController.cancelSwipe();
if (cellInfo.cell == null) {
if (cellInfo.valid) {
@@ -1604,27 +1597,21 @@ public final class Launcher extends Activity
}
boolean isAllAppsVisible() {
- return mAllAppsGrid.isZooming() || mAllAppsGrid.isVisible();
+ return mAllAppsGrid.isVisible();
}
void showAllApps() {
- if (mMode == MODE_ALL_APPS) {
- return;
- }
-
- mSwipeController.setRange(-1, 0);
- mSwipeController.setImmediate(-1);
- mWorkspace.hide();
+ mSwipeController.setMode(SwipeController.MODE_ALL_APPS, true);
+ //mWorkspace.hide();
// TODO: fade these two too
mDeleteZone.setVisibility(View.GONE);
//mHandleView.setVisibility(View.GONE);
}
- void closeAllApps() {
+ void closeAllApps(boolean animated) {
if (mAllAppsGrid.isVisible()) {
- mSwipeController.setRange(0, 1);
- mSwipeController.setImmediate(1);
+ mSwipeController.setMode(SwipeController.MODE_WORKSPACE, animated);
mWorkspace.getChildAt(mWorkspace.getCurrentScreen()).requestFocus();
// TODO: fade these two too
@@ -1761,91 +1748,6 @@ public final class Launcher extends Activity
}
/**
- * Implementation of the method from SwipeController.SwipeListener.
- */
- public void onStartSwipe() {
- switch (mMode) {
- case MODE_WORKSPACE:
- mWorkspace.enableChildrenCache();
- break;
- case MODE_ALL_APPS:
- break;
- case MODE_ALL_APPS_ZOOMED:
- break;
- }
- }
-
- /**
- * Implementation of the method from SwipeController.SwipeListener.
- *
- * @param amount The final value of the swipe (-1, 0 or 1)
- */
- public void onFinishSwipe(int amount) {
- switch (mMode) {
- case MODE_WORKSPACE:
- if (amount == -1) {
- setWorkspaceAndAllAppsScale(-amount);
- mWorkspace.clearChildrenCache();
- mMode = MODE_ALL_APPS;
- mSwipeController.setRange(0, 1);
- }
- break;
- case MODE_ALL_APPS:
- if (amount == 1) {
- setWorkspaceAndAllAppsScale(1-amount);
- mWorkspace.clearChildrenCache();
- mMode = MODE_WORKSPACE;
- mSwipeController.setRange(-1, 0);
- }
- break;
- case MODE_ALL_APPS_ZOOMED:
- break;
- }
- }
-
- /**
- * Implementation of the method from SwipeController.SwipeListener.
- */
- public void onSwipe(float amount) {
- switch (mMode) {
- case MODE_WORKSPACE:
- // We can open the all apps view.
- // 0 == workspace is showing
- // -1 == all apps is showing
- setWorkspaceAndAllAppsScale(-amount);
- break;
- case MODE_ALL_APPS:
- // We can close it, or (someday) zoom it further
- // 0 == all apps showing
- // 1 == workspace is showing
- setWorkspaceAndAllAppsScale(1-amount);
- break;
- }
- }
-
- /**
- * Set the scale factor for the workspace and the all apps grid.
- *
- * @param amount A float between 0 and 1, where:
- * 0 == workspace is showing and
- * 1 == the all apps grid is showing.
- */
- private void setWorkspaceAndAllAppsScale(float amount) {
- //Log.d("setWorkspaceAndAllAppsScale", "setWorkspaceAndAllAppsScale amount=" + amount);
- if (amount < 0.001f) {
- amount = 0.0f;
- }
- if (amount > 0.999f) {
- amount = 1.0f;
- mWorkspace.setVisibility(View.INVISIBLE);
- } else {
- mWorkspace.setVisibility(View.VISIBLE);
- }
- //mWorkspace.setScale(1-amount);
- mAllAppsGrid.setScale(amount);
- }
-
- /**
* Implementation of the method from LauncherModel.Callbacks.
*/
public int getCurrentWorkspaceScreen() {