Merge "Fix all RemoteInputView colors when isColorized changes." into sc-dev
This commit is contained in:
@@ -873,14 +873,19 @@ public class NotificationContentView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBackgroundTintColor(int color) {
|
public void setBackgroundTintColor(int color) {
|
||||||
|
boolean colorized = mNotificationEntry.getSbn().getNotification().isColorized();
|
||||||
if (mExpandedSmartReplyView != null) {
|
if (mExpandedSmartReplyView != null) {
|
||||||
boolean colorized = mNotificationEntry.getSbn().getNotification().isColorized();
|
|
||||||
mExpandedSmartReplyView.setBackgroundTintColor(color, colorized);
|
mExpandedSmartReplyView.setBackgroundTintColor(color, colorized);
|
||||||
}
|
}
|
||||||
if (mHeadsUpSmartReplyView != null) {
|
if (mHeadsUpSmartReplyView != null) {
|
||||||
boolean colorized = mNotificationEntry.getSbn().getNotification().isColorized();
|
|
||||||
mHeadsUpSmartReplyView.setBackgroundTintColor(color, colorized);
|
mHeadsUpSmartReplyView.setBackgroundTintColor(color, colorized);
|
||||||
}
|
}
|
||||||
|
if (mExpandedRemoteInput != null) {
|
||||||
|
mExpandedRemoteInput.setBackgroundTintColor(color, colorized);
|
||||||
|
}
|
||||||
|
if (mHeadsUpRemoteInput != null) {
|
||||||
|
mHeadsUpRemoteInput.setBackgroundTintColor(color, colorized);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVisibleType() {
|
public int getVisibleType() {
|
||||||
@@ -1243,8 +1248,7 @@ public class NotificationContentView extends FrameLayout {
|
|||||||
View actionContainerCandidate = view.findViewById(
|
View actionContainerCandidate = view.findViewById(
|
||||||
com.android.internal.R.id.actions_container);
|
com.android.internal.R.id.actions_container);
|
||||||
if (actionContainerCandidate instanceof FrameLayout) {
|
if (actionContainerCandidate instanceof FrameLayout) {
|
||||||
RemoteInputView existing = (RemoteInputView)
|
RemoteInputView existing = view.findViewWithTag(RemoteInputView.VIEW_TAG);
|
||||||
view.findViewWithTag(RemoteInputView.VIEW_TAG);
|
|
||||||
|
|
||||||
if (existing != null) {
|
if (existing != null) {
|
||||||
existing.onNotificationUpdateOrReset();
|
existing.onNotificationUpdateOrReset();
|
||||||
@@ -1292,13 +1296,9 @@ public class NotificationContentView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (existing != null) {
|
if (existing != null) {
|
||||||
if (entry.getSbn().getNotification().isColorized()) {
|
int backgroundColor = entry.getRow().getCurrentBackgroundTint();
|
||||||
existing.setBackgroundTintColor(
|
boolean colorized = mNotificationEntry.getSbn().getNotification().isColorized();
|
||||||
entry.getSbn().getNotification().color, true);
|
existing.setBackgroundTintColor(backgroundColor, colorized);
|
||||||
} else {
|
|
||||||
existing.setBackgroundTintColor(
|
|
||||||
entry.getRow().getCurrentBackgroundTint(), false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import android.content.pm.ShortcutManager;
|
|||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
@@ -157,52 +158,48 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
|
|||||||
/**
|
/**
|
||||||
* The remote view needs to adapt to colorized notifications when set
|
* The remote view needs to adapt to colorized notifications when set
|
||||||
* It overrides the background of itself as well as all of its childern
|
* It overrides the background of itself as well as all of its childern
|
||||||
* @param color colorized notification color
|
* @param backgroundColor colorized notification color
|
||||||
*/
|
*/
|
||||||
public void setBackgroundTintColor(int color, boolean colorized) {
|
public void setBackgroundTintColor(final int backgroundColor, boolean colorized) {
|
||||||
if (colorized == mColorized && color == mTint) return;
|
if (colorized == mColorized && backgroundColor == mTint) return;
|
||||||
mColorized = colorized;
|
mColorized = colorized;
|
||||||
mTint = color;
|
mTint = backgroundColor;
|
||||||
final int[][] states = new int[][]{
|
final int editBgColor;
|
||||||
new int[]{com.android.internal.R.attr.state_enabled},
|
final int accentColor;
|
||||||
new int[]{},
|
final int textColor;
|
||||||
};
|
final int hintTextColor;
|
||||||
final int[] colors;
|
|
||||||
if (colorized) {
|
if (colorized) {
|
||||||
final boolean dark = !ContrastColorUtil.isColorLight(color);
|
final boolean dark = !ContrastColorUtil.isColorLight(backgroundColor);
|
||||||
final int finalColor = dark
|
final int foregroundColor = dark ? Color.WHITE : Color.BLACK;
|
||||||
? Color.WHITE
|
editBgColor = backgroundColor;
|
||||||
: Color.BLACK;
|
accentColor = foregroundColor;
|
||||||
colors = new int[]{
|
textColor = foregroundColor;
|
||||||
finalColor,
|
hintTextColor = ColorUtils.setAlphaComponent(foregroundColor, 0x99);
|
||||||
finalColor & 0x4DFFFFFF // %30 opacity
|
|
||||||
};
|
|
||||||
mEditText.setUniformBackgroundTintColor(color);
|
|
||||||
mEditText.setUniformForegroundColor(finalColor);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
mEditText.setTextColor(mContext.getColor(R.color.remote_input_text));
|
textColor = mContext.getColor(R.color.remote_input_text);
|
||||||
mEditText.setHintTextColor(mContext.getColorStateList(R.color.remote_input_hint));
|
hintTextColor = mContext.getColor(R.color.remote_input_hint);
|
||||||
TypedArray ta = getContext().getTheme().obtainStyledAttributes(new int[]{
|
try (TypedArray ta = getContext().getTheme().obtainStyledAttributes(new int[]{
|
||||||
com.android.internal.R.attr.colorAccent,
|
com.android.internal.R.attr.colorAccent,
|
||||||
com.android.internal.R.attr.colorBackgroundFloating,
|
com.android.internal.R.attr.colorBackgroundFloating,
|
||||||
});
|
})) {
|
||||||
int colorAccent = ta.getColor(0, 0);
|
accentColor = ta.getColor(0, textColor);
|
||||||
int colorBackgroundFloating = ta.getColor(1, 0);
|
editBgColor = ta.getColor(1, backgroundColor);
|
||||||
ta.recycle();
|
}
|
||||||
mEditText.setTextBackgroundColors(colorAccent, colorBackgroundFloating);
|
|
||||||
colors = new int[]{
|
|
||||||
colorAccent,
|
|
||||||
colorBackgroundFloating & 0x4DFFFFFF // %30 opacity
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
mEditText.setBackgroundColor(color);
|
mEditText.setAllColors(backgroundColor, editBgColor,
|
||||||
final ColorStateList tint = new ColorStateList(states, colors);
|
accentColor, textColor, hintTextColor);
|
||||||
mSendButton.setImageTintList(tint);
|
final ColorStateList accentTint = new ColorStateList(new int[][]{
|
||||||
mProgressBar.setProgressTintList(tint);
|
new int[]{com.android.internal.R.attr.state_enabled},
|
||||||
mProgressBar.setIndeterminateTintList(tint);
|
new int[]{},
|
||||||
mProgressBar.setSecondaryProgressTintList(tint);
|
}, new int[]{
|
||||||
setBackgroundColor(color);
|
accentColor,
|
||||||
|
accentColor & 0x4DFFFFFF // %30 opacity
|
||||||
|
});
|
||||||
|
mSendButton.setImageTintList(accentTint);
|
||||||
|
mProgressBar.setProgressTintList(accentTint);
|
||||||
|
mProgressBar.setIndeterminateTintList(accentTint);
|
||||||
|
mProgressBar.setSecondaryProgressTintList(accentTint);
|
||||||
|
setBackgroundColor(backgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -796,20 +793,6 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUniformBackgroundTintColor(int color) {
|
|
||||||
mBackgroundColor.setColor(color);
|
|
||||||
mTextBackground.setColor(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setUniformForegroundColor(int color) {
|
|
||||||
int stroke = getContext().getResources()
|
|
||||||
.getDimensionPixelSize(R.dimen.remote_input_view_text_stroke);
|
|
||||||
mTextBackground.setStroke(stroke, color);
|
|
||||||
setTextColor(color);
|
|
||||||
setHintTextColor(ColorUtils.setAlphaComponent(color, 0x99));
|
|
||||||
setTextCursorDrawable(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getFocusedRect(Rect r) {
|
public void getFocusedRect(Rect r) {
|
||||||
super.getFocusedRect(r);
|
super.getFocusedRect(r);
|
||||||
@@ -938,11 +921,17 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
|
|||||||
return remainingItems;
|
return remainingItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setTextBackgroundColors(int strokeColor, int textBackground) {
|
protected void setAllColors(int backgroundColor, int editBackgroundColor,
|
||||||
mTextBackground.setColor(textBackground);
|
int accentColor, int textColor, int hintTextColor) {
|
||||||
|
setBackgroundColor(backgroundColor);
|
||||||
|
mBackgroundColor.setColor(backgroundColor);
|
||||||
|
mTextBackground.setColor(editBackgroundColor);
|
||||||
int stroke = getContext().getResources()
|
int stroke = getContext().getResources()
|
||||||
.getDimensionPixelSize(R.dimen.remote_input_view_text_stroke);
|
.getDimensionPixelSize(R.dimen.remote_input_view_text_stroke);
|
||||||
mTextBackground.setStroke(stroke, strokeColor);
|
mTextBackground.setStroke(stroke, accentColor);
|
||||||
|
setTextColor(textColor);
|
||||||
|
setHintTextColor(hintTextColor);
|
||||||
|
getTextCursorDrawable().setColorFilter(accentColor, PorterDuff.Mode.SRC_IN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user