Loading core/java/android/app/Notification.java +23 −11 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.graphics.drawable.Icon.TYPE_URI; import static android.graphics.drawable.Icon.TYPE_URI_ADAPTIVE_BITMAP; import static com.android.internal.util.ContrastColorUtil.satisfiesTextContrast; import static com.android.internal.widget.ConversationLayout.CONVERSATION_LAYOUT_ENABLED; import android.annotation.ColorInt; import android.annotation.DimenRes; Loading Loading @@ -389,6 +390,7 @@ public class Notification implements Parcelable STANDARD_LAYOUTS.add(R.layout.notification_template_material_big_text); STANDARD_LAYOUTS.add(R.layout.notification_template_material_inbox); STANDARD_LAYOUTS.add(R.layout.notification_template_material_messaging); STANDARD_LAYOUTS.add(R.layout.notification_template_material_conversation); STANDARD_LAYOUTS.add(R.layout.notification_template_material_media); STANDARD_LAYOUTS.add(R.layout.notification_template_material_big_media); STANDARD_LAYOUTS.add(R.layout.notification_template_header); Loading Loading @@ -5138,7 +5140,7 @@ public class Notification implements Parcelable int color = isColorized(p) ? getPrimaryTextColor(p) : getSecondaryTextColor(p); contentView.setDrawableTint(R.id.expand_button, false, color, PorterDuff.Mode.SRC_ATOP); contentView.setInt(R.id.notification_header, "setOriginalNotificationColor", contentView.setInt(R.id.expand_button, "setOriginalNotificationColor", color); } Loading Loading @@ -6116,7 +6118,9 @@ public class Notification implements Parcelable } private int getMessagingLayoutResource() { return R.layout.notification_template_material_messaging; return CONVERSATION_LAYOUT_ENABLED ? R.layout.notification_template_material_conversation : R.layout.notification_template_material_messaging; } private int getActionLayoutResource() { Loading Loading @@ -7390,7 +7394,7 @@ public class Notification implements Parcelable public RemoteViews makeContentView(boolean increasedHeight) { mBuilder.mOriginalActions = mBuilder.mActions; mBuilder.mActions = new ArrayList<>(); RemoteViews remoteViews = makeMessagingView(true /* displayImagesAtEnd */, RemoteViews remoteViews = makeMessagingView(true /* isCollapsed */, false /* hideLargeIcon */); mBuilder.mActions = mBuilder.mOriginalActions; mBuilder.mOriginalActions = null; Loading Loading @@ -7480,19 +7484,18 @@ public class Notification implements Parcelable */ @Override public RemoteViews makeBigContentView() { return makeMessagingView(false /* displayImagesAtEnd */, true /* hideLargeIcon */); return makeMessagingView(false /* isCollapsed */, true /* hideLargeIcon */); } /** * Create a messaging layout. * * @param displayImagesAtEnd should images be displayed at the end of the content instead * of inline. * @param isCollapsed Should this use the collapsed layout * @param hideRightIcons Should the reply affordance be shown at the end of the notification * @return the created remoteView. */ @NonNull private RemoteViews makeMessagingView(boolean displayImagesAtEnd, boolean hideRightIcons) { private RemoteViews makeMessagingView(boolean isCollapsed, boolean hideRightIcons) { CharSequence conversationTitle = !TextUtils.isEmpty(super.mBigContentTitle) ? super.mBigContentTitle : mConversationTitle; Loading Loading @@ -7533,14 +7536,21 @@ public class Notification implements Parcelable mBuilder.getPrimaryTextColor(p)); contentView.setInt(R.id.status_bar_latest_event_content, "setMessageTextColor", mBuilder.getSecondaryTextColor(p)); contentView.setBoolean(R.id.status_bar_latest_event_content, "setDisplayImagesAtEnd", displayImagesAtEnd); contentView.setInt(R.id.status_bar_latest_event_content, "setNotificationBackgroundColor", mBuilder.resolveBackgroundColor(p)); contentView.setBoolean(R.id.status_bar_latest_event_content, "setIsCollapsed", isCollapsed); contentView.setIcon(R.id.status_bar_latest_event_content, "setAvatarReplacement", avatarReplacement); contentView.setCharSequence(R.id.status_bar_latest_event_content, "setNameReplacement", nameReplacement); contentView.setBoolean(R.id.status_bar_latest_event_content, "setIsOneToOne", isOneToOne); contentView.setCharSequence(R.id.status_bar_latest_event_content, "setConversationTitle", conversationTitle); contentView.setIcon(R.id.status_bar_latest_event_content, "setLargeIcon", mBuilder.mN.mLargeIcon); contentView.setBundle(R.id.status_bar_latest_event_content, "setData", mBuilder.mN.extras); return contentView; Loading Loading @@ -7601,9 +7611,11 @@ public class Notification implements Parcelable */ @Override public RemoteViews makeHeadsUpContentView(boolean increasedHeight) { RemoteViews remoteViews = makeMessagingView(true /* displayImagesAtEnd */, RemoteViews remoteViews = makeMessagingView(true /* isCollapsed */, true /* hideLargeIcon */); if (!CONVERSATION_LAYOUT_ENABLED) { remoteViews.setInt(R.id.notification_messaging, "setMaxDisplayedLines", 1); } return remoteViews; } Loading core/java/android/view/NotificationHeaderView.java +4 −9 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.widget.RemoteViews; import com.android.internal.R; import com.android.internal.widget.CachingIconView; import com.android.internal.widget.NotificationExpandButton; import java.util.ArrayList; Loading @@ -56,7 +57,7 @@ public class NotificationHeaderView extends ViewGroup { private OnClickListener mAppOpsListener; private HeaderTouchListener mTouchListener = new HeaderTouchListener(); private LinearLayout mTransferChip; private ImageView mExpandButton; private NotificationExpandButton mExpandButton; private CachingIconView mIcon; private View mProfileBadge; private View mOverlayIcon; Loading @@ -65,7 +66,6 @@ public class NotificationHeaderView extends ViewGroup { private View mAppOps; private View mAudiblyAlertedIcon; private int mIconColor; private int mOriginalNotificationColor; private boolean mExpanded; private boolean mShowExpandButtonAtEnd; private boolean mShowWorkBadgeAtEnd; Loading Loading @@ -324,13 +324,8 @@ public class NotificationHeaderView extends ViewGroup { return mIconColor; } @RemotableViewMethod public void setOriginalNotificationColor(int color) { mOriginalNotificationColor = color; } public int getOriginalNotificationColor() { return mOriginalNotificationColor; return mExpandButton.getOriginalNotificationColor(); } @RemotableViewMethod Loading Loading @@ -371,7 +366,7 @@ public class NotificationHeaderView extends ViewGroup { contentDescriptionId = R.string.expand_button_content_description_collapsed; } mExpandButton.setImageDrawable(getContext().getDrawable(drawableId)); mExpandButton.setColorFilter(mOriginalNotificationColor); mExpandButton.setColorFilter(getOriginalNotificationColor()); mExpandButton.setContentDescription(mContext.getText(contentDescriptionId)); } Loading core/java/com/android/internal/widget/CachingIconView.java +9 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.widget.ImageView; import android.widget.RemoteViews; import java.util.Objects; import java.util.function.Consumer; /** * An ImageView for displaying an Icon. Avoids reloading the Icon when possible. Loading @@ -44,6 +45,7 @@ public class CachingIconView extends ImageView { private boolean mInternalSetDrawable; private boolean mForceHidden; private int mDesiredVisibility; private Consumer<Integer> mOnVisibilityChangedListener; @UnsupportedAppUsage public CachingIconView(Context context, @Nullable AttributeSet attrs) { Loading Loading @@ -198,6 +200,13 @@ public class CachingIconView extends ImageView { private void updateVisibility() { int visibility = mDesiredVisibility == VISIBLE && mForceHidden ? INVISIBLE : mDesiredVisibility; if (mOnVisibilityChangedListener != null) { mOnVisibilityChangedListener.accept(visibility); } super.setVisibility(visibility); } public void setOnVisibilityChangedListener(Consumer<Integer> listener) { mOnVisibilityChangedListener = listener; } } core/java/com/android/internal/widget/ConversationLayout.java 0 → 100644 +866 −0 File added.Preview size limit exceeded, changes collapsed. Show changes core/java/com/android/internal/widget/IMessagingLayout.java 0 → 100644 +42 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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 */ package com.android.internal.widget; import android.content.Context; import java.util.ArrayList; /** * An interface for a MessagingLayout */ public interface IMessagingLayout { /** * @return the layout containing the messages */ MessagingLinearLayout getMessagingLinearLayout(); /** * @return the context of this view */ Context getContext(); /** * @return the list of messaging groups */ ArrayList<MessagingGroup> getMessagingGroups(); } Loading
core/java/android/app/Notification.java +23 −11 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.graphics.drawable.Icon.TYPE_URI; import static android.graphics.drawable.Icon.TYPE_URI_ADAPTIVE_BITMAP; import static com.android.internal.util.ContrastColorUtil.satisfiesTextContrast; import static com.android.internal.widget.ConversationLayout.CONVERSATION_LAYOUT_ENABLED; import android.annotation.ColorInt; import android.annotation.DimenRes; Loading Loading @@ -389,6 +390,7 @@ public class Notification implements Parcelable STANDARD_LAYOUTS.add(R.layout.notification_template_material_big_text); STANDARD_LAYOUTS.add(R.layout.notification_template_material_inbox); STANDARD_LAYOUTS.add(R.layout.notification_template_material_messaging); STANDARD_LAYOUTS.add(R.layout.notification_template_material_conversation); STANDARD_LAYOUTS.add(R.layout.notification_template_material_media); STANDARD_LAYOUTS.add(R.layout.notification_template_material_big_media); STANDARD_LAYOUTS.add(R.layout.notification_template_header); Loading Loading @@ -5138,7 +5140,7 @@ public class Notification implements Parcelable int color = isColorized(p) ? getPrimaryTextColor(p) : getSecondaryTextColor(p); contentView.setDrawableTint(R.id.expand_button, false, color, PorterDuff.Mode.SRC_ATOP); contentView.setInt(R.id.notification_header, "setOriginalNotificationColor", contentView.setInt(R.id.expand_button, "setOriginalNotificationColor", color); } Loading Loading @@ -6116,7 +6118,9 @@ public class Notification implements Parcelable } private int getMessagingLayoutResource() { return R.layout.notification_template_material_messaging; return CONVERSATION_LAYOUT_ENABLED ? R.layout.notification_template_material_conversation : R.layout.notification_template_material_messaging; } private int getActionLayoutResource() { Loading Loading @@ -7390,7 +7394,7 @@ public class Notification implements Parcelable public RemoteViews makeContentView(boolean increasedHeight) { mBuilder.mOriginalActions = mBuilder.mActions; mBuilder.mActions = new ArrayList<>(); RemoteViews remoteViews = makeMessagingView(true /* displayImagesAtEnd */, RemoteViews remoteViews = makeMessagingView(true /* isCollapsed */, false /* hideLargeIcon */); mBuilder.mActions = mBuilder.mOriginalActions; mBuilder.mOriginalActions = null; Loading Loading @@ -7480,19 +7484,18 @@ public class Notification implements Parcelable */ @Override public RemoteViews makeBigContentView() { return makeMessagingView(false /* displayImagesAtEnd */, true /* hideLargeIcon */); return makeMessagingView(false /* isCollapsed */, true /* hideLargeIcon */); } /** * Create a messaging layout. * * @param displayImagesAtEnd should images be displayed at the end of the content instead * of inline. * @param isCollapsed Should this use the collapsed layout * @param hideRightIcons Should the reply affordance be shown at the end of the notification * @return the created remoteView. */ @NonNull private RemoteViews makeMessagingView(boolean displayImagesAtEnd, boolean hideRightIcons) { private RemoteViews makeMessagingView(boolean isCollapsed, boolean hideRightIcons) { CharSequence conversationTitle = !TextUtils.isEmpty(super.mBigContentTitle) ? super.mBigContentTitle : mConversationTitle; Loading Loading @@ -7533,14 +7536,21 @@ public class Notification implements Parcelable mBuilder.getPrimaryTextColor(p)); contentView.setInt(R.id.status_bar_latest_event_content, "setMessageTextColor", mBuilder.getSecondaryTextColor(p)); contentView.setBoolean(R.id.status_bar_latest_event_content, "setDisplayImagesAtEnd", displayImagesAtEnd); contentView.setInt(R.id.status_bar_latest_event_content, "setNotificationBackgroundColor", mBuilder.resolveBackgroundColor(p)); contentView.setBoolean(R.id.status_bar_latest_event_content, "setIsCollapsed", isCollapsed); contentView.setIcon(R.id.status_bar_latest_event_content, "setAvatarReplacement", avatarReplacement); contentView.setCharSequence(R.id.status_bar_latest_event_content, "setNameReplacement", nameReplacement); contentView.setBoolean(R.id.status_bar_latest_event_content, "setIsOneToOne", isOneToOne); contentView.setCharSequence(R.id.status_bar_latest_event_content, "setConversationTitle", conversationTitle); contentView.setIcon(R.id.status_bar_latest_event_content, "setLargeIcon", mBuilder.mN.mLargeIcon); contentView.setBundle(R.id.status_bar_latest_event_content, "setData", mBuilder.mN.extras); return contentView; Loading Loading @@ -7601,9 +7611,11 @@ public class Notification implements Parcelable */ @Override public RemoteViews makeHeadsUpContentView(boolean increasedHeight) { RemoteViews remoteViews = makeMessagingView(true /* displayImagesAtEnd */, RemoteViews remoteViews = makeMessagingView(true /* isCollapsed */, true /* hideLargeIcon */); if (!CONVERSATION_LAYOUT_ENABLED) { remoteViews.setInt(R.id.notification_messaging, "setMaxDisplayedLines", 1); } return remoteViews; } Loading
core/java/android/view/NotificationHeaderView.java +4 −9 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.widget.RemoteViews; import com.android.internal.R; import com.android.internal.widget.CachingIconView; import com.android.internal.widget.NotificationExpandButton; import java.util.ArrayList; Loading @@ -56,7 +57,7 @@ public class NotificationHeaderView extends ViewGroup { private OnClickListener mAppOpsListener; private HeaderTouchListener mTouchListener = new HeaderTouchListener(); private LinearLayout mTransferChip; private ImageView mExpandButton; private NotificationExpandButton mExpandButton; private CachingIconView mIcon; private View mProfileBadge; private View mOverlayIcon; Loading @@ -65,7 +66,6 @@ public class NotificationHeaderView extends ViewGroup { private View mAppOps; private View mAudiblyAlertedIcon; private int mIconColor; private int mOriginalNotificationColor; private boolean mExpanded; private boolean mShowExpandButtonAtEnd; private boolean mShowWorkBadgeAtEnd; Loading Loading @@ -324,13 +324,8 @@ public class NotificationHeaderView extends ViewGroup { return mIconColor; } @RemotableViewMethod public void setOriginalNotificationColor(int color) { mOriginalNotificationColor = color; } public int getOriginalNotificationColor() { return mOriginalNotificationColor; return mExpandButton.getOriginalNotificationColor(); } @RemotableViewMethod Loading Loading @@ -371,7 +366,7 @@ public class NotificationHeaderView extends ViewGroup { contentDescriptionId = R.string.expand_button_content_description_collapsed; } mExpandButton.setImageDrawable(getContext().getDrawable(drawableId)); mExpandButton.setColorFilter(mOriginalNotificationColor); mExpandButton.setColorFilter(getOriginalNotificationColor()); mExpandButton.setContentDescription(mContext.getText(contentDescriptionId)); } Loading
core/java/com/android/internal/widget/CachingIconView.java +9 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.widget.ImageView; import android.widget.RemoteViews; import java.util.Objects; import java.util.function.Consumer; /** * An ImageView for displaying an Icon. Avoids reloading the Icon when possible. Loading @@ -44,6 +45,7 @@ public class CachingIconView extends ImageView { private boolean mInternalSetDrawable; private boolean mForceHidden; private int mDesiredVisibility; private Consumer<Integer> mOnVisibilityChangedListener; @UnsupportedAppUsage public CachingIconView(Context context, @Nullable AttributeSet attrs) { Loading Loading @@ -198,6 +200,13 @@ public class CachingIconView extends ImageView { private void updateVisibility() { int visibility = mDesiredVisibility == VISIBLE && mForceHidden ? INVISIBLE : mDesiredVisibility; if (mOnVisibilityChangedListener != null) { mOnVisibilityChangedListener.accept(visibility); } super.setVisibility(visibility); } public void setOnVisibilityChangedListener(Consumer<Integer> listener) { mOnVisibilityChangedListener = listener; } }
core/java/com/android/internal/widget/ConversationLayout.java 0 → 100644 +866 −0 File added.Preview size limit exceeded, changes collapsed. Show changes
core/java/com/android/internal/widget/IMessagingLayout.java 0 → 100644 +42 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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 */ package com.android.internal.widget; import android.content.Context; import java.util.ArrayList; /** * An interface for a MessagingLayout */ public interface IMessagingLayout { /** * @return the layout containing the messages */ MessagingLinearLayout getMessagingLinearLayout(); /** * @return the context of this view */ Context getContext(); /** * @return the list of messaging groups */ ArrayList<MessagingGroup> getMessagingGroups(); }