Example usage for android.view Window FEATURE_ACTION_MODE_OVERLAY

List of usage examples for android.view Window FEATURE_ACTION_MODE_OVERLAY

Introduction

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

Prototype

int FEATURE_ACTION_MODE_OVERLAY

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

Click Source Link

Document

Flag for specifying the behavior of action modes when an Action Bar is not present.

Usage

From source file:com.pshelf.hugo.pshelf.PrincipalDrawer.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    getWindow().requestFeature(Window.FEATURE_ACTION_MODE_OVERLAY);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_drawer);

    mTitle = mDrawerTitle = getTitle();/*from  w  ww.  ja  v a2  s. com*/
    mListaMenu = getResources().getStringArray(R.array.lista_menu);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);

    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener

    mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mListaMenu));
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());

    // enable ActionBar app icon to behave as action to toggle nav drawer

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon

    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            getSupportActionBar().setTitle(mTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            getSupportActionBar().setTitle(mDrawerTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    if (savedInstanceState == null) {
        selectItem(0);
    }
    mDrawerLayout.openDrawer(mDrawerList);
}

From source file:nf.frex.android.FrexActivity.java

/**
 * Called when the activity is first created.
 */// w ww . ja v  a  2  s  .  c om
@Override
public void onCreate(Bundle savedInstanceState) {
    //Log.d(TAG, "onCreate(savedInstanceState=" + savedInstanceState + ")");
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_ACTION_BAR);
    requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    requestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);

    if (PRE_SDK14) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        // Fix: Frex to stop working on screen orientation changes (Android 2.3.x only)
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    } else {
        getActionBar().setBackgroundDrawable(new PaintDrawable(Color.argb(128, 0, 0, 0)));
    }

    view = new FractalView(this);
    setContentView(view);

    if (!tryReadingFrexDocIntent(getIntent())) {
        if (savedInstanceState != null) {
            view.restoreInstanceState(new BundlePropertySet(savedInstanceState));
        } else {
            PropertySet propertySet = (PropertySet) getLastNonConfigurationInstance();
            if (propertySet != null) {
                view.restoreInstanceState(propertySet);
            }
        }
    }
}

