List of usage examples for android.view View getSystemUiVisibility
public int getSystemUiVisibility()
From source file:com.jungle.base.utils.MiscUtils.java
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB) public static void setImmersiveMode(Activity activity) { View decorView = activity.getWindow().getDecorView(); int option = decorView.getSystemUiVisibility(); if (Build.VERSION.SDK_INT >= 14) { option ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; }// ww w . j a v a2 s. c o m if (Build.VERSION.SDK_INT >= 16) { option ^= View.SYSTEM_UI_FLAG_FULLSCREEN; } if (Build.VERSION.SDK_INT >= 19) { //option ^= View.SYSTEM_UI_FLAG_IMMERSIVE; } decorView.setSystemUiVisibility(option); }
From source file:com.example.android.advancedimmersivemode.AdvancedImmersiveModeFragment.java
/** * Detects and toggles immersive mode (also known as "hidey bar" mode). *///from w w w . ja va 2 s .c om public void toggleUiFlags() { // BEGIN_INCLUDE (get_current_ui_flags) // The "Decor View" is the parent view of the Activity. It's also conveniently the easiest // one to find from within a fragment, since there's a handy helper method to pull it, and // we don't have to bother with picking a view somewhere deeper in the hierarchy and calling // "findViewById" on it. View decorView = getActivity().getWindow().getDecorView(); int uiOptions = decorView.getSystemUiVisibility(); int newUiOptions = uiOptions; // END_INCLUDE (get_current_ui_flags) // BEGIN_INCLUDE (toggle_lowprofile_mode) // Low profile mode doesn't resize the screen at all, but it covers the nav & status bar // icons with black so they're less distracting. Unlike "full screen" and "hide nav bar," // this mode doesn't interact with immersive mode at all, but it's instructive when running // this sample to observe the differences in behavior. if (mLowProfileCheckBox.isChecked()) { newUiOptions |= View.SYSTEM_UI_FLAG_LOW_PROFILE; } else { newUiOptions &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE; } // END_INCLUDE (toggle_lowprofile_mode) // BEGIN_INCLUDE (toggle_fullscreen_mode) // When enabled, this flag hides non-critical UI, such as the status bar, // which usually shows notification icons, battery life, etc // on phone-sized devices. The bar reappears when the user swipes it down. When immersive // mode is also enabled, the app-drawable area expands, and when the status bar is swiped // down, it appears semi-transparently and slides in over the app, instead of pushing it // down. if (mHideStatusBarCheckBox.isChecked()) { newUiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN; } else { newUiOptions &= ~View.SYSTEM_UI_FLAG_FULLSCREEN; } // END_INCLUDE (toggle_fullscreen_mode) // BEGIN_INCLUDE (toggle_hidenav_mode) // When enabled, this flag hides the black nav bar along the bottom, // where the home/back buttons are. The nav bar normally instantly reappears // when the user touches the screen. When immersive mode is also enabled, the nav bar // stays hidden until the user swipes it back. if (mHideNavCheckbox.isChecked()) { newUiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; } else { newUiOptions &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; } // END_INCLUDE (toggle_hidenav_mode) // BEGIN_INCLUDE (toggle_immersive_mode) // Immersive mode doesn't do anything without at least one of the previous flags // enabled. When enabled, it allows the user to swipe the status and/or nav bars // off-screen. When the user swipes the bars back onto the screen, the flags are cleared // and immersive mode is automatically disabled. if (mImmersiveModeCheckBox.isChecked()) { newUiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE; } else { newUiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE; } // END_INCLUDE (toggle_immersive_mode) // BEGIN_INCLUDE (toggle_immersive_mode_sticky) // There's actually two forms of immersive mode, normal and "sticky". Sticky immersive mode // is different in 2 key ways: // // * Uses semi-transparent bars for the nav and status bars // * This UI flag will *not* be cleared when the user interacts with the UI. // When the user swipes, the bars will temporarily appear for a few seconds and then // disappear again. if (mImmersiveModeStickyCheckBox.isChecked()) { newUiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; } else { newUiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; } // END_INCLUDE (toggle_immersive_mode_sticky) // BEGIN_INCLUDE (set_ui_flags) //Set the new UI flags. decorView.setSystemUiVisibility(newUiOptions); // END_INCLUDE (set_ui_flags) dumpFlagStateToLog(uiOptions); }
From source file:com.mishiranu.dashchan.ui.gallery.GalleryActivity.java
@TargetApi(Build.VERSION_CODES.KITKAT) private void invalidateSystemUiVisibility() { ActionBar actionBar = getActionBar(); boolean visible = isSystemUiVisible(); if (visible) { actionBar.show();/*from ww w. j a va 2s . c om*/ } else { actionBar.hide(); } if (C.API_LOLLIPOP && expandedScreen) { View decorView = getWindow().getDecorView(); int visibility = decorView.getSystemUiVisibility(); visibility = FlagUtils.set(visibility, View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION, !visible); decorView.setSystemUiVisibility(visibility); } if (pagerUnit != null) { pagerUnit.invalidateControlsVisibility(); } }
From source file:com.manning.androidhacks.hack044.MainActivity3X.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//from ww w . jav a 2 s . co m final View contentView = findViewById(R.id.content); contentView.setOnSystemUiVisibilityChangeListener(new OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int visibility) { final ActionBar actionBar = getActionBar(); if (actionBar != null) { contentView.setSystemUiVisibility(visibility); if (visibility == View.STATUS_BAR_VISIBLE) { actionBar.show(); } else { actionBar.hide(); } } } }); contentView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (contentView.getSystemUiVisibility() == View.STATUS_BAR_VISIBLE) { contentView.setSystemUiVisibility(View.STATUS_BAR_HIDDEN); } else { contentView.setSystemUiVisibility(View.STATUS_BAR_VISIBLE); } } }); }
From source file:jahirfiquitiva.iconshowcase.activities.AltWallpaperViewerActivity.java
public void setupFullScreen() { makeStatusBarIconsWhite();/* www . j av a2 s . c o m*/ getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); View decorView = getWindow().getDecorView(); decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { decorView.setSystemUiVisibility( decorView.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); } }
From source file:com.achep.acdisplay.acdisplay.AcDisplayActivity.java
@SuppressLint("NewApi") private void populateFlags(boolean windowHasFocus) { Window window = getWindow();/* www . ja va 2s . co m*/ View decorView = window.getDecorView(); int windowFlags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; if (windowHasFocus) { int visibilityUi = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LOW_PROFILE; if (mConfig.isFullScreen()) { // Hide status bar if fullscreen mode is enabled. visibilityUi = visibilityUi | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_FULLSCREEN; } if (Device.hasKitKatApi()) { // Hide navigation bar and flag sticky. visibilityUi = visibilityUi | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; } decorView.setSystemUiVisibility(visibilityUi); window.addFlags(windowFlags); mTimeout.resume(); mTimeout.setTimeoutDelayed(mConfig.getTimeoutNormal(), true); } else { int visibilityUi = decorView.getSystemUiVisibility(); if (Device.hasKitKatApi()) { // Clear immersive sticky flag. // Hopefully it will fix annoying Android feature: IMMERSIVE_PANIC visibilityUi ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; } decorView.setSystemUiVisibility(visibilityUi); window.clearFlags(windowFlags); mTimeout.setTimeoutDelayed(mConfig.getTimeoutNormal(), true); mTimeout.pause(); } }
From source file:info.ipeanut.googletrainingcoursedemos.advancedimmersivemode.AdvancedImmersiveModeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) { final View flagsView = inflater.inflate(R.layout.fragment_flags, container, false); mLowProfileCheckBox = (CheckBox) flagsView.findViewById(R.id.flag_enable_lowprof); mHideNavCheckbox = (CheckBox) flagsView.findViewById(R.id.flag_hide_navbar); mHideStatusBarCheckBox = (CheckBox) flagsView.findViewById(R.id.flag_hide_statbar); mImmersiveModeCheckBox = (CheckBox) flagsView.findViewById(R.id.flag_enable_immersive); mImmersiveModeStickyCheckBox = (CheckBox) flagsView.findViewById(R.id.flag_enable_immersive_sticky); Button toggleFlagsButton = (Button) flagsView.findViewById(R.id.btn_changeFlags); toggleFlagsButton.setOnClickListener(new View.OnClickListener() { @Override// ww w. j av a 2 s .c o m public void onClick(View view) { toggleUiFlags(); } }); Button presetsImmersiveModeButton = (Button) flagsView.findViewById(R.id.btn_immersive); presetsImmersiveModeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // For immersive mode, the FULLSCREEN, HIDE_HAVIGATION and IMMERSIVE // flags should be set (you can use IMMERSIVE_STICKY instead of IMMERSIVE // as appropriate for your app). The LOW_PROFILE flag should be cleared. // Immersive mode is primarily for situations where the user will be // interacting with the screen, like games or reading books. int uiOptions = flagsView.getSystemUiVisibility(); uiOptions &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE; uiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN; uiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; uiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE; uiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; flagsView.setSystemUiVisibility(uiOptions); dumpFlagStateToLog(uiOptions); // The below code just updates the checkboxes to reflect which flags have been set. mLowProfileCheckBox.setChecked(false); mHideNavCheckbox.setChecked(true); mHideStatusBarCheckBox.setChecked(true); mImmersiveModeCheckBox.setChecked(true); mImmersiveModeStickyCheckBox.setChecked(false); } }); Button presetsLeanbackModeButton = (Button) flagsView.findViewById(R.id.btn_leanback); presetsLeanbackModeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // For leanback mode, only the HIDE_NAVE and HIDE_STATUSBAR flags // should be checked. In this case IMMERSIVE should *not* be set, // since this mode is left as soon as the user touches the screen. int uiOptions = flagsView.getSystemUiVisibility(); uiOptions &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE; uiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN; uiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; uiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE; uiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; flagsView.setSystemUiVisibility(uiOptions); dumpFlagStateToLog(uiOptions); // The below code just updates the checkboxes to reflect which flags have been set. mLowProfileCheckBox.setChecked(false); mHideNavCheckbox.setChecked(true); mHideStatusBarCheckBox.setChecked(true); mImmersiveModeCheckBox.setChecked(false); mImmersiveModeStickyCheckBox.setChecked(false); } }); // Setting these flags makes the content appear under the navigation // bars, so that showing/hiding the nav bars doesn't resize the content // window, which can be jarring. int uiOptions = flagsView.getSystemUiVisibility(); uiOptions |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; uiOptions |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE; uiOptions |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; flagsView.setSystemUiVisibility(uiOptions); return flagsView; }
From source file:com.example.android.advancedimmersivemode.AdvancedImmersiveModeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) { final View flagsView = inflater.inflate(R.layout.fragment_flags, container, false); mLowProfileCheckBox = (CheckBox) flagsView.findViewById(R.id.flag_enable_lowprof); mHideNavCheckbox = (CheckBox) flagsView.findViewById(R.id.flag_hide_navbar); mHideStatusBarCheckBox = (CheckBox) flagsView.findViewById(R.id.flag_hide_statbar); mImmersiveModeCheckBox = (CheckBox) flagsView.findViewById(R.id.flag_enable_immersive); mImmersiveModeStickyCheckBox = (CheckBox) flagsView.findViewById(R.id.flag_enable_immersive_sticky); Button toggleFlagsButton = (Button) flagsView.findViewById(R.id.btn_changeFlags); toggleFlagsButton.setOnClickListener(new View.OnClickListener() { @Override//from ww w . ja v a 2s . com public void onClick(View view) { toggleUiFlags(); } }); Button presetsImmersiveModeButton = (Button) flagsView.findViewById(R.id.btn_immersive); presetsImmersiveModeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // BEGIN_INCLUDE(immersive_presets) // For immersive mode, the FULLSCREEN, HIDE_HAVIGATION and IMMERSIVE // flags should be set (you can use IMMERSIVE_STICKY instead of IMMERSIVE // as appropriate for your app). The LOW_PROFILE flag should be cleared. // Immersive mode is primarily for situations where the user will be // interacting with the screen, like games or reading books. int uiOptions = flagsView.getSystemUiVisibility(); uiOptions &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE; uiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN; uiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; uiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE; uiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; flagsView.setSystemUiVisibility(uiOptions); // END_INCLUDE(immersive_presets) dumpFlagStateToLog(uiOptions); // The below code just updates the checkboxes to reflect which flags have been set. mLowProfileCheckBox.setChecked(false); mHideNavCheckbox.setChecked(true); mHideStatusBarCheckBox.setChecked(true); mImmersiveModeCheckBox.setChecked(true); mImmersiveModeStickyCheckBox.setChecked(false); } }); Button presetsLeanbackModeButton = (Button) flagsView.findViewById(R.id.btn_leanback); presetsLeanbackModeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // BEGIN_INCLUDE(leanback_presets) // For leanback mode, only the HIDE_NAVE and HIDE_STATUSBAR flags // should be checked. In this case IMMERSIVE should *not* be set, // since this mode is left as soon as the user touches the screen. int uiOptions = flagsView.getSystemUiVisibility(); uiOptions &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE; uiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN; uiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; uiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE; uiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; flagsView.setSystemUiVisibility(uiOptions); // END_INCLUDE(leanback_presets) dumpFlagStateToLog(uiOptions); // The below code just updates the checkboxes to reflect which flags have been set. mLowProfileCheckBox.setChecked(false); mHideNavCheckbox.setChecked(true); mHideStatusBarCheckBox.setChecked(true); mImmersiveModeCheckBox.setChecked(false); mImmersiveModeStickyCheckBox.setChecked(false); } }); // Setting these flags makes the content appear under the navigation // bars, so that showing/hiding the nav bars doesn't resize the content // window, which can be jarring. int uiOptions = flagsView.getSystemUiVisibility(); uiOptions |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; uiOptions |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE; uiOptions |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; flagsView.setSystemUiVisibility(uiOptions); return flagsView; }
From source file:net.zorgblub.typhon.fragment.ReadingFragment.java
private void toggleTitleBar() { AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity == null) { return;/*from w w w . ja v a 2s . com*/ } stopAnimating(); if (this.titleBarLayout.getVisibility() == View.VISIBLE) { titleBarLayout.setVisibility(View.GONE); updateFromPrefs(); } else { titleBarLayout.setVisibility(View.VISIBLE); View decorView = activity.getWindow().getDecorView(); int uiOptions = decorView.getSystemUiVisibility(); int newUiOptions = uiOptions; newUiOptions &= ~View.SYSTEM_UI_FLAG_FULLSCREEN; //newUiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; decorView.setSystemUiVisibility(newUiOptions); activity.getSupportActionBar().show(); dictionaryPane.conceal(); } }
From source file:org.brandroid.openmanager.activities.OpenExplorer.java
@SuppressWarnings("deprecation") public void setLights(Boolean on) { try {//from w ww . j ava 2 s . c om View root = getCurrentFocus().getRootView(); int vis = on ? View.STATUS_BAR_VISIBLE : View.STATUS_BAR_HIDDEN; if (root.getSystemUiVisibility() != vis) root.setSystemUiVisibility(vis); } catch (Exception e) { } }