diff options
7 files changed, 107 insertions, 35 deletions
diff --git a/packages/SystemUI/res/color/remote_input_send.xml b/packages/SystemUI/res/color/remote_input_send.xml index fe2ffaa838eb..bd91ef9785d1 100644 --- a/packages/SystemUI/res/color/remote_input_send.xml +++ b/packages/SystemUI/res/color/remote_input_send.xml @@ -16,6 +16,6 @@ --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_enabled="true" android:color="@android:color/white" /> - <item android:color="#4dffffff" /> <!-- 30% white --> + <item android:state_enabled="true" android:color="?android:attr/colorAccent" /> + <item android:color="?android:attr/colorAccent" android:alpha=".3" /> </selector>
\ No newline at end of file diff --git a/packages/SystemUI/res/color/remote_input_text.xml b/packages/SystemUI/res/color/remote_input_text.xml index 8e18e16f8abc..33eeb7794d09 100644 --- a/packages/SystemUI/res/color/remote_input_text.xml +++ b/packages/SystemUI/res/color/remote_input_text.xml @@ -16,6 +16,6 @@ --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_enabled="true" android:color="@color/remote_input_text_enabled" /> <!-- white --> - <item android:color="#99ffffff" /> <!-- 60% white --> + <item android:state_enabled="true" android:color="?android:attr/textColorTertiary" /> + <item android:color="?android:attr/textColorTertiary" android:alpha=".6" /> </selector>
\ No newline at end of file diff --git a/packages/SystemUI/res/layout/remote_input.xml b/packages/SystemUI/res/layout/remote_input.xml index b5d48b4636a8..43182eb991e5 100644 --- a/packages/SystemUI/res/layout/remote_input.xml +++ b/packages/SystemUI/res/layout/remote_input.xml @@ -19,7 +19,6 @@ <!-- LinearLayout --> <com.android.systemui.statusbar.policy.RemoteInputView xmlns:android="http://schemas.android.com/apk/res/android" - android:theme="@style/systemui_theme_remote_input" android:id="@+id/remote_input" android:layout_height="match_parent" android:layout_width="match_parent"> @@ -33,6 +32,10 @@ android:paddingBottom="4dp" android:paddingStart="16dp" android:paddingEnd="12dp" + android:layout_marginRight="5dp" + android:layout_marginLeft="20dp" + android:layout_marginTop="5dp" + android:layout_marginBottom="20dp" android:gravity="start|center_vertical" android:textAppearance="?android:attr/textAppearance" android:textColor="@color/remote_input_text" @@ -53,6 +56,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="center" + android:paddingBottom="20dp" android:paddingStart="12dp" android:paddingEnd="24dp" android:id="@+id/remote_input_send" @@ -66,6 +70,7 @@ android:id="@+id/remote_input_progress" android:layout_width="24dp" android:layout_height="24dp" + android:layout_marginBottom="10dp" android:layout_marginEnd="6dp" android:layout_gravity="center" android:visibility="invisible" diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml index 424172458b80..d4783197e1f1 100644 --- a/packages/SystemUI/res/values/colors.xml +++ b/packages/SystemUI/res/values/colors.xml @@ -153,10 +153,9 @@ <color name="minimize_dock_shadow_end">#00000000</color> <color name="default_remote_input_background">@*android:color/notification_default_color</color> - <color name="remote_input_text_enabled">#ffffffff</color> <color name="remote_input_hint">#99ffffff</color> - <color name="remote_input_accent">#eeeeee</color> + <color name="remote_input_accent">?android:attr/colorAccent</color> <color name="quick_step_track_background_background_dark">#1F000000</color> <color name="quick_step_track_background_background_light">#33FFFFFF</color> diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml index fb885cb3fdbe..ff9ea0175ec0 100644 --- a/packages/SystemUI/res/values/styles.xml +++ b/packages/SystemUI/res/values/styles.xml @@ -384,10 +384,6 @@ <!-- Overridden by values-television/styles.xml with tv-specific settings --> <style name="volume_dialog_theme" parent="qs_theme"/> - <style name="systemui_theme_remote_input" parent="@android:style/Theme.DeviceDefault.Light"> - <item name="android:colorAccent">@color/remote_input_accent</item> - </style> - <style name="Theme.SystemUI.Dialog" parent="@android:style/Theme.DeviceDefault.Light.Dialog" /> <style name="Theme.SystemUI.Dialog.Alert" parent="@*android:style/Theme.DeviceDefault.Light.Dialog.Alert" /> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java index d3065aa36a5f..2cd84b0f6385 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java @@ -22,8 +22,6 @@ import android.annotation.Nullable; import android.app.Notification; import android.app.PendingIntent; import android.content.Context; -import android.content.res.Resources; -import android.content.res.TypedArray; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Build; @@ -32,7 +30,6 @@ import android.util.ArrayMap; import android.util.AttributeSet; import android.util.Log; import android.util.Pair; -import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.NotificationHeaderView; @@ -44,7 +41,6 @@ import android.widget.ImageView; import android.widget.LinearLayout; import com.android.internal.annotations.VisibleForTesting; -import com.android.internal.util.ContrastColorUtil; import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; @@ -1272,23 +1268,6 @@ public class NotificationContentView extends FrameLayout { } } if (hasRemoteInput) { - int color = entry.getSbn().getNotification().color; - if (color == Notification.COLOR_DEFAULT) { - color = mContext.getColor(R.color.default_remote_input_background); - } - if (mContext.getResources().getBoolean( - com.android.internal.R.bool.config_tintNotificationsWithTheme)) { - Resources.Theme theme = new ContextThemeWrapper(mContext, - com.android.internal.R.style.Theme_DeviceDefault_DayNight).getTheme(); - TypedArray ta = theme.obtainStyledAttributes( - new int[]{com.android.internal.R.attr.colorAccent}); - color = ta.getColor(0, color); - ta.recycle(); - } - existing.setBackgroundColor(ContrastColorUtil.ensureTextBackgroundColor(color, - mContext.getColor(R.color.remote_input_text_enabled), - mContext.getColor(R.color.remote_input_hint))); - existing.setWrapper(wrapper); existing.setOnVisibilityChangedListener(this::setRemoteInputVisible); @@ -1310,6 +1289,10 @@ public class NotificationContentView extends FrameLayout { } } } + + if (existing != null && entry.getSbn().getNotification().isColorized()) { + existing.overrideBackgroundTintColor(entry.getSbn().getNotification().color); + } return existing; } return null; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java index 320b00af0fc5..f72d2ae191d1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java @@ -31,8 +31,15 @@ import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ShortcutManager; +import android.content.res.ColorStateList; +import android.content.res.Resources; +import android.content.res.TypedArray; +import android.graphics.Color; import android.graphics.Rect; +import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; +import android.graphics.drawable.GradientDrawable; +import android.graphics.drawable.LayerDrawable; import android.net.Uri; import android.os.Bundle; import android.os.ServiceManager; @@ -70,6 +77,7 @@ import androidx.annotation.NonNull; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto; import com.android.internal.statusbar.IStatusBarService; +import com.android.internal.util.ContrastColorUtil; import com.android.systemui.Dependency; import com.android.systemui.Interpolators; import com.android.systemui.R; @@ -137,12 +145,40 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene ServiceManager.getService(Context.STATUS_BAR_SERVICE)); } + /** + * The remote view needs to adapt to colorized notifications when set + * @param color colorized notification color + */ + public void overrideBackgroundTintColor(int color) { + mEditText.setBackgroundTintColor(color); + final boolean dark = !ContrastColorUtil.isColorLight(color); + int[][] states = new int[][] { + new int[] {android.R.attr.state_enabled}, + new int[] {}, + }; + + final int finalColor = dark + ? Color.WHITE + : Color.BLACK; + + int[] colors = new int[] { + finalColor, + finalColor & 0x4DFFFFFF // %30 opacity + }; + + final ColorStateList tint = new ColorStateList(states, colors); + mSendButton.setImageTintList(tint); + mProgressBar.setProgressTintList(tint); + mProgressBar.setIndeterminateTintList(tint); + mProgressBar.setSecondaryProgressTintList(tint); + mEditText.setForegroundColor(finalColor); + } + @Override protected void onFinishInflate() { super.onFinishInflate(); mProgressBar = findViewById(R.id.remote_input_progress); - mSendButton = findViewById(R.id.remote_input_send); mSendButton.setOnClickListener(this); @@ -362,6 +398,12 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene } } + @Override + public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + mEditText.updateCornerRadius(heightMeasureSpec / 2); + } + /** Populates the text field of the remote input with the given content. */ public void setEditTextContent(@Nullable CharSequence editTextContent) { mEditText.setText(editTextContent); @@ -651,17 +693,47 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene private final OnReceiveContentListener mOnReceiveContentListener = this::onReceiveContent; - private final Drawable mBackground; private RemoteInputView mRemoteInputView; + private GradientDrawable mTextBackground; + private ColorDrawable mBackgroundColor; + private LayerDrawable mBackground; boolean mShowImeOnInputConnection; private LightBarController mLightBarController; private InputMethodManager mInputMethodManager; + private int mColor = Notification.COLOR_DEFAULT; UserHandle mUser; + private int mStokeWidth; public RemoteEditText(Context context, AttributeSet attrs) { super(context, attrs); - mBackground = getBackground(); mLightBarController = Dependency.get(LightBarController.class); + mTextBackground = createBackground(context, attrs); + mBackgroundColor = new ColorDrawable(); + mBackground = new LayerDrawable(new Drawable[] {mBackgroundColor, mTextBackground}); + float density = context.getResources().getDisplayMetrics().density; + mStokeWidth = (int) (2 * density); + setDefaultColors(); + } + + private void setDefaultColors() { + Resources.Theme theme = getContext().getTheme(); + TypedArray ta = theme.obtainStyledAttributes( + new int[]{android.R.attr.colorAccent, + com.android.internal.R.attr.colorBackgroundFloating}); + mTextBackground.setStroke(mStokeWidth, + ta.getColor(0, Notification.COLOR_DEFAULT)); + mColor = ta.getColor(1, Notification.COLOR_DEFAULT); + mTextBackground.setColor(mColor); + } + + private GradientDrawable createBackground(Context context, AttributeSet attrs) { + float density = context.getResources().getDisplayMetrics().density; + int padding = (int) (12 * density); + GradientDrawable d = new GradientDrawable(); + d.setShape(GradientDrawable.RECTANGLE); + d.setPadding(padding, padding, padding, padding); + d.setCornerRadius(padding); + return d; } void setSupportedMimeTypes(@Nullable Collection<String> mimeTypes) { @@ -724,6 +796,19 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene } } + protected void setBackgroundTintColor(int color) { + mBackgroundColor.setColor(color); + mTextBackground.setColor(color); + } + + protected void setForegroundColor(int color) { + mTextBackground.setStroke(mStokeWidth, color); + setTextColor(color); + // %60 + setHintTextColor(color & 0x99FFFFFF); + setTextCursorDrawable(null); + } + @Override public void getFocusedRect(Rect r) { super.getFocusedRect(r); @@ -811,6 +896,10 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene setSelection(getText().length()); } + void updateCornerRadius(float radius) { + mTextBackground.setCornerRadius(radius); + } + void setInnerFocusable(boolean focusable) { setFocusableInTouchMode(focusable); setFocusable(focusable); |