Java Code Examples for com.actionbarsherlock.app.ActionBar#DISPLAY_SHOW_HOME

The following examples show how to use com.actionbarsherlock.app.ActionBar#DISPLAY_SHOW_HOME . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActionBarView.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
@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);
    mExpandedActionView = null;
    if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0) {
        mHomeLayout.setVisibility(VISIBLE);
    }
    if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
        if (mTitleLayout == null) {
            initTitle();
        } else {
            mTitleLayout.setVisibility(VISIBLE);
        }
    }
    if (mTabScrollView != null && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) {
        mTabScrollView.setVisibility(VISIBLE);
    }
    if (mSpinner != null && mNavigationMode == ActionBar.NAVIGATION_MODE_LIST) {
        mSpinner.setVisibility(VISIBLE);
    }
    if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
        mCustomNavView.setVisibility(VISIBLE);
    }
    mExpandedHomeLayout.setIcon(null);
    mCurrentExpandedItem = null;
    requestLayout();
    item.setActionViewExpanded(false);

    return true;
}
 
Example 2
Source File: ActionBarView.java    From android-apps with MIT License 5 votes vote down vote up
@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);
    mExpandedActionView = null;
    if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0) {
        mHomeLayout.setVisibility(VISIBLE);
    }
    if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
        if (mTitleLayout == null) {
            initTitle();
        } else {
            mTitleLayout.setVisibility(VISIBLE);
        }
    }
    if (mTabScrollView != null && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) {
        mTabScrollView.setVisibility(VISIBLE);
    }
    if (mSpinner != null && mNavigationMode == ActionBar.NAVIGATION_MODE_LIST) {
        mSpinner.setVisibility(VISIBLE);
    }
    if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
        mCustomNavView.setVisibility(VISIBLE);
    }
    mExpandedHomeLayout.setIcon(null);
    mCurrentExpandedItem = null;
    requestLayout();
    item.setActionViewExpanded(false);

    return true;
}
 
Example 3
Source File: ActionBarView.java    From zen4android with MIT License 5 votes vote down vote up
@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);
    mExpandedActionView = null;
    if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0) {
        mHomeLayout.setVisibility(VISIBLE);
    }
    if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
        if (mTitleLayout == null) {
            initTitle();
        } else {
            mTitleLayout.setVisibility(VISIBLE);
        }
    }
    if (mTabScrollView != null && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) {
        mTabScrollView.setVisibility(VISIBLE);
    }
    if (mSpinner != null && mNavigationMode == ActionBar.NAVIGATION_MODE_LIST) {
        mSpinner.setVisibility(VISIBLE);
    }
    if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
        mCustomNavView.setVisibility(VISIBLE);
    }
    mExpandedHomeLayout.setIcon(null);
    mCurrentExpandedItem = null;
    requestLayout();
    item.setActionViewExpanded(false);

    return true;
}
 
Example 4
Source File: ActionBarView.java    From zhangshangwuda with Apache License 2.0 5 votes vote down vote up
@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);
    mExpandedActionView = null;
    if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0) {
        mHomeLayout.setVisibility(VISIBLE);
    }
    if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
        if (mTitleLayout == null) {
            initTitle();
        } else {
            mTitleLayout.setVisibility(VISIBLE);
        }
    }
    if (mTabScrollView != null && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) {
        mTabScrollView.setVisibility(VISIBLE);
    }
    if (mSpinner != null && mNavigationMode == ActionBar.NAVIGATION_MODE_LIST) {
        mSpinner.setVisibility(VISIBLE);
    }
    if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
        mCustomNavView.setVisibility(VISIBLE);
    }
    mExpandedHomeLayout.setIcon(null);
    mCurrentExpandedItem = null;
    requestLayout();
    item.setActionViewExpanded(false);

    return true;
}
 
