Example usage for android.view View SYSTEM_UI_FLAG_LOW_PROFILE

List of usage examples for android.view View SYSTEM_UI_FLAG_LOW_PROFILE

Introduction

In this page you can find the example usage for android.view View SYSTEM_UI_FLAG_LOW_PROFILE.

Prototype

int SYSTEM_UI_FLAG_LOW_PROFILE

To view the source code for android.view View SYSTEM_UI_FLAG_LOW_PROFILE.

Click Source Link

Document

Flag for #setSystemUiVisibility(int) : View has requested the system UI to enter an unobtrusive "low profile" mode.

Usage

From source file:com.aujur.ebookreader.activity.ReadingFragment.java

private void updateFromPrefs() {

    SherlockFragmentActivity activity = getSherlockActivity();

    if (activity == null) {
        return;//from w  w w.java  2 s.c om
    }

    bookView.setTextSize(config.getTextSize());

    int marginH = config.getHorizontalMargin();
    int marginV = config.getVerticalMargin();

    this.textLoader.setFontFamily(config.getDefaultFontFamily());
    this.bookView.setFontFamily(config.getDefaultFontFamily());
    this.textLoader.setSansSerifFontFamily(config.getSansSerifFontFamily());
    this.textLoader.setSerifFontFamily(config.getSerifFontFamily());

    bookView.setHorizontalMargin(marginH);
    bookView.setVerticalMargin(marginV);

    if (!isAnimating()) {
        bookView.setEnableScrolling(config.isScrollingEnabled());
    }

    textLoader.setStripWhiteSpace(config.isStripWhiteSpaceEnabled());
    textLoader.setAllowStyling(config.isAllowStyling());
    textLoader.setUseColoursFromCSS(config.isUseColoursFromCSS());

    bookView.setLineSpacing(config.getLineSpacing());

    if (config.isFullScreenEnabled()) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        activity.getSupportActionBar().hide();
    } else {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        activity.getSupportActionBar().show();
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && config.isDimSystemUI()) {
        activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    }

    if (config.isKeepScreenOn()) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    } else {
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }

    restoreColorProfile();

    // Check if we need a restart
    if (config.isFullScreenEnabled() != savedConfigState.fullscreen
            || config.isShowPageNumbers() != savedConfigState.usePageNum
            || config.isBrightnessControlEnabled() != savedConfigState.brightness
            || config.isStripWhiteSpaceEnabled() != savedConfigState.stripWhiteSpace
            || !config.getDefaultFontFamily().getName().equalsIgnoreCase(savedConfigState.fontName)
            || !config.getSerifFontFamily().getName().equalsIgnoreCase(savedConfigState.serifFontName)
            || !config.getSansSerifFontFamily().getName().equalsIgnoreCase(savedConfigState.sansSerifFontName)
            || config.getHorizontalMargin() != savedConfigState.hMargin
            || config.getVerticalMargin() != savedConfigState.vMargin
            || config.getTextSize() != savedConfigState.textSize
            || config.isScrollingEnabled() != savedConfigState.scrolling
            || config.isAllowStyling() != savedConfigState.allowStyling
            || config.isUseColoursFromCSS() != savedConfigState.allowColoursFromCSS) {

        textLoader.invalidateCachedText();
        restartActivity();
    }

    Configuration.OrientationLock orientation = config.getScreenOrientation();

    switch (orientation) {
    case PORTRAIT:
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;
    case LANDSCAPE:
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        break;
    case REVERSE_LANDSCAPE:
        getActivity().setRequestedOrientation(8); // Android 2.3+ value
        break;
    case REVERSE_PORTRAIT:
        getActivity().setRequestedOrientation(9); // Android 2.3+ value
        break;
    default:
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }
}

