@SuppressLint("NewApi") private void setNavigationBarTint(final int tintColor, boolean force) { if (mNavigationBarView == null) return; if (mSettingsHelper.shouldLinkStatusBarAndNavBar() && !force) { log("Ignoring manual navigation bar color change cause we're linked"); return; } log("Setting navigation bar color to " + tintColor); if (mSettingsHelper.animateStatusBarTintChange()) { if (tintColor != KITKAT_TRANSPARENT_COLOR) { ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), mLastSetNavBarTint, tintColor); colorAnimation.addUpdateListener( new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { mNavigationBarView.setBackgroundColor((Integer) animator.getAnimatedValue()); } }); colorAnimation.start(); } else { mNavigationBarView.setBackgroundColor(KITKAT_TRANSPARENT_COLOR); Utils.setViewBackground( mNavigationBarView, new BarBackgroundDrawable( mStatusBarView.getContext(), mResources, R.drawable.nav_background)); } } else { if (tintColor == KITKAT_TRANSPARENT_COLOR) { mNavigationBarView.setBackgroundColor(KITKAT_TRANSPARENT_COLOR); Utils.setViewBackground( mNavigationBarView, new BarBackgroundDrawable( mNavigationBarView.getContext(), mResources, R.drawable.nav_background)); } else { mNavigationBarView.setBackgroundColor(tintColor); } } if (mNavigationBarView != null && tintColor != KITKAT_TRANSPARENT_COLOR) { Intent intent = new Intent("gravitybox.intent.action.ACTION_NAVBAR_CHANGED"); intent.putExtra("navbarBgColor", tintColor); intent.putExtra("navbarColorEnable", true); mNavigationBarView.getContext().sendBroadcast(intent); } mLastSetNavBarTint = tintColor; }
@SuppressLint("NewApi") public void setStatusBarTint(final int tintColor) { if (mStatusBarView == null) return; log("Setting statusbar color to " + tintColor); if (mSettingsHelper.animateStatusBarTintChange()) { int animateFrom = mLastSetColor == KITKAT_TRANSPARENT_COLOR ? Color.TRANSPARENT : mLastSetColor; int animateTo = tintColor == KITKAT_TRANSPARENT_COLOR ? Color.TRANSPARENT : tintColor; ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), animateFrom, animateTo); colorAnimation.addUpdateListener( new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { mGradientDrawable.setColor((Integer) animator.getAnimatedValue()); } }); Utils.setViewBackground(mStatusBarView, mGradientDrawable); mGradientDrawable.setMode(mSettingsHelper.getOverlayMode()); colorAnimation.start(); } else { mStatusBarView.setAlpha(1f); if (tintColor == KITKAT_TRANSPARENT_COLOR) { Utils.setViewBackground(mStatusBarView, mGradientDrawable); mGradientDrawable.setColor(Color.TRANSPARENT); mGradientDrawable.setMode(mSettingsHelper.getOverlayMode()); } else { Utils.setViewBackground(mStatusBarView, mGradientDrawable); mGradientDrawable.setColor(tintColor); mGradientDrawable.setMode(mSettingsHelper.getOverlayMode()); } } mLastSetColor = tintColor; if (mSettingsHelper.shouldLinkStatusBarAndNavBar() && !mKeyboardUp) { mNavigationBarTint = tintColor; setNavigationBarTint(tintColor, true); } }
public void setStatusBarView(View view) { mStatusBarView = view; Utils.setViewBackground(mStatusBarView, mGradientDrawable); }