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

Commit 5f003f4e authored by Selim Cinek's avatar Selim Cinek Committed by Android (Google) Code Review
Browse files

Merge changes I69b33b0c,If904c85e,I28444df4,I3bfa4580,I88d9667d, ... into rvc-dev

* changes:
  Decrease avatar and sender name sizes in MessagingStyle
  Fixed various conversation layout appearences
  Implemented FacePile if no group icon is present
  Fixed the behavior of headers in conversation groups
  Ensured correct coloring of badge in dark mode
  Fixed an issue where the bubble badge was visible independent of the icon
  Improved transitions for expanding messaging notifications
  Adjusted single line representation to include a colon
  Made the expand button positioning conditional on expanded state
  Ensured that the sender of the first message is hidden
  Baseline for the new ConversationLayout
parents 83cf8551 9ac3edc4
Loading
Loading
Loading
Loading
+23 −11
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.graphics.drawable.Icon.TYPE_URI;
import static android.graphics.drawable.Icon.TYPE_URI_ADAPTIVE_BITMAP;
import static android.graphics.drawable.Icon.TYPE_URI_ADAPTIVE_BITMAP;


import static com.android.internal.util.ContrastColorUtil.satisfiesTextContrast;
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.ColorInt;
import android.annotation.DimenRes;
import android.annotation.DimenRes;
@@ -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_big_text);
        STANDARD_LAYOUTS.add(R.layout.notification_template_material_inbox);
        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_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_media);
        STANDARD_LAYOUTS.add(R.layout.notification_template_material_big_media);
        STANDARD_LAYOUTS.add(R.layout.notification_template_material_big_media);
        STANDARD_LAYOUTS.add(R.layout.notification_template_header);
        STANDARD_LAYOUTS.add(R.layout.notification_template_header);
@@ -5138,7 +5140,7 @@ public class Notification implements Parcelable
            int color = isColorized(p) ? getPrimaryTextColor(p) : getSecondaryTextColor(p);
            int color = isColorized(p) ? getPrimaryTextColor(p) : getSecondaryTextColor(p);
            contentView.setDrawableTint(R.id.expand_button, false, color,
            contentView.setDrawableTint(R.id.expand_button, false, color,
                    PorterDuff.Mode.SRC_ATOP);
                    PorterDuff.Mode.SRC_ATOP);
            contentView.setInt(R.id.notification_header, "setOriginalNotificationColor",
            contentView.setInt(R.id.expand_button, "setOriginalNotificationColor",
                    color);
                    color);
        }
        }


