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

Commit e63854a7 authored by Anthony Chen's avatar Anthony Chen Committed by Android (Google) Code Review
Browse files

Merge "Allow notification expansion to be toggleable."

parents 9507d707 6bf88a01
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -20,4 +20,4 @@
    android:id="@+id/notification_more_divider"
    android:layout_width="match_parent"
    android:layout_height="@dimen/notification_divider_height"
    android:background="#FF616161" />
    android:background="@color/notification_divider_color" />
+3 −0
Original line number Diff line number Diff line
@@ -78,6 +78,9 @@
    <!-- The color of the material notification background when low priority -->
    <color name="notification_material_background_low_priority_color">#fff5f5f5</color>

    <!-- The color of the dividing line between grouped notifications. -->
    <color name="notification_divider_color">#FF616161</color>

    <!-- The background color of the notification shade -->
    <color name="notification_shade_background_color">#ffeeeeee</color>

+26 −0
Original line number Diff line number Diff line
@@ -369,4 +369,30 @@
         has rounded corners, then the contents will be clipped to those corners. -->
    <bool name="config_clipNotificationsToOutline">false</bool>

    <!-- Whether or not notifications that can be expanded will always be in their expanded state.
         This value only affects notifications that are not a group of notifications from the same
         applications. If this value is false, then only the first notification will be expanded;
         the other notifications need to be manually expanded by the user. -->
    <bool name="config_alwaysExpandNonGroupedNotifications">false</bool>

    <!-- Whether or not an expandable notification can be manually expanded or collapsed by the
         user. Grouped notifications are still expandable even if this value is false. -->
    <bool name="config_enableNonGroupedNotificationExpand">true</bool>

    <!-- Whether or not there should be dividing lines between child notifications when the
         group has been expanded. -->
    <bool name="config_showDividersWhenGroupNotificationExpanded">false</bool>

    <!-- Whether or not the dividing lines should be shown when the container is expanding and
         collapsing. If this value is true, then the lines will only show when the container has
         been completely expanded. -->
    <bool name="config_hideDividersDuringExpand">false</bool>

    <!-- Whether or not child notifications that are part of a group will have shadows. -->
    <bool name="config_enableShadowOnChildNotifications">true</bool>

    <!-- Whether or not a view containing child notifications will have a custom background when
         it has been expanded to reveal its children. -->
    <bool name="config_showGroupNotificationBgWhenExpanded">false</bool>

</resources>
+13 −0
Original line number Diff line number Diff line
@@ -330,6 +330,19 @@
    <!-- The corner radius of the shadow behind the notification. -->
    <dimen name="notification_shadow_radius">0dp</dimen>

    <!-- The alpha of the dividing line between child notifications of a notification group. -->
    <item name="notification_divider_alpha" format="float" type="dimen">0.5</item>

    <!-- The height of the divider between the individual notifications in a notification
         group. -->
    <dimen name="notification_children_container_divider_height">@dimen/notification_divider_height</dimen>

    <!-- The height of the header for a container containing child notifications. -->
    <dimen name="notification_children_container_header_height">53dp</dimen>

    <!-- The top margin for the notification children container in its non-expanded form. -->
    <dimen name="notification_children_container_margin_top">@*android:dimen/notification_content_margin_top</dimen>

    <!-- The height of a notification header -->
    <dimen name="notification_header_height">53dp</dimen>

+24 −6
Original line number Diff line number Diff line
@@ -170,6 +170,18 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    private OnExpandClickListener mOnExpandClickListener;
    private boolean mGroupExpansionChanging;

    /**
     * Whether or not a notification that is not part of a group of notifications can be manually
     * expanded by the user.
     */
    private boolean mEnableNonGroupedNotificationExpand;

    /**
     * Whether or not to update the background of the header of the notification when its expanded.
     * If {@code true}, the header background will disappear when expanded.
     */
    private boolean mShowGroupBackgroundWhenExpanded;

    private OnClickListener mExpandClickListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
@@ -182,7 +194,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTIFICATION_GROUP_EXPANDER,
                        nowExpanded);
                onExpansionChanged(true /* userAction */, wasExpanded);
            } else {
            } else if (mEnableNonGroupedNotificationExpand) {
                if (v.isAccessibilityFocused()) {
                    mPrivateLayout.setFocusOnVisibilityChange();
                }
@@ -1148,7 +1160,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    }

    public interface ExpansionLogger {
        public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
        void logNotificationExpansion(String key, boolean userAction, boolean expanded);
    }

    public ExpandableNotificationRow(Context context, AttributeSet attrs) {
@@ -1171,11 +1183,16 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        mMaxHeadsUpHeight = getFontScaledHeight(R.dimen.notification_max_heads_up_height);
        mMaxHeadsUpHeightIncreased = getFontScaledHeight(
                R.dimen.notification_max_heads_up_height_increased);

        Resources res = getResources();
        mIncreasedPaddingBetweenElements = res.getDimensionPixelSize(
                R.dimen.notification_divider_height_increased);
        mIconTransformContentShiftNoIcon = res.getDimensionPixelSize(
                R.dimen.notification_icon_transform_content_shift);
        mEnableNonGroupedNotificationExpand =
                res.getBoolean(R.bool.config_enableNonGroupedNotificationExpand);
        mShowGroupBackgroundWhenExpanded =
                res.getBoolean(R.bool.config_showGroupNotificationBgWhenExpanded);
    }

    /**
@@ -1391,7 +1408,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        if (mIsSummaryWithChildren && !mShowingPublic) {
            return !mChildrenExpanded;
        }
        return mExpandable;
        return mEnableNonGroupedNotificationExpand && mExpandable;
    }

    public void setExpandable(boolean expandable) {
@@ -1992,7 +2009,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    public void updateBackgroundForGroupState() {
        if (mIsSummaryWithChildren) {
            // Only when the group has finished expanding do we hide its background.
            mShowNoBackground = isGroupExpanded() && !isGroupExpansionChanging() && !isUserLocked();
            mShowNoBackground = !mShowGroupBackgroundWhenExpanded && isGroupExpanded()
                    && !isGroupExpansionChanging() && !isUserLocked();
            mChildrenContainer.updateHeaderForExpansion(mShowNoBackground);
            List<ExpandableNotificationRow> children = mChildrenContainer.getNotificationChildren();
            for (int i = 0; i < children.size(); i++) {
@@ -2001,7 +2019,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        } else if (isChildInGroup()) {
            final int childColor = getShowingLayout().getBackgroundColorForExpansionState();
            // Only show a background if the group is expanded OR if it is expanding / collapsing
            // and has a custom background color
            // and has a custom background color.
            final boolean showBackground = isGroupExpanded()
                    || ((mNotificationParent.isGroupExpansionChanging()
                    || mNotificationParent.isUserLocked()) && childColor != 0);
Loading