Java Code Examples for android.view.View#getSystemUiVisibility()

The following examples show how to use android.view.View#getSystemUiVisibility() . These examples are extracted from open source projects. 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 Project: DevUtils   File: BarUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 设置 Navigation Bar 是否高亮模式
 * @param window      {@link Window}
 * @param isLightMode 是否高亮模式
 * @return {@code true} success, {@code false} fail
 */
public static boolean setNavBarLightMode(final Window window, final boolean isLightMode) {
    if (window != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        View decorView = window.getDecorView();
        int vis = decorView.getSystemUiVisibility();
        if (isLightMode) {
            vis |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        } else {
            vis &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        }
        decorView.setSystemUiVisibility(vis);
        return true;
    }
    return false;
}
 
Example 2
Source Project: styT   File: StatusbarColorUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 设置状态栏颜色
 *
 * @param view
 * @param dark
 */
private static void setStatusBarDarkIcon(View view, boolean dark) {
    int oldVis = view.getSystemUiVisibility();
    int newVis = oldVis;
    if (dark) {
        newVis |= SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
    } else {
        newVis &= ~SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
    }
    if (newVis != oldVis) {
        view.setSystemUiVisibility(newVis);
    }
}
 
Example 3
Source Project: DevUtils   File: BarUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获取 Navigation Bar 是否高亮模式
 * @param window {@link Window}
 * @return {@code true} yes, {@code false} no
 */
public static boolean isNavBarLightMode(final Window window) {
    if (window != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        View decorView = window.getDecorView();
        int vis = decorView.getSystemUiVisibility();
        return (vis & View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR) != 0;
    }
    return false;
}
 
Example 4
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public void setLightStatusBar(Window window, boolean lightStatusBar) {
    // 设置浅色状态栏时的界面显示
    View decor = window.getDecorView();
    int ui = decor.getSystemUiVisibility();
    if (lightStatusBar) {
        ui |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
    } else {
        ui &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
    }
    decor.setSystemUiVisibility(ui);

}
 
Example 5
Source Project: TheGreatAdapter   File: ViewUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static void clearLightStatusBar(@NonNull View view) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        int flags = view.getSystemUiVisibility();
        flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        view.setSystemUiVisibility(flags);
    }
}
 
Example 6
Source Project: 365browser   File: WebappActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets activity's decor view into an immersive mode.
 * If immersive mode is not supported, this method no-ops.
 */
private void enterImmersiveMode() {
    // Immersive mode is only supported in API 19+.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;

    if (mSetImmersiveRunnable == null) {

        final View decor = getWindow().getDecorView();

        mSetImmersiveRunnable = new Runnable() {
            @Override
            public void run() {
                int currentFlags = decor.getSystemUiVisibility();
                int desiredFlags = currentFlags | IMMERSIVE_MODE_UI_FLAGS;
                if (currentFlags != desiredFlags) {
                    decor.setSystemUiVisibility(desiredFlags);
                }
            }
        };

        // When we enter immersive mode for the first time, register a
        // SystemUiVisibilityChangeListener that restores immersive mode. This is necessary
        // because user actions like focusing a keyboard will break out of immersive mode.
        decor.setOnSystemUiVisibilityChangeListener(new OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int newFlags) {
                if ((newFlags & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
                    asyncSetImmersive(RESTORE_IMMERSIVE_MODE_DELAY_MILLIS);
                }
            }
        });
    }

    asyncSetImmersive(0);
}
 
Example 7
Source Project: Android-utils   File: BarUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Set the status bar's light mode.
 *
 * @param window      The window.
 * @param isLightMode True to set status bar light mode, false otherwise.
 */
public static void setStatusBarLightMode(@NonNull final Window window,
                                         final boolean isLightMode) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        View decorView = window.getDecorView();
        int vis = decorView.getSystemUiVisibility();
        if (isLightMode) {
            vis |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        } else {
            vis &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        }
        decorView.setSystemUiVisibility(vis);
    }
}
 
Example 8
public static void setLightNavigationBar(Window window, boolean enable) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        final View decorView = window.getDecorView();
        int flags = decorView.getSystemUiVisibility();
        if (enable) {
            flags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        } else {
            flags &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        }
        decorView.setSystemUiVisibility(flags);
    }
}
 
Example 9
Source Project: AndroidNavigation   File: AppUtils.java    License: MIT License 5 votes vote down vote up
public static void setNavigationBarHidden(Window window, boolean hidden) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        View decorView = window.getDecorView();
        int systemUi = decorView.getSystemUiVisibility();
        if (hidden) {
            systemUi |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
            systemUi |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        } else {
            systemUi &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
            systemUi &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        }
        window.getDecorView().setSystemUiVisibility(systemUi);
    }
}
 
