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

Commit 09cfbe0d authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed the behavior of headers in conversation groups

The header text would be hidden because of an issue
and the sanitization of the header didn't apply.

Bug: 150905003
Test: add group of conversations, observe name not hidden
Change-Id: I3bfa45804459ab9b0f8b7a1c6cf5b6bd8ace9c78
parent e9714eb0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@

                <!-- Header -->
                <LinearLayout
                    android:id="@+id/conversation_header"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
+1 −0
Original line number Diff line number Diff line
@@ -3882,6 +3882,7 @@
  <java-symbol type="id" name="expand_button_container" />
  <java-symbol type="id" name="messaging_group_content_container" />
  <java-symbol type="id" name="expand_button_and_content_container" />
  <java-symbol type="id" name="conversation_header" />
  <java-symbol type="dimen" name="conversation_expand_button_top_margin_expanded" />
  <java-symbol type="dimen" name="conversation_expand_button_expanded_size" />
  <java-symbol type="dimen" name="messaging_group_singleline_sender_padding_end" />
+21 −12
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.graphics.drawable.Icon;
import android.text.TextUtils;
import android.view.NotificationHeaderView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

@@ -182,24 +183,28 @@ public class NotificationHeaderUtil {

    private void sanitizeChild(View child) {
        if (child != null) {
            NotificationHeaderView header = (NotificationHeaderView) child.findViewById(
            ViewGroup header = child.findViewById(
                    com.android.internal.R.id.notification_header);
            if (header == null) {
                header = child.findViewById(
                        com.android.internal.R.id.conversation_header);
            }
            sanitizeHeader(header);
        }
    }

    private void sanitizeHeader(NotificationHeaderView rowHeader) {
    private void sanitizeHeader(ViewGroup rowHeader) {
        if (rowHeader == null) {
            return;
        }
        final int childCount = rowHeader.getChildCount();
        View time = rowHeader.findViewById(com.android.internal.R.id.time);
        boolean hasVisibleText = false;
        for (int i = 1; i < childCount - 1 ; i++) {
        for (int i = 0; i < childCount; i++) {
            View child = rowHeader.getChildAt(i);
            if (child instanceof TextView
                    && child.getVisibility() != View.GONE
                    && !mDividers.contains(Integer.valueOf(child.getId()))
                    && !mDividers.contains(child.getId())
                    && child != time) {
                hasVisibleText = true;
                break;
@@ -212,14 +217,14 @@ public class NotificationHeaderUtil {
        time.setVisibility(timeVisibility);
        View left = null;
        View right;
        for (int i = 1; i < childCount - 1 ; i++) {
        for (int i = 0; i < childCount; i++) {
            View child = rowHeader.getChildAt(i);
            if (mDividers.contains(Integer.valueOf(child.getId()))) {
            if (mDividers.contains(child.getId())) {
                boolean visible = false;
                // Lets find the item to the right
                for (i++; i < childCount - 1; i++) {
                for (i++; i < childCount; i++) {
                    right = rowHeader.getChildAt(i);
                    if (mDividers.contains(Integer.valueOf(right.getId()))) {
                    if (mDividers.contains(right.getId())) {
                        // A divider was found, this needs to be hidden
                        i--;
                        break;
@@ -276,14 +281,18 @@ public class NotificationHeaderUtil {
            if (!mApply) {
                return;
            }
            NotificationHeaderView header = row.getContractedNotificationHeader();
            if (header == null) {
                // No header found. We still consider this to be the same to avoid weird flickering
            View contractedChild = row.getPrivateLayout().getContractedChild();
            if (contractedChild == null) {
                return;
            }
            View ownView = contractedChild.findViewById(mId);
            if (ownView == null) {
                // No view found. We still consider this to be the same to avoid weird flickering
                // when for example showing an undo notification
                return;
            }
            Object childData = mExtractor == null ? null : mExtractor.extractData(row);
            mApply = mComparator.compare(mParentView, header.findViewById(mId),
            mApply = mComparator.compare(mParentView, ownView,
                    mParentData, childData);
        }

+0 −13
Original line number Diff line number Diff line
@@ -1057,19 +1057,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        return getShowingLayout().getVisibleNotificationHeader();
    }


    /**
     * @return the contracted notification header. This can be different from
     * {@link #getNotificationHeader()} and also {@link #getVisibleNotificationHeader()} and only
     * returns the contracted version.
     */
    public NotificationHeaderView getContractedNotificationHeader() {
        if (mIsSummaryWithChildren) {
            return mChildrenContainer.getHeaderView();
        }
        return mPrivateLayout.getContractedNotificationHeader();
    }

    public void setLongPressListener(LongPressListener longPressListener) {
        mLongPressListener = longPressListener;
    }
+0 −7
Original line number Diff line number Diff line
@@ -1492,13 +1492,6 @@ public class NotificationContentView extends FrameLayout {
        }
    }

    public NotificationHeaderView getContractedNotificationHeader() {
        if (mContractedChild != null) {
            return mContractedWrapper.getNotificationHeader();
        }
        return null;
    }

    public NotificationHeaderView getVisibleNotificationHeader() {
        NotificationViewWrapper wrapper = getVisibleWrapper(mVisibleType);
        return wrapper == null ? null : wrapper.getNotificationHeader();