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

The following examples show how to use android.view.View#getSystemUiVisibility() . 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: AndroidUtilities.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
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 2
Source File: Presenter.java    From react-native-navigation with 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 3
Source File: SystemBarUtil.java    From paper-launcher with 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 4
Source File: SpecialBarFontUtils.java    From MNProgressHUD with 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 5
Source File: UIUtils.java    From DoraemonKit with 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 6
Source File: DynamicViewUtils.java    From dynamic-utils with 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 7
Source File: SpecialBarFontUtils.java    From ImmersionBar with 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 8
Source File: BarUtils.java    From Android-utils with 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 9
Source File: AppUtils.java    From AndroidNavigation with 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 File: BarUtils.java    From DevUtils with 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 11
Source File: BarUtils.java    From Android-utils with 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 12
Source File: WebappActivity.java    From 365browser with 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 13
Source File: ViewUtils.java    From TheGreatAdapter with 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 14
Source File: LightStatusBarCompat.java    From status-bar-compat with Apache License 2.0 5 votes vote down vote up
@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 15
Source File: BarUtils.java    From DevUtils with 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 16
Source File: StatusbarColorUtils.java    From styT with 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 17
Source File: DreamService.java    From android_9.0.0_r45 with 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 18
Source File: WindowUtil.java    From youqu_master with 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);
}
 
Example 19
Source File: Utils.java    From android-browser-helper with 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 20
Source File: SystemUiVisibilityUtil.java    From mr-mantou-android with GNU General Public License v3.0 4 votes vote down vote up
public static boolean hasFlags(View view, int flags) {
    return (view.getSystemUiVisibility() & flags) == flags;
}