From 90b47efcfabc42ac45349f19a14b904ebc42ca39 Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Mon, 4 Jan 2016 12:25:28 -0500 Subject: [PATCH] Use CIE-LCh interpolator for theme changing --- .../main/java/com/moez/QKSMS/common/CIELCHEvaluator.java | 6 +++--- QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java | 3 ++- .../com/moez/QKSMS/ui/messagelist/MessageListFragment.java | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/QKSMS/src/main/java/com/moez/QKSMS/common/CIELCHEvaluator.java b/QKSMS/src/main/java/com/moez/QKSMS/common/CIELCHEvaluator.java index e63d7173..3d021366 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/common/CIELCHEvaluator.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/common/CIELCHEvaluator.java @@ -31,9 +31,9 @@ public class CIELChEvaluator implements TypeEvaluator { public Integer evaluate(float fraction, Integer ignored, Integer ignored2) { // CIELCH to CIELAB - double L = mStartColor.L * fraction + mEndColor.L * (1 - fraction); - double C = mStartColor.C * fraction + mEndColor.C * (1 - fraction); - double H = mStartColor.H * fraction + mEndColor.H * (1 - fraction); + double L = mStartColor.L * (1 - fraction) + mEndColor.L * fraction; + double C = mStartColor.C * (1 - fraction) + mEndColor.C * fraction; + double H = mStartColor.H * (1 - fraction) + mEndColor.H * fraction; double a = Math.cos(Math.toRadians(H)) * C; double b = Math.sin(Math.toRadians(H)) * C; diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java index 0bee3052..06c326b3 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java @@ -21,6 +21,7 @@ import android.view.animation.DecelerateInterpolator; import android.widget.LinearLayout; import com.moez.QKSMS.R; import com.moez.QKSMS.common.AnalyticsManager; +import com.moez.QKSMS.common.CIELChEvaluator; import com.moez.QKSMS.common.LiveViewManager; import com.moez.QKSMS.common.preferences.QKPreference; import com.moez.QKSMS.common.utils.ColorUtils; @@ -557,7 +558,7 @@ public class ThemeManager { mTextOnColorSecondary = mResources.getColor(isColorDarkEnough(mColor) ? R.color.theme_dark_text_secondary : R.color.theme_light_text_secondary); - ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, color); + ValueAnimator colorAnimation = ValueAnimator.ofObject(new CIELChEvaluator(colorFrom, color), 0); colorAnimation.setDuration(TRANSITION_LENGTH); colorAnimation.setInterpolator(new DecelerateInterpolator()); colorAnimation.addUpdateListener(animation -> { diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListFragment.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListFragment.java index ae24604b..e7c7a852 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListFragment.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListFragment.java @@ -54,6 +54,7 @@ import com.moez.QKSMS.R; import com.moez.QKSMS.common.CIELChEvaluator; import com.moez.QKSMS.common.ConversationPrefsHelper; import com.moez.QKSMS.common.DialogHelper; +import com.moez.QKSMS.common.LiveViewManager; import com.moez.QKSMS.common.conversationdetails.ConversationDetailsDialog; import com.moez.QKSMS.common.preferences.QKPreference; import com.moez.QKSMS.common.utils.DrmUtils; @@ -220,7 +221,7 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa } mConversationPrefs = new ConversationPrefsHelper(mContext, mThreadId); - mCIELChEvaluator = new CIELChEvaluator(ThemeManager.getColor(), mConversationPrefs.getColor()); + mCIELChEvaluator = new CIELChEvaluator(mConversationPrefs.getColor(), ThemeManager.getColor()); mIsSmsEnabled = MmsConfig.isSmsEnabled(mContext); mConversationDetailsDialog = new ConversationDetailsDialog(mContext, getFragmentManager()); setHasOptionsMenu(true);