diff options
author | Mike Cleron <mcleron@google.com> | 2009-11-08 14:56:25 -0800 |
---|---|---|
committer | Mike Cleron <mcleron@google.com> | 2009-11-08 15:39:29 -0800 |
commit | b64b67a012fd22c0e705a89709fae0e6c9d15522 (patch) | |
tree | b72152b7500b93c59eeb6df76a6eb2431939cfa3 | |
parent | 3c675fc62a6196282bc452b1a8edabce84c98201 (diff) | |
download | packages_apps_trebuchet-b64b67a012fd22c0e705a89709fae0e6c9d15522.zip packages_apps_trebuchet-b64b67a012fd22c0e705a89709fae0e6c9d15522.tar.gz packages_apps_trebuchet-b64b67a012fd22c0e705a89709fae0e6c9d15522.tar.bz2 |
Fix http://b/issue?id=2203681
There is a race between the view system
dispatching focus and mRollo being intialized. Now
if AllApps is supposed to gain focus before mRollo
is ready we remember that state and gain focus
later.
-rw-r--r-- | res/xml/default_workspace.xml | 31 | ||||
-rw-r--r-- | src/com/android/launcher2/AllAppsView.java | 42 |
2 files changed, 44 insertions, 29 deletions
diff --git a/res/xml/default_workspace.xml b/res/xml/default_workspace.xml index 2c8b8ff..df7ca1e 100644 --- a/res/xml/default_workspace.xml +++ b/res/xml/default_workspace.xml @@ -16,31 +16,28 @@ <favorites xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher2"> -com.android.camera - <!-- Left screen [1] --> - <favorite launcher:packageName="com.android.camera" launcher:className="com.android.camera.Camera" launcher:screen="1" launcher:x="1" launcher:y="3" /> - + <favorite launcher:packageName="com.android.camera" launcher:className="com.android.camera.Camera" launcher:screen="1" launcher:x="2" launcher:y="3" /> - + <!-- Middle screen [2] --> <search launcher:screen="2" launcher:x="0" launcher:y="0" /> - <favorite + <favorite launcher:packageName="com.android.contacts" launcher:className="com.android.contacts.DialtactsActivity" launcher:screen="2" @@ -83,23 +80,23 @@ com.android.camera launcher:y="2" /> <!-- Right screen [3] --> - - <appwidget - launcher:packageName="com.android.settings" - launcher:className="com.android.settings.widget.SettingsAppWidgetProvider" - launcher:screen="3" - launcher:x="0" - launcher:y="0" - launcher:spanX="4" - launcher:spanY="1" /> - + + <appwidget + launcher:packageName="com.android.settings" + launcher:className="com.android.settings.widget.SettingsAppWidgetProvider" + launcher:screen="3" + launcher:x="0" + launcher:y="0" + launcher:spanX="4" + launcher:spanY="1" /> + <favorite launcher:packageName="com.google.android.gm" launcher:className="com.google.android.gm.ConversationListActivityGmail" launcher:screen="3" launcher:x="1" launcher:y="3" /> - + <favorite launcher:packageName="com.google.android.talk" launcher:className="com.google.android.talk.SigningInActivity" diff --git a/src/com/android/launcher2/AllAppsView.java b/src/com/android/launcher2/AllAppsView.java index d96268c..722213d 100644 --- a/src/com/android/launcher2/AllAppsView.java +++ b/src/com/android/launcher2/AllAppsView.java @@ -110,6 +110,8 @@ public class AllAppsView extends RSSurfaceView private int mDownIconIndex = -1; private int mCurrentIconIndex = -1; + private boolean mShouldGainFocus; + static class Defines { public static final int ALLOC_PARAMS = 0; @@ -192,6 +194,10 @@ public class AllAppsView extends RSSurfaceView mRollo.setApps(mAllAppsList); Log.d(TAG, "surfaceChanged... calling mRollo.setApps"); } + if (mShouldGainFocus) { + gainFocus(); + mShouldGainFocus = false; + } } else { mRollo.mHasSurface = true; mRollo.dirtyCheck(); @@ -249,24 +255,36 @@ public class AllAppsView extends RSSurfaceView } if (gainFocus) { - if (!mArrowNavigation && mRollo.mState.iconCount > 0) { - // Select the first icon when we gain keyboard focus - mArrowNavigation = true; - mRollo.selectIcon(Math.round(mRollo.mMessageProc.mPosX) * Defines.COLUMNS_PER_PAGE, - SELECTED_FOCUSED); - mRollo.mState.save(); + if (mRollo != null) { + gainFocus(); + } else { + mShouldGainFocus = true; } } else { - if (mArrowNavigation) { - // Clear selection when we lose focus - mRollo.clearSelectedIcon(); - mRollo.setHomeSelected(SELECTED_NONE); - mRollo.mState.save(); - mArrowNavigation = false; + if (mRollo != null) { + if (mArrowNavigation) { + // Clear selection when we lose focus + mRollo.clearSelectedIcon(); + mRollo.setHomeSelected(SELECTED_NONE); + mRollo.mState.save(); + mArrowNavigation = false; + } + } else { + mShouldGainFocus = false; } } } + private void gainFocus() { + if (!mArrowNavigation && mRollo.mState.iconCount > 0) { + // Select the first icon when we gain keyboard focus + mArrowNavigation = true; + mRollo.selectIcon(Math.round(mRollo.mMessageProc.mPosX) * Defines.COLUMNS_PER_PAGE, + SELECTED_FOCUSED); + mRollo.mState.save(); + } + } + @Override public boolean onKeyDown(int keyCode, KeyEvent event) { |