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

Commit 414ad334 authored by Selim Cinek's avatar Selim Cinek
Browse files

Continued low-priority group implementation

Adapting the low-priority group implementation
according to spec. Expanding a group takes 2 taps now.

Test: add low-priority group observe behavior
Change-Id: Ic563a8fe0e71df746b9b548adc8d1698940b1a83
Fixes: 35125708
parent 17fd64b3
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -4040,15 +4040,23 @@ public class Notification implements Parcelable
        }

        /**
         * Construct a RemoteViews for the final notification header only
         * Construct a RemoteViews for the final notification header only. This will not be
         * colorized.
         *
         * @hide
         */
        public RemoteViews makeNotificationHeader() {
            Boolean colorized = (Boolean) mN.extras.get(EXTRA_COLORIZED);
            mN.extras.putBoolean(EXTRA_COLORIZED, false);
            RemoteViews header = new BuilderRemoteViews(mContext.getApplicationInfo(),
                    R.layout.notification_template_header);
            resetNotificationHeader(header);
            bindNotificationHeader(header, false /* ambient */);
            if (colorized != null) {
                mN.extras.putBoolean(EXTRA_COLORIZED, colorized);
            } else {
                mN.extras.remove(EXTRA_COLORIZED);
            }
            return header;
        }

@@ -4167,8 +4175,6 @@ public class Notification implements Parcelable
                    mN.extras.putCharSequence(EXTRA_SUB_TEXT, newSummary);
                }
            }
            Boolean colorized = (Boolean) mN.extras.get(EXTRA_COLORIZED);
            mN.extras.putBoolean(EXTRA_COLORIZED, false);

            RemoteViews header = makeNotificationHeader();

@@ -4177,11 +4183,6 @@ public class Notification implements Parcelable
            } else {
                mN.extras.remove(EXTRA_SUB_TEXT);
            }
            if (colorized != null) {
                mN.extras.putBoolean(EXTRA_COLORIZED, colorized);
            } else {
                mN.extras.remove(EXTRA_COLORIZED);
            }
            mN.color = color;
            return header;
        }