Example 10
Source Project: Android-utils   File: BarUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Is the nav bar light mode.
 *
 * @param window The window.
 * @return {@code true}: yes<br>{@code false}: no
 */
public static boolean isNavBarLightMode(@NonNull final Window window) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        View decorView = window.getDecorView();
        int vis = decorView.getSystemUiVisibility();
        return (vis & View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR) != 0;
    }
    return false;
}
 
Example 11
/**
 * 设置状态栏颜色
 *
 * @param view
 * @param dark
 */
private static void setStatusBarDarkIcon(View view, boolean dark) {
    int oldVis = view.getSystemUiVisibility();
    int newVis = oldVis;
    if (dark) {
        newVis |= SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
    } else {
        newVis &= ~SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
    }
    if (newVis != oldVis) {
        view.setSystemUiVisibility(newVis);
    }
}
 
Example 12
Source Project: dynamic-utils   File: DynamicViewUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Set light status bar if we are using light primary color on API 23 and above devices.
 *
 * @param view The view to get the system ui flags.
 * @param light {@code true} to set the light status bar.
 */
@TargetApi(Build.VERSION_CODES.M)
public static void setLightStatusBar(@NonNull View view, boolean light) {
    if (DynamicSdkUtils.is23()) {
        int flags = view.getSystemUiVisibility();
        if (light) {
            flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        } else {
            flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        }

        view.setSystemUiVisibility(flags);
    }
}
 
Example 13
Source Project: DoraemonKit   File: UIUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static boolean checkFullScreenByCode(Context context) {
    if (context instanceof Activity) {
        Window window = ((Activity) context).getWindow();
        if (window != null) {
            View decorView = window.getDecorView();
            if (decorView != null) {
                return (decorView.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_FULLSCREEN) == View.SYSTEM_UI_FLAG_FULLSCREEN;
            }
        }
    }
    return false;
}
 
Example 14
/**
 * 设置状态栏颜色
 *
 * @param view
 * @param dark
 */
private static void setStatusBarDarkIcon(View view, boolean dark) {
    int oldVis = view.getSystemUiVisibility();
    int newVis = oldVis;
    if (dark) {
        newVis |= SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
    } else {
        newVis &= ~SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
    }
    if (newVis != oldVis) {
        view.setSystemUiVisibility(newVis);
    }
}
 
Example 15
Source Project: paper-launcher   File: SystemBarUtil.java    License: MIT License 5 votes vote down vote up
public static void enableLightStatusBar(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        View view = activity.getWindow().getDecorView();

        int flags = view.getSystemUiVisibility();
        flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        view.setSystemUiVisibility(flags);
    }
}
 
Example 16
Source Project: react-native-navigation   File: Presenter.java    License: MIT License 5 votes vote down vote up
private void setStatusBarVisible(Bool visible) {
    View decorView = activity.getWindow().getDecorView();
    int flags = decorView.getSystemUiVisibility();
    if (visible.isFalse()) {
        flags |= View.SYSTEM_UI_FLAG_FULLSCREEN;
    } else {
        flags &= ~View.SYSTEM_UI_FLAG_FULLSCREEN;
    }
    decorView.setSystemUiVisibility(flags);
}
 
Example 17
public static boolean hasFlags(View view, int flags) {
    return (view.getSystemUiVisibility() & flags) == flags;
}
 
Example 18
Source Project: android-browser-helper   File: Utils.java    License: Apache License 2.0 4 votes vote down vote up
private static void addSystemUiVisibilityFlag(Activity activity, int flag) {
    View root = activity.getWindow().getDecorView().getRootView();
    int visibility = root.getSystemUiVisibility();
    visibility |= flag;
    root.setSystemUiVisibility(visibility);
}
 
Example 19
Source Project: android_9.0.0_r45   File: DreamService.java    License: Apache License 2.0 4 votes vote down vote up
private boolean getSystemUiVisibilityFlagValue(int flag, boolean defaultValue) {
    View v = mWindow == null ? null : mWindow.getDecorView();
    return v == null ? defaultValue : (v.getSystemUiVisibility() & flag) != 0;
}
 
Example 20
Source Project: youqu_master   File: WindowUtil.java    License: Apache License 2.0 4 votes vote down vote up
private static void showNavigationBar(Context context) {
    View decorView = scanForActivity(context).getWindow().getDecorView();
    int systemUiVisibility = decorView.getSystemUiVisibility();
    systemUiVisibility &= ~FLAGS;
    decorView.setSystemUiVisibility(systemUiVisibility);
}