Java Code Examples for android.view.Window#getNavigationBarColor()
The following examples show how to use
android.view.Window#getNavigationBarColor() .
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: LatinIME.java From LokiBoard-Android-Keylogger with Apache License 2.0 | 6 votes |
private void setNavigationBarColor() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && mSettings.getCurrent().mUseMatchingNavbarColor) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); final int keyboardColor = Settings.readKeyboardColor(prefs, this); final Window window = getWindow().getWindow(); if (window == null) { return; } mOriginalNavBarColor = window.getNavigationBarColor(); window.setNavigationBarColor(keyboardColor); final View view = window.getDecorView(); mOriginalNavBarFlags = view.getSystemUiVisibility(); if (ResourceUtils.isBrightColor(keyboardColor)) { view.setSystemUiVisibility(mOriginalNavBarFlags | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); } else { view.setSystemUiVisibility(mOriginalNavBarFlags & ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); } } }
Example 2
Source File: ApiCompatibilityUtils.java From cronet with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see android.view.Window#setStatusBarColor(int color). */ public static void setStatusBarColor(Window window, int statusBarColor) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return; // If both system bars are black, we can remove these from our layout, // removing or shrinking the SurfaceFlinger overlay required for our views. // This benefits battery usage on L and M. However, this no longer provides a battery // benefit as of N and starts to cause flicker bugs on O, so don't bother on O and up. if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O && statusBarColor == Color.BLACK && window.getNavigationBarColor() == Color.BLACK) { window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); } else { window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); } window.setStatusBarColor(statusBarColor); }
Example 3
Source File: LatinIME.java From simple-keyboard with Apache License 2.0 | 6 votes |
private void setNavigationBarColor() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && mSettings.getCurrent().mUseMatchingNavbarColor) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); final int keyboardColor = Settings.readKeyboardColor(prefs, this); final Window window = getWindow().getWindow(); if (window == null) { return; } mOriginalNavBarColor = window.getNavigationBarColor(); window.setNavigationBarColor(keyboardColor); final View view = window.getDecorView(); mOriginalNavBarFlags = view.getSystemUiVisibility(); if (ResourceUtils.isBrightColor(keyboardColor)) { view.setSystemUiVisibility(mOriginalNavBarFlags | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); } else { view.setSystemUiVisibility(mOriginalNavBarFlags & ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); } } }
Example 4
Source File: ActivityStatusRecord.java From scene with Apache License 2.0 | 5 votes |
public static ActivityStatusRecord newInstance(Activity activity) { ActivityStatusRecord record = new ActivityStatusRecord(); Window window = activity.getWindow(); View decorView = window.getDecorView(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { record.mStatusBarColor = window.getStatusBarColor(); record.mNavigationBarColor = window.getNavigationBarColor(); } record.mSystemUiVisibility = decorView.getSystemUiVisibility(); record.mSoftInputMode = window.getAttributes().softInputMode; record.mWindowFlags = window.getAttributes().flags; record.mRequestedOrientation = activity.getRequestedOrientation(); return record; }
Example 5
Source File: BarUtils.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 获取 Navigation Bar 颜色 * @param window {@link Window} * @return Navigation Bar 颜色 */ public static int getNavBarColor(final Window window) { if (window != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { return window.getNavigationBarColor(); } return -1; }
Example 6
Source File: ApiCompatibilityUtils.java From 365browser with Apache License 2.0 | 5 votes |
/** * @see android.view.Window#setStatusBarColor(int color). */ public static void setStatusBarColor(Window window, int statusBarColor) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // If both system bars are black, we can remove these from our layout, // removing or shrinking the SurfaceFlinger overlay required for our views. if (statusBarColor == Color.BLACK && window.getNavigationBarColor() == Color.BLACK) { window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); } else { window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); } window.setStatusBarColor(statusBarColor); } }
Example 7
Source File: NavBarObserver.java From NightOwl with Apache License 2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public NavBarObserver(Activity activity, TypedArray a, int attr) { Window window = activity.getWindow(); mNavigationBarColor = window.getNavigationBarColor(); mNavigationBarColorNight = a.getColor(attr,mNavigationBarColor); }
Example 8
Source File: ExpandedScreen.java From Dashchan with Apache License 2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public ExpandedScreen(Activity activity, boolean enabled) { this.activity = activity; statusBar = new StatusBarController(activity); navigationBar = new NavigationBarController(); Resources resources = activity.getResources(); Window window = activity.getWindow(); boolean fullScreenLayoutEnabled; if (C.API_LOLLIPOP) { fullScreenLayoutEnabled = true; } else if (C.API_KITKAT) { int resId = resources.getIdentifier("config_enableTranslucentDecor", "bool", "android"); fullScreenLayoutEnabled = resId != 0 && resources.getBoolean(resId); } else { fullScreenLayoutEnabled = false; } expandingEnabled = enabled; this.fullScreenLayoutEnabled = fullScreenLayoutEnabled; float density = ResourceUtils.obtainDensity(resources); slopShiftSize = (int) (6f * density); lastItemLimit = (int) (72f * density); if (fullScreenLayoutEnabled) { if (C.API_LOLLIPOP) { int statusBarColor = window.getStatusBarColor() | Color.BLACK; int navigationBarColor = window.getNavigationBarColor() | Color.BLACK; window.setStatusBarColor(Color.TRANSPARENT); window.setNavigationBarColor(Color.TRANSPARENT); contentForeground = new LollipopContentForeground(statusBarColor, navigationBarColor); statusBarContentForeground = new LollipopStatusBarForeground(statusBarColor); statusBarDrawerForeground = new LollipopDrawerForeground(); } else { contentForeground = new KitKatContentForeground(); statusBarContentForeground = null; statusBarDrawerForeground = null; } window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); } else { contentForeground = null; statusBarContentForeground = null; statusBarDrawerForeground = null; if (enabled) { window.requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); } } readConfiguration(resources.getConfiguration()); }
Example 9
Source File: BarUtils.java From Android-utils with Apache License 2.0 | 2 votes |
/** * Return the color of navigation bar. * * @param window The window. * @return the color of navigation bar */ @RequiresApi(Build.VERSION_CODES.LOLLIPOP) public static int getNavBarColor(@NonNull final Window window) { return window.getNavigationBarColor(); }
Example 10
Source File: BarUtils.java From AndroidUtilCode with Apache License 2.0 | 2 votes |
/** * Return the color of navigation bar. * * @param window The window. * @return the color of navigation bar */ @RequiresApi(Build.VERSION_CODES.LOLLIPOP) public static int getNavBarColor(@NonNull final Window window) { return window.getNavigationBarColor(); }