+43 −27
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import android.view.MotionEvent;
import android.view.NotificationHeaderView;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.ViewStub;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
@@ -159,14 +158,15 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    private OnClickListener mExpandClickListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mShowingPublic && mGroupManager.isSummaryOfGroup(mStatusBarNotification)) {
            if (!mShowingPublic && (!mIsLowPriority || isExpanded())
                    && mGroupManager.isSummaryOfGroup(mStatusBarNotification)) {
                mGroupExpansionChanging = true;
                final boolean wasExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification);
                boolean nowExpanded = mGroupManager.toggleGroupExpansion(mStatusBarNotification);
                mOnExpandClickListener.onExpandClicked(mEntry, nowExpanded);
                MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTIFICATION_GROUP_EXPANDER,
                        nowExpanded);
                logExpansionEvent(true /* userAction */, wasExpanded);
                onExpansionChanged(true /* userAction */, wasExpanded);
            } else {
                if (v.isAccessibilityFocused()) {
                    mPrivateLayout.setFocusOnVisibilityChange();
@@ -253,6 +253,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        }
        if (mIsSummaryWithChildren) {
            setIconAnimationRunningForChild(running, mChildrenContainer.getHeaderView());
            setIconAnimationRunningForChild(running, mChildrenContainer.getLowPriorityHeaderView());
            List<ExpandableNotificationRow> notificationChildren =
                    mChildrenContainer.getNotificationChildren();
            for (int i = 0; i < notificationChildren.size(); i++) {
@@ -320,8 +321,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        mShowingPublicInitialized = false;
        updateNotificationColor();
        if (mIsSummaryWithChildren) {
            mChildrenContainer.recreateNotificationHeader(mExpandClickListener,
                    mEntry.notification);
            mChildrenContainer.recreateNotificationHeader(mExpandClickListener);
            mChildrenContainer.onNotificationUpdated();
        }
        if (mIconAnimationRunning) {
@@ -687,9 +687,13 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        return mPrivateLayout.getNotificationHeader();
    }

    private NotificationHeaderView getVisibleNotificationHeader() {
    /**
     * @return the currently visible notification header. This can be different from
     * {@link #getNotificationHeader()} in case it is a low-priority group.
     */
    public NotificationHeaderView getVisibleNotificationHeader() {
        if (mIsSummaryWithChildren && !mShowingPublic) {
            return mChildrenContainer.getHeaderView();
            return mChildrenContainer.getVisibleHeader();
        }
        return getShowingLayout().getVisibleNotificationHeader();
    }
@@ -909,7 +913,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    }

    public View getNotificationIcon() {
        NotificationHeaderView notificationHeader = getNotificationHeader();
        NotificationHeaderView notificationHeader = getVisibleNotificationHeader();
        if (notificationHeader != null) {
            return notificationHeader.getIcon();
        }
@@ -1032,6 +1036,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        }
    }

    public boolean isLowPriority() {
        return mIsLowPriority;
    }

    public void setUseIncreasedCollapsedHeight(boolean use) {
        mUseIncreasedCollapsedHeight = use;
        mNotificationInflater.setUsesIncreasedHeight(use);
@@ -1136,7 +1144,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
            public void onInflate(ViewStub stub, View inflated) {
                mChildrenContainer = (NotificationChildrenContainer) inflated;
                mChildrenContainer.setIsLowPriority(mIsLowPriority);
                mChildrenContainer.setNotificationParent(ExpandableNotificationRow.this);
                mChildrenContainer.setContainingNotification(ExpandableNotificationRow.this);
                mChildrenContainer.onNotificationUpdated();
                mTranslateableViews.add(mChildrenContainer);
            }
@@ -1265,9 +1273,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        if (mChildrenContainer != null) {
            mChildrenContainer.setVisibility(!mShowingPublic && mIsSummaryWithChildren ? VISIBLE
                    : INVISIBLE);
            mChildrenContainer.updateHeaderVisibility(!mShowingPublic && mIsSummaryWithChildren
                    ? VISIBLE
                    : INVISIBLE);
            mChildrenContainer.setHeaderVisible(!mShowingPublic && mIsSummaryWithChildren);
        }
        // The limits might have changed if the view suddenly became a group or vice versa
        updateLimits();
@@ -1335,7 +1341,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
     */
    public void setUserExpanded(boolean userExpanded) {
        setUserExpanded(userExpanded, false /* allowChildExpansion */);
        updateShelfIconColor();
    }

    /**
@@ -1346,22 +1351,28 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
     */
    public void setUserExpanded(boolean userExpanded, boolean allowChildExpansion) {
        mFalsingManager.setNotificationExpanded();
        if (mIsSummaryWithChildren && !mShowingPublic && allowChildExpansion) {
        if (mIsSummaryWithChildren && !mShowingPublic && allowChildExpansion
                && !mChildrenContainer.showingAsLowPriority()) {
            final boolean wasExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification);
            mGroupManager.setGroupExpanded(mStatusBarNotification, userExpanded);
            logExpansionEvent(true /* userAction */, wasExpanded);
            onExpansionChanged(true /* userAction */, wasExpanded);
            return;
        }
        if (userExpanded && !mExpandable) return;
        final boolean wasExpanded = isExpanded();
        mHasUserChangedExpansion = true;
        mUserExpanded = userExpanded;
        logExpansionEvent(true, wasExpanded);
        onExpansionChanged(true /* userAction */, wasExpanded);
    }

    public void resetUserExpansion() {
        boolean changed = mUserExpanded;
        mHasUserChangedExpansion = false;
        mUserExpanded = false;
        if (changed && mIsSummaryWithChildren) {
            mChildrenContainer.onExpansionChanged();
        }
        updateShelfIconColor();
    }

    public boolean isUserLocked() {
@@ -1395,9 +1406,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        if (expand != mIsSystemExpanded) {
            final boolean wasExpanded = isExpanded();
            mIsSystemExpanded = expand;
            updateShelfIconColor();
            notifyHeightChanged(false /* needsAnimation */);
            logExpansionEvent(false, wasExpanded);
            onExpansionChanged(false /* userAction */, wasExpanded);
            if (mIsSummaryWithChildren) {
                mChildrenContainer.updateGroupOverflow();
            }
@@ -1411,7 +1421,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        if (onKeyguard != mOnKeyguard) {
            final boolean wasExpanded = isExpanded();
            mOnKeyguard = onKeyguard;
            logExpansionEvent(false, wasExpanded);
            onExpansionChanged(false /* userAction */, wasExpanded);
            if (wasExpanded != isExpanded()) {
                if (mIsSummaryWithChildren) {
                    mChildrenContainer.updateGroupOverflow();
@@ -1482,8 +1492,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        mIsSummaryWithChildren = StatusBar.ENABLE_CHILD_NOTIFICATIONS
                && mChildrenContainer != null && mChildrenContainer.getNotificationChildCount() > 0;
        if (mIsSummaryWithChildren && mChildrenContainer.getHeaderView() == null) {
            mChildrenContainer.recreateNotificationHeader(mExpandClickListener,
                    mEntry.notification);
            mChildrenContainer.recreateNotificationHeader(mExpandClickListener
            );
        }
        getShowingLayout().updateBackgroundColor(false /* animate */);
        mPrivateLayout.updateExpandButtons(isExpandable());
@@ -1538,7 +1548,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
     * the top.
     */
    private void updateContentShiftHeight() {
        NotificationHeaderView notificationHeader = getNotificationHeader();
        NotificationHeaderView notificationHeader = getVisibleNotificationHeader();
        if (notificationHeader != null) {
            CachingIconView icon = notificationHeader.getIcon();
            mIconTransformContentShift = getRelativeTopPadding(icon) + icon.getHeight();
@@ -1932,7 +1942,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
            if (isGroupExpanded()) {
                return 1.0f;
            } else if (isUserLocked()) {
                return mChildrenContainer.getGroupExpandFraction();
                return mChildrenContainer.getIncreasedPaddingAmount();
            }
        } else if (isColorized() && (!mIsLowPriority || isExpanded())) {
            return -1.0f;
@@ -1955,14 +1965,20 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        return super.disallowSingleClick(event);
    }

    private void logExpansionEvent(boolean userAction, boolean wasExpanded) {
    private void onExpansionChanged(boolean userAction, boolean wasExpanded) {
        boolean nowExpanded = isExpanded();
        if (mIsSummaryWithChildren) {
        if (mIsSummaryWithChildren && (!mIsLowPriority || wasExpanded)) {
            nowExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification);
        }
        if (wasExpanded != nowExpanded && mLogger != null) {
        if (nowExpanded != wasExpanded) {
            updateShelfIconColor();
            if (mLogger != null) {
                mLogger.logNotificationExpansion(mLoggingKey, userAction, nowExpanded);
            }
            if (mIsSummaryWithChildren) {
                mChildrenContainer.onExpansionChanged();
            }
        }
    }

    @Override
+19 −7
Original line number Diff line number Diff line
@@ -631,7 +631,7 @@ public class NotificationContentView extends FrameLayout {
    }

    public int getMinHeight(boolean likeGroupExpanded) {
        if (likeGroupExpanded || !mIsChildInGroup || isGroupExpanded() || mIsLowPriority) {
        if (likeGroupExpanded || !mIsChildInGroup || isGroupExpanded()) {
            return mContractedChild.getHeight();
        } else {
            return mSingleLineView.getHeight();
@@ -905,7 +905,7 @@ public class NotificationContentView extends FrameLayout {
                height = mContentHeight;
            }
            int expandedVisualType = getVisualTypeForHeight(height);
            int collapsedVisualType = mIsChildInGroup && !isGroupExpanded() && !mIsLowPriority
            int collapsedVisualType = mIsChildInGroup && !isGroupExpanded()
                    ? VISIBLE_TYPE_SINGLELINE
                    : getVisualTypeForHeight(mContainingNotification.getCollapsedHeight());
            return mTransformationStartVisibleType == collapsedVisualType
@@ -926,7 +926,7 @@ public class NotificationContentView extends FrameLayout {
        if (!noExpandedChild && viewHeight == mExpandedChild.getHeight()) {
            return VISIBLE_TYPE_EXPANDED;
        }
        if (!mUserExpanding && mIsChildInGroup && !isGroupExpanded() && !mIsLowPriority) {
        if (!mUserExpanding && mIsChildInGroup && !isGroupExpanded()) {
            return VISIBLE_TYPE_SINGLELINE;
        }

@@ -1005,6 +1005,18 @@ public class NotificationContentView extends FrameLayout {

    public void setIsChildInGroup(boolean isChildInGroup) {
        mIsChildInGroup = isChildInGroup;
        if (mContractedChild != null) {
            mContractedWrapper.setIsChildInGroup(mIsChildInGroup);
        }
        if (mExpandedChild != null) {
            mExpandedWrapper.setIsChildInGroup(mIsChildInGroup);
        }
        if (mHeadsUpChild != null) {
            mHeadsUpWrapper.setIsChildInGroup(mIsChildInGroup);
        }
        if (mAmbientChild != null) {
            mAmbientWrapper.setIsChildInGroup(mIsChildInGroup);
        }
        updateSingleLineView();
    }

@@ -1013,16 +1025,16 @@ public class NotificationContentView extends FrameLayout {
        mBeforeN = entry.targetSdk < Build.VERSION_CODES.N;
        updateSingleLineView();
        if (mContractedChild != null) {
            mContractedWrapper.notifyContentUpdated(entry.notification, mIsLowPriority);
            mContractedWrapper.notifyContentUpdated(entry.row);
        }
        if (mExpandedChild != null) {
            mExpandedWrapper.notifyContentUpdated(entry.notification, mIsLowPriority);
            mExpandedWrapper.notifyContentUpdated(entry.row);
        }
        if (mHeadsUpChild != null) {
            mHeadsUpWrapper.notifyContentUpdated(entry.notification, mIsLowPriority);
            mHeadsUpWrapper.notifyContentUpdated(entry.row);
        }
        if (mAmbientChild != null) {
            mAmbientWrapper.notifyContentUpdated(entry.notification, mIsLowPriority);
            mAmbientWrapper.notifyContentUpdated(entry.row);
        }
        applyRemoteInput(entry);
        updateLegacy();
+2 −1
Original line number Diff line number Diff line
@@ -443,7 +443,8 @@ public class NotificationShelf extends ActivatableNotificationView {
            }
            int shelfColor = icon.getStaticDrawableColor();
            if (!noIcon && shelfColor != StatusBarIconView.NO_COLOR) {
                int notificationColor = row.getNotificationHeader().getOriginalNotificationColor();
                int notificationColor
                        = row.getVisibleNotificationHeader().getOriginalNotificationColor();
                shelfColor = NotificationUtils.interpolateColors(notificationColor, shelfColor,
                        iconState.iconAppearAmount);
            }
+3 −3
Original line number Diff line number Diff line
@@ -36,9 +36,9 @@ public class NotificationBigPictureTemplateViewWrapper extends NotificationTempl
    }

    @Override
    public void notifyContentUpdated(StatusBarNotification notification, boolean isLowPriority) {
        super.notifyContentUpdated(notification, isLowPriority);
        updateImageTag(notification);
    public void notifyContentUpdated(ExpandableNotificationRow row) {
        super.notifyContentUpdated(row);
        updateImageTag(row.getStatusBarNotification());
    }

    private void updateImageTag(StatusBarNotification notification) {
Loading