From source file:net.zorgblub.typhon.fragment.ReadingFragment.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void updateFromPrefs() {

    AppCompatActivity activity = (AppCompatActivity) getActivity();

    if (activity == null) {
        return;//from  w w w  .  ja  va 2  s  .c  o m
    }

    bookView.setTextSize(config.getTextSize());

    int marginH = config.getHorizontalMargin();
    int marginV = config.getVerticalMargin();

    this.textLoader.setFontFamily(config.getDefaultFontFamily());
    this.bookView.setFontFamily(config.getDefaultFontFamily());
    this.textLoader.setSansSerifFontFamily(config.getSansSerifFontFamily());
    this.textLoader.setSerifFontFamily(config.getSerifFontFamily());

    bookView.setHorizontalMargin(marginH);
    bookView.setVerticalMargin(marginV);

    if (!isAnimating()) {
        bookView.setEnableScrolling(config.isScrollingEnabled());
    }

    textLoader.setStripWhiteSpace(config.isStripWhiteSpaceEnabled());
    textLoader.setAllowStyling(config.isAllowStyling());
    textLoader.setUseColoursFromCSS(config.isUseColoursFromCSS());

    bookView.setLineSpacing(config.getLineSpacing());

    if (config.isFullScreenEnabled()) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        activity.getSupportActionBar().hide();

    } else {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        activity.getSupportActionBar().show();
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        if (config.isFullScreenEnabled()) {
            activity.getWindow().getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    // | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        }
        if (config.isDimSystemUI()) {
            activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
        }
    }

    if (config.isKeepScreenOn()) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    } else {
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }

    restoreColorProfile();

    // Check if we need a restart
    if (config.isFullScreenEnabled() != savedConfigState.fullscreen
            || config.isShowPageNumbers() != savedConfigState.usePageNum
            || config.isBrightnessControlEnabled() != savedConfigState.brightness
            || config.isStripWhiteSpaceEnabled() != savedConfigState.stripWhiteSpace
            || !config.getDefaultFontFamily().getName().equalsIgnoreCase(savedConfigState.fontName)
            || !config.getSerifFontFamily().getName().equalsIgnoreCase(savedConfigState.serifFontName)
            || !config.getSansSerifFontFamily().getName().equalsIgnoreCase(savedConfigState.sansSerifFontName)
            || config.getHorizontalMargin() != savedConfigState.hMargin
            || config.getVerticalMargin() != savedConfigState.vMargin
            || config.getTextSize() != savedConfigState.textSize
            || config.isScrollingEnabled() != savedConfigState.scrolling
            || config.isAllowStyling() != savedConfigState.allowStyling
            || config.isUseColoursFromCSS() != savedConfigState.allowColoursFromCSS
            || config.isRikaiEnabled() != savedConfigState.rikaiEnabled
            || dictionaryService.getLastUpdateTimestamp() > this.dictionaryLastUpdate) {
        DictionaryServiceImpl.reset();
        textLoader.invalidateCachedText();
        restartActivity();
    }

    Configuration.OrientationLock orientation = config.getScreenOrientation();

    switch (orientation) {
    case PORTRAIT:
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;
    case LANDSCAPE:
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        break;
    case REVERSE_LANDSCAPE:
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); // Android 2.3+ value
        break;
    case REVERSE_PORTRAIT:
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); // Android 2.3+ value
        break;
    default:
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }
}

From source file:com.concentricsky.android.khanacademy.app.VideoDetailActivity.java

private void setNavVisibility(boolean visible) {
    Log.d(LOG_TAG, "setNavVisibility: " + visible);
    // Fire HD:/*from   w w w  . j  ava  2  s .  co  m*/
    // View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_FULLSCREEN : These do nothing.
    // View.SYSTEM_UI_FLAG_HIDE_NAVIGATION : This works as expected, but isn't good enough.
    // WindowManager.LayoutParams.FLAG_FULLSCREEN : This is great, but 
    // a) can't keep stable layout (video grows when added, shrinks when removed),
    // b) No way to hook the event where the user touches the handle, so that behavior differs from a touch on the rest of the screen.

    handler.removeCallbacks(navHider);
    navVis = visible;
    if (visible) {
        // Flags, menu items, and action bar should already be correct in portrait, but it won't hurt.
        findViewById(R.id.detail_pane_container).setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
        getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getActionBar().show();
        if (mainMenu != null) {
            for (int i = 0; i < mainMenu.size(); ++i) {
                mainMenu.getItem(i).setVisible(true);
            }
        }

        setControlsVisible(shouldShowVideoControls);

        if (videoFragment != null && videoFragment.isPlaying()) {
            handler.postDelayed(navHider, NAV_HIDE_DELAY);
        }
    } else {
        if (isFullscreen()) {
            findViewById(R.id.detail_pane_container).setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            getActionBar().hide();
            // Hide menu items in landscape to prevent the action overflow menu / share menu from
            // disappearing on nav hide when the user is trying to interact with them.
            // The right solution would be to force the nav to stay open while the menus are open, 
            // but there doesn't appear to be a way to check (?!). We get NO call to onOptionsMenuClosed
            // when that is overridden, so we cannot track it ourselves either. In fact, if the options menu
            // is open it consumes the first touch event outside itself to close itself, so we can't even
            // do it by listening to touches and assuming they close the menu.
            if (mainMenu != null) {
                for (int i = 0; i < mainMenu.size(); ++i) {
                    mainMenu.getItem(i).setVisible(false);
                }
            }
        }
        setControlsVisible(false);
    }
}

