Handle callbacks to CollapsibleActionViews that are in an actionLayout.

Also, the onActionViewCollapsed needs to be called before detaching
the action view, so that the action view can dismiss the keyboard properly.

Fixes the Gmail search case where the keyboard doesn't disappear on hitting
the "up" affordance after a search.

Change-Id: I3c2f3f90f0edf6473404e6ceae3fa08866cad736
This commit is contained in:
Amith Yamasani
2011-07-26 16:14:26 -07:00
parent e3f5edf975
commit 10da590839
3 changed files with 11 additions and 7 deletions

View File

@@ -330,9 +330,9 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
@Override
public void clearFocus() {
mClearingFocus = true;
setImeVisibility(false);
super.clearFocus();
mQueryTextView.clearFocus();
setImeVisibility(false);
mClearingFocus = false;
}
@@ -1041,8 +1041,9 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
*/
@Override
public void onActionViewCollapsed() {
clearFocus();
updateViewsVisibility(true);
mQueryTextView.setText("");
setIconified(true);
mExpandedInActionView = false;
}

View File

@@ -563,7 +563,7 @@ public final class MenuItemImpl implements MenuItem {
public MenuItem setActionView(int resId) {
final Context context = mMenu.getContext();
final LayoutInflater inflater = LayoutInflater.from(context);
setActionView(inflater.inflate(resId, new LinearLayout(context)));
setActionView(inflater.inflate(resId, new LinearLayout(context), false));
return this;
}

View File

@@ -1323,11 +1323,18 @@ public class ActionBarView extends AbsActionBarView {
if (mExpandedActionView instanceof CollapsibleActionView) {
((CollapsibleActionView) mExpandedActionView).onActionViewExpanded();
}
return true;
}
@Override
public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) {
// Do this before detaching the actionview from the hierarchy, in case
// it needs to dismiss the soft keyboard, etc.
if (mExpandedActionView instanceof CollapsibleActionView) {
((CollapsibleActionView) mExpandedActionView).onActionViewCollapsed();
}
removeView(mExpandedActionView);
removeView(mExpandedHomeLayout);
if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0) {
@@ -1349,16 +1356,12 @@ public class ActionBarView extends AbsActionBarView {
if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
mCustomNavView.setVisibility(VISIBLE);
}
View collapsedView = mExpandedActionView;
mExpandedActionView = null;
mExpandedHomeLayout.setIcon(null);
mCurrentExpandedItem = null;
requestLayout();
item.setActionViewExpanded(false);
if (collapsedView instanceof CollapsibleActionView) {
((CollapsibleActionView) collapsedView).onActionViewCollapsed();
}
return true;
}