From source file:com.mishiranu.dashchan.ui.navigator.NavigatorActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override/*  ww w.j a  v a  2 s.  co m*/
public void onCreate(Bundle savedInstanceState) {
    currentPreferences = Preferences.getCurrent();
    if (C.API_LOLLIPOP) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        requestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
    }
    ResourceUtils.applyPreferredTheme(this);
    expandedScreen = new ExpandedScreen(this, Preferences.isExpandedScreen());
    super.onCreate(savedInstanceState);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    float density = ResourceUtils.obtainDensity(this);
    setContentView(R.layout.activity_main);
    ClickableToast.register(clickableToastHolder);
    FavoritesStorage.getInstance().getObservable().register(this);
    watcherServiceClient.bind(this);
    pageManager = new PageManager();
    actionIconSet = new ActionIconSet(this);
    progressView = findViewById(R.id.progress);
    errorView = findViewById(R.id.error);
    errorText = (TextView) findViewById(R.id.error_text);
    listView = (PullableListView) findViewById(android.R.id.list);
    registerForContextMenu(listView);
    drawerCommon = (ViewGroup) findViewById(R.id.drawer_common);
    drawerWide = (ViewGroup) findViewById(R.id.drawer_wide);
    TypedArray typedArray = obtainStyledAttributes(new int[] { R.attr.styleDrawerSpecial });
    int drawerResId = typedArray.getResourceId(0, 0);
    typedArray.recycle();
    ContextThemeWrapper styledContext = drawerResId != 0 ? new ContextThemeWrapper(this, drawerResId) : this;
    int drawerBackground = ResourceUtils.getColor(styledContext, R.attr.backgroundDrawer);
    drawerCommon.setBackgroundColor(drawerBackground);
    drawerWide.setBackgroundColor(drawerBackground);
    drawerListView = new SortableListView(styledContext, this);
    drawerListView.setId(android.R.id.tabcontent);
    drawerListView.setOnSortingStateChangedListener(this);
    drawerForm = new DrawerForm(styledContext, this, this, watcherServiceClient);
    drawerForm.bind(drawerListView);
    drawerParent = new FrameLayout(this);
    drawerParent.addView(drawerListView);
    drawerCommon.addView(drawerParent);
    uiManager = new UiManager(this, this, expandedScreen);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (C.API_LOLLIPOP) {
        FrameLayout foreground = new FrameLayout(this);
        drawerLayout.addView(foreground, drawerLayout.indexOfChild(drawerCommon), new DrawerLayout.LayoutParams(
                DrawerLayout.LayoutParams.MATCH_PARENT, DrawerLayout.LayoutParams.MATCH_PARENT));
        getLayoutInflater().inflate(R.layout.widget_toolbar, foreground);
        Toolbar toolbar = (Toolbar) foreground.findViewById(R.id.toolbar);
        setActionBar(toolbar);
        toolbarView = toolbar;
        expandedScreen.setToolbar(toolbar, foreground);
    } else {
        getActionBar().setIcon(R.drawable.ic_logo); // Show white logo on search
    }
    drawerToggle = new DrawerToggle(this, drawerLayout);
    if (C.API_LOLLIPOP) {
        drawerCommon.setElevation(6f * density);
        drawerWide.setElevation(4f * density);
    } else {
        drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);
    }
    drawerLayout.addDrawerListener(drawerToggle);
    drawerLayout.addDrawerListener(drawerForm);
    if (toolbarView == null) {
        drawerLayout.addDrawerListener(new ExpandedScreenDrawerLocker());
    }
    ViewUtils.applyToolbarStyle(this, toolbarView);
    if (Preferences.isActiveScrollbar()) {
        listView.setFastScrollEnabled(true);
        if (!C.API_LOLLIPOP) {
            ListViewUtils.colorizeListThumb4(listView);
        }
    }
    listView.setOnItemClickListener(this);
    listView.setOnItemLongClickListener(this);
    listView.getWrapper().setOnPullListener(this);
    listView.getWrapper().setPullStateListener(this);
    listView.setClipToPadding(false);
    ScrollListenerComposite scrollListenerComposite = new ScrollListenerComposite();
    listView.setOnScrollListener(scrollListenerComposite);
    scrollListenerComposite.add(new BusyScrollListener(this));
    updateWideConfiguration(true);
    expandedScreen.setDrawerOverToolbarEnabled(!wideMode);
    expandedScreen.setContentListView(listView, scrollListenerComposite);
    expandedScreen.setDrawerListView(drawerParent, drawerListView, drawerForm.getHeaderView());
    expandedScreen.addAdditionalView(progressView, true);
    expandedScreen.addAdditionalView(errorView, true);
    expandedScreen.finishInitialization();
    LocalBroadcastManager.getInstance(this).registerReceiver(newPostReceiver,
            new IntentFilter(C.ACTION_POST_SENT));
    if (savedInstanceState == null) {
        savedInstanceState = pageManager.readFromStorage();
    }
    PageHolder savedCurrentPageHolder = pageManager.restore(savedInstanceState);
    if (savedCurrentPageHolder != null) {
        navigatePageHolder(savedCurrentPageHolder, false);
    } else {
        navigateIntent(getIntent(), false);
    }
    if (savedInstanceState == null) {
        startUpdateTask();
        int drawerInitialPosition = Preferences.getDrawerInitialPosition();
        if (drawerInitialPosition != Preferences.DRAWER_INITIAL_POSITION_CLOSED) {
            if (!wideMode) {
                drawerLayout.post(() -> drawerLayout.openDrawer(Gravity.START));
            }
            if (drawerInitialPosition == Preferences.DRAWER_INITIAL_POSITION_FORUMS) {
                drawerForm.setChanSelectMode(true);
            }
        }
    }
}

From source file:org.chromium.chrome.browser.customtabs.CustomTabActivity.java

@Override
public void preInflationStartup() {
    super.preInflationStartup();
    mIntentDataProvider = new CustomTabIntentDataProvider(getIntent(), this);
    mSession = mIntentDataProvider.getSession();
    supportRequestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
    mHasPrerender = !TextUtils/* w  w  w  .  j a  va 2s  .  c om*/
            .isEmpty(CustomTabsConnection.getInstance(getApplication()).getPrerenderedUrl(mSession));
    if (getSavedInstanceState() == null && CustomTabsConnection.hasWarmUpBeenFinished(getApplication())) {
        mMainTab = createMainTab();
        loadUrlInTab(mMainTab, new LoadUrlParams(getUrlToLoad()),
                IntentHandler.getTimestampFromIntent(getIntent()));
        mHasCreatedTabEarly = true;
    }
}

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

@Override
public boolean requestFeature(int featureId) {
    if (DEBUG)//from  w  ww .  j  av  a  2  s .  c  om
        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:com.actionbarsherlock.internal.ActionBarSherlockCompat.java

private ViewGroup generateLayout() {
    if (DEBUG)//from  www.  ja  v  a2s  .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;
}