Example usage for android.view Window FEATURE_ACTION_BAR

List of usage examples for android.view Window FEATURE_ACTION_BAR

Introduction

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

Prototype

int FEATURE_ACTION_BAR

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

Click Source Link

Document

Flag for enabling the Action Bar.

Usage

From source file:com.actionbarsherlock.internal.ActionBarSherlockCompat.java

@Override
public boolean requestFeature(int featureId) {
    if (DEBUG)/*w ww  .j  a v  a 2 s  . co  m*/
        Log.d(TAG, "[requestFeature] featureId: " + featureId);

    if (mContentParent != null) {
        throw new AndroidRuntimeException("requestFeature() must be called before adding content");
    }

    switch (featureId) {
    case Window.FEATURE_ACTION_BAR:
    case Window.FEATURE_ACTION_BAR_OVERLAY:
    case Window.FEATURE_ACTION_MODE_OVERLAY:
    case Window.FEATURE_INDETERMINATE_PROGRESS:
    case Window.FEATURE_NO_TITLE:
    case Window.FEATURE_PROGRESS:
        mFeatures |= (1 << featureId);
        return true;

    default:
        return false;
    }
}

From source file:cn.edu.zafu.corepage.base.BaseActivity.java

@Override
public boolean onMenuOpened(int featureId, Menu menu) {
    if (featureId == Window.FEATURE_ACTION_BAR && menu != null) {
        if (menu.getClass().getSimpleName().equals("MenuBuilder")) {
            try {
                Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE);
                m.setAccessible(true);/*from   w  w  w . j a v  a 2 s  .  c  om*/
                m.invoke(menu, true);
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
    return super.onMenuOpened(featureId, menu);
}

From source file:org.symptomcheck.capstone.ui.MainActivityOld.java

@Override
public boolean onMenuOpened(int featureId, Menu menu) {
    if (featureId == Window.FEATURE_ACTION_BAR && menu != null) {
        if (menu.getClass().getSimpleName().equals("MenuBuilder")) {
            try {
                Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE);
                m.setAccessible(true);/*from www  .jav  a  2s . co m*/
                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:de.rosche.spectraTelemetry.SpectraTelemetry.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initapp = true;//from   w  w  w .j  ava 2s.  c  om
    //sandbox();
    initialized = false;
    if (android.os.Build.VERSION.SDK_INT > 10) {
        requestWindowFeature(Window.FEATURE_ACTION_BAR);
        //getOverflowMenu();
    }
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (mBluetoothAdapter == null) {
        finishDialogNoBluetooth();
        return;
    }
    setContentView(R.layout.term_activity);
    Message msg = new Message();
    msg.what = STOPSPLASH;
    splashHandler.sendMessageDelayed(msg, SPLASHTIME);
}

From source file:com.hzx.luoyechat.activity.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main_activity, menu);
    onMenuOpened(Window.FEATURE_ACTION_BAR, menu);
    return true;//from  w  w w  .j a va2s .  c  om
}

From source file:com.actionbarsherlock.internal.ActionBarSherlockCompat.java

private ViewGroup generateLayout() {
    if (DEBUG)/*from www  .j  ava  2 s.  c om*/
        Log.d(TAG, "[generateLayout]");

    // Apply data from current theme.

    TypedArray a = mActivity.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme);

    mIsFloating = a.getBoolean(R.styleable.SherlockTheme_android_windowIsFloating, false);

    if (!a.hasValue(R.styleable.SherlockTheme_windowActionBar)) {
        throw new IllegalStateException(
                "You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.");
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowNoTitle, false)) {
        requestFeature(Window.FEATURE_NO_TITLE);
    } else if (a.getBoolean(R.styleable.SherlockTheme_windowActionBar, false)) {
        // Don't allow an action bar if there is no title.
        requestFeature(Window.FEATURE_ACTION_BAR);
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowActionBarOverlay, false)) {
        requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowActionModeOverlay, false)) {
        requestFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
    }

    a.recycle();

    int layoutResource;
    if (!hasFeature(Window.FEATURE_NO_TITLE)) {
        if (mIsFloating) {
            //Trash original dialog LinearLayout
            mDecor = (ViewGroup) mDecor.getParent();
            mDecor.removeAllViews();

            layoutResource = R.layout.abs__dialog_title_holo;
        } else {
            if (hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) {
                layoutResource = R.layout.abs__screen_action_bar_overlay;
            } else {
                layoutResource = R.layout.abs__screen_action_bar;
            }
        }
    } else if (hasFeature(Window.FEATURE_ACTION_MODE_OVERLAY) && !hasFeature(Window.FEATURE_NO_TITLE)) {
        layoutResource = R.layout.abs__screen_simple_overlay_action_mode;
    } else {
        layoutResource = R.layout.abs__screen_simple;
    }

    if (DEBUG)
        Log.d(TAG, "[generateLayout] using screen XML " + mActivity.getResources().getString(layoutResource));
    View in = mActivity.getLayoutInflater().inflate(layoutResource, null);
    mDecor.addView(in, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));

    ViewGroup contentParent = (ViewGroup) mDecor.findViewById(R.id.abs__content);
    if (contentParent == null) {
        throw new RuntimeException("Couldn't find content container view");
    }

    //Make our new child the true content view (for fragments). VERY VOLATILE!
    mDecor.setId(View.NO_ID);
    contentParent.setId(android.R.id.content);

    if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) {
        IcsProgressBar progress = getCircularProgressBar(false);
        if (progress != null) {
            progress.setIndeterminate(true);
        }
    }

    return contentParent;
}

