Bug 889094 - NPE in BrowserToolbar due to late initialization of mFocusOrder. [r=sriram,bnicholson]

This commit is contained in:
Michal Kajda 2013-07-10 11:12:25 -07:00
parent 9000441a55
commit 4543e6fdcf

View File

@ -232,6 +232,16 @@ public class BrowserToolbar extends GeckoRelativeLayout
mMenuIcon = (GeckoImageView) findViewById(R.id.menu_icon);
mActionItemBar = (LinearLayout) findViewById(R.id.menu_items);
mHasSoftMenuButton = !HardwareUtils.hasMenuButton();
// We use different layouts on phones and tablets, so adjust the focus
// order appropriately.
if (HardwareUtils.isTablet()) {
mFocusOrder = Arrays.asList(mTabs, mBack, mForward, this,
mSiteSecurity, mReader, mStop, mActionItemBar, mMenu);
} else {
mFocusOrder = Arrays.asList(this, mSiteSecurity, mReader, mStop,
mTabs, mMenu);
}
}
@Override
@ -419,16 +429,6 @@ public class BrowserToolbar extends GeckoRelativeLayout
}
});
}
// We use different layouts on phones and tablets, so adjust the focus
// order appropriately.
if (HardwareUtils.isTablet()) {
mFocusOrder = Arrays.asList(mTabs, mBack, mForward, this,
mSiteSecurity, mReader, mStop, mActionItemBar, mMenu);
} else {
mFocusOrder = Arrays.asList(this, mSiteSecurity, mReader, mStop,
mTabs, mMenu);
}
}
@Override
@ -893,26 +893,27 @@ public class BrowserToolbar extends GeckoRelativeLayout
continue;
}
if (prevView != null) {
if (view == mActionItemBar) {
final int childCount = mActionItemBar.getChildCount();
if (childCount > 1) {
View firstChild = mActionItemBar.getChildAt(0);
firstChild.setNextFocusLeftId(prevView.getId());
prevView.setNextFocusRightId(firstChild.getId());
if (view == mActionItemBar) {
final int childCount = mActionItemBar.getChildCount();
for (int child = 0; child < childCount; child++) {
View childView = mActionItemBar.getChildAt(child);
if (prevView != null) {
childView.setNextFocusLeftId(prevView.getId());
prevView.setNextFocusRightId(childView.getId());
}
view = mActionItemBar.getChildAt(childCount - 1);
prevView = childView;
}
view.setNextFocusLeftId(prevView.getId());
prevView.setNextFocusRightId(view.getId());
} else {
if (prevView != null) {
view.setNextFocusLeftId(prevView.getId());
prevView.setNextFocusRightId(view.getId());
}
prevView = view;
}
}
if (needsNewFocus) {
requestFocus();
}
prevView = view;
if (needsNewFocus) {
requestFocus();
}
}