Fixes the incorrect hover icon color in drop bar when dark theme

Bug: 78641863
Test: Manual test with dark and light wallpapers
Change-Id: Ic3fb68f5c5f746482a7f23b11284e30ac3e10168
This commit is contained in:
Mehdi Alizadeh 2018-04-30 11:15:39 -07:00
parent 3aa3eb51e2
commit 3e024c0e1c
2 changed files with 23 additions and 2 deletions

View File

@ -192,8 +192,10 @@ public abstract class ButtonDropTarget extends TextView
mCurrentFilter = new ColorMatrix();
}
Themes.setColorScaleOnMatrix(getTextColor(), mSrcFilter);
Themes.setColorScaleOnMatrix(targetColor, mDstFilter);
int defaultTextColor = mOriginalTextColor.getDefaultColor();
Themes.setColorChangeOnMatrix(defaultTextColor, getTextColor(), mSrcFilter);
Themes.setColorChangeOnMatrix(defaultTextColor, targetColor, mDstFilter);
ValueAnimator anim1 = ValueAnimator.ofObject(
new FloatArrayEvaluator(mCurrentFilter.getArray()),
mSrcFilter.getArray(), mDstFilter.getArray());

View File

@ -78,4 +78,23 @@ public class Themes {
target.setScale(Color.red(color) / 255f, Color.green(color) / 255f,
Color.blue(color) / 255f, Color.alpha(color) / 255f);
}
/**
* Changes a color matrix such that, when applied to srcColor, it produces dstColor.
*
* Note that values on the last column of target ColorMatrix can be negative, and may result in
* negative values when applied on a color. Such negative values will be automatically shifted
* up to 0 by the framework.
*
* @param srcColor The color to start from
* @param dstColor The color to create by applying target on srcColor
* @param target The ColorMatrix to transform the color
*/
public static void setColorChangeOnMatrix(int srcColor, int dstColor, ColorMatrix target) {
target.reset();
target.getArray()[4] = Color.red(dstColor) - Color.red(srcColor);
target.getArray()[9] = Color.green(dstColor) - Color.green(srcColor);
target.getArray()[14] = Color.blue(dstColor) - Color.blue(srcColor);
target.getArray()[19] = Color.alpha(dstColor) - Color.alpha(srcColor);
}
}