diff options
author | The Android Automerger <android-build@android.com> | 2009-11-20 15:02:19 -0800 |
---|---|---|
committer | The Android Automerger <android-build@android.com> | 2009-11-20 15:02:19 -0800 |
commit | b438e144789a8c40329aa3035a5d286fccd5ec09 (patch) | |
tree | 575a5408dad73632cb4a197c87141f77978bfeb1 | |
parent | ebf3991a60cbd5f510eb0eae8fe2c2c0e2bca357 (diff) | |
parent | 418928e9d0168609cc802e95c18930d131147e7a (diff) | |
download | android_packages_apps_Trebuchet-b438e144789a8c40329aa3035a5d286fccd5ec09.tar.gz android_packages_apps_Trebuchet-b438e144789a8c40329aa3035a5d286fccd5ec09.tar.bz2 android_packages_apps_Trebuchet-b438e144789a8c40329aa3035a5d286fccd5ec09.zip |
Merge branch 'eclair' into eclair-release
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 56 | ||||
-rw-r--r-- | src/com/android/launcher2/LauncherModel.java | 13 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 11 |
3 files changed, 45 insertions, 35 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index cbf09b0b0..52d89c3ec 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -589,12 +589,16 @@ public final class Launcher extends Activity @SuppressWarnings({"UnusedDeclaration"}) public void previousScreen(View v) { - mWorkspace.scrollLeft(); + if (!isAllAppsVisible()) { + mWorkspace.scrollLeft(); + } } @SuppressWarnings({"UnusedDeclaration"}) public void nextScreen(View v) { - mWorkspace.scrollRight(); + if (!isAllAppsVisible()) { + mWorkspace.scrollRight(); + } } /** @@ -815,7 +819,7 @@ public final class Launcher extends Activity } void closeSystemDialogs() { - closeAllApps(false); + closeAllApps(true); getWindow().closeAllPanels(); try { @@ -831,6 +835,9 @@ public final class Launcher extends Activity } catch (Exception e) { // An exception is thrown if the dialog is not visible, which is fine } + + // Whatever we were doing is hereby canceled. + mWaitingForResult = false; } @Override @@ -839,21 +846,21 @@ public final class Launcher extends Activity // Close the menu if (Intent.ACTION_MAIN.equals(intent.getAction())) { + // also will cancel mWaitingForResult. closeSystemDialogs(); - // Whatever we were doing is hereby canceled. - mWaitingForResult = false; - // Set this flag so that onResume knows to close the search dialog if it's open, // because this was a new intent (thus a press of 'home' or some such) rather than // for example onResume being called when the user pressed the 'back' button. mIsNewIntent = true; + boolean alreadyOnHome = ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) + != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); + boolean allAppsVisible = isAllAppsVisible(); if (!mWorkspace.isDefaultScreenShowing()) { - mWorkspace.moveToDefaultScreen(); + mWorkspace.moveToDefaultScreen(alreadyOnHome && !allAppsVisible); } - - closeAllApps(false); + closeAllApps(alreadyOnHome && allAppsVisible); final View v = getWindow().peekDecorView(); if (v != null && v.getWindowToken() != null) { @@ -1318,8 +1325,6 @@ public final class Launcher extends Activity public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { - case KeyEvent.KEYCODE_BACK: - return true; case KeyEvent.KEYCODE_HOME: return true; case KeyEvent.KEYCODE_VOLUME_DOWN: @@ -1331,18 +1336,6 @@ public final class Launcher extends Activity } } else if (event.getAction() == KeyEvent.ACTION_UP) { switch (event.getKeyCode()) { - case KeyEvent.KEYCODE_BACK: - if (event.isTracking() && !event.isCanceled()) { - mWorkspace.dispatchKeyEvent(event); - if (isAllAppsVisible()) { - closeAllApps(true); - } else { - closeFolder(); - } - dismissPreview(mPreviousView); - dismissPreview(mNextView); - } - return true; case KeyEvent.KEYCODE_HOME: return true; } @@ -1351,6 +1344,17 @@ public final class Launcher extends Activity return super.dispatchKeyEvent(event); } + @Override + public void onBackPressed() { + if (isAllAppsVisible()) { + closeAllApps(true); + } else { + closeFolder(); + } + dismissPreview(mPreviousView); + dismissPreview(mNextView); + } + private void closeFolder() { Folder folder = mWorkspace.getOpenFolder(); if (folder != null) { @@ -1904,7 +1908,11 @@ public final class Launcher extends Activity } private void cleanup() { - dismissDialog(DIALOG_CREATE_SHORTCUT); + try { + dismissDialog(DIALOG_CREATE_SHORTCUT); + } catch (Exception e) { + // An exception is thrown if the dialog is not visible, which is fine + } } /** diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java index 85d47a916..d9017dab6 100644 --- a/src/com/android/launcher2/LauncherModel.java +++ b/src/com/android/launcher2/LauncherModel.java @@ -278,8 +278,6 @@ public class LauncherModel extends BroadcastReceiver { ArrayList<ApplicationInfo> added = null; ArrayList<ApplicationInfo> removed = null; ArrayList<ApplicationInfo> modified = null; - boolean update = false; - boolean remove = false; synchronized (mLock) { if (mBeforeFirstLoad) { @@ -298,11 +296,9 @@ public class LauncherModel extends BroadcastReceiver { if (Intent.ACTION_PACKAGE_CHANGED.equals(action)) { mAllAppsList.updatePackage(context, packageName); - update = true; } else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) { if (!replacing) { mAllAppsList.removePackage(packageName); - remove = true; } // else, we are replacing the package, so a PACKAGE_ADDED will be sent // later, we will update the package at this time @@ -311,7 +307,6 @@ public class LauncherModel extends BroadcastReceiver { mAllAppsList.addPackage(context, packageName); } else { mAllAppsList.updatePackage(context, packageName); - update = true; } } @@ -345,7 +340,7 @@ public class LauncherModel extends BroadcastReceiver { } }); } - if (update || modified != null) { + if (modified != null) { final ArrayList<ApplicationInfo> modifiedFinal = modified; mHandler.post(new Runnable() { public void run() { @@ -353,7 +348,7 @@ public class LauncherModel extends BroadcastReceiver { } }); } - if (remove || removed != null) { + if (removed != null) { final ArrayList<ApplicationInfo> removedFinal = removed; mHandler.post(new Runnable() { public void run() { @@ -980,7 +975,9 @@ public class LauncherModel extends BroadcastReceiver { private void bindAllApps() { synchronized (mLock) { - final ArrayList<ApplicationInfo> results = mAllAppsList.added; + final ArrayList<ApplicationInfo> results + = (ArrayList<ApplicationInfo>)mAllAppsList.data.clone(); + // We're adding this now, so clear out this so we don't re-send them. mAllAppsList.added = new ArrayList<ApplicationInfo>(); mHandler.post(new Runnable() { public void run() { diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index d0cec8af1..ac94ccae8 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -947,6 +947,10 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag } void snapToScreen(int whichScreen) { + snapToScreen(whichScreen, true); + } + + void snapToScreen(int whichScreen, boolean animate) { //if (!mScroller.isFinished()) return; whichScreen = Math.max(0, Math.min(whichScreen, getChildCount() - 1)); @@ -970,7 +974,8 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag final int delta = newX - mScrollX; final int duration = screenDelta * 300; awakenScrollBars(duration); - mScroller.startScroll(mScrollX, 0, delta, 0, duration); + // 1ms is close to don't animate + mScroller.startScroll(mScrollX, 0, delta, 0, animate ? duration : 1); invalidate(); } @@ -1420,8 +1425,8 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag } } - void moveToDefaultScreen() { - snapToScreen(mDefaultScreen); + void moveToDefaultScreen(boolean animate) { + snapToScreen(mDefaultScreen, animate); getChildAt(mDefaultScreen).requestFocus(); } |