Example 5
Source File: ActionBarView.java    From Libraries-for-Android-Developers with MIT License 5 votes vote down vote up
@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);
    mExpandedActionView = null;
    if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0) {
        mHomeLayout.setVisibility(VISIBLE);
    }
    if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
        if (mTitleLayout == null) {
            initTitle();
        } else {
            mTitleLayout.setVisibility(VISIBLE);
        }
    }
    if (mTabScrollView != null && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) {
        mTabScrollView.setVisibility(VISIBLE);
    }
    if (mSpinner != null && mNavigationMode == ActionBar.NAVIGATION_MODE_LIST) {
        mSpinner.setVisibility(VISIBLE);
    }
    if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
        mCustomNavView.setVisibility(VISIBLE);
    }
    mExpandedHomeLayout.setIcon(null);
    mCurrentExpandedItem = null;
    requestLayout();
    item.setActionViewExpanded(false);

    return true;
}
 
Example 6
Source File: ActionBarContainer.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);

    final boolean hasTabs = mTabContainer != null && mTabContainer.getVisibility() != GONE;

    if (mTabContainer != null && mTabContainer.getVisibility() != GONE) {
        final int containerHeight = getMeasuredHeight();
        final int tabHeight = mTabContainer.getMeasuredHeight();

        if ((mActionBarView.getDisplayOptions() & ActionBar.DISPLAY_SHOW_HOME) == 0) {
            // Not showing home, put tabs on top.
            final int count = getChildCount();
            for (int i = 0; i < count; i++) {
                final View child = getChildAt(i);

                if (child == mTabContainer) continue;

                if (!mActionBarView.isCollapsed()) {
                    child.offsetTopAndBottom(tabHeight);
                }
            }
            mTabContainer.layout(l, 0, r, tabHeight);
        } else {
            mTabContainer.layout(l, containerHeight - tabHeight, r, containerHeight);
        }
    }

    boolean needsInvalidate = false;
    if (mIsSplit) {
        if (mSplitBackground != null) {
            mSplitBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
            needsInvalidate = true;
        }
    } else {
        if (mBackground != null) {
            mBackground.setBounds(mActionBarView.getLeft(), mActionBarView.getTop(),
                    mActionBarView.getRight(), mActionBarView.getBottom());
            needsInvalidate = true;
        }
        if ((mIsStacked = hasTabs && mStackedBackground != null)) {
            mStackedBackground.setBounds(mTabContainer.getLeft(), mTabContainer.getTop(),
                    mTabContainer.getRight(), mTabContainer.getBottom());
            needsInvalidate = true;
        }
    }

    if (needsInvalidate) {
        invalidate();
    }
}
 
