public SystemChromeFader(Activity activity) { this.activity = activity; statusBarAlpha = Color.alpha(activity.getWindow().getStatusBarColor()); navBarAlpha = Color.alpha(activity.getWindow().getNavigationBarColor()); fadeNavBar = ViewUtils.isNavBarOnBottom(activity); }
public SystemChromeFader(Activity activity) { this.activity = activity; if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP){ statusBarAlpha = Color.alpha(activity.getWindow().getStatusBarColor()); navBarAlpha = Color.alpha(activity.getWindow().getNavigationBarColor()); } fadeNavBar = ViewUtils.isNavBarOnBottom(activity); }
@Override public void onDrag(float elasticOffset, float elasticOffsetPixels, float rawOffset, float rawOffsetPixels) { if (elasticOffsetPixels > 0) { // dragging downward, fade the status bar in proportion activity.getWindow().setStatusBarColor(ColorUtils.modifyAlpha(activity.getWindow() .getStatusBarColor(), (int) ((1f - rawOffset) * statusBarAlpha))); } else if (elasticOffsetPixels == 0) { // reset activity.getWindow().setStatusBarColor(ColorUtils.modifyAlpha( activity.getWindow().getStatusBarColor(), statusBarAlpha)); activity.getWindow().setNavigationBarColor(ColorUtils.modifyAlpha( activity.getWindow().getNavigationBarColor(), navBarAlpha)); } else if (fadeNavBar) { // dragging upward, fade the navigation bar in proportion activity.getWindow().setNavigationBarColor( ColorUtils.modifyAlpha(activity.getWindow().getNavigationBarColor(), (int) ((1f - rawOffset) * navBarAlpha))); } }
@Override public void onDrag(float elasticOffset, float elasticOffsetPixels, float rawOffset, float rawOffsetPixels) { if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP) { if (elasticOffsetPixels > 0) { // dragging downward, fade the status bar in proportion activity.getWindow().setStatusBarColor(ColorUtils.modifyAlpha(activity.getWindow() .getStatusBarColor(), (int) ((1f - rawOffset) * statusBarAlpha))); } else if (elasticOffsetPixels == 0) { // reset activity.getWindow().setStatusBarColor(ColorUtils.modifyAlpha( activity.getWindow().getStatusBarColor(), statusBarAlpha)); activity.getWindow().setNavigationBarColor(ColorUtils.modifyAlpha( activity.getWindow().getNavigationBarColor(), navBarAlpha)); } else if (fadeNavBar) { // dragging upward, fade the navigation bar in proportion activity.getWindow().setNavigationBarColor( ColorUtils.modifyAlpha(activity.getWindow().getNavigationBarColor(), (int) ((1f - rawOffset) * navBarAlpha))); } } }
@TargetApi(21) private void setStatusBarColor(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. Window window = this.getWindow(); 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); } } }
@TargetApi(21) private void setStatusBarColor(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. Window window = this.getWindow(); 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); } } }
public SystemChromeFader(Activity activity) { this.activity = activity; statusBarAlpha = Color.alpha(activity.getWindow().getStatusBarColor()); navBarAlpha = Color.alpha(activity.getWindow().getNavigationBarColor()); fadeNavBar = ViewUtils.isNavBarOnBottom(activity); }
if (statusBarColor == Color.BLACK && window.getNavigationBarColor() == Color.BLACK) { window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); } else {
@Override public void onDrag(float elasticOffset, float elasticOffsetPixels, float rawOffset, float rawOffsetPixels) { if (elasticOffsetPixels > 0) { // dragging downward, fade the status bar in proportion activity.getWindow().setStatusBarColor(ColorUtils.modifyAlpha(activity.getWindow() .getStatusBarColor(), (int) ((1f - rawOffset) * statusBarAlpha))); } else if (elasticOffsetPixels == 0) { // reset activity.getWindow().setStatusBarColor(ColorUtils.modifyAlpha( activity.getWindow().getStatusBarColor(), statusBarAlpha)); activity.getWindow().setNavigationBarColor(ColorUtils.modifyAlpha( activity.getWindow().getNavigationBarColor(), navBarAlpha)); } else if (fadeNavBar) { // dragging upward, fade the navigation bar in proportion activity.getWindow().setNavigationBarColor( ColorUtils.modifyAlpha(activity.getWindow().getNavigationBarColor(), (int) ((1f - rawOffset) * navBarAlpha))); } }
} else { if (getAnimationType() == AnimationType.Slide) { setNavigationBarColor(requireActivity().getWindow().getNavigationBarColor()); } else { setNavigationBarColor(Color.TRANSPARENT);