private void initialize(Window window, Context context) { View decor = window.getDecorView(); ViewGroup group = (ViewGroup) window.getDecorView(); LayoutInflater inflater = (LayoutInflater) decor.getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.lib_title_container, group, true); inflater.inflate(R.layout.lib_left_nav, group, true); mContext = decor.getContext(); mIsOverlay = window.hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY); mTitleBar = (TitleBarView) decor.findViewById(R.id.title_container); mLeftNav = (LeftNavView) decor.findViewById(R.id.left_nav); mContent = group.getChildAt(0); if (mTitleBar == null || mLeftNav == null) { throw new IllegalStateException( getClass().getSimpleName() + ": incompatible window decor!"); } setDisplayOptions(DEFAULT_DISPLAY_OPTIONS); showOptionsMenu(true); }
@TargetApi(HONEYCOMB) public WindowAssert hasFeature(@WindowFeature int feature) { isNotNull(); //noinspection ResourceType assertThat(actual.hasFeature(feature)) // .overridingErrorMessage("Expected feature <%s> but was not present.", featureToString(feature)) // .isTrue(); return this; }
@Override public boolean hasFeature(int feature) { if (ActionBarSherlock.DEBUG) Log.d(TAG, "[hasFeature] feature: " + feature); final boolean result = mActivity.getWindow().hasFeature(feature); if (ActionBarSherlock.DEBUG) Log.d(TAG, "[hasFeature] returning " + result); return result; }
@Override public boolean hasFeature(int feature) { if (DEBUG) Log.d(TAG, "[hasFeature] feature: " + feature); final boolean result = mActivity.getWindow().hasFeature(feature); if (DEBUG) Log.d(TAG, "[hasFeature] returning " + result); return result; }
@TargetApi(11) private void handleActionBarOverlay(ViewGroup.MarginLayoutParams params, Activity activity) { // ActionBar overlay is only available as of Android 3.0 Honeycomb. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { final boolean flags = activity.getWindow().hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY); if (flags) { setActionBarMargin(params, activity); } } }
private void initWindowDecorActionBar() { 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 WindowDecorActionBar(this); mActionBar.setDefaultDisplayHomeAsUpEnabled(mEnableDefaultActionBarUp); mWindow.setDefaultIcon(mActivityInfo.getIconResource()); mWindow.setDefaultLogo(mActivityInfo.getLogoResource()); }
boolean hasFeature(int feature) { Window window = getWindow(); //get the window instance. if (android.os.Build.VERSION.SDK_INT >= 11) { // if we are running api level 11 and later return window.hasFeature(feature); //call hasFeature } else { try { Class c = window.getClass(); Method getFeatures = c.getDeclaredMethod("getFeatures");//get the getFeatures method using reflection getFeatures.setAccessible(true);//make it public Integer features = getFeatures.invoke(window, null); //invoke it return (features.intValue() & (1 << feature)) != 0; //check if we have the feature and return the result. } catch (Exception e) { return false;//in case invocation fails with any reason } } }
@TargetApi(HONEYCOMB) public WindowAssert hasFeature(@WindowFeature int feature) { isNotNull(); //noinspection ResourceType assertThat(actual.hasFeature(feature)) // .overridingErrorMessage("Expected feature <%s> but was not present.", featureToString(feature)) // .isTrue(); return this; }
@Override public void openOptionsMenu() { ActionBar actionBar = getSupportActionBar(); if (getWindow().hasFeature(Window.FEATURE_OPTIONS_PANEL) && (actionBar == null || !actionBar.openOptionsMenu())) { super.openOptionsMenu(); } }
@Override public void closeOptionsMenu() { ActionBar actionBar = getSupportActionBar(); if (getWindow().hasFeature(Window.FEATURE_OPTIONS_PANEL) && (actionBar == null || !actionBar.closeOptionsMenu())) { super.closeOptionsMenu(); } } }