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:com.tencent.tws.assistant.support.v4.app.TwsFragmentActivity.java

/**
 * @hide/*from   ww  w. j ava  2  s  . c  o  m*/
 */
protected boolean onPrepareOptionsPanel(View view, Menu menu) {
    return super.onPreparePanel(Window.FEATURE_OPTIONS_PANEL, view, menu);
}

From source file:lewa.support.v7.app.ActionBarActivityDelegateBase.java

@Override
public View onCreatePanelView(int featureId) {
    View createdPanelView = null;
    if (featureId == Window.FEATURE_OPTIONS_PANEL) {
        boolean show = true;
        MenuBuilder menu = mMenu;//from   w ww  . ja va2  s .  c  o  m
        if (mActionMode == null) {
            // We only want to dispatch Activity/Fragment menu calls if there isn't
            // currently an action mode

            if (menu == null) {
                // We don't have a menu created, so create one
                menu = createMenu();
                setMenu(menu);

                // Make sure we're not dispatching item changes to presenters
                menu.stopDispatchingItemsChanged();
                // Dispatch onCreateOptionsMenu
                show = mActivity.superOnCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, menu);
            }
            if (show) {
                // Make sure we're not dispatching item changes to presenters
                menu.stopDispatchingItemsChanged();
                // Dispatch onPrepareOptionsMenu
                show = mActivity.superOnPreparePanel(Window.FEATURE_OPTIONS_PANEL, null, menu);
            }
        }

        if (show) {

            createdPanelView = (View) getListMenuView(mActivity, this);
            //createdPanelView = mActionBarView.mOptionalMenuState.shownPanelView;
            // Allow menu to start dispatching changes to presenters
            menu.startDispatchingItemsChanged();
        } else {
            // If the menu isn't being shown, we no longer need it
            setMenu(null);
        }
    }

    return createdPanelView;
}

From source file:lewa.support.v7.app.ActionBarActivityDelegateBase.java

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    if (featureId == Window.FEATURE_OPTIONS_PANEL) {
        item = MenuWrapperFactory.createMenuItemWrapper(item);
    }/*from w w  w .  j  a  va 2s.com*/
    if (mActionBarView != null && mActionBarView.getSplitView() != null) {
        mSplitView = (LewaActionBarContainer) (mActionBarView.getSplitView());
        if (mSplitView.isActionOptionMenuVisible()) {
            //                mSplitView.setActionOptionMenuVisibility(false);
            mSplitView.setActionOptionMenuVisibility(false, true, 80);
        }
    }
    return mActivity.superOnMenuItemSelected(featureId, item);
}

From source file:com.actionbarsherlock.ActionBarSherlock.java

/**
 * Internal method to trigger the menu creation process.
 *
 * @return {@code true} if menu creation should proceed.
 *///from  w  ww  . j  a  v  a 2 s. c o m
protected final boolean callbackCreateOptionsMenu(Menu menu) {
    if (DEBUG)
        Log.d(TAG, "[callbackCreateOptionsMenu] menu: " + menu);

    boolean result = true;
    if (mActivity instanceof OnCreatePanelMenuListener) {
        OnCreatePanelMenuListener listener = (OnCreatePanelMenuListener) mActivity;
        result = listener.onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, menu);
    } else if (mActivity instanceof OnCreateOptionsMenuListener) {
        OnCreateOptionsMenuListener listener = (OnCreateOptionsMenuListener) mActivity;
        result = listener.onCreateOptionsMenu(menu);
    }

    if (DEBUG)
        Log.d(TAG, "[callbackCreateOptionsMenu] returning " + result);
    return result;
}

From source file:com.actionbarsherlock.ActionBarSherlock.java

/**
 * Internal method to trigger the menu preparation process.
 *
 * @return {@code true} if menu preparation should proceed.
 *///from w ww .ja va  2s . co  m
protected final boolean callbackPrepareOptionsMenu(Menu menu) {
    if (DEBUG)
        Log.d(TAG, "[callbackPrepareOptionsMenu] menu: " + menu);

    boolean result = true;
    if (mActivity instanceof OnPreparePanelListener) {
        OnPreparePanelListener listener = (OnPreparePanelListener) mActivity;
        result = listener.onPreparePanel(Window.FEATURE_OPTIONS_PANEL, null, menu);
    } else if (mActivity instanceof OnPrepareOptionsMenuListener) {
        OnPrepareOptionsMenuListener listener = (OnPrepareOptionsMenuListener) mActivity;
        result = listener.onPrepareOptionsMenu(menu);
    }

    if (DEBUG)
        Log.d(TAG, "[callbackPrepareOptionsMenu] returning " + result);
    return result;
}

From source file:com.actionbarsherlock.ActionBarSherlock.java

