Example usage for android.view Window FEATURE_OPTIONS_PANEL

List of usage examples for android.view Window FEATURE_OPTIONS_PANEL

Introduction

In this page you can find the example usage for android.view Window FEATURE_OPTIONS_PANEL.

Prototype

int FEATURE_OPTIONS_PANEL

To view the source code for android.view Window FEATURE_OPTIONS_PANEL.

Click Source Link

Document

Flag for the "options panel" feature.

Usage

From source file:android.support.v4.app._ActionBarSherlockTrojanHorse.java

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    if (DEBUG)/* www.  j  a  v a2 s .c  o  m*/
        Log.d(TAG, "[onMenuItemSelected] featureId: " + featureId + ", item: " + item);

    if (featureId == Window.FEATURE_OPTIONS_PANEL) {
        if (onOptionsItemSelected(item)) {
            return true;
        }

        if (mFragments.mActive != null) {
            for (int i = 0; i < mFragments.mAdded.size(); i++) {
                Fragment f = mFragments.mAdded.get(i);
                if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible
                        && f instanceof OnOptionsItemSelectedListener) {
                    if (((OnOptionsItemSelectedListener) f).onOptionsItemSelected(item)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}

From source file:com.actionbarsherlock.app.SherlockActivity.java

@Override
public boolean onCreatePanelMenu(int featureId, Menu menu) {
    if (featureId == Window.FEATURE_OPTIONS_PANEL) {
        return onCreateOptionsMenu(menu);
    }/*from ww w  . ja  va 2  s .  c o m*/
    return false;
}

From source file:im.vector.activity.MXCActionBarActivity.java

@Override
public boolean onMenuOpened(int featureId, Menu menu) {
    // display the menu icon with the text
    if (((featureId == Window.FEATURE_ACTION_BAR) || ((featureId == Window.FEATURE_OPTIONS_PANEL)))
            && menu != null) {/*from  ww  w.ja  v a  2s.  c o m*/
        if (menu.getClass().getSimpleName().equals("MenuBuilder")) {
            try {
                Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE);
                m.setAccessible(true);
                m.invoke(menu, true);
            } catch (NoSuchMethodException e) {
                //Log.e(TAG, "onMenuOpened", e);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
    return super.onMenuOpened(featureId, menu);
}

From source file:com.actionbarsherlock.app.SherlockFragmentActivity.java

@Override
public final boolean onPreparePanel(int featureId, View view, android.view.Menu menu) {
    if (DEBUG)/*  w ww.  j  a va  2 s . c om*/
        Log.d(TAG, "[onPreparePanel] featureId: " + featureId + ", view: " + view + ", menu: " + menu);

    if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativePrepare) {
        mIgnoreNativePrepare = true;
        boolean result = getSherlock().dispatchPrepareOptionsMenu(menu);
        mIgnoreNativePrepare = false;

        if (DEBUG)
            Log.d(TAG, "[onPreparePanel] returning " + result);
        return result;
    }
    return super.onPreparePanel(featureId, view, menu);
}

From source file:com.actionbarsherlock.app.SherlockActivity.java

@Override
public boolean onPreparePanel(int featureId, View view, Menu menu) {
    if (featureId == Window.FEATURE_OPTIONS_PANEL) {
        return onPrepareOptionsMenu(menu);
    }/*  w ww. j av  a  2  s.  com*/
    return false;
}

From source file:com.actionbarsherlock.app.SherlockActivity.java

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    if (featureId == Window.FEATURE_OPTIONS_PANEL) {
        return onOptionsItemSelected(item);
    }/*ww  w .j a va 2s  .c o  m*/
    return false;
}

From source file:android.support.v7.widget.ToolbarWidgetWrapper.java

public ToolbarWidgetWrapper(Toolbar toolbar, boolean style, int defaultNavigationContentDescription,
        int defaultNavigationIcon) {
    mToolbar = toolbar;// www .ja  v  a2  s.  co  m
    mTitle = toolbar.getTitle();
    mSubtitle = toolbar.getSubtitle();
    mTitleSet = mTitle != null;
    mNavIcon = toolbar.getNavigationIcon();
    final TintTypedArray a = TintTypedArray.obtainStyledAttributes(toolbar.getContext(), null,
            R.styleable.ActionBar, R.attr.actionBarStyle, 0);
    mDefaultNavigationIcon = a.getDrawable(R.styleable.ActionBar_homeAsUpIndicator);
    if (style) {
        final CharSequence title = a.getText(R.styleable.ActionBar_title);
        if (!TextUtils.isEmpty(title)) {
            setTitle(title);
        }

        final CharSequence subtitle = a.getText(R.styleable.ActionBar_subtitle);
        if (!TextUtils.isEmpty(subtitle)) {
            setSubtitle(subtitle);
        }

        final Drawable logo = a.getDrawable(R.styleable.ActionBar_logo);
        if (logo != null) {
            setLogo(logo);
        }

        final Drawable icon = a.getDrawable(R.styleable.ActionBar_icon);
        if (icon != null) {
            setIcon(icon);
        }
        if (mNavIcon == null && mDefaultNavigationIcon != null) {
            setNavigationIcon(mDefaultNavigationIcon);
        }
        setDisplayOptions(a.getInt(R.styleable.ActionBar_displayOptions, 0));

        final int customNavId = a.getResourceId(R.styleable.ActionBar_customNavigationLayout, 0);
        if (customNavId != 0) {
            setCustomView(LayoutInflater.from(mToolbar.getContext()).inflate(customNavId, mToolbar, false));
            setDisplayOptions(mDisplayOpts | ActionBar.DISPLAY_SHOW_CUSTOM);
        }

        final int height = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
        if (height > 0) {
            final ViewGroup.LayoutParams lp = mToolbar.getLayoutParams();
            lp.height = height;
            mToolbar.setLayoutParams(lp);
        }

        final int contentInsetStart = a.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetStart, -1);
        final int contentInsetEnd = a.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetEnd, -1);
        if (contentInsetStart >= 0 || contentInsetEnd >= 0) {
            mToolbar.setContentInsetsRelative(Math.max(contentInsetStart, 0), Math.max(contentInsetEnd, 0));
        }

        final int titleTextStyle = a.getResourceId(R.styleable.ActionBar_titleTextStyle, 0);
        if (titleTextStyle != 0) {
            mToolbar.setTitleTextAppearance(mToolbar.getContext(), titleTextStyle);
        }

        final int subtitleTextStyle = a.getResourceId(R.styleable.ActionBar_subtitleTextStyle, 0);
        if (subtitleTextStyle != 0) {
            mToolbar.setSubtitleTextAppearance(mToolbar.getContext(), subtitleTextStyle);
        }

        final int popupTheme = a.getResourceId(R.styleable.ActionBar_popupTheme, 0);
        if (popupTheme != 0) {
            mToolbar.setPopupTheme(popupTheme);
        }
    } else {
        mDisplayOpts = detectDisplayOptions();
    }
    a.recycle();

    mDrawableManager = AppCompatDrawableManager.get();

    setDefaultNavigationContentDescription(defaultNavigationContentDescription);
    mHomeDescription = mToolbar.getNavigationContentDescription();

    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        final ActionMenuItem mNavItem = new ActionMenuItem(mToolbar.getContext(), 0, android.R.id.home, 0, 0,
                mTitle);

        @Override
        public void onClick(View v) {
            if (mWindowCallback != null && mMenuPrepared) {
                mWindowCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mNavItem);
            }
        }
    });
}