From source file:com.hzx.luoyechat.activity.MainActivity.java

@Override
public boolean onMenuOpened(int featureId, Menu menu) {

    if (/**/featureId == Window.FEATURE_ACTION_BAR && menu != null) {
        if (menu.getClass().getSimpleName().equals("MenuBuilder")) {
            try {
                Method method = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE);
                method.setAccessible(true);
                method.invoke(menu, true);
            } catch (Exception e) {
                e.printStackTrace();//from   w  ww.ja v  a  2  s. c  om
            }
        }
    }

    return super.onMenuOpened(Window.FEATURE_ACTION_BAR, menu);
}

From source file:com.aimfire.gallery.GalleryActivity.java

@Override
public boolean onMenuOpened(int featureId, Menu menu) {
    /*//from   w  ww. ja v  a 2s. com
     * if the overflow menu was opened, we will hide action bar
     * after a longer delay, to allow user enough time to see
     * what's in the overflow menu
     */
    if (featureId == Window.FEATURE_ACTION_BAR) {
        if (AUTO_HIDE) {
            delayedHide(AUTO_HIDE_DELAY_LONG_MILLIS);
        }
    }

    /*
     * opening menu apparently reset the full screen flags. so 
     * redo it here.
     */
    //forceFullScreen();

    return super.onMenuOpened(featureId, menu);
}

From source file:com.codename1.impl.android.AndroidImplementation.java