/**
 * Internal method for dispatching options menu selection to the owning
 * activity callback./*from w  ww  .j av a2 s. c  om*/
 *
 * @param item Selected options menu item.
 * @return {@code true} if the item selection was handled in the callback.
 */
protected final boolean callbackOptionsItemSelected(MenuItem item) {
    if (DEBUG)
        Log.d(TAG, "[callbackOptionsItemSelected] item: " + item.getTitleCondensed());

    boolean result = false;
    if (mActivity instanceof OnMenuItemSelectedListener) {
        OnMenuItemSelectedListener listener = (OnMenuItemSelectedListener) mActivity;
        result = listener.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item);
    } else if (mActivity instanceof OnOptionsItemSelectedListener) {
        OnOptionsItemSelectedListener listener = (OnOptionsItemSelectedListener) mActivity;
        result = listener.onOptionsItemSelected(item);
    }

    if (DEBUG)
        Log.d(TAG, "[callbackOptionsItemSelected] returning " + result);
    return result;
}

From source file:lewa.support.v7.app.ActionBarActivityDelegateBase.java

@Override
boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_MENU: {
        // LEWA MODIFY BEGIN
        if (true && mActionBar != null && mActionMode != null) {// action mode 
            mActionModeView.toggleActionModeOptionMenu();
        } else if (true && mActionBar != null) {
            //refresh menu
            if (splitActionBarView != null && mActivity != null) {
                LinearLayout splitView = splitActionBarView.getActionOptionMenuBar();
                if (splitView != null && splitView.getVisibility() != View.VISIBLE) {

                    //                  mActivity.invalidateOptionsMenu();

                    if (!mInvalidateMenuPosted) {
                        mInvalidateMenuPosted = true;
                        final MenuBuilder menu = createMenu();
                        if (mActivity.superOnCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, menu)
                                && mActivity.superOnPreparePanel(Window.FEATURE_OPTIONS_PANEL, null, menu)) {
                            setMenu(menu);
                        } else {
                            setMenu(null);
                        }/* www. j a  v a2  s .c  om*/
                        //                        updateActionMenuCount(splitActionBarView, mMenu);
                        mInvalidateMenuPosted = false;
                    } else {
                        return true;
                    }

                    //                   final MenuBuilder menu = createMenu();
                    //                  if (mMenu != null) {
                    //                      if (mActivity.superOnPreparePanel(Window.FEATURE_OPTIONS_PANEL, null, mMenu)) {
                    //                           
                    //                               setMenu(mMenu);
                    //                           } else {
                    //      
                    //                               setMenu(null);
                    //                           }
                    //                           updateActionMenuCount(splitActionBarView, mMenu);
                    //                  } 

                }
            }

            mActionBarView.toggleActionOptionMenu();

        }
        // LEWA MODIFY END

        return true;
    }
    }
    return false;
}

From source file:android.support.v7.app.AppCompatDelegateImplV7.java

boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_MENU:
        onKeyUpPanel(Window.FEATURE_OPTIONS_PANEL, event);
        return true;
    case KeyEvent.KEYCODE_BACK:
        PanelFeatureState st = getPanelState(Window.FEATURE_OPTIONS_PANEL, false);
        if (st != null && st.isOpen) {
            closePanel(st, true);/* ww  w  . jav a  2  s  .c o m*/
            return true;
        }
        if (onBackPressed()) {
            return true;
        }
        break;
    }
    return false;
}

From source file:android.support.v7.app.AppCompatDelegateImplV7.java

boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_MENU:
        onKeyDownPanel(Window.FEATURE_OPTIONS_PANEL, event);
        return true;
    }//from   ww w.j av a  2 s . c o  m

    // On API v7-10 we need to manually call onKeyShortcut() as this is not called
    // from the Activity
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        return onKeyShortcut(keyCode, event);
    }
    return false;
}

From source file:android.support.v7ox.app.AppCompatDelegateImplV7.java

boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_MENU:
        onKeyUpPanel(Window.FEATURE_OPTIONS_PANEL, event);
        return true;
    case KeyEvent.KEYCODE_BACK:
        final boolean wasLongPressBackDown = mLongPressBackDown;
        mLongPressBackDown = false;//  w w  w .j ava  2  s.  com

        PanelFeatureState st = getPanelState(Window.FEATURE_OPTIONS_PANEL, false);
        if (st != null && st.isOpen) {
            if (!wasLongPressBackDown) {
                // Certain devices allow opening the options menu via a long press of the
                // back button. We should only close the open options menu if it wasn't
                // opened via a long press gesture.
                closePanel(st, true);
            }
            return true;
        }
        if (onBackPressed()) {
            return true;
        }
        break;
    }
    return false;
}