Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc68ad7c authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz Committed by Android (Google) Code Review
Browse files

Merge "Fix disabled state of CallStyle buttons to make them look/act disabled" into tm-qpr-dev

parents 016a6b97 1eda1ef9
Loading
Loading
Loading
Loading
+39 −5
Original line number Diff line number Diff line
@@ -6185,10 +6185,8 @@ public class Notification implements Parcelable
        private RemoteViews generateActionButton(Action action, boolean emphasizedMode,
                StandardTemplateParams p) {
            final boolean tombstone = (action.actionIntent == null);
            RemoteViews button = new BuilderRemoteViews(mContext.getApplicationInfo(),
                    emphasizedMode ? getEmphasizedActionLayoutResource()
                            : tombstone ? getActionTombstoneLayoutResource()
                                    : getActionLayoutResource());
            final RemoteViews button = new BuilderRemoteViews(mContext.getApplicationInfo(),
                    getActionButtonLayoutResource(emphasizedMode, tombstone));
            if (!tombstone) {
                button.setOnClickPendingIntent(R.id.action0, action.actionIntent);
            }
@@ -6200,6 +6198,12 @@ public class Notification implements Parcelable
                // change the background bgColor
                CharSequence title = action.title;
                int buttonFillColor = getColors(p).getSecondaryAccentColor();
                if (tombstone) {
                    buttonFillColor = setAlphaComponentByFloatDimen(mContext,
                            ContrastColorUtil.resolveSecondaryColor(
                                    mContext, getColors(p).getBackgroundColor(), mInNightMode),
                            R.dimen.notification_action_disabled_container_alpha);
                }
                if (isLegacy()) {
                    title = ContrastColorUtil.clearColorSpans(title);
                } else {
@@ -6215,8 +6219,14 @@ public class Notification implements Parcelable
                    title = ensureColorSpanContrast(title, buttonFillColor);
                }
                button.setTextViewText(R.id.action0, processTextSpans(title));
                final int textColor = ContrastColorUtil.resolvePrimaryColor(mContext,
                int textColor = ContrastColorUtil.resolvePrimaryColor(mContext,
                        buttonFillColor, mInNightMode);
                if (tombstone) {
                    textColor = setAlphaComponentByFloatDimen(mContext,
                            ContrastColorUtil.resolveSecondaryColor(
                                    mContext, getColors(p).getBackgroundColor(), mInNightMode),
                            R.dimen.notification_action_disabled_content_alpha);
                }
                button.setTextColor(R.id.action0, textColor);
                // We only want about 20% alpha for the ripple
                final int rippleColor = (textColor & 0x00ffffff) | 0x33000000;
@@ -6246,6 +6256,26 @@ public class Notification implements Parcelable
            return button;
        }
        private int getActionButtonLayoutResource(boolean emphasizedMode, boolean tombstone) {
            if (emphasizedMode) {
                return tombstone ? getEmphasizedTombstoneActionLayoutResource()
                        : getEmphasizedActionLayoutResource();
            } else {
                return tombstone ? getActionTombstoneLayoutResource()
                        : getActionLayoutResource();
            }
        }
        /**
         * Set the alpha component of {@code color} to be {@code alphaDimenResId}.
         */
        private static int setAlphaComponentByFloatDimen(Context context, @ColorInt int color,
                @DimenRes int alphaDimenResId) {
            final TypedValue alphaValue = new TypedValue();
            context.getResources().getValue(alphaDimenResId, alphaValue, true);
            return ColorUtils.setAlphaComponent(color, Math.round(alphaValue.getFloat() * 255));
        }
        /**
         * Extract the color from a full-length span from the text.
         *
@@ -6725,6 +6755,10 @@ public class Notification implements Parcelable
            return R.layout.notification_material_action_emphasized;
        }
        private int getEmphasizedTombstoneActionLayoutResource() {
            return R.layout.notification_material_action_emphasized_tombstone;
        }
        private int getActionTombstoneLayoutResource() {
            return R.layout.notification_material_action_tombstone;
        }
+30 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2023 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<com.android.internal.widget.EmphasizedNotificationButton
    xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/NotificationEmphasizedAction"
    android:id="@+id/action0"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_marginStart="12dp"
    android:drawablePadding="6dp"
    android:enabled="false"
    android:gravity="center"
    android:singleLine="true"
    android:ellipsize="end"
/>
+2 −0
Original line number Diff line number Diff line
@@ -150,6 +150,8 @@
    <color name="notification_default_color">#757575</color> <!-- Gray 600 -->

    <color name="notification_action_button_text_color">@color/notification_default_color</color>
    <item  name="notification_action_disabled_content_alpha" format="float" type="dimen">0.38</item>
    <item  name="notification_action_disabled_container_alpha" format="float" type="dimen">0.12</item>

    <color name="notification_progress_background_color">@color/notification_secondary_text_color_current</color>

+4 −0
Original line number Diff line number Diff line
@@ -3304,7 +3304,10 @@
  <java-symbol type="id" name="notification_action_list_margin_target" />
  <java-symbol type="dimen" name="notification_actions_padding_start"/>
  <java-symbol type="dimen" name="notification_actions_collapsed_priority_width"/>
  <!--prefer to use disabled content and surface alpha values for disabled actions-->
  <java-symbol type="dimen" name="notification_action_disabled_alpha" />
  <java-symbol type="dimen" name="notification_action_disabled_content_alpha" />
  <java-symbol type="dimen" name="notification_action_disabled_container_alpha" />
  <java-symbol type="id" name="tag_margin_end_when_icon_visible" />
  <java-symbol type="id" name="tag_margin_end_when_icon_gone" />
  <java-symbol type="id" name="tag_uses_right_icon_drawable" />
@@ -3356,6 +3359,7 @@
  <java-symbol type="string" name="unsupported_display_size_message" />

  <java-symbol type="layout" name="notification_material_action_emphasized" />
  <java-symbol type="layout" name="notification_material_action_emphasized_tombstone" />

  <!-- Package name for the device provisioning package -->
  <java-symbol type="string" name="config_deviceProvisioningPackage" />