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.v7ox.app.AppCompatDelegateImplV7.java

boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_MENU:
        onKeyDownPanel(Window.FEATURE_OPTIONS_PANEL, event);
        // We need to return true here and not let it bubble up to the Window.
        // For empty menus, PhoneWindow's KEYCODE_BACK handling will steals all events,
        // not allowing the Activity to call onBackPressed().
        return true;
    case KeyEvent.KEYCODE_BACK:
        // Certain devices allow opening the options menu via a long press of the back
        // button. We keep a record of whether the last event is from a long press.
        mLongPressBackDown = (event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0;
        break;/*from   w w  w  .  j a v  a2s.  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) {
        // We do not return true here otherwise dispatchKeyEvent will not reach the Activity
        // (which results in the back button not working)
        onKeyShortcut(keyCode, event);
    }
    return false;
}

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

private void doInvalidatePanelMenu(int featureId) {
    PanelFeatureState st = getPanelState(featureId, true);
    Bundle savedActionViewStates = null;
    if (st.menu != null) {
        savedActionViewStates = new Bundle();
        st.menu.saveActionViewStates(savedActionViewStates);
        if (savedActionViewStates.size() > 0) {
            st.frozenActionViewState = savedActionViewStates;
        }/*w w  w.  j  a  va  2 s  . c om*/
        // This will be started again when the panel is prepared.
        st.menu.stopDispatchingItemsChanged();
        st.menu.clear();
    }
    st.refreshMenuContent = true;
    st.refreshDecorView = true;

    // Prepare the options panel if we have an action bar
    if ((featureId == FEATURE_ACTION_BAR || featureId == FEATURE_OPTIONS_PANEL)
            && mDecorContentParent != null) {
        st = getPanelState(Window.FEATURE_OPTIONS_PANEL, false);
        if (st != null) {
            st.isPrepared = false;
            preparePanel(st, null);
        }
    }
}

From source file:org.mozilla.gecko.BrowserApp.java

@Override
protected void initializeChrome() {
    super.initializeChrome();

    mDoorHangerPopup.setAnchor(mBrowserToolbar.getDoorHangerAnchor());
    mDoorHangerPopup.setOnVisibilityChangeListener(this);

    mDynamicToolbar.setLayerView(mLayerView);
    setDynamicToolbarEnabled(mDynamicToolbar.isEnabled());

    // Intercept key events for gamepad shortcuts
    mLayerView.setOnKeyListener(this);

    // Initialize the actionbar menu items on startup for both large and small tablets
    if (HardwareUtils.isTablet()) {
        onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, null);
        invalidateOptionsMenu();/*from   ww  w .j a  v  a  2  s . c om*/
    }
}

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

private void doInvalidatePanelMenu(int featureId) {
    PanelFeatureState st = getPanelState(featureId, true);
    Bundle savedActionViewStates = null;
    if (st.menu != null) {
        savedActionViewStates = new Bundle();
        st.menu.saveActionViewStates(savedActionViewStates);
        if (savedActionViewStates.size() > 0) {
            st.frozenActionViewState = savedActionViewStates;
        }/*  w ww . ja v a 2 s. com*/
        // This will be started again when the panel is prepared.
        st.menu.stopDispatchingItemsChanged();
        st.menu.clear();
    }
    st.refreshMenuContent = true;
    st.refreshDecorView = true;

    // Prepare the options panel if we have an action bar
    if ((featureId == FEATURE_SUPPORT_ACTION_BAR || featureId == FEATURE_OPTIONS_PANEL)
            && mDecorContentParent != null) {
        st = getPanelState(Window.FEATURE_OPTIONS_PANEL, false);
        if (st != null) {
            st.isPrepared = false;
            preparePanel(st, null);
        }
    }
}

