Java Code Examples for android.view.View.SYSTEM_UI_FLAG_IMMERSIVE

The following are Jave code examples for showing how to use SYSTEM_UI_FLAG_IMMERSIVE of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: TubiPlayer   File: Utils.java   Source Code and License Vote up 7 votes
public static void hideSystemUI(@NonNull final Activity activity, final boolean immediate, final int delayMs) {
    View decorView = activity.getWindow().getDecorView();
    // Set the IMMERSIVE flag.
    // Set the content to appear under the system bars so that the content
    // doesn't resize when the system bars hide and show.
    int uiState = 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 (Util.SDK_INT > 18) {
        uiState |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                | View.SYSTEM_UI_FLAG_IMMERSIVE;
    } else {
        final Handler handler = new Handler();
        decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int visibility) {
                if (visibility == View.VISIBLE) {
                    Runnable runnable = new Runnable() {
                        @Override
                        public void run() {
                            hideSystemUI(activity, false);
                        }
                    };
                    if(immediate){
                        handler.post(runnable);
                    }else{
                        handler.postDelayed(runnable, delayMs);
                    }
                }
            }
        });
    }
    decorView.setSystemUiVisibility(uiState);
}
 
Example 2
Project: LaunchEnr   File: ImmersiveUtils.java   Source Code and License Vote up 6 votes
public static void toggleHideyBar(Activity activity, boolean onResume) {

        int newUiOptions = activity.getWindow().getDecorView().getSystemUiVisibility();

        if (onResume) {

            applyImmersiveMode(activity);

        } else {
            newUiOptions ^= View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
            newUiOptions ^= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
            newUiOptions ^= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
            newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;

            newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
            newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE;
            newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
            activity.getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
        }
    }
 
Example 3
Project: CodeCompilerApp   File: SystemUiHelperImplKK.java   Source Code and License Vote up 6 votes
@Override
protected int createHideFlags() {
    int flag = super.createHideFlags();

    if (mLevel == SystemUiHelper.LEVEL_IMMERSIVE) {
        // If the client requested immersive mode, and we're on Android 4.4
        // or later, add relevant flags. Applying HIDE_NAVIGATION without
        // IMMERSIVE prevents the activity from accepting all touch events,
        // so we only do this on Android 4.4 and later (where IMMERSIVE is
        // present).
        flag |= ((mFlags & SystemUiHelper.FLAG_IMMERSIVE_STICKY) != 0)
                        ? View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                        : View.SYSTEM_UI_FLAG_IMMERSIVE;
    }

    return flag;
}
 
Example 4
Project: RetroMusicPlayer   File: SystemUiHelperImplKK.java   Source Code and License Vote up 6 votes
@Override
protected int createHideFlags() {
    int flag = super.createHideFlags();

    if (mLevel == SystemUiHelper.LEVEL_IMMERSIVE) {
        // If the client requested immersive mode, and we're on Android 4.4
        // or later, add relevant flags. Applying HIDE_NAVIGATION without
        // IMMERSIVE prevents the activity from accepting all touch events,
        // so we only do this on Android 4.4 and later (where IMMERSIVE is
        // present).
        flag |= ((mFlags & SystemUiHelper.FLAG_IMMERSIVE_STICKY) != 0)
                        ? View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                        : View.SYSTEM_UI_FLAG_IMMERSIVE;
    }

    return flag;
}
 
Example 5
Project: Quran   File: PagerActivity.java   Source Code and License Vote up 5 votes
@TargetApi(Build.VERSION_CODES.KITKAT)
private void setUiVisibilityKitKat(boolean isVisible) {
  int flags = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
      | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
      | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
  if (!isVisible) {
    flags |= View.SYSTEM_UI_FLAG_LOW_PROFILE
        | View.SYSTEM_UI_FLAG_FULLSCREEN
        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
        | View.SYSTEM_UI_FLAG_IMMERSIVE;
  }
  viewPager.setSystemUiVisibility(flags);
}
 
Example 6
Project: LauncherTV   File: Launcher.java   Source Code and License Vote up 5 votes
private void setFullScreen() {
	try {
		if (Build.VERSION.SDK_INT < 19) {
			getWindow().setFlags(
					WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER,
					WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER
			);
		} else {
			View decorView = getWindow().getDecorView();

			int uiOptions = 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
					| View.SYSTEM_UI_FLAG_IMMERSIVE;

			decorView.setSystemUiVisibility(uiOptions);

			getWindow().setFlags(
					WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER,
					WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER
			);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 7
Project: aos-Video   File: PlayerController.java   Source Code and License Vote up 4 votes
protected void showSystemBar(boolean show) {
    if (mSystemBarShowing == show) return;
    mSystemUiVisibility = mPlayerView.getSystemUiVisibility();
    if (PlayerConfig.hasHackedFullScreen()) {
        final int STATUS_BAR_GONE =  (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1 ? 0x00000004 : 0x000008);
        if (show)
            mSystemUiVisibility &= ~STATUS_BAR_GONE;
        else
            mSystemUiVisibility |= STATUS_BAR_GONE;
        manualVisibilityChange=true;
        mPlayerView.setSystemUiVisibility(mSystemUiVisibility);
        mSystemBarGone = !show;
    } else {
        int systemUiFlag = View.SYSTEM_UI_FLAG_LOW_PROFILE;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { /* ICS and less */
            if (show)
                mWindow.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            else
                mWindow.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        } else { /* JB and more */
            systemUiFlag |= 0x00000004 /* View.SYSTEM_UI_FLAG_FULLSCREEN */;
        }
        if (show) {
            mSystemUiVisibility &= ~systemUiFlag;
            if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
                mSystemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE;
        }
        else {
            mSystemUiVisibility |= systemUiFlag;
            if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
                    mSystemUiVisibility |= View.SYSTEM_UI_FLAG_IMMERSIVE;
        }
        mPlayerView.setSystemUiVisibility(mSystemUiVisibility);
        manualVisibilityChange=true;
        mSystemBarGone = false;
        if (PlayerConfig.canSystemBarHide()) {
            if (!show)
                mHandler.sendEmptyMessageDelayed(MSG_HIDE_SYSTEM_BAR, 1000);
        }
    }
    mSystemBarShowing = show;
}
 
Example 8
Project: SeafoodBerserker   File: PlayActivity.java   Source Code and License Vote up 4 votes
@Override
protected void onResume() {
    super.onResume();

    // Hide the status bar.
    int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY  ;
    getWindow().getDecorView().setSystemUiVisibility(uiOptions);

    mSounds = App.getInstance(this).getSoundEffects();


    unpause();

    updateScores();

    mSounds.playBGMusic();


}