@@ -6116,7 +6118,9 @@ public class Notification implements Parcelable
        }
        }


        private int getMessagingLayoutResource() {
        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() {
        private int getActionLayoutResource() {
@@ -7390,7 +7394,7 @@ public class Notification implements Parcelable
        public RemoteViews makeContentView(boolean increasedHeight) {
        public RemoteViews makeContentView(boolean increasedHeight) {
            mBuilder.mOriginalActions = mBuilder.mActions;
            mBuilder.mOriginalActions = mBuilder.mActions;
            mBuilder.mActions = new ArrayList<>();
            mBuilder.mActions = new ArrayList<>();
            RemoteViews remoteViews = makeMessagingView(true /* displayImagesAtEnd */,
            RemoteViews remoteViews = makeMessagingView(true /* isCollapsed */,
                    false /* hideLargeIcon */);
                    false /* hideLargeIcon */);
            mBuilder.mActions = mBuilder.mOriginalActions;
            mBuilder.mActions = mBuilder.mOriginalActions;
            mBuilder.mOriginalActions = null;
            mBuilder.mOriginalActions = null;
@@ -7480,19 +7484,18 @@ public class Notification implements Parcelable
         */
         */
        @Override
        @Override
        public RemoteViews makeBigContentView() {
        public RemoteViews makeBigContentView() {
            return makeMessagingView(false /* displayImagesAtEnd */, true /* hideLargeIcon */);
            return makeMessagingView(false /* isCollapsed */, true /* hideLargeIcon */);
        }
        }


        /**
        /**
         * Create a messaging layout.
         * Create a messaging layout.
         *
         *
         * @param displayImagesAtEnd should images be displayed at the end of the content instead
         * @param isCollapsed Should this use the collapsed layout
         *                           of inline.
         * @param hideRightIcons Should the reply affordance be shown at the end of the notification
         * @param hideRightIcons Should the reply affordance be shown at the end of the notification
         * @return the created remoteView.
         * @return the created remoteView.
         */
         */
        @NonNull
        @NonNull
        private RemoteViews makeMessagingView(boolean displayImagesAtEnd, boolean hideRightIcons) {
        private RemoteViews makeMessagingView(boolean isCollapsed, boolean hideRightIcons) {
            CharSequence conversationTitle = !TextUtils.isEmpty(super.mBigContentTitle)
            CharSequence conversationTitle = !TextUtils.isEmpty(super.mBigContentTitle)
                    ? super.mBigContentTitle
                    ? super.mBigContentTitle
                    : mConversationTitle;
                    : mConversationTitle;
@@ -7533,14 +7536,21 @@ public class Notification implements Parcelable
                    mBuilder.getPrimaryTextColor(p));
                    mBuilder.getPrimaryTextColor(p));
            contentView.setInt(R.id.status_bar_latest_event_content, "setMessageTextColor",
            contentView.setInt(R.id.status_bar_latest_event_content, "setMessageTextColor",
                    mBuilder.getSecondaryTextColor(p));
                    mBuilder.getSecondaryTextColor(p));
            contentView.setBoolean(R.id.status_bar_latest_event_content, "setDisplayImagesAtEnd",
            contentView.setInt(R.id.status_bar_latest_event_content,
                    displayImagesAtEnd);
                    "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",
            contentView.setIcon(R.id.status_bar_latest_event_content, "setAvatarReplacement",
                    avatarReplacement);
                    avatarReplacement);
            contentView.setCharSequence(R.id.status_bar_latest_event_content, "setNameReplacement",
            contentView.setCharSequence(R.id.status_bar_latest_event_content, "setNameReplacement",
                    nameReplacement);
                    nameReplacement);
            contentView.setBoolean(R.id.status_bar_latest_event_content, "setIsOneToOne",
            contentView.setBoolean(R.id.status_bar_latest_event_content, "setIsOneToOne",
                    isOneToOne);
                    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",
            contentView.setBundle(R.id.status_bar_latest_event_content, "setData",
                    mBuilder.mN.extras);
                    mBuilder.mN.extras);
            return contentView;
            return contentView;
@@ -7601,9 +7611,11 @@ public class Notification implements Parcelable
         */
         */
        @Override
        @Override
        public RemoteViews makeHeadsUpContentView(boolean increasedHeight) {
        public RemoteViews makeHeadsUpContentView(boolean increasedHeight) {
            RemoteViews remoteViews = makeMessagingView(true /* displayImagesAtEnd */,
            RemoteViews remoteViews = makeMessagingView(true /* isCollapsed */,
                    true /* hideLargeIcon */);
                    true /* hideLargeIcon */);
            if (!CONVERSATION_LAYOUT_ENABLED) {
                remoteViews.setInt(R.id.notification_messaging, "setMaxDisplayedLines", 1);
                remoteViews.setInt(R.id.notification_messaging, "setMaxDisplayedLines", 1);
            }
            return remoteViews;
            return remoteViews;
        }
        }


+4 −9
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@ import android.widget.RemoteViews;


import com.android.internal.R;
import com.android.internal.R;
import com.android.internal.widget.CachingIconView;
import com.android.internal.widget.CachingIconView;
import com.android.internal.widget.NotificationExpandButton;


import java.util.ArrayList;
import java.util.ArrayList;


@@ -56,7 +57,7 @@ public class NotificationHeaderView extends ViewGroup {
    private OnClickListener mAppOpsListener;
    private OnClickListener mAppOpsListener;
    private HeaderTouchListener mTouchListener = new HeaderTouchListener();
    private HeaderTouchListener mTouchListener = new HeaderTouchListener();
    private LinearLayout mTransferChip;
    private LinearLayout mTransferChip;
    private ImageView mExpandButton;
    private NotificationExpandButton mExpandButton;
    private CachingIconView mIcon;
    private CachingIconView mIcon;
    private View mProfileBadge;
    private View mProfileBadge;
    private View mOverlayIcon;
    private View mOverlayIcon;
@@ -65,7 +66,6 @@ public class NotificationHeaderView extends ViewGroup {
    private View mAppOps;
    private View mAppOps;
    private View mAudiblyAlertedIcon;
    private View mAudiblyAlertedIcon;
    private int mIconColor;
    private int mIconColor;
    private int mOriginalNotificationColor;
    private boolean mExpanded;
    private boolean mExpanded;
    private boolean mShowExpandButtonAtEnd;
    private boolean mShowExpandButtonAtEnd;
    private boolean mShowWorkBadgeAtEnd;
    private boolean mShowWorkBadgeAtEnd;
@@ -324,13 +324,8 @@ public class NotificationHeaderView extends ViewGroup {
        return mIconColor;
        return mIconColor;
    }
    }


    @RemotableViewMethod
    public void setOriginalNotificationColor(int color) {
        mOriginalNotificationColor = color;
    }

    public int getOriginalNotificationColor() {
    public int getOriginalNotificationColor() {
        return mOriginalNotificationColor;
        return mExpandButton.getOriginalNotificationColor();
    }
    }


    @RemotableViewMethod
    @RemotableViewMethod
@@ -371,7 +366,7 @@ public class NotificationHeaderView extends ViewGroup {
            contentDescriptionId = R.string.expand_button_content_description_collapsed;
            contentDescriptionId = R.string.expand_button_content_description_collapsed;
        }
        }
        mExpandButton.setImageDrawable(getContext().getDrawable(drawableId));
        mExpandButton.setImageDrawable(getContext().getDrawable(drawableId));
        mExpandButton.setColorFilter(mOriginalNotificationColor);
        mExpandButton.setColorFilter(getOriginalNotificationColor());
        mExpandButton.setContentDescription(mContext.getText(contentDescriptionId));
        mExpandButton.setContentDescription(mContext.getText(contentDescriptionId));
    }
    }


+9 −0
Original line number Original line Diff line number Diff line
@@ -32,6 +32,7 @@ import android.widget.ImageView;
import android.widget.RemoteViews;
import android.widget.RemoteViews;


import java.util.Objects;
import java.util.Objects;
import java.util.function.Consumer;


/**
/**
 * An ImageView for displaying an Icon. Avoids reloading the Icon when possible.
 * An ImageView for displaying an Icon. Avoids reloading the Icon when possible.
@@ -44,6 +45,7 @@ public class CachingIconView extends ImageView {
    private boolean mInternalSetDrawable;
    private boolean mInternalSetDrawable;
    private boolean mForceHidden;
    private boolean mForceHidden;
    private int mDesiredVisibility;
    private int mDesiredVisibility;
    private Consumer<Integer> mOnVisibilityChangedListener;


    @UnsupportedAppUsage
    @UnsupportedAppUsage
    public CachingIconView(Context context, @Nullable AttributeSet attrs) {
    public CachingIconView(Context context, @Nullable AttributeSet attrs) {
@@ -198,6 +200,13 @@ public class CachingIconView extends ImageView {
    private void updateVisibility() {
    private void updateVisibility() {
        int visibility = mDesiredVisibility == VISIBLE && mForceHidden ? INVISIBLE
        int visibility = mDesiredVisibility == VISIBLE && mForceHidden ? INVISIBLE
                : mDesiredVisibility;
                : mDesiredVisibility;
        if (mOnVisibilityChangedListener != null) {
            mOnVisibilityChangedListener.accept(visibility);
        }
        super.setVisibility(visibility);
        super.setVisibility(visibility);
    }
    }

    public void setOnVisibilityChangedListener(Consumer<Integer> listener) {
        mOnVisibilityChangedListener = listener;
    }
}
}
+866 −0

File added.

Preview size limit exceeded, changes collapsed.

+42 −0
Original line number Original line 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