Example 7
Source File: ActionBarView.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
public void setDisplayOptions(int options) {
    final int flagsChanged = mDisplayOptions == -1 ? -1 : options ^ mDisplayOptions;
    mDisplayOptions = options;

    if ((flagsChanged & DISPLAY_RELAYOUT_MASK) != 0) {
        final boolean showHome = (options & ActionBar.DISPLAY_SHOW_HOME) != 0;
        final int vis = showHome && mExpandedActionView == null ? VISIBLE : GONE;
        mHomeLayout.setVisibility(vis);

        if ((flagsChanged & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
            final boolean setUp = (options & ActionBar.DISPLAY_HOME_AS_UP) != 0;
            mHomeLayout.setUp(setUp);

            // Showing home as up implicitly enables interaction with it.
            // In honeycomb it was always enabled, so make this transition
            // a bit easier for developers in the common case.
            // (It would be silly to show it as up without responding to it.)
            if (setUp) {
                setHomeButtonEnabled(true);
            }
        }

        if ((flagsChanged & ActionBar.DISPLAY_USE_LOGO) != 0) {
            final boolean logoVis = mLogo != null && (options & ActionBar.DISPLAY_USE_LOGO) != 0;
            mHomeLayout.setIcon(logoVis ? mLogo : mIcon);
        }

        if ((flagsChanged & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
            if ((options & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
                initTitle();
            } else {
                removeView(mTitleLayout);
            }
        }

        if (mTitleLayout != null && (flagsChanged &
                (ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME)) != 0) {
            final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0;
            mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE);
            mTitleLayout.setEnabled(!showHome && homeAsUp);
        }

        if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) {
            if ((options & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
                addView(mCustomNavView);
            } else {
                removeView(mCustomNavView);
            }
        }

        requestLayout();
    } else {
        invalidate();
    }

    // Make sure the home button has an accurate content description for accessibility.
    if (!mHomeLayout.isEnabled()) {
        mHomeLayout.setContentDescription(null);
    } else if ((options & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
        mHomeLayout.setContentDescription(mContext.getResources().getText(
                R.string.abs__action_bar_up_description));
    } else {
        mHomeLayout.setContentDescription(mContext.getResources().getText(
                R.string.abs__action_bar_home_description));
    }
}
 
Example 8
Source File: ActionBarContainer.java    From android-apps with MIT License 4 votes vote down vote up
@Override
public void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);

    final boolean hasTabs = mTabContainer != null && mTabContainer.getVisibility() != GONE;

    if (mTabContainer != null && mTabContainer.getVisibility() != GONE) {
        final int containerHeight = getMeasuredHeight();
        final int tabHeight = mTabContainer.getMeasuredHeight();

        if ((mActionBarView.getDisplayOptions() & ActionBar.DISPLAY_SHOW_HOME) == 0) {
            // Not showing home, put tabs on top.
            final int count = getChildCount();
            for (int i = 0; i < count; i++) {
                final View child = getChildAt(i);

                if (child == mTabContainer) continue;

                if (!mActionBarView.isCollapsed()) {
                    child.offsetTopAndBottom(tabHeight);
                }
            }
            mTabContainer.layout(l, 0, r, tabHeight);
        } else {
            mTabContainer.layout(l, containerHeight - tabHeight, r, containerHeight);
        }
    }

    boolean needsInvalidate = false;
    if (mIsSplit) {
        if (mSplitBackground != null) {
            mSplitBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
            needsInvalidate = true;
        }
    } else {
        if (mBackground != null) {
            mBackground.setBounds(mActionBarView.getLeft(), mActionBarView.getTop(),
                    mActionBarView.getRight(), mActionBarView.getBottom());
            needsInvalidate = true;
        }
        if ((mIsStacked = hasTabs && mStackedBackground != null)) {
            mStackedBackground.setBounds(mTabContainer.getLeft(), mTabContainer.getTop(),
                    mTabContainer.getRight(), mTabContainer.getBottom());
            needsInvalidate = true;
        }
    }

    if (needsInvalidate) {
        invalidate();
    }
}
 
Example 9
Source File: ActionBarView.java    From android-apps with MIT License 4 votes vote down vote up
public void setDisplayOptions(int options) {
    final int flagsChanged = mDisplayOptions == -1 ? -1 : options ^ mDisplayOptions;
    mDisplayOptions = options;

    if ((flagsChanged & DISPLAY_RELAYOUT_MASK) != 0) {
        final boolean showHome = (options & ActionBar.DISPLAY_SHOW_HOME) != 0;
        final int vis = showHome && mExpandedActionView == null ? VISIBLE : GONE;
        mHomeLayout.setVisibility(vis);

        if ((flagsChanged & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
            final boolean setUp = (options & ActionBar.DISPLAY_HOME_AS_UP) != 0;
            mHomeLayout.setUp(setUp);

            // Showing home as up implicitly enables interaction with it.
            // In honeycomb it was always enabled, so make this transition
            // a bit easier for developers in the common case.
            // (It would be silly to show it as up without responding to it.)
            if (setUp) {
                setHomeButtonEnabled(true);
            }
        }

        if ((flagsChanged & ActionBar.DISPLAY_USE_LOGO) != 0) {
            final boolean logoVis = mLogo != null && (options & ActionBar.DISPLAY_USE_LOGO) != 0;
            mHomeLayout.setIcon(logoVis ? mLogo : mIcon);
        }

        if ((flagsChanged & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
            if ((options & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
                initTitle();
            } else {
                removeView(mTitleLayout);
            }
        }

        if (mTitleLayout != null && (flagsChanged &
                (ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME)) != 0) {
            final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0;
            mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE);
            mTitleLayout.setEnabled(!showHome && homeAsUp);
        }

        if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) {
            if ((options & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
                addView(mCustomNavView);
            } else {
                removeView(mCustomNavView);
            }
        }

        requestLayout();
    } else {
        invalidate();
    }

    // Make sure the home button has an accurate content description for accessibility.
    if (!mHomeLayout.isEnabled()) {
        mHomeLayout.setContentDescription(null);
    } else if ((options & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
        mHomeLayout.setContentDescription(mContext.getResources().getText(
                R.string.abs__action_bar_up_description));
    } else {
        mHomeLayout.setContentDescription(mContext.getResources().getText(
                R.string.abs__action_bar_home_description));
    }
}
 
Example 10
Source File: ActionBarContainer.java    From zen4android with MIT License 4 votes vote down vote up
@Override
public void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);

    final boolean hasTabs = mTabContainer != null && mTabContainer.getVisibility() != GONE;

    if (mTabContainer != null && mTabContainer.getVisibility() != GONE) {
        final int containerHeight = getMeasuredHeight();
        final int tabHeight = mTabContainer.getMeasuredHeight();

        if ((mActionBarView.getDisplayOptions() & ActionBar.DISPLAY_SHOW_HOME) == 0) {
            // Not showing home, put tabs on top.
            final int count = getChildCount();
            for (int i = 0; i < count; i++) {
                final View child = getChildAt(i);

                if (child == mTabContainer) continue;

                if (!mActionBarView.isCollapsed()) {
                    child.offsetTopAndBottom(tabHeight);
                }
            }
            mTabContainer.layout(l, 0, r, tabHeight);
        } else {
            mTabContainer.layout(l, containerHeight - tabHeight, r, containerHeight);
        }
    }

    boolean needsInvalidate = false;
    if (mIsSplit) {
        if (mSplitBackground != null) {
            mSplitBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
            needsInvalidate = true;
        }
    } else {
        if (mBackground != null) {
            mBackground.setBounds(mActionBarView.getLeft(), mActionBarView.getTop(),
                    mActionBarView.getRight(), mActionBarView.getBottom());
            needsInvalidate = true;
        }
        if ((mIsStacked = hasTabs && mStackedBackground != null)) {
            mStackedBackground.setBounds(mTabContainer.getLeft(), mTabContainer.getTop(),
                    mTabContainer.getRight(), mTabContainer.getBottom());
            needsInvalidate = true;
        }
    }

    if (needsInvalidate) {
        invalidate();
    }
}
 
Example 11
Source File: ActionBarView.java    From zen4android with MIT License 4 votes vote down vote up
public void setDisplayOptions(int options) {
    final int flagsChanged = mDisplayOptions == -1 ? -1 : options ^ mDisplayOptions;
    mDisplayOptions = options;

    if ((flagsChanged & DISPLAY_RELAYOUT_MASK) != 0) {
        final boolean showHome = (options & ActionBar.DISPLAY_SHOW_HOME) != 0;
        final int vis = showHome && mExpandedActionView == null ? VISIBLE : GONE;
        mHomeLayout.setVisibility(vis);

        if ((flagsChanged & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
            final boolean setUp = (options & ActionBar.DISPLAY_HOME_AS_UP) != 0;
            mHomeLayout.setUp(setUp);

            // Showing home as up implicitly enables interaction with it.
            // In honeycomb it was always enabled, so make this transition
            // a bit easier for developers in the common case.
            // (It would be silly to show it as up without responding to it.)
            if (setUp) {
                setHomeButtonEnabled(true);
            }
        }

        if ((flagsChanged & ActionBar.DISPLAY_USE_LOGO) != 0) {
            final boolean logoVis = mLogo != null && (options & ActionBar.DISPLAY_USE_LOGO) != 0;
            mHomeLayout.setIcon(logoVis ? mLogo : mIcon);
        }

        if ((flagsChanged & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
            if ((options & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
                initTitle();
            } else {
                removeView(mTitleLayout);
            }
        }

        if (mTitleLayout != null && (flagsChanged &
                (ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME)) != 0) {
            final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0;
            mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE);
            mTitleLayout.setEnabled(!showHome && homeAsUp);
        }

        if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) {
            if ((options & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
                addView(mCustomNavView);
            } else {
                removeView(mCustomNavView);
            }
        }

        requestLayout();
    } else {
        invalidate();
    }

    // Make sure the home button has an accurate content description for accessibility.
    if (!mHomeLayout.isEnabled()) {
        mHomeLayout.setContentDescription(null);
    } else if ((options & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
        mHomeLayout.setContentDescription(mContext.getResources().getText(
                R.string.abs__action_bar_up_description));
    } else {
        mHomeLayout.setContentDescription(mContext.getResources().getText(
                R.string.abs__action_bar_home_description));
    }
}
 
Example 12
Source File: ActionBarContainer.java    From zhangshangwuda with Apache License 2.0 4 votes vote down vote up
@Override
public void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);

    final boolean hasTabs = mTabContainer != null && mTabContainer.getVisibility() != GONE;

    if (mTabContainer != null && mTabContainer.getVisibility() != GONE) {
        final int containerHeight = getMeasuredHeight();
        final int tabHeight = mTabContainer.getMeasuredHeight();

        if ((mActionBarView.getDisplayOptions() & ActionBar.DISPLAY_SHOW_HOME) == 0) {
            // Not showing home, put tabs on top.
            final int count = getChildCount();
            for (int i = 0; i < count; i++) {
                final View child = getChildAt(i);

                if (child == mTabContainer) continue;

                if (!mActionBarView.isCollapsed()) {
                    child.offsetTopAndBottom(tabHeight);
                }
            }
            mTabContainer.layout(l, 0, r, tabHeight);
        } else {
            mTabContainer.layout(l, containerHeight - tabHeight, r, containerHeight);
        }
    }

    boolean needsInvalidate = false;
    if (mIsSplit) {
        if (mSplitBackground != null) {
            mSplitBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
            needsInvalidate = true;
        }
    } else {
        if (mBackground != null) {
            mBackground.setBounds(mActionBarView.getLeft(), mActionBarView.getTop(),
                    mActionBarView.getRight(), mActionBarView.getBottom());
            needsInvalidate = true;
        }
        if ((mIsStacked = hasTabs && mStackedBackground != null)) {
            mStackedBackground.setBounds(mTabContainer.getLeft(), mTabContainer.getTop(),
                    mTabContainer.getRight(), mTabContainer.getBottom());
            needsInvalidate = true;
        }
    }

    if (needsInvalidate) {
        invalidate();
    }
}
 
Example 13
Source File: ActionBarView.java    From zhangshangwuda with Apache License 2.0 4 votes vote down vote up
public void setDisplayOptions(int options) {
    final int flagsChanged = mDisplayOptions == -1 ? -1 : options ^ mDisplayOptions;
    mDisplayOptions = options;

    if ((flagsChanged & DISPLAY_RELAYOUT_MASK) != 0) {
        final boolean showHome = (options & ActionBar.DISPLAY_SHOW_HOME) != 0;
        final int vis = showHome && mExpandedActionView == null ? VISIBLE : GONE;
        mHomeLayout.setVisibility(vis);

        if ((flagsChanged & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
            final boolean setUp = (options & ActionBar.DISPLAY_HOME_AS_UP) != 0;
            mHomeLayout.setUp(setUp);

            // Showing home as up implicitly enables interaction with it.
            // In honeycomb it was always enabled, so make this transition
            // a bit easier for developers in the common case.
            // (It would be silly to show it as up without responding to it.)
            if (setUp) {
                setHomeButtonEnabled(true);
            }
        }

        if ((flagsChanged & ActionBar.DISPLAY_USE_LOGO) != 0) {
            final boolean logoVis = mLogo != null && (options & ActionBar.DISPLAY_USE_LOGO) != 0;
            mHomeLayout.setIcon(logoVis ? mLogo : mIcon);
        }

        if ((flagsChanged & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
            if ((options & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
                initTitle();
            } else {
                removeView(mTitleLayout);
            }
        }

        if (mTitleLayout != null && (flagsChanged &
                (ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME)) != 0) {
            final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0;
            mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE);
            mTitleLayout.setEnabled(!showHome && homeAsUp);
        }

        if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) {
            if ((options & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
                addView(mCustomNavView);
            } else {
                removeView(mCustomNavView);
            }
        }

        requestLayout();
    } else {
        invalidate();
    }

    // Make sure the home button has an accurate content description for accessibility.
    if (!mHomeLayout.isEnabled()) {
        mHomeLayout.setContentDescription(null);
    } else if ((options & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
        mHomeLayout.setContentDescription(mContext.getResources().getText(
                R.string.abs__action_bar_up_description));
    } else {
        mHomeLayout.setContentDescription(mContext.getResources().getText(
                R.string.abs__action_bar_home_description));
    }
}
 
Example 14
Source File: ActionBarContainer.java    From Libraries-for-Android-Developers with MIT License 4 votes vote down vote up
@Override
public void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);

    final boolean hasTabs = mTabContainer != null && mTabContainer.getVisibility() != GONE;

    if (mTabContainer != null && mTabContainer.getVisibility() != GONE) {
        final int containerHeight = getMeasuredHeight();
        final int tabHeight = mTabContainer.getMeasuredHeight();

        if ((mActionBarView.getDisplayOptions() & ActionBar.DISPLAY_SHOW_HOME) == 0) {
            // Not showing home, put tabs on top.
            final int count = getChildCount();
            for (int i = 0; i < count; i++) {
                final View child = getChildAt(i);

                if (child == mTabContainer) continue;

                if (!mActionBarView.isCollapsed()) {
                    child.offsetTopAndBottom(tabHeight);
                }
            }
            mTabContainer.layout(l, 0, r, tabHeight);
        } else {
            mTabContainer.layout(l, containerHeight - tabHeight, r, containerHeight);
        }
    }

    boolean needsInvalidate = false;
    if (mIsSplit) {
        if (mSplitBackground != null) {
            mSplitBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
            needsInvalidate = true;
        }
    } else {
        if (mBackground != null) {
            mBackground.setBounds(mActionBarView.getLeft(), mActionBarView.getTop(),
                    mActionBarView.getRight(), mActionBarView.getBottom());
            needsInvalidate = true;
        }
        if ((mIsStacked = hasTabs && mStackedBackground != null)) {
            mStackedBackground.setBounds(mTabContainer.getLeft(), mTabContainer.getTop(),
                    mTabContainer.getRight(), mTabContainer.getBottom());
            needsInvalidate = true;
        }
    }

    if (needsInvalidate) {
        invalidate();
    }
}
 
Example 15
Source File: ActionBarView.java    From Libraries-for-Android-Developers with MIT License 4 votes vote down vote up
public void setDisplayOptions(int options) {
    final int flagsChanged = mDisplayOptions == -1 ? -1 : options ^ mDisplayOptions;
    mDisplayOptions = options;

    if ((flagsChanged & DISPLAY_RELAYOUT_MASK) != 0) {
        final boolean showHome = (options & ActionBar.DISPLAY_SHOW_HOME) != 0;
        final int vis = showHome && mExpandedActionView == null ? VISIBLE : GONE;
        mHomeLayout.setVisibility(vis);

        if ((flagsChanged & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
            final boolean setUp = (options & ActionBar.DISPLAY_HOME_AS_UP) != 0;
            mHomeLayout.setUp(setUp);

            // Showing home as up implicitly enables interaction with it.
            // In honeycomb it was always enabled, so make this transition
            // a bit easier for developers in the common case.
            // (It would be silly to show it as up without responding to it.)
            if (setUp) {
                setHomeButtonEnabled(true);
            }
        }

        if ((flagsChanged & ActionBar.DISPLAY_USE_LOGO) != 0) {
            final boolean logoVis = mLogo != null && (options & ActionBar.DISPLAY_USE_LOGO) != 0;
            mHomeLayout.setIcon(logoVis ? mLogo : mIcon);
        }

        if ((flagsChanged & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
            if ((options & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
                initTitle();
            } else {
                removeView(mTitleLayout);
            }
        }

        if (mTitleLayout != null && (flagsChanged &
                (ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME)) != 0) {
            final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0;
            mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE);
            mTitleLayout.setEnabled(!showHome && homeAsUp);
        }

        if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) {
            if ((options & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
                addView(mCustomNavView);
            } else {
                removeView(mCustomNavView);
            }
        }

        requestLayout();
    } else {
        invalidate();
    }

    // Make sure the home button has an accurate content description for accessibility.
    if (!mHomeLayout.isEnabled()) {
        mHomeLayout.setContentDescription(null);
    } else if ((options & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
        mHomeLayout.setContentDescription(mContext.getResources().getText(
                R.string.abs__action_bar_up_description));
    } else {
        mHomeLayout.setContentDescription(mContext.getResources().getText(
                R.string.abs__action_bar_home_description));
    }
}