diff options
author | Deepanshu Gupta <deepanshu@google.com> | 2014-05-13 17:42:06 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-05-13 17:42:06 +0000 |
commit | d388afada25c950f87fa285ccfeb1c3343454762 (patch) | |
tree | d2ff537bf114e280abc7ac5b9bf559a359afb657 /tools | |
parent | ebd909cca1f69028878f15e6fb0ece6e8c8da584 (diff) | |
parent | b6de60e0020dbed906b1d275de17f8c615b2b242 (diff) | |
download | frameworks_base-d388afada25c950f87fa285ccfeb1c3343454762.zip frameworks_base-d388afada25c950f87fa285ccfeb1c3343454762.tar.gz frameworks_base-d388afada25c950f87fa285ccfeb1c3343454762.tar.bz2 |
am b6de60e0: am df2da3d7: am 7bc363ba: Add special system view cookie to OverflowButton. [DO NOT MERGE]
* commit 'b6de60e0020dbed906b1d275de17f8c615b2b242':
Add special system view cookie to OverflowButton. [DO NOT MERGE]
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 67120f1..997fca1 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 @@ -22,8 +22,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.ActionBarImpl; +import com.android.internal.util.Predicate; import com.android.internal.view.menu.MenuBuilder; import com.android.internal.view.menu.MenuBuilderAccessor; import com.android.internal.view.menu.MenuItemImpl; @@ -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. */ @@ -165,10 +169,33 @@ public class ActionBarLayout extends LinearLayout { if (mActionBarView != null) { // 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)); + } } } |