From source file:org.catrobat.catroid.uitest.util.UiTestUtils.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void clickOnHomeActionBarButton(Solo solo) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
        Activity activity = solo.getCurrentActivity();

        ActionMenuItem logoNavItem = new ActionMenuItem(activity, 0, android.R.id.home, 0, 0, "");
        ActionBarSherlockCompat actionBarSherlockCompat = (ActionBarSherlockCompat) Reflection
                .invokeMethod(SherlockFragmentActivity.class, activity, "getSherlock");
        actionBarSherlockCompat.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, logoNavItem);
    } else {//  w w w.  j  av a 2s  .  c o m
        solo.clickOnActionBarHomeButton();
    }
}

From source file:android.app.Activity.java

/**
 * Called when a key was pressed down and not handled by any of the views
 * inside of the activity. So, for example, key presses while the cursor 
 * is inside a TextView will not trigger the event (unless it is a navigation
 * to another object) because TextView handles its own key presses.
 * //from  ww w .  ja  v a  2  s  .  co  m
 * <p>If the focused view didn't want this event, this method is called.
 *
 * <p>The default implementation takes care of {@link KeyEvent#KEYCODE_BACK}
 * by calling {@link #onBackPressed()}, though the behavior varies based
 * on the application compatibility mode: for
 * {@link android.os.Build.VERSION_CODES#ECLAIR} or later applications,
 * it will set up the dispatch to call {@link #onKeyUp} where the action
 * will be performed; for earlier applications, it will perform the
 * action immediately in on-down, as those versions of the platform
 * behaved.
 * 
 * <p>Other additional default key handling may be performed
 * if configured with {@link #setDefaultKeyMode}.
 * 
 * @return Return <code>true</code> to prevent this event from being propagated
 * further, or <code>false</code> to indicate that you have not handled 
 * this event and it should continue to be propagated.
 * @see #onKeyUp
 * @see android.view.KeyEvent
 */
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.ECLAIR) {
            event.startTracking();
        } else {
            onBackPressed();
        }
        return true;
    }

    if (mDefaultKeyMode == DEFAULT_KEYS_DISABLE) {
        return false;
    } else if (mDefaultKeyMode == DEFAULT_KEYS_SHORTCUT) {
        if (getWindow().performPanelShortcut(Window.FEATURE_OPTIONS_PANEL, keyCode, event,
                Menu.FLAG_ALWAYS_PERFORM_CLOSE)) {
            return true;
        }
        return false;
    } else {
        // Common code for DEFAULT_KEYS_DIALER & DEFAULT_KEYS_SEARCH_*
        boolean clearSpannable = false;
        boolean handled;
        if ((event.getRepeatCount() != 0) || event.isSystem()) {
            clearSpannable = true;
            handled = false;
        } else {
            handled = TextKeyListener.getInstance().onKeyDown(null, mDefaultKeySsb, keyCode, event);
            if (handled && mDefaultKeySsb.length() > 0) {
                // something useable has been typed - dispatch it now.

                final String str = mDefaultKeySsb.toString();
                clearSpannable = true;

                switch (mDefaultKeyMode) {
                case DEFAULT_KEYS_DIALER:
                    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + str));
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                    break;
                case DEFAULT_KEYS_SEARCH_LOCAL:
                    startSearch(str, false, null, false);
                    break;
                case DEFAULT_KEYS_SEARCH_GLOBAL:
                    startSearch(str, false, null, true);
                    break;
                }
            }
        }
        if (clearSpannable) {
            mDefaultKeySsb.clear();
            mDefaultKeySsb.clearSpans();
            Selection.setSelection(mDefaultKeySsb, 0);
        }
        return handled;
    }
}

From source file:android.app.Activity.java

/**
 * Default implementation of//from  w w  w. ja  v  a2 s.  c  om
 * {@link android.view.Window.Callback#onCreatePanelMenu}
 * for activities.  This calls through to the new
 * {@link #onCreateOptionsMenu} method for the
 * {@link android.view.Window#FEATURE_OPTIONS_PANEL} panel,
 * so that subclasses of Activity don't need to deal with feature codes.
 */
