diff options
author | Deepanshu Gupta <deepanshu@google.com> | 2014-04-29 19:54:25 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-04-29 19:54:25 +0000 |
commit | 7592afeaa09b64b566c7599c78c676d762fa23fc (patch) | |
tree | 2b45669cd92cc5dede1825563f955b944486c171 /tools | |
parent | f38475bc28fe5596e27d44cfad74d4efb537623c (diff) | |
parent | 674af92fd3a618695448ff88568b03390e90bc66 (diff) | |
download | frameworks_base-7592afeaa09b64b566c7599c78c676d762fa23fc.zip frameworks_base-7592afeaa09b64b566c7599c78c676d762fa23fc.tar.gz frameworks_base-7592afeaa09b64b566c7599c78c676d762fa23fc.tar.bz2 |
Merge "Add special system view cookie to OverflowButton."
Diffstat (limited to 'tools')
-rw-r--r-- | tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java index 49027c6..08512e7 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java @@ -23,8 +23,10 @@ import com.android.ide.common.rendering.api.ActionBarCallback.HomeButtonStyle; import com.android.ide.common.rendering.api.RenderResources; import com.android.ide.common.rendering.api.ResourceValue; import com.android.ide.common.rendering.api.SessionParams; +import com.android.ide.common.rendering.api.SystemViewCookie; import com.android.internal.R; import com.android.internal.app.WindowDecorActionBar; +import com.android.internal.util.Predicate; import com.android.internal.view.menu.MenuBuilder; import com.android.internal.view.menu.MenuItemImpl; import com.android.internal.widget.ActionBarAccessor; @@ -56,6 +58,8 @@ import android.widget.RelativeLayout; import java.util.ArrayList; +import static com.android.ide.common.rendering.api.SystemViewCookie.ACTION_BAR_OVERFLOW; + /** * A layout representing the action bar. */ @@ -164,10 +168,33 @@ public class ActionBarLayout extends LinearLayout { } // Set action bar to be split, if needed. - mActionBarView.setSplitView((ActionBarContainer) findViewById(R.id.split_action_bar)); + ActionBarContainer splitView = (ActionBarContainer) findViewById(R.id.split_action_bar); + mActionBarView.setSplitView(splitView); mActionBarView.setSplitActionBar(mSplit); inflateMenus(); + + // Find if the Overflow Menu Button (the three dots) exists. If yes, + // add the view cookie. + Predicate<View> overflowMenuButtonTest = new Predicate<View>() { + @Override + public boolean apply(View view) { + return view.getClass().getName() + .equals("android.widget.ActionMenuPresenter$OverflowMenuButton"); + } + }; + View overflowMenu = null; + if (mSplit) { + if (splitView != null) { + overflowMenu = splitView.findViewByPredicate(overflowMenuButtonTest); + } + } + else { + overflowMenu = mActionBarView.findViewByPredicate(overflowMenuButtonTest); + } + if (overflowMenu != null) { + mBridgeContext.addViewKey(overflowMenu, new SystemViewCookie(ACTION_BAR_OVERFLOW)); + } } } |