From source file:com.actionbarsherlock.app.SherlockFragmentActivity.java

@Override
public final boolean onMenuItemSelected(int featureId, android.view.MenuItem item) {
    if (DEBUG)//from w w  w . j  a  v  a 2s  . c  o  m
        Log.d(TAG, "[onMenuItemSelected] featureId: " + featureId + ", item: " + item);

    if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativeSelected) {
        mIgnoreNativeSelected = true;
        boolean result = getSherlock().dispatchOptionsItemSelected(item);
        mIgnoreNativeSelected = false;

        if (DEBUG)
            Log.d(TAG, "[onMenuItemSelected] returning " + result);
        return result;
    }
    return super.onMenuItemSelected(featureId, item);
}

From source file:android.support.v7.internal.widget.ToolbarWidgetWrapper.java

public ToolbarWidgetWrapper(Toolbar toolbar, boolean style, int defaultNavigationContentDescription,
        int defaultNavigationIcon) {
    mToolbar = toolbar;/*from   ww  w.  j  av a 2s .  c o  m*/
    mTitle = toolbar.getTitle();
    mSubtitle = toolbar.getSubtitle();
    mTitleSet = mTitle != null;
    mNavIcon = toolbar.getNavigationIcon();

    if (style) {
        final TintTypedArray a = TintTypedArray.obtainStyledAttributes(toolbar.getContext(), null,
                R.styleable.ActionBar, R.attr.actionBarStyle, 0);

        final CharSequence title = a.getText(R.styleable.ActionBar_title);
        if (!TextUtils.isEmpty(title)) {
            setTitle(title);
        }

        final CharSequence subtitle = a.getText(R.styleable.ActionBar_subtitle);
        if (!TextUtils.isEmpty(subtitle)) {
            setSubtitle(subtitle);
        }

        final Drawable logo = a.getDrawable(R.styleable.ActionBar_logo);
        if (logo != null) {
            setLogo(logo);
        }

        final Drawable icon = a.getDrawable(R.styleable.ActionBar_icon);
        if (mNavIcon == null && icon != null) {
            setIcon(icon);
        }

        final Drawable navIcon = a.getDrawable(R.styleable.ActionBar_homeAsUpIndicator);
        if (navIcon != null) {
            setNavigationIcon(navIcon);
        }

        setDisplayOptions(a.getInt(R.styleable.ActionBar_displayOptions, 0));

        final int customNavId = a.getResourceId(R.styleable.ActionBar_customNavigationLayout, 0);
        if (customNavId != 0) {
            setCustomView(LayoutInflater.from(mToolbar.getContext()).inflate(customNavId, mToolbar, false));
            setDisplayOptions(mDisplayOpts | ActionBar.DISPLAY_SHOW_CUSTOM);
        }

        final int height = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
        if (height > 0) {
            final ViewGroup.LayoutParams lp = mToolbar.getLayoutParams();
            lp.height = height;
            mToolbar.setLayoutParams(lp);
        }

        final int contentInsetStart = a.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetStart, -1);
        final int contentInsetEnd = a.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetEnd, -1);
        if (contentInsetStart >= 0 || contentInsetEnd >= 0) {
            mToolbar.setContentInsetsRelative(Math.max(contentInsetStart, 0), Math.max(contentInsetEnd, 0));
        }

        final int titleTextStyle = a.getResourceId(R.styleable.ActionBar_titleTextStyle, 0);
        if (titleTextStyle != 0) {
            mToolbar.setTitleTextAppearance(mToolbar.getContext(), titleTextStyle);
        }

        final int subtitleTextStyle = a.getResourceId(R.styleable.ActionBar_subtitleTextStyle, 0);
        if (subtitleTextStyle != 0) {
            mToolbar.setSubtitleTextAppearance(mToolbar.getContext(), subtitleTextStyle);
        }

        final int popupTheme = a.getResourceId(R.styleable.ActionBar_popupTheme, 0);
        if (popupTheme != 0) {
            mToolbar.setPopupTheme(popupTheme);
        }

        a.recycle();
        // Keep the TintManager in case we need it later
        mTintManager = a.getTintManager();
    } else {
        mDisplayOpts = detectDisplayOptions();
        // Create a TintManager in case we need it later
        mTintManager = new TintManager(toolbar.getContext());
    }

    setDefaultNavigationContentDescription(defaultNavigationContentDescription);
    mHomeDescription = mToolbar.getNavigationContentDescription();

    setDefaultNavigationIcon(mTintManager.getDrawable(defaultNavigationIcon));

    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        final ActionMenuItem mNavItem = new ActionMenuItem(mToolbar.getContext(), 0, android.R.id.home, 0, 0,
                mTitle);

        @Override
        public void onClick(View v) {
            if (mWindowCallback != null && mMenuPrepared) {
                mWindowCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mNavItem);
            }
        }
    });
}