public boolean onCreatePanelMenu(int featureId, Menu menu) {
    if (featureId == Window.FEATURE_OPTIONS_PANEL) {
        boolean show = onCreateOptionsMenu(menu);
        show |= mFragments.dispatchCreateOptionsMenu(menu, getMenuInflater());
        return show;
    }
    return false;
}

From source file:android.app.Activity.java

/**
 * Default implementation of/*from  w  w w .  ja v a  2 s.  c om*/
 * {@link android.view.Window.Callback#onPreparePanel}
 * for activities.  This
 * calls through to the new {@link #onPrepareOptionsMenu} method for the
 * {@link android.view.Window#FEATURE_OPTIONS_PANEL}
 * panel, so that subclasses of
 * Activity don't need to deal with feature codes.
 */
public boolean onPreparePanel(int featureId, View view, Menu menu) {
    if (featureId == Window.FEATURE_OPTIONS_PANEL && menu != null) {
        boolean goforit = onPrepareOptionsMenu(menu);
        goforit |= mFragments.dispatchPrepareOptionsMenu(menu);
        return goforit;
    }
    return true;
}

From source file:android.app.Activity.java

/**
 * Default implementation of/* ww  w . j a  va2 s  . c o  m*/
 * {@link android.view.Window.Callback#onMenuItemSelected}
 * for activities.  This calls through to the new
 * {@link #onOptionsItemSelected} method for the
 * {@link android.view.Window#FEATURE_OPTIONS_PANEL}
 * panel, so that subclasses of
 * Activity don't need to deal with feature codes.
 */
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    CharSequence titleCondensed = item.getTitleCondensed();

    switch (featureId) {
    case Window.FEATURE_OPTIONS_PANEL:
        // Put event logging here so it gets called even if subclass
        // doesn't call through to superclass's implmeentation of each
        // of these methods below
        if (titleCondensed != null) {
            EventLog.writeEvent(50000, 0, titleCondensed.toString());
        }
        if (onOptionsItemSelected(item)) {
            return true;
        }
        if (mFragments.dispatchOptionsItemSelected(item)) {
            return true;
        }
        if (item.getItemId() == android.R.id.home && mActionBar != null
                && (mActionBar.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
            if (mParent == null) {
                return onNavigateUp();
            } else {
                return mParent.onNavigateUpFromChild(this);
            }
        }
        return false;

    case Window.FEATURE_CONTEXT_MENU:
        if (titleCondensed != null) {
            EventLog.writeEvent(50000, 1, titleCondensed.toString());
        }
        if (onContextItemSelected(item)) {
            return true;
        }
        return mFragments.dispatchContextItemSelected(item);

    default:
        return false;
    }
}

From source file:android.app.Activity.java

/**
 * Default implementation of//  www .j  a v  a2 s .co m
 * {@link android.view.Window.Callback#onPanelClosed(int, Menu)} for
 * activities. This calls through to {@link #onOptionsMenuClosed(Menu)}
 * method for the {@link android.view.Window#FEATURE_OPTIONS_PANEL} panel,
 * so that subclasses of Activity don't need to deal with feature codes.
 * For context menus ({@link Window#FEATURE_CONTEXT_MENU}), the
 * {@link #onContextMenuClosed(Menu)} will be called.
 */
public void onPanelClosed(int featureId, Menu menu) {
    switch (featureId) {
    case Window.FEATURE_OPTIONS_PANEL:
        mFragments.dispatchOptionsMenuClosed(menu);
        onOptionsMenuClosed(menu);
        break;

    case Window.FEATURE_CONTEXT_MENU:
        onContextMenuClosed(menu);
        break;

    case Window.FEATURE_ACTION_BAR:
        initActionBar();
        mActionBar.dispatchMenuVisibilityChanged(false);
        break;
    }
}