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

Commit e1d2a135 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add star signifier for summarizations" into main

parents 58b9f87c fe577534
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
<!--
Copyright (C) 2025 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="16dp"
    android:height="16dp"
    android:tint="?android:attr/colorControlNormal"
    android:viewportHeight="960"
    android:viewportWidth="960">
    <path android:fillColor="#ffffff" android:pathData="M354,673L480,597L606,674L573,530L684,434L538,421L480,285L422,420L276,433L387,530L354,673ZM233,840L298,559L80,370L368,345L480,80L592,345L880,370L662,559L727,840L480,691L233,840ZM480,490L480,490L480,490L480,490L480,490L480,490L480,490L480,490L480,490L480,490Z"/>
</vector>
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -5888,6 +5888,7 @@
  <java-symbol type="bool" name="config_deviceSupportsWifiUsd" />

  <java-symbol type="array" name="config_notificationDefaultUnsupportedAdjustments" />
  <java-symbol type="drawable" name="ic_notification_summarization" />

  <!-- Advanced Protection Service USB feature -->
  <java-symbol type="string" name="usb_apm_usb_plugged_in_when_locked_notification_title" />
+39 −2
Original line number Diff line number Diff line
@@ -20,10 +20,17 @@ import android.app.Notification
import android.app.Notification.EXTRA_SUMMARIZED_CONTENT
import android.content.Context
import android.content.pm.LauncherApps
import android.graphics.Typeface
import android.graphics.drawable.AnimatedImageDrawable
import android.os.Handler
import android.service.notification.NotificationListenerService.Ranking
import android.service.notification.NotificationListenerService.RankingMap
import android.text.SpannableString
import android.text.Spanned
import android.text.TextUtils
import android.text.style.ImageSpan
import android.text.style.StyleSpan
import com.android.internal.R
import com.android.internal.widget.ConversationLayout
import com.android.internal.widget.MessagingImageMessage
import com.android.internal.widget.MessagingLayout
@@ -49,6 +56,7 @@ import javax.inject.Inject
class ConversationNotificationProcessor
@Inject
constructor(
    @ShadeDisplayAware private val context: Context,
    private val launcherApps: LauncherApps,
    private val conversationNotificationManager: ConversationNotificationManager,
) {
@@ -67,9 +75,38 @@ constructor(
            messagingStyle.shortcutIcon = launcherApps.getShortcutIcon(shortcutInfo)
            shortcutInfo.label?.let { label -> messagingStyle.conversationTitle = label }
        }
        if (NmSummarizationUiFlag.isEnabled) {
        if (NmSummarizationUiFlag.isEnabled && !TextUtils.isEmpty(entry.ranking.summarization)) {
            val icon = context.getDrawable(R.drawable.ic_notification_summarization)?.mutate()
            val imageSpan =
                icon?.let {
                    it.setBounds(
                        /* left= */ 0,
                        /* top= */ 0,
                        icon.getIntrinsicWidth(),
                        icon.getIntrinsicHeight(),
                    )
                    ImageSpan(it, ImageSpan.ALIGN_CENTER)
                }
            val decoratedSummary =
                SpannableString("x" + entry.ranking.summarization).apply {
                    setSpan(
                        /* what = */ imageSpan,
                        /* start = */ 0,
                        /* end = */ 1,
                        /* flags = */ Spanned.SPAN_INCLUSIVE_EXCLUSIVE,
                    )
                    entry.ranking.summarization?.let {
                        setSpan(
                            /* what = */ StyleSpan(Typeface.BOLD),
                            /* start = */ 1,
                            /* end = */ it.length,
                            /* flags = */ Spanned.SPAN_EXCLUSIVE_INCLUSIVE,
                        )
                    }
                }
            entry.sbn.notification.extras.putCharSequence(
                EXTRA_SUMMARIZED_CONTENT, entry.ranking.summarization
                EXTRA_SUMMARIZED_CONTENT,
                decoratedSummary,
            )
        }

+3 −4
Original line number Diff line number Diff line
@@ -289,7 +289,7 @@ public class HybridConversationNotificationView extends HybridNotificationView {
            CharSequence titleText,
            CharSequence contentText,
            CharSequence conversationSenderName,
            @Nullable String summarization
            @Nullable CharSequence summarization
    ) {
        if (AsyncHybridViewInflation.isUnexpectedlyInLegacyMode()) return;
        if (summarization != null) {
@@ -304,9 +304,8 @@ public class HybridConversationNotificationView extends HybridNotificationView {
                mConversationSenderName.setText(conversationSenderName);
            }
        }
        // TODO (b/217799515): super.bind() doesn't use contentView, remove the contentView
        //  argument when the flag is removed
        super.bind(/* title = */ titleText, /* text = */ contentText, /* contentView = */ null);
        super.bind(/* title = */ titleText, /* text = */ contentText,
                /* stripSpans = */ TextUtils.isEmpty(summarization));
    }

    private static void setSize(View view, int size) {
+10 −1
Original line number Diff line number Diff line
@@ -121,6 +121,11 @@ public class HybridNotificationView extends AlphaOptimizedLinearLayout

    public void bind(@Nullable CharSequence title, @Nullable CharSequence text,
            @Nullable View contentView) {
        bind(/* title = */ title, /* text = */ text, /* stripSpans */ true);
    }

    public void bind(@Nullable CharSequence title, @Nullable CharSequence text,
            boolean stripSpans) {
        mTitleView.setText(title != null ? title.toString() : title);
        mTitleView.setVisibility(TextUtils.isEmpty(title) ? GONE : VISIBLE);
        if (TextUtils.isEmpty(text)) {
@@ -128,7 +133,11 @@ public class HybridNotificationView extends AlphaOptimizedLinearLayout
            mTextView.setText(null);
        } else {
            mTextView.setVisibility(VISIBLE);
            if (stripSpans) {
                mTextView.setText(text.toString());
            } else {
                mTextView.setText(text);
            }
        }
        requestLayout();
    }
Loading