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

Commit 928bb16c authored by Steve Elliott's avatar Steve Elliott
Browse files

Add importance ring around conversation badge

Bug: 150905003
Test: manual
Change-Id: I967122fcf6404491fb514bc42e5f9e64490b8024
parent 28e4801c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -7584,6 +7584,7 @@ public class Notification implements Parcelable
                isOneToOne = !isGroupConversation();
            }
            boolean isConversationLayout = mConversationType != CONVERSATION_TYPE_LEGACY;
            boolean isImportantConversation = mConversationType == CONVERSATION_TYPE_IMPORTANT;
            Icon largeIcon = isConversationLayout ? mShortcutIcon : mBuilder.mN.mLargeIcon;
            TemplateBindResult bindResult = new TemplateBindResult();
            StandardTemplateParams p = mBuilder.mParams.reset()
@@ -7626,6 +7627,10 @@ public class Notification implements Parcelable
                    isOneToOne);
            contentView.setCharSequence(R.id.status_bar_latest_event_content,
                    "setConversationTitle", conversationTitle);
            if (isConversationLayout) {
                contentView.setBoolean(R.id.status_bar_latest_event_content,
                        "setIsImportantConversation", isImportantConversation);
            }
            contentView.setIcon(R.id.status_bar_latest_event_content, "setLargeIcon",
                    largeIcon);
            contentView.setBundle(R.id.status_bar_latest_event_content, "setData",
+13 −7
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ public class ConversationLayout extends FrameLayout
    private int mIconSizeBadged;
    private int mIconSizeCentered;
    private CachingIconView mIcon;
    private View mImportanceRingView;
    private int mExpandedGroupTopMargin;
    private View mConversationFacePile;
    private int mNotificationBackgroundColor;
@@ -169,6 +170,7 @@ public class ConversationLayout extends FrameLayout
        mTextPaint.setAntiAlias(true);
        mConversationIcon = findViewById(R.id.conversation_icon);
        mIcon = findViewById(R.id.icon);
        mImportanceRingView = findViewById(R.id.conversation_icon_badge_ring);
        mConversationIconBadge = findViewById(R.id.conversation_icon_badge);
        mIcon.setOnVisibilityChangedListener((visibility) -> {
            // Always keep the badge visibility in sync with the icon. This is necessary in cases
@@ -212,6 +214,14 @@ public class ConversationLayout extends FrameLayout
        mNameReplacement = nameReplacement;
    }

    /**
     * Sets this conversation as "important", adding some additional UI treatment.
     */
    @RemotableViewMethod
    public void setIsImportantConversation(boolean isImportantConversation) {
        mImportanceRingView.setVisibility(isImportantConversation ? VISIBLE : GONE);
    }

    /**
     * Set this layout to show the collapsed representation.
     *
@@ -309,14 +319,12 @@ public class ConversationLayout extends FrameLayout
        updateTitleAndNamesDisplay();

        updateConversationLayout();

    }

    /**
     * Update the layout according to the data provided (i.e mIsOneToOne, expanded etc);
     */
    private void updateConversationLayout() {
        // TODO: resolve this from shortcuts
        // Set avatar and name
        CharSequence conversationText = mConversationTitle;
        // TODO: display the secondary text somewhere
@@ -463,7 +471,7 @@ public class ConversationLayout extends FrameLayout
        int marginTop;
        int iconSize;
        if (mIsOneToOne || mIsCollapsed) {
            // Baded format
            // Badged format
            gravity = Gravity.LEFT;
            marginStart = mBadgedSideMargins;
            marginTop = mBadgedSideMargins;
@@ -479,11 +487,9 @@ public class ConversationLayout extends FrameLayout
        layoutParams.gravity = gravity;
        layoutParams.topMargin = marginTop;
        layoutParams.setMarginStart(marginStart);
        layoutParams.width = iconSize;
        layoutParams.height = iconSize;
        mConversationIconBadge.setLayoutParams(layoutParams);
        ViewGroup.LayoutParams iconParams = mIcon.getLayoutParams();
        iconParams.width = iconSize;
        iconParams.height = iconSize;
        mIcon.setLayoutParams(iconParams);
    }

    @RemotableViewMethod
+32 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ 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
  -->

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">

    <solid
        android:color="@color/transparent"/>

    <stroke
        android:color="@color/conversation_important_highlight"
        android:width="2dp"/>

    <size
        android:width="26dp"
        android:height="26dp"/>
</shape>
+19 −5
Original line number Diff line number Diff line
@@ -58,18 +58,32 @@

            <FrameLayout
                android:id="@+id/conversation_icon_badge"
                android:layout_width="20dp"
                android:layout_height="20dp"
                android:layout_width="@dimen/conversation_icon_size_badged"
                android:layout_height="@dimen/conversation_icon_size_badged"
                android:layout_marginLeft="@dimen/conversation_badge_side_margin"
                android:layout_marginTop="@dimen/conversation_badge_side_margin"
                android:background="@drawable/conversation_badge_background" >
            >
                <ImageView
                    android:id="@+id/conversation_icon_badge_bg"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:src="@drawable/conversation_badge_background"
                />
                <!-- Badge: 20x20, 48dp padding left + top -->
                <com.android.internal.widget.CachingIconView
                    android:id="@+id/icon"
                    android:layout_width="@dimen/conversation_icon_size_badged"
                    android:layout_height="@dimen/conversation_icon_size_badged"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:padding="4dp"
                    android:layout_gravity="center"
                />
                <ImageView
                    android:id="@+id/conversation_icon_badge_ring"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:src="@drawable/conversation_badge_ring"
                    android:visibility="gone"
                />
            </FrameLayout>
        </FrameLayout>
    </FrameLayout>
+2 −0
Original line number Diff line number Diff line
@@ -226,4 +226,6 @@
    <color name="resolver_text_color_secondary_dark">#ffC4C6C6</color>
    <color name="resolver_empty_state_text">#FF202124</color>
    <color name="resolver_empty_state_icon">#FF5F6368</color>

    <color name="conversation_important_highlight">#F9AB00</color>
</resources>
Loading