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

Commit 4018c507 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Hide app name from collapsed CallStyle.

Also some small fixes:
* Bind the title in the CallStyle builder.
* Remove an unnecessary findViewById.
* Rename a method overload for clarity.

Bug: 179178086
Test: manual inspection
Change-Id: I6e96864c17718b9729b108e4db82534aad33675f
parent 12fa627b
Loading
Loading
Loading
Loading
+43 −14
Original line number Diff line number Diff line
@@ -5011,9 +5011,13 @@ public class Notification implements Parcelable
            boolean showProgress = handleProgressBar(contentView, ex, p);
            boolean hasSecondLine = showProgress;
            if (p.hasTitle()) {
                contentView.setViewVisibility(R.id.title, View.VISIBLE);
                contentView.setTextViewText(R.id.title, processTextSpans(p.title));
                setTextViewColorPrimary(contentView, R.id.title, p);
                contentView.setViewVisibility(p.mTitleViewId, View.VISIBLE);
                contentView.setTextViewText(p.mTitleViewId, processTextSpans(p.title));
                setTextViewColorPrimary(contentView, p.mTitleViewId, p);
            } else if (p.mTitleViewId != R.id.title) {
                // This alternate title view ID is not cleared by resetStandardTemplate
                contentView.setViewVisibility(p.mTitleViewId, View.GONE);
                contentView.setTextViewText(p.mTitleViewId, null);
            }
            if (p.text != null && p.text.length() != 0
                    && (!showProgress || p.mAllowTextWithProgress)) {
@@ -5441,6 +5445,11 @@ public class Notification implements Parcelable
                // keep the divider visible between that title and the next text element.
                return true;
            }
            if (p.mHideAppName) {
                // The app name is being hidden, so we definitely want to return here.
                // Assume that there is a title which will replace it in the header.
                return p.hasTitle();
            }
            contentView.setViewVisibility(R.id.app_name_text, View.VISIBLE);
            contentView.setTextViewText(R.id.app_name_text, loadHeaderAppName());
            contentView.setTextColor(R.id.app_name_text, getSecondaryTextColor(p));
