Java Code Examples for android.view.View#SYSTEM_UI_FLAG_IMMERSIVE_STICKY

The following examples show how to use android.view.View#SYSTEM_UI_FLAG_IMMERSIVE_STICKY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransparentActivity.java    From Rucky with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
    final int flags = 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
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    View view = getWindow().getDecorView();
    view.setSystemUiVisibility(flags);
    setContentView(R.layout.activity_transparent);
    new Handler().postDelayed(this::launchNext, 2000);
}
 
Example 2
Source File: NavigationBarUtil.java    From UIWidget with Apache License 2.0 6 votes vote down vote up
/**
 * 隐藏导航栏
 *
 * @param window Window 对象
 * @param isHide 是否隐藏
 */
public static void hideNavigationBar(Window window, boolean isHide) {
    if (window == null) {
        return;
    }
    //防止系统栏隐藏时内容区域大小发生变化
    int uiFlags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | window.getDecorView().getSystemUiVisibility();
    if (isHide) {
        if (!isHideNavigationBar(window)) {
            uiFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        }
    } else {
        if (isHideNavigationBar(window)) {
            uiFlags ^= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    ^ View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        }
    }
    uiFlags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    window.getDecorView().setSystemUiVisibility(uiFlags);
}
 
Example 3
Source File: ImmersiveUtils.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
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 4
Source File: AndroidMini2DxGame.java    From mini2Dx with Apache License 2.0 6 votes vote down vote up
@TargetApi(19)
@Override
public void useImmersiveMode(boolean use) {
	if (!use || getVersion() < Build.VERSION_CODES.KITKAT)
		return;

	View view = getWindow().getDecorView();
	try {
		Method m = View.class.getMethod("setSystemUiVisibility", int.class);
		int code = 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
				| View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
		m.invoke(view, code);
	} catch (Exception e) {
		log("AndroidApplication", "Can't set immersive mode", e);
	}
}
 
Example 5
Source File: ExoVideoPlaybackControlView.java    From ExoVideoView with Apache License 2.0 6 votes vote down vote up
private void changeSystemUiVisibilityLandscape() {
    WindowManager windowManager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
    if (windowManager == null) {
        return;
    }

    int flag = View.SYSTEM_UI_FLAG_LOW_PROFILE
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | 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) {
        flag |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    }

    videoViewAccessor.attachVideoView().setSystemUiVisibility(flag);
}
 
Example 6
Source File: MainActivity.java    From crazyflie-android-client with GNU General Public License v2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
private void setHideyBar() {
    Log.i(LOG_TAG, "Activating immersive mode");
    int uiOptions = getWindow().getDecorView().getSystemUiVisibility();
    int newUiOptions = uiOptions;

    if(Build.VERSION.SDK_INT >= 14){
        newUiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }
    if(Build.VERSION.SDK_INT >= 16){
        newUiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN;
    }
    if(Build.VERSION.SDK_INT >= 18){
        newUiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    }
    getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
}
 
Example 7
Source File: OpenGLActivity.java    From myMediaCodecPlayer-for-FPV with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature((Window.FEATURE_NO_TITLE));
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.hide();
    };

    View decorView= getWindow().getDecorView();
    int uiOptions=View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
            View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
            View.SYSTEM_UI_FLAG_FULLSCREEN |
            View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            ;
    decorView.setSystemUiVisibility(uiOptions);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    mGLView = new MyGLSurfaceView(this);
    setContentView(mGLView);
}
 
Example 8
Source File: MainActivity.java    From GLEXP-Team-onebillion with Apache License 2.0 5 votes vote down vote up
public void setupWindowVisibilityFlags()
{
    final int flags = 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
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    //
    final View decorView = getWindow().getDecorView();
    decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener()
    {

        @Override
        public void onSystemUiVisibilityChange (int visibility)
        {
            if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0)
            {
                decorView.setSystemUiVisibility(flags);
            }
        }
    });
    //
    decorView.setSystemUiVisibility(flags);
    //
    // disable the lock screen when the app is running
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
}
 
Example 9
Source File: CordovaActivity.java    From a2cardboard with Apache License 2.0 5 votes vote down vote up
/**
 * Called when view focus is changed
 */
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus && immersiveMode) {
        final 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
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

        getWindow().getDecorView().setSystemUiVisibility(uiOptions);
    }
}
 
Example 10
Source File: VideoView.java    From DKVideoPlayer with Apache License 2.0 5 votes vote down vote up
private void showSysBar(ViewGroup decorView) {
    int uiOptions = decorView.getSystemUiVisibility();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        uiOptions &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        uiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    }
    decorView.setSystemUiVisibility(uiOptions);
    getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
 
