diff options
author | Winson Chung <winsonc@google.com> | 2011-07-21 11:46:32 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2011-07-21 11:48:43 -0700 |
commit | 4d279d94ade1c0d455404312b3c9cfde0078c547 (patch) | |
tree | aa7bf49d38894173563d98df254475ca7a104969 | |
parent | f55cd6a46c25cab8b3a9e90ba3cff4ca237149df (diff) | |
download | packages_apps_trebuchet-4d279d94ade1c0d455404312b3c9cfde0078c547.zip packages_apps_trebuchet-4d279d94ade1c0d455404312b3c9cfde0078c547.tar.gz packages_apps_trebuchet-4d279d94ade1c0d455404312b3c9cfde0078c547.tar.bz2 |
Fixing various issues with the dock.
- Prevent crash due to no overlays in certain device configurations
- Fixing kb crash and adding content description for Apps button
Change-Id: Ie2a2bc29e7b9408a165f93d108fdd803193afc29
-rw-r--r-- | src/com/android/launcher2/BubbleTextView.java | 12 | ||||
-rw-r--r-- | src/com/android/launcher2/FocusHelper.java | 17 | ||||
-rw-r--r-- | src/com/android/launcher2/Hotseat.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 7 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 2 |
5 files changed, 30 insertions, 16 deletions
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java index 57a6584..476d063 100644 --- a/src/com/android/launcher2/BubbleTextView.java +++ b/src/com/android/launcher2/BubbleTextView.java @@ -330,16 +330,4 @@ public class BubbleTextView extends TextView implements VisibilityChangedBroadca } return true; } - - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) { - return FocusHelper.handleBubbleTextViewKeyEvent(this, keyCode, event) - || super.onKeyDown(keyCode, event); - } - - @Override - public boolean onKeyUp(int keyCode, KeyEvent event) { - return FocusHelper.handleBubbleTextViewKeyEvent(this, keyCode, event) - || super.onKeyUp(keyCode, event); - } } diff --git a/src/com/android/launcher2/FocusHelper.java b/src/com/android/launcher2/FocusHelper.java index 233fd6f..3783d56 100644 --- a/src/com/android/launcher2/FocusHelper.java +++ b/src/com/android/launcher2/FocusHelper.java @@ -31,9 +31,19 @@ import java.util.Collections; import java.util.Comparator; /** + * A keyboard listener we set on all the workspace icons. + */ +class BubbleTextViewKeyEventListener implements View.OnKeyListener { + @Override + public boolean onKey(View v, int keyCode, KeyEvent event) { + return FocusHelper.handleBubbleTextViewKeyEvent((BubbleTextView) v, keyCode, event); + } +} + +/** * A keyboard listener we set on all the hotseat buttons. */ -class HotseatKeyEventListener implements View.OnKeyListener { +class HotseatBubbleTextViewKeyEventListener implements View.OnKeyListener { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { final Configuration configuration = v.getResources().getConfiguration(); @@ -612,6 +622,7 @@ public class FocusHelper { final Workspace workspace = (Workspace) layout.getParent(); final ViewGroup launcher = (ViewGroup) workspace.getParent(); final ViewGroup tabs = (ViewGroup) launcher.findViewById(R.id.qsb_bar); + final ViewGroup hotseat = (ViewGroup) launcher.findViewById(R.id.hotseat); int iconIndex = parent.indexOfChild(v); int iconCount = parent.getChildCount(); int pageIndex = workspace.indexOfChild(layout); @@ -678,11 +689,13 @@ public class FocusHelper { break; case KeyEvent.KEYCODE_DPAD_DOWN: if (handleKeyEvent) { - // Select the closest icon in the next line, otherwise select the tab bar + // Select the closest icon in the next line, otherwise select the button bar View newIcon = getClosestBubbleTextViewOnLine(layout, parent, v, 1); if (newIcon != null) { newIcon.requestFocus(); wasHandled = true; + } else if (hotseat != null) { + hotseat.requestFocus(); } } break; diff --git a/src/com/android/launcher2/Hotseat.java b/src/com/android/launcher2/Hotseat.java index deab131..491691e 100644 --- a/src/com/android/launcher2/Hotseat.java +++ b/src/com/android/launcher2/Hotseat.java @@ -57,6 +57,7 @@ public class Hotseat extends FrameLayout { public void setup(Launcher launcher) { mLauncher = launcher; + setOnKeyListener(new HotseatBubbleTextViewKeyEventListener()); } CellLayout getLayout() { @@ -96,11 +97,14 @@ public class Hotseat extends FrameLayout { inflater.inflate(R.layout.application, mContent, false); allAppsButton.setCompoundDrawablesWithIntrinsicBounds(null, context.getResources().getDrawable(R.drawable.apps_hotseat_button), null, null); - // button.setText(context.getString(R.string.all_apps_button_label)); + // allAppsButton.setText(context.getString(R.string.all_apps_button_label)); + allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label)); allAppsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(android.view.View v) { - mLauncher.showAllApps(true); + if (mLauncher != null) { + mLauncher.showAllApps(true); + } } }); diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 0abdec0..3050be4 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -2874,6 +2874,13 @@ public final class Launcher extends Activity final Workspace workspace = mWorkspace; for (int i=start; i<end; i++) { final ItemInfo item = shortcuts.get(i); + + // Short circuit if we are loading dock items for a configuration which has no dock + if (item.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT && + mHotseat == null) { + continue; + } + switch (item.itemType) { case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION: case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT: diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index b86fa41..e71e0f8 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -453,6 +453,7 @@ public class Workspace extends SmoothPagedView final CellLayout layout; if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { layout = mLauncher.getHotseat().getLayout(); + child.setOnKeyListener(null); if (screen < 0) { screen = mLauncher.getHotseat().getOrderInHotseat(x, y); @@ -464,6 +465,7 @@ public class Workspace extends SmoothPagedView } } else { layout = (CellLayout) getChildAt(screen); + child.setOnKeyListener(new BubbleTextViewKeyEventListener()); } CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams(); |