@@ -5817,7 +5826,7 @@ public class Notification implements Parcelable
         *
         * @hide
         */
        public RemoteViews makeNotificationHeader() {
        public RemoteViews makeNotificationGroupHeader() {
            return makeNotificationHeader(mParams.reset()
                    .viewType(StandardTemplateParams.VIEW_TYPE_GROUP_HEADER)
                    .fillTextsFrom(this));
@@ -9440,7 +9449,9 @@ public class Notification implements Parcelable
        }

        private RemoteViews makeCallLayout(int viewType) {
            final boolean isCollapsed = viewType == StandardTemplateParams.VIEW_TYPE_NORMAL;
            Bundle extras = mBuilder.mN.extras;
            CharSequence title = mPerson != null ? mPerson.getName() : null;
            CharSequence text = mBuilder.processLegacyText(extras.getCharSequence(EXTRA_TEXT));
            if (text == null) {
                text = getDefaultText();
@@ -9452,22 +9463,26 @@ public class Notification implements Parcelable
                    .callStyleActions(true)
                    .allowTextWithProgress(true)
                    .hideLargeIcon(true)
                    .hideAppName(isCollapsed)
                    .titleViewId(R.id.conversation_text)
                    .title(title)
                    .text(text)
                    .summaryText(mBuilder.processLegacyText(mVerificationText));
            mBuilder.mActions = getActionsListWithSystemActions();
            final RemoteViews contentView;
            if (p.mViewType != StandardTemplateParams.VIEW_TYPE_NORMAL) {
                contentView = mBuilder.applyStandardTemplateWithActions(
                        R.layout.notification_template_material_big_call, p, null /* result */);
            } else {
            if (isCollapsed) {
                contentView = mBuilder.applyStandardTemplate(
                        R.layout.notification_template_material_call, p, null /* result */);
            } else {
                contentView = mBuilder.applyStandardTemplateWithActions(
                        R.layout.notification_template_material_big_call, p, null /* result */);
            }

            // Bind some extra conversation-specific header fields.
            mBuilder.setTextViewColorPrimary(contentView, R.id.conversation_text, p);
            if (!p.mHideAppName) {
                mBuilder.setTextViewColorSecondary(contentView, R.id.app_name_divider, p);
                contentView.setViewVisibility(R.id.app_name_divider, View.VISIBLE);
            }
            bindCallerVerification(contentView, p);

            // Bind some custom CallLayout properties
@@ -12144,12 +12159,13 @@ public class Notification implements Parcelable
        public static int VIEW_TYPE_NORMAL = 1;
        public static int VIEW_TYPE_BIG = 2;
        public static int VIEW_TYPE_HEADS_UP = 3;
        public static int VIEW_TYPE_MINIMIZED = 4;
        public static int VIEW_TYPE_PUBLIC = 5;
        public static int VIEW_TYPE_GROUP_HEADER = 6;
        public static int VIEW_TYPE_MINIMIZED = 4;    // header only for minimized state
        public static int VIEW_TYPE_PUBLIC = 5;       // header only for automatic public version
        public static int VIEW_TYPE_GROUP_HEADER = 6; // header only for top of group

        int mViewType = VIEW_TYPE_UNSPECIFIED;
        boolean mHeaderless;
        boolean mHideAppName;
        boolean mHideTitle;
        boolean mHideActions;
        boolean mHideProgress;
@@ -12157,6 +12173,7 @@ public class Notification implements Parcelable
        boolean mPromotePicture;
        boolean mCallStyleActions;
        boolean mAllowTextWithProgress;
        int mTitleViewId;
        int mTextViewId;
        CharSequence title;
        CharSequence text;
@@ -12170,6 +12187,7 @@ public class Notification implements Parcelable
        final StandardTemplateParams reset() {
            mViewType = VIEW_TYPE_UNSPECIFIED;
            mHeaderless = false;
            mHideAppName = false;
            mHideTitle = false;
            mHideActions = false;
            mHideProgress = false;
@@ -12177,6 +12195,7 @@ public class Notification implements Parcelable
            mPromotePicture = false;
            mCallStyleActions = false;
            mAllowTextWithProgress = false;
            mTitleViewId = R.id.title;
            mTextViewId = R.id.text;
            title = null;
            text = null;
@@ -12202,6 +12221,11 @@ public class Notification implements Parcelable
            return this;
        }

        public StandardTemplateParams hideAppName(boolean hideAppName) {
            mHideAppName = hideAppName;
            return this;
        }

        final StandardTemplateParams hideActions(boolean hideActions) {
            this.mHideActions = hideActions;
            return this;
@@ -12237,6 +12261,11 @@ public class Notification implements Parcelable
            return this;
        }

        public StandardTemplateParams titleViewId(int titleViewId) {
            mTitleViewId = titleViewId;
            return this;
        }

        public StandardTemplateParams textViewId(int textViewId) {
            mTextViewId = textViewId;
            return this;
+0 −1
Original line number Diff line number Diff line
@@ -100,7 +100,6 @@ public class CallLayout extends FrameLayout {
        }
        // TODO(b/179178086): crop/clip the icon to a circle?
        mConversationIconView.setImageIcon(icon);
        mConversationText.setText(callerName);
    }

    @RemotableViewMethod
+1 −3
Original line number Diff line number Diff line
@@ -1346,9 +1346,7 @@ public class NotificationContentView extends FrameLayout {
        }
        ImageView bubbleButton = layout.findViewById(com.android.internal.R.id.bubble_button);
        View actionContainer = layout.findViewById(com.android.internal.R.id.actions_container);
        LinearLayout actionContainerLayout =
                layout.findViewById(com.android.internal.R.id.actions_container_layout);
        if (bubbleButton == null || actionContainer == null || actionContainerLayout == null) {
        if (bubbleButton == null || actionContainer == null) {
            return;
        }
        boolean isPersonWithShortcut =
+1 −1
Original line number Diff line number Diff line
@@ -324,7 +324,7 @@ public class NotificationChildrenContainer extends ViewGroup {
        StatusBarNotification notification = mContainingNotification.getEntry().getSbn();
        final Notification.Builder builder = Notification.Builder.recoverBuilder(getContext(),
                notification.getNotification());
        RemoteViews header = builder.makeNotificationHeader();
        RemoteViews header = builder.makeNotificationGroupHeader();
        if (mNotificationHeader == null) {
            mNotificationHeader = (NotificationHeaderView) header.apply(getContext(), this);
            mNotificationHeader.findViewById(com.android.internal.R.id.expand_button)