forked from upstream-mirrors/quik
Tint status bar with new color
This commit is contained in:
@@ -34,9 +34,10 @@ public class ColorUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int darken(int color) {
|
public static int darken(int color) {
|
||||||
return Color.argb(Color.alpha(color),
|
float[] hsv = new float[3];
|
||||||
(int) (Color.red(color) * 0.7),
|
Color.colorToHSV(color, hsv);
|
||||||
(int) (Color.green(color) * 0.7),
|
hsv[2] *= 0.75f;
|
||||||
(int) (Color.blue(color) * 0.7));
|
color = Color.HSVToColor(hsv);
|
||||||
|
return color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@@ -25,6 +24,7 @@ import android.widget.LinearLayout;
|
|||||||
import com.moez.QKSMS.R;
|
import com.moez.QKSMS.R;
|
||||||
import com.moez.QKSMS.common.AnalyticsManager;
|
import com.moez.QKSMS.common.AnalyticsManager;
|
||||||
import com.moez.QKSMS.common.LiveViewManager;
|
import com.moez.QKSMS.common.LiveViewManager;
|
||||||
|
import com.moez.QKSMS.common.utils.ColorUtils;
|
||||||
import com.moez.QKSMS.interfaces.LiveView;
|
import com.moez.QKSMS.interfaces.LiveView;
|
||||||
import com.moez.QKSMS.receiver.IconColorReceiver;
|
import com.moez.QKSMS.receiver.IconColorReceiver;
|
||||||
import com.moez.QKSMS.ui.base.QKActivity;
|
import com.moez.QKSMS.ui.base.QKActivity;
|
||||||
@@ -71,6 +71,7 @@ public class ThemeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static int sColor;
|
private static int sColor;
|
||||||
|
private static int sActiveColor;
|
||||||
private static int sBackgroundColor;
|
private static int sBackgroundColor;
|
||||||
private static Theme sTheme;
|
private static Theme sTheme;
|
||||||
|
|
||||||
@@ -256,6 +257,7 @@ public class ThemeManager {
|
|||||||
mContext = context;
|
mContext = context;
|
||||||
|
|
||||||
sColor = Integer.parseInt(sPrefs.getString(SettingsFragment.THEME, "" + ThemeManager.DEFAULT_COLOR));
|
sColor = Integer.parseInt(sPrefs.getString(SettingsFragment.THEME, "" + ThemeManager.DEFAULT_COLOR));
|
||||||
|
sActiveColor = sColor;
|
||||||
|
|
||||||
if (context instanceof QKActivity) {
|
if (context instanceof QKActivity) {
|
||||||
mActivity = (QKActivity) context;
|
mActivity = (QKActivity) context;
|
||||||
@@ -270,10 +272,10 @@ public class ThemeManager {
|
|||||||
|
|
||||||
if (mActivity != null && sStatusTintEnabled) {
|
if (mActivity != null && sStatusTintEnabled) {
|
||||||
if (sStatusTintEnabled) {
|
if (sStatusTintEnabled) {
|
||||||
mWindow.setStatusBarColor(darkenColor(sColor));
|
mWindow.setStatusBarColor(ColorUtils.darken(sColor));
|
||||||
}
|
}
|
||||||
if (sNavigationTintEnabled) {
|
if (sNavigationTintEnabled) {
|
||||||
mWindow.setNavigationBarColor(darkenColor(sColor));
|
mWindow.setNavigationBarColor(ColorUtils.darken(sColor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,7 +588,7 @@ public class ThemeManager {
|
|||||||
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
|
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
|
||||||
colorAnimation.setDuration(TRANSITION_LENGTH);
|
colorAnimation.setDuration(TRANSITION_LENGTH);
|
||||||
colorAnimation.addUpdateListener(animation -> {
|
colorAnimation.addUpdateListener(animation -> {
|
||||||
mWindow.setStatusBarColor(darkenColor((Integer) animation.getAnimatedValue()));
|
mWindow.setStatusBarColor(ColorUtils.darken((Integer) animation.getAnimatedValue()));
|
||||||
});
|
});
|
||||||
colorAnimation.start();
|
colorAnimation.start();
|
||||||
}
|
}
|
||||||
@@ -602,7 +604,7 @@ public class ThemeManager {
|
|||||||
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
|
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
|
||||||
colorAnimation.setDuration(TRANSITION_LENGTH);
|
colorAnimation.setDuration(TRANSITION_LENGTH);
|
||||||
colorAnimation.addUpdateListener(animation -> {
|
colorAnimation.addUpdateListener(animation -> {
|
||||||
mWindow.setNavigationBarColor(darkenColor((Integer) animation.getAnimatedValue()));
|
mWindow.setNavigationBarColor(ColorUtils.darken((Integer) animation.getAnimatedValue()));
|
||||||
});
|
});
|
||||||
colorAnimation.start();
|
colorAnimation.start();
|
||||||
}
|
}
|
||||||
@@ -622,6 +624,7 @@ public class ThemeManager {
|
|||||||
|
|
||||||
int colourFrom = sColor;
|
int colourFrom = sColor;
|
||||||
sColor = color;
|
sColor = color;
|
||||||
|
sActiveColor = color;
|
||||||
|
|
||||||
sPrefs.edit().putString(SettingsFragment.THEME, "" + color).apply();
|
sPrefs.edit().putString(SettingsFragment.THEME, "" + color).apply();
|
||||||
|
|
||||||
@@ -654,10 +657,10 @@ public class ThemeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sStatusTintEnabled) {
|
if (sStatusTintEnabled) {
|
||||||
mWindow.setStatusBarColor(darkenColor(color1));
|
mWindow.setStatusBarColor(ColorUtils.darken(color1));
|
||||||
}
|
}
|
||||||
if (sNavigationTintEnabled) {
|
if (sNavigationTintEnabled) {
|
||||||
mWindow.setNavigationBarColor(darkenColor(color1));
|
mWindow.setNavigationBarColor(ColorUtils.darken(color1));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
colorAnimation.addListener(new AnimatorListenerAdapter() {
|
colorAnimation.addListener(new AnimatorListenerAdapter() {
|
||||||
@@ -688,12 +691,20 @@ public class ThemeManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int darkenColor(int color) {
|
public static void setActiveColor(int color) {
|
||||||
float[] hsv = new float[3];
|
sActiveColor = color;
|
||||||
Color.colorToHSV(color, hsv);
|
|
||||||
hsv[2] *= 0.75f;
|
if (mActivity != null) {
|
||||||
color = Color.HSVToColor(hsv);
|
if (mActivity.getSupportActionBar() != null) {
|
||||||
return color;
|
mActivity.getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sStatusTintEnabled) {
|
||||||
|
mWindow.setStatusBarColor(ColorUtils.darken(color));
|
||||||
|
}
|
||||||
|
if (sNavigationTintEnabled) {
|
||||||
|
mWindow.setNavigationBarColor(ColorUtils.darken(color));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isColorDarkEnough(int color) {
|
private static boolean isColorDarkEnough(int color) {
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import android.content.CursorLoader;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.Loader;
|
import android.content.Loader;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteException;
|
import android.database.sqlite.SQLiteException;
|
||||||
import android.database.sqlite.SqliteWrapper;
|
import android.database.sqlite.SqliteWrapper;
|
||||||
@@ -780,8 +779,10 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMenuChanging(float percentOpen) {
|
public void onMenuChanging(float percentOpen) {
|
||||||
mContext.getToolbar().setBackgroundColor((int) mArgbEvaluator.evaluate(
|
if (mConversationPrefs != null) {
|
||||||
percentOpen, 0xFF000000 | mConversationPrefs.getColor(), 0xFF000000 | ThemeManager.getColor()));
|
ThemeManager.setActiveColor((int) mArgbEvaluator.evaluate(
|
||||||
|
percentOpen, 0xFF000000 | mConversationPrefs.getColor(), 0xFF000000 | ThemeManager.getColor()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user