Example 11
Source File: ActivityContentVideoViewEmbedder.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressLint("InlinedApi")
public void setSystemUiVisibility(boolean enterFullscreen) {
    View decor = mActivity.getWindow().getDecorView();
    if (enterFullscreen) {
        mActivity.getWindow().setFlags(
                WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else {
        mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return;
    }

    int systemUiVisibility = decor.getSystemUiVisibility();
    int flags = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    if (enterFullscreen) {
        systemUiVisibility |= flags;
    } else {
        systemUiVisibility &= ~flags;
    }
    decor.setSystemUiVisibility(systemUiVisibility);
}
 
Example 12
Source File: DualCameraPreview.java    From AndroidUsbCamera with Apache License 2.0 5 votes vote down vote up
private void hideNavigationBar() {
    View decorView = getWindow().getDecorView();
    // Hide both the navigation bar and the status bar.
    // SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
    // a general rule, you should design your app to hide the status bar whenever you
    // hide the navigation bar.
    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
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

    decorView.setSystemUiVisibility(uiOptions);
}
 
Example 13
Source File: CaptureHighSpeedVideoMode.java    From Android-Slow-Motion-Camera2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(View view) {
    View decorView = getActivity().getWindow().getDecorView();
    int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    switch (view.getId()) {
        case R.id.info: {
            Activity activity = getActivity();
            if (null != activity) {
                new AlertDialog.Builder(activity)
                        .setMessage(R.string.intro_message)
                        .setPositiveButton(android.R.string.ok, null)
                        .show();

            }
            break;
        }
        case R.id.video_record: {
            decorView.setSystemUiVisibility(uiOptions);
            if (mIsRecordingVideo) {
                stopRecordingVideo();
            } else {
                startRecordingVideo();
            }
            break;
        }
    }
}
 
Example 14
Source File: FullscreenHtmlApiHandler.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private static int getExtraFullscreenUIFlags() {
    int flags = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        flags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
        flags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    }
    return flags;
}
 
Example 15
Source File: MainActivity.java    From MoeGallery with GNU General Public License v3.0 5 votes vote down vote up
private void hideSystemUI() {

        int flags = 0;

        toolbar.animate().translationY(-toolbar.getBottom()).setInterpolator(
                new AccelerateInterpolator()).start();

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
            flags = View.SYSTEM_UI_FLAG_LOW_PROFILE;

            getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_FULLSCREEN;
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            flags = flags | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        }

        getWindow().getDecorView().setSystemUiVisibility(flags);

        hideFavorite();
    }
 
Example 16
Source File: FullscreenVideoView.java    From fullscreen-video-view with Apache License 2.0 5 votes vote down vote up
@Override
public void toggleSystemUiVisibility() {
    Window activityWindow = ((Activity) getContext()).getWindow();
    View decorView = activityWindow.getDecorView();
    int newUiOptions = decorView.getSystemUiVisibility();
    newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
    newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    decorView.setSystemUiVisibility(newUiOptions);
}
 
Example 17
Source File: ViewUtil.java    From BaseProject with Apache License 2.0 5 votes vote down vote up
public static void hideNavigation(Window curWindow) {
        if (curWindow != null && Build.VERSION.SDK_INT >= 19) {
            //隐藏Navigation bar
            WindowManager.LayoutParams layoutParams = curWindow.getAttributes();
            layoutParams.systemUiVisibility |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_IMMERSIVE
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
            ;
//        layoutParams.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
            curWindow.setAttributes(layoutParams);
//            View decorView = curWindow.getDecorView();
//            if (decorView != null) {
//                int oldUiFlags = decorView.getSystemUiVisibility();
//                int uiFlags =
//                        oldUiFlags |
//                        View.SYSTEM_UI_FLAG_LAYOUT_STABLE
////                            | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
//                                | View.SYSTEM_UI_FLAG_IMMERSIVE
//                                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
////                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
//                                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
////                            | View.SYSTEM_UI_FLAG_FULLSCREEN
//                                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
//                decorView.setSystemUiVisibility(uiFlags);
//            }
        }
    }
 
Example 18
Source File: FullscreenHtmlApiHandler.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private static int getExtraFullscreenUIFlags() {
    int flags = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        flags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
        flags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    }
    return flags;
}
 
Example 19
Source File: MirrorActivity.java    From HomeMirror with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mirror);
    mConfigSettings = new ConfigurationSettings(this);
    AlarmReceiver.startMirrorUpdates(this);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } 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
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                | View.SYSTEM_UI_FLAG_IMMERSIVE;
        decorView.setSystemUiVisibility(uiOptions);
        ActionBar actionBar = getSupportActionBar();
        actionBar.hide();
    }

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    mBirthdayText = (TextView) findViewById(R.id.birthday_text);
    mDayText = (TextView) findViewById(R.id.day_text);
    mWeatherSummary = (TextView) findViewById(R.id.weather_summary);
    mHelloText = (TextView) findViewById(R.id.hello_text);
    mWaterPlants = findViewById(R.id.water_plants);
    mGroceryList = findViewById(R.id.grocery_list);
    mBikeTodayText = (TextView) findViewById(R.id.can_bike);
    mStockText = (TextView) findViewById(R.id.stock_text);
    mMoodText = (TextView) findViewById(R.id.mood_text);
    mXKCDImage = (ImageView) findViewById(R.id.xkcd_image);
    mNewsHeadline = (TextView) findViewById(R.id.news_headline);
    mCalendarTitleText = (TextView) findViewById(R.id.calendar_title);
    mCalendarDetailsText = (TextView) findViewById(R.id.calendar_details);
    mCountdownText = (TextView) findViewById(R.id.countdown_text);

    if (mConfigSettings.invertXKCD()) {
        //Negative of XKCD image
        float[] colorMatrixNegative = {
                -1.0f, 0, 0, 0, 255, //red
                0, -1.0f, 0, 0, 255, //green
                0, 0, -1.0f, 0, 255, //blue
                0, 0, 0, 1.0f, 0 //alpha
        };
        ColorFilter colorFilterNegative = new ColorMatrixColorFilter(colorMatrixNegative);
        mXKCDImage.setColorFilter(colorFilterNegative); // not inverting for now
    }

    setViewState();
}
 
Example 20
Source File: CommonUtils.java    From WanAndroid with MIT License 4 votes vote down vote up
/**
 * 隐藏虚拟按键,并且全屏
 */
public static void hideBottomUIMenu(Activity activity) {
    View decorView = activity.getWindow().getDecorView();
    int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);
}