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

Commit d9e18369 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Fully custom view notifications now receive minimal decoration when targeting S.

* The level of decoration for fully custom notifications can be customized with FULLY_CUSTOM_VIEW_NOTIF_DECORATION
* The level of decoration for decorated notifications can be customized with DECORATED_CUSTOM_VIEW_NOTIF_DECORATION
* Adds some helpful logic when "backporting" S logic so that we can see what UNDO notifications will really look like.

Note: this patch now includes code that used to be in separate reviews: I700472b9c8fba2563b447f570cab7dd60a0a3984 and I55e12843a3edc6e9a78e5b8c848400a8f9228d1c

Test: Manual
Bug: 173522761
Change-Id: I7aba1aec2ba3023857735754c000977c4491b774
parent 86cb4910
Loading
Loading
Loading
Loading
+313 −61

File changed.

Preview size limit exceeded, changes collapsed.

+28 −0
Original line number Diff line number Diff line
@@ -14629,6 +14629,34 @@ public final class Settings {
         */
        public static final String BACKPORT_S_NOTIF_RULES = "backport_s_notif_rules";
        /**
         * The decoration to put on fully custom views that target S.
         *
         * <p>Values are:
         * <br>0: DECORATION_NONE: no decorations.
         * <br>1: DECORATION_MINIMAL: most minimal template; just the icon and the expander.
         * <br>2: DECORATION_PARTIAL: basic template without the top line.
         * <br>3: DECORATION_FULL_COMPATIBLE: basic template with the top line; 40dp of height.
         * <br>4: DECORATION_FULL_CONSTRAINED: basic template with the top line;  28dp of height.
         * <p>See {@link android.app.Notification.DevFlags} for more details.
         * @hide
         */
        public static final String FULLY_CUSTOM_VIEW_NOTIF_DECORATION =
                "fully_custom_view_notif_decoration";
        /**
         * The decoration to put on decorated custom views that target S.
         *
         * <p>Values are:
         * <br>2: DECORATION_PARTIAL: basic template without the top line.
         * <br>3: DECORATION_FULL_COMPATIBLE: basic template with the top line; 40dp of height.
         * <br>4: DECORATION_FULL_CONSTRAINED: basic template with the top line;  28dp of height.
         * <p>See {@link android.app.Notification.DevFlags} for more details.
         * @hide
         */
        public static final String DECORATED_CUSTOM_VIEW_NOTIF_DECORATION =
                "decorated_custom_view_notif_decoration";
        /**
         * Block untrusted touches mode.
         *
+82 −67
Original line number Diff line number Diff line
@@ -45,6 +45,45 @@
        android:padding="@dimen/notification_icon_circle_padding"
        />

    <ImageView
        android:id="@+id/right_icon"
        android:layout_width="@dimen/notification_right_icon_size"
        android:layout_height="@dimen/notification_right_icon_size"
        android:layout_gravity="center_vertical|end"
        android:layout_marginTop="@dimen/notification_right_icon_headerless_margin"
        android:layout_marginBottom="@dimen/notification_right_icon_headerless_margin"
        android:layout_marginEnd="@dimen/notification_header_expand_icon_size"
        android:background="@drawable/notification_large_icon_outline"
        android:importantForAccessibility="no"
        android:scaleType="centerCrop"
        />

    <FrameLayout
        android:id="@+id/alternate_expand_target"
        android:layout_width="@dimen/notification_content_margin_start"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:importantForAccessibility="no"
        />

    <FrameLayout
        android:id="@+id/expand_button_touch_container"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="end">

        <com.android.internal.widget.NotificationExpandButton
            android:id="@+id/expand_button"
            android:layout_width="@dimen/notification_header_expand_icon_size"
            android:layout_height="@dimen/notification_header_expand_icon_size"
            android:layout_gravity="center_vertical|end"
            android:contentDescription="@string/expand_button_content_description_collapsed"
            android:paddingTop="@dimen/notification_expand_button_padding_top"
            android:scaleType="center"
            />

    </FrameLayout>

    <LinearLayout
        android:id="@+id/notification_headerless_view_column"
        android:layout_width="match_parent"
@@ -64,11 +103,23 @@
        variant is 56dp and the 2- and 3-line variants are both 76dp.
        -->
        <FrameLayout
            android:id="@+id/notification_headerless_margin_extra_top"
            android:layout_width="match_parent"
            android:layout_height="@dimen/notification_headerless_margin_extra"
            android:layout_weight="1"
            />

        <!--
        Because RemoteViews doesn't allow us to remove specific views, this container allows us
        to remove the NotificationTopLineView without removing other padding items.
        -->
        <FrameLayout
            android:id="@+id/notification_top_line_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clipChildren="false"
            >

            <!-- extends ViewGroup -->
            <NotificationTopLineView
                android:id="@+id/notification_top_line"
@@ -102,6 +153,8 @@

            </NotificationTopLineView>

        </FrameLayout>

        <LinearLayout
            android:id="@+id/notification_main_column"
            android:layout_width="match_parent"
@@ -135,6 +188,7 @@
        variant is 56dp and the 2- and 3-line variants are both 76dp.
        -->
        <FrameLayout
            android:id="@+id/notification_headerless_margin_extra_bottom"
            android:layout_width="match_parent"
            android:layout_height="@dimen/notification_headerless_margin_extra"
            android:layout_weight="1"
@@ -142,43 +196,4 @@

    </LinearLayout>

    <ImageView
        android:id="@+id/right_icon"
        android:layout_width="@dimen/notification_right_icon_size"
        android:layout_height="@dimen/notification_right_icon_size"
        android:layout_gravity="center_vertical|end"
        android:layout_marginTop="@dimen/notification_right_icon_headerless_margin"
        android:layout_marginBottom="@dimen/notification_right_icon_headerless_margin"
        android:layout_marginEnd="@dimen/notification_header_expand_icon_size"
        android:background="@drawable/notification_large_icon_outline"
        android:importantForAccessibility="no"
        android:scaleType="centerCrop"
        />

    <FrameLayout
        android:id="@+id/alternate_expand_target"
        android:layout_width="@dimen/notification_content_margin_start"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:importantForAccessibility="no"
        />

    <FrameLayout
        android:id="@+id/expand_button_touch_container"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="end">

        <com.android.internal.widget.NotificationExpandButton
            android:id="@+id/expand_button"
            android:layout_width="@dimen/notification_header_expand_icon_size"
            android:layout_height="@dimen/notification_header_expand_icon_size"
            android:layout_gravity="center_vertical|end"
            android:contentDescription="@string/expand_button_content_description_collapsed"
            android:paddingTop="@dimen/notification_expand_button_padding_top"
            android:scaleType="center"
            />

    </FrameLayout>

</com.android.internal.widget.NotificationMaxHeightFrameLayout>
+8 −2
Original line number Diff line number Diff line
@@ -301,12 +301,18 @@
    <!-- The top padding for the notification expand button. -->
    <dimen name="notification_expand_button_padding_top">1dp</dimen>

    <!-- minimum vertical margin for the headerless notification content -->
    <!-- minimum vertical margin for the headerless notification content, when cap = 60dp -->
    <dimen name="notification_headerless_margin_minimum">8dp</dimen>

    <!-- extra vertical margin for the headerless notification content -->
    <!-- extra vertical margin for the headerless notification content, when cap = 60dp -->
    <dimen name="notification_headerless_margin_extra">10dp</dimen>

    <!-- minimum vertical margin for the headerless notification content, when cap = 48dp -->
    <dimen name="notification_headerless_margin_constrained_minimum">14dp</dimen>

    <!-- extra vertical margin for the headerless notification content, when cap = 48dp -->
    <dimen name="notification_headerless_margin_constrained_extra">4dp</dimen>

    <!-- The height of each of the 1 or 2 lines in the headerless notification template -->
    <dimen name="notification_headerless_line_height">20sp</dimen>

+5 −0
Original line number Diff line number Diff line
@@ -2876,6 +2876,9 @@
  <java-symbol type="id" name="alternate_expand_target" />
  <java-symbol type="id" name="notification_header" />
  <java-symbol type="id" name="notification_top_line" />
  <java-symbol type="id" name="notification_top_line_container" />
  <java-symbol type="id" name="notification_headerless_margin_extra_top" />
  <java-symbol type="id" name="notification_headerless_margin_extra_bottom" />
  <java-symbol type="id" name="time_divider" />
  <java-symbol type="id" name="header_text_divider" />
  <java-symbol type="id" name="header_text_secondary_divider" />
@@ -2897,6 +2900,8 @@
  <java-symbol type="dimen" name="notification_header_icon_size" />
  <java-symbol type="dimen" name="notification_header_app_name_margin_start" />
  <java-symbol type="dimen" name="notification_header_separating_margin" />
  <java-symbol type="dimen" name="notification_headerless_margin_constrained_minimum" />
  <java-symbol type="dimen" name="notification_headerless_margin_constrained_extra" />
  <java-symbol type="string" name="default_notification_channel_label" />
  <java-symbol type="string" name="importance_from_user" />
  <java-symbol type="string" name="importance_from_person" />
Loading