@Override
public void init(Object m) {
    if (m instanceof CodenameOneActivity) {
        setContext(null);// w w  w  . ja  va  2  s .  c om
        setActivity((CodenameOneActivity) m);
    } else {
        setActivity(null);
        setContext((Context) m);
    }

    instance = this;
    if (getActivity() != null && getActivity().hasUI()) {
        if (!hasActionBar()) {
            try {
                getActivity().requestWindowFeature(Window.FEATURE_NO_TITLE);
            } catch (Exception e) {
                //Log.d("Codename One", "No idea why this throws a Runtime Error", e);
            }
        } else {
            getActivity().invalidateOptionsMenu();
            try {
                getActivity().requestWindowFeature(Window.FEATURE_ACTION_BAR);
                getActivity().requestWindowFeature(Window.FEATURE_PROGRESS);

                if (android.os.Build.VERSION.SDK_INT >= 21) {
                    //WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
                    getActivity().getWindow().addFlags(-2147483648);
                }
            } catch (Exception e) {
                //Log.d("Codename One", "No idea why this throws a Runtime Error", e);
            }
            NotifyActionBar notify = new NotifyActionBar(getActivity(), false);
            notify.run();
        }

        if (statusBarHidden) {
            getActivity().getWindow().getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
            getActivity().getWindow().setStatusBarColor(android.graphics.Color.TRANSPARENT);
        }

        if (Display.getInstance().getProperty("StatusbarHidden", "").equals("true")) {
            getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }

        if (Display.getInstance().getProperty("KeepScreenOn", "").equals("true")) {
            getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        }

        if (Display.getInstance().getProperty("DisableScreenshots", "").equals("true")) {
            getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
        }

        if (m instanceof CodenameOneActivity) {
            ((CodenameOneActivity) m).setDefaultIntentResultListener(this);
            ((CodenameOneActivity) m).setIntentResultListener(this);
        }

        /**
         * translate our default font height depending on the screen density.
         * this is required for new high resolution devices. otherwise
         * everything looks awfully small.
         *
         * we use our default font height value of 16 and go from there. i
         * thought about using new Paint().getTextSize() for this value but if
         * some new version of android suddenly returns values already tranlated
         * to the screen then we might end up with too large fonts. the
         * documentation is not very precise on that.
         */
        final int defaultFontPixelHeight = 16;
        this.defaultFontHeight = this.translatePixelForDPI(defaultFontPixelHeight);

        this.defaultFont = (CodenameOneTextPaint) ((NativeFont) this.createFont(Font.FACE_SYSTEM,
                Font.STYLE_PLAIN, Font.SIZE_MEDIUM)).font;
        Display.getInstance().setTransitionYield(-1);

        initSurface();
        /**
         * devices are extremely sensitive so dragging should start a little
         * later than suggested by default implementation.
         */
        this.setDragStartPercentage(1);
        VirtualKeyboardInterface vkb = new AndroidKeyboard(this);
        Display.getInstance().registerVirtualKeyboard(vkb);
        Display.getInstance().setDefaultVirtualKeyboard(vkb);

        InPlaceEditView.endEdit();

        getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

        if (nativePeers.size() > 0) {
            for (int i = 0; i < nativePeers.size(); i++) {
                ((AndroidImplementation.AndroidPeer) nativePeers.elementAt(i)).init();
            }
        }
    } else {
        /**
         * translate our default font height depending on the screen density.
         * this is required for new high resolution devices. otherwise
         * everything looks awfully small.
         *
         * we use our default font height value of 16 and go from there. i
         * thought about using new Paint().getTextSize() for this value but if
         * some new version of android suddenly returns values already tranlated
         * to the screen then we might end up with too large fonts. the
         * documentation is not very precise on that.
         */
        final int defaultFontPixelHeight = 16;
        this.defaultFontHeight = this.translatePixelForDPI(defaultFontPixelHeight);

        this.defaultFont = (CodenameOneTextPaint) ((NativeFont) this.createFont(Font.FACE_SYSTEM,
                Font.STYLE_PLAIN, Font.SIZE_MEDIUM)).font;
    }
    HttpURLConnection.setFollowRedirects(false);
    CookieHandler.setDefault(null);
}

From source file:android.app.Activity.java

/**
 * Creates a new ActionBar, locates the inflated ActionBarView,
 * initializes the ActionBar with the view, and sets mActionBar.
 *//*  w  ww . ja va  2s .  c  om*/
private void initActionBar() {
    Window window = getWindow();

    // Initializing the window decor can change window feature flags.
    // Make sure that we have the correct set before performing the test below.
    window.getDecorView();

    if (isChild() || !window.hasFeature(Window.FEATURE_ACTION_BAR) || mActionBar != null) {
        return;
    }

    mActionBar = new ActionBarImpl(this);
    mActionBar.setDefaultDisplayHomeAsUpEnabled(mEnableDefaultActionBarUp);

    mWindow.setDefaultIcon(mActivityInfo.getIconResource());
    mWindow.setDefaultLogo(mActivityInfo.getLogoResource());
}