Fixing focus issues in Launcher (keyboard support).
Change-Id: Ieafd713393daf5628f229a66441bd3ed293245da
diff --git a/src/com/android/launcher2/CustomizeTrayTabHost.java b/src/com/android/launcher2/CustomizeTrayTabHost.java
index 3e04025..5c683c4 100644
--- a/src/com/android/launcher2/CustomizeTrayTabHost.java
+++ b/src/com/android/launcher2/CustomizeTrayTabHost.java
@@ -16,8 +16,7 @@
package com.android.launcher2;
-import com.android.launcher.R;
-import com.android.launcher2.CustomizePagedView.CustomizationType;
+import java.util.Random;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -28,10 +27,14 @@
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.TextView;
+import com.android.launcher.R;
+import com.android.launcher2.CustomizePagedView.CustomizationType;
+
public class CustomizeTrayTabHost extends TabHost implements LauncherTransitionable {
// tags for the customization tabs
private static final String WIDGETS_TAG = "widgets";
@@ -69,7 +72,8 @@
tabView = (TextView) mInflater.inflate(R.layout.tab_widget_indicator, tabWidget, false);
tabView.setText(mContext.getString(R.string.widgets_tab_label));
- addTab(newTabSpec(WIDGETS_TAG).setIndicator(tabView).setContent(contentFactory));
+ addTab(newTabSpec(WIDGETS_TAG)
+ .setIndicator(tabView).setContent(contentFactory));
tabView = (TextView) mInflater.inflate(R.layout.tab_widget_indicator, tabWidget, false);
tabView.setText(mContext.getString(R.string.applications_tab_label));
addTab(newTabSpec(APPLICATIONS_TAG)
@@ -82,6 +86,7 @@
tabView.setText(mContext.getString(R.string.shortcuts_tab_label));
addTab(newTabSpec(SHORTCUTS_TAG)
.setIndicator(tabView).setContent(contentFactory));
+
setOnTabChangedListener(new OnTabChangeListener() {
public void onTabChanged(String tabId) {
final CustomizePagedView.CustomizationType newType =
@@ -149,6 +154,14 @@
super.onLayout(changed, l, t, r, b);
}
+ @Override
+ public int getDescendantFocusability() {
+ if (getVisibility() != View.VISIBLE) {
+ return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
+ }
+ return super.getDescendantFocusability();
+ }
+
CustomizationType getCustomizeFilterForTabTag(String tag) {
if (tag.equals(WIDGETS_TAG)) {
return CustomizationType.WidgetCustomization;