From source file:android.support.v7ox.widget.ToolbarWidgetWrapper.java

public ToolbarWidgetWrapper(Toolbar toolbar, boolean style, int defaultNavigationContentDescription,
        int defaultNavigationIcon) {
    mToolbar = toolbar;/*  w  w w.  j  ava  2s  .c o m*/
    mTitle = toolbar.getTitle();
    mSubtitle = toolbar.getSubtitle();
    mTitleSet = mTitle != null;
    mNavIcon = toolbar.getNavigationIcon();

    if (style) {
        final TintTypedArray a = TintTypedArray.obtainStyledAttributes(toolbar.getContext(), null,
                R.styleable.ActionBar, R.attr.actionBarStyle_ox, 0);

        final CharSequence title = a.getText(R.styleable.ActionBar_title);
        if (!TextUtils.isEmpty(title)) {
            setTitle(title);
        }

        final CharSequence subtitle = a.getText(R.styleable.ActionBar_subtitle);
        if (!TextUtils.isEmpty(subtitle)) {
            setSubtitle(subtitle);
        }

        final Drawable logo = a.getDrawable(R.styleable.ActionBar_logo);
        if (logo != null) {
            setLogo(logo);
        }

        final Drawable icon = a.getDrawable(R.styleable.ActionBar_icon);
        if (mNavIcon == null && icon != null) {
            setIcon(icon);
        }

        final Drawable navIcon = a.getDrawable(R.styleable.ActionBar_homeAsUpIndicator_ox);
        if (navIcon != null) {
            setNavigationIcon(navIcon);
        }

        setDisplayOptions(a.getInt(R.styleable.ActionBar_displayOptions, 0));

        final int customNavId = a.getResourceId(R.styleable.ActionBar_customNavigationLayout, 0);
        if (customNavId != 0) {
            setCustomView(LayoutInflater.from(mToolbar.getContext()).inflate(customNavId, mToolbar, false));
            setDisplayOptions(mDisplayOpts | ActionBar.DISPLAY_SHOW_CUSTOM);
        }

        final int height = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
        if (height > 0) {
            final ViewGroup.LayoutParams lp = mToolbar.getLayoutParams();
            lp.height = height;
            mToolbar.setLayoutParams(lp);
        }

        final int contentInsetStart = a.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetStart, -1);
        final int contentInsetEnd = a.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetEnd, -1);
        if (contentInsetStart >= 0 || contentInsetEnd >= 0) {
            mToolbar.setContentInsetsRelative(Math.max(contentInsetStart, 0), Math.max(contentInsetEnd, 0));
        }

        final int titleTextStyle = a.getResourceId(R.styleable.ActionBar_titleTextStyle, 0);
        if (titleTextStyle != 0) {
            mToolbar.setTitleTextAppearance(mToolbar.getContext(), titleTextStyle);
        }

        final int subtitleTextStyle = a.getResourceId(R.styleable.ActionBar_subtitleTextStyle, 0);
        if (subtitleTextStyle != 0) {
            mToolbar.setSubtitleTextAppearance(mToolbar.getContext(), subtitleTextStyle);
        }

        final int popupTheme = a.getResourceId(R.styleable.ActionBar_popupTheme, 0);
        if (popupTheme != 0) {
            mToolbar.setPopupTheme(popupTheme);
        }

        a.recycle();
    } else {
        mDisplayOpts = detectDisplayOptions();
    }

    mDrawableManager = AppCompatDrawableManager.get();

    setDefaultNavigationContentDescription(defaultNavigationContentDescription);
    mHomeDescription = mToolbar.getNavigationContentDescription();

    setDefaultNavigationIcon(mDrawableManager.getDrawable(getContext(), defaultNavigationIcon));

    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        final ActionMenuItem mNavItem = new ActionMenuItem(mToolbar.getContext(), 0, android.R.id.home, 0, 0,
                mTitle);

        @Override
        public void onClick(View v) {
            if (mWindowCallback != null && mMenuPrepared) {
                mWindowCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mNavItem);
            }
        }
    });
}