From source file:org.videolan.vlc.gui.video.VideoPlayerActivity.java

/**
 * Dim the status bar and/or navigation icons when needed on Android 3.x.
 * Hide it on Android 4.0 and later//from ww w  .  j av a 2s . co m
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void dimStatusBar(boolean dim) {
    if (!Util.isHoneycombOrLater() || !Util.hasNavBar())
        return;
    mSurface.setSystemUiVisibility(
            dim ? (Util.hasCombBar() ? View.SYSTEM_UI_FLAG_LOW_PROFILE : View.SYSTEM_UI_FLAG_HIDE_NAVIGATION)
                    : View.SYSTEM_UI_FLAG_VISIBLE);
}

From source file:com.grass.caishi.cc.activity.main.MainActivity.java

/**
 * ???/*from   ww  w.  j a va 2 s.co  m*/
 */
public void hideNavigationBar() {
    int uiFlags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
            | View.SYSTEM_UI_FLAG_FULLSCREEN; // hide status bar

    if (android.os.Build.VERSION.SDK_INT >= 19) {
        uiFlags |= 0x00001000; // SYSTEM_UI_FLAG_IMMERSIVE_STICKY: hide navigation bars - compatibility: building API level is lower thatn 19, use magic number directly for higher API target level
    } else {
        uiFlags |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
    }

    getWindow().getDecorView().setSystemUiVisibility(uiFlags);
}

From source file:com.android.soma.Launcher.java

private Cling initCling(int clingId, int scrimId, boolean animate, boolean dimNavBarVisibilty) {
    Cling cling = (Cling) findViewById(clingId);
    View scrim = null;//from w  ww .  j a  v  a2  s . c om
    if (scrimId > 0) {
        scrim = findViewById(R.id.cling_scrim);
    }
    if (cling != null) {
        cling.init(this, scrim);
        cling.show(animate, SHOW_CLING_DURATION);

        if (dimNavBarVisibilty) {
            cling.setSystemUiVisibility(cling.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LOW_PROFILE);
        }
    }
    return cling;
}

From source file:com.android.soma.Launcher.java

private void dismissCling(final Cling cling, final Runnable postAnimationCb, final String flag, int duration,
        boolean restoreNavBarVisibilty) {
    // To catch cases where siblings of top-level views are made invisible, just check whether
    // the cling is directly set to GONE before dismissing it.
    if (cling != null && cling.getVisibility() != View.GONE) {
        final Runnable cleanUpClingCb = new Runnable() {
            public void run() {
                cling.cleanup();/*from   www.  ja  va  2 s  .  c  o  m*/
                // We should update the shared preferences on a background thread
                new Thread("dismissClingThread") {
                    public void run() {
                        SharedPreferences.Editor editor = mSharedPrefs.edit();
                        editor.putBoolean(flag, true);
                        editor.commit();
                    }
                }.start();
                if (postAnimationCb != null) {
                    postAnimationCb.run();
                }
            }
        };
        if (duration <= 0) {
            cleanUpClingCb.run();
        } else {
            cling.hide(duration, cleanUpClingCb);
        }
        mHideFromAccessibilityHelper.restoreImportantForAccessibility(mDragLayer);

        if (restoreNavBarVisibilty) {
            cling.setSystemUiVisibility(cling.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LOW_PROFILE);
        }
    }
}