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

Commit 1baa70a0 authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz Committed by Android (Google) Code Review
Browse files

Merge "[Minimal HUN] - Apply Minimal HUN to Standard Notifications" into main

parents 16f8e169 c7669e8c
Loading
Loading
Loading
Loading
+65 −0
Original line number Diff line number Diff line
@@ -5709,6 +5709,7 @@ public class Notification implements Parcelable
                TemplateBindResult result) {
            p.headerless(resId == getBaseLayoutResource()
                    || resId == getHeadsUpBaseLayoutResource()
                    || resId == getCompactHeadsUpBaseLayoutResource()
                    || resId == getMessagingLayoutResource()
                    || resId == R.layout.notification_template_material_media);
            RemoteViews contentView = new BuilderRemoteViews(mContext.getApplicationInfo(), resId);
@@ -6593,6 +6594,36 @@ public class Notification implements Parcelable
                    null /* result */);
        }
        /**
         * Construct a RemoteViews for the final compact heads-up notification layout.
         * @hide
         */
        public RemoteViews createCompactHeadsUpContentView() {
            // TODO(b/336225281): re-evaluate custom view usage.
            if (useExistingRemoteView(mN.headsUpContentView)) {
                return fullyCustomViewRequiresDecoration(false /* fromStyle */)
                        ? minimallyDecoratedHeadsUpContentView(mN.headsUpContentView)
                        : mN.headsUpContentView;
            } else if (mStyle != null) {
                final RemoteViews styleView = mStyle.makeCompactHeadsUpContentView();
                if (styleView != null) {
                    return styleView;
                }
            }
            final StandardTemplateParams p = mParams.reset()
                    .viewType(StandardTemplateParams.VIEW_TYPE_HEADS_UP)
                    .fillTextsFrom(this);
            // Notification text is shown as secondary header text
            // for the minimal hun when it is provided.
            // Time(when and chronometer) is not shown for the minimal hun.
            p.headerTextSecondary(p.mText).text(null).hideTime(true);
            return applyStandardTemplate(
                    getCompactHeadsUpBaseLayoutResource(), p,
                    null /* result */);
        }
        /**
         * Construct a RemoteViews representing the heads up notification layout.
         *
@@ -7269,6 +7300,10 @@ public class Notification implements Parcelable
            return R.layout.notification_template_material_heads_up_base;
        }
        private int getCompactHeadsUpBaseLayoutResource() {
            return R.layout.notification_template_material_compact_heads_up_base;
        }
        private int getBigBaseLayoutResource() {
            return R.layout.notification_template_material_big_base;
        }
@@ -7794,6 +7829,16 @@ public class Notification implements Parcelable
            return null;
        }
        /**
         * Construct a Style-specific RemoteViews for the final compact HUN layout.
         * return null to use the standard compact heads up view.
         * @hide
         */
        @Nullable
        public RemoteViews makeCompactHeadsUpContentView() {
            return null;
        }
        /**
         * Apply any style-specific extras to this notification before shipping it out.
         * @hide
@@ -9103,6 +9148,16 @@ public class Notification implements Parcelable
            return makeMessagingView(StandardTemplateParams.VIEW_TYPE_HEADS_UP);
        }
        /**
         * @hide
         */
        @Nullable
        @Override
        public RemoteViews makeCompactHeadsUpContentView() {
            // TODO(b/336229954): Apply minimal HUN treatment to Messaging Notifications.
            return makeHeadsUpContentView(false);
        }
        /**
         * @hide
         */
@@ -10272,6 +10327,16 @@ public class Notification implements Parcelable
            return makeCallLayout(StandardTemplateParams.VIEW_TYPE_HEADS_UP);
        }
        /**
         * @hide
         */
        @Nullable
        @Override
        public RemoteViews makeCompactHeadsUpContentView() {
            // TODO(b/336228700): Apply minimal HUN treatment for Call Style.
            return makeHeadsUpContentView(false);
        }
        /**
         * @hide
         */
+8 −1
Original line number Diff line number Diff line
@@ -139,3 +139,10 @@ flag {
  description: "Cleans up spans and unnecessary new lines from standard notification templates"
  bug: "313439845"
}

flag {
  name: "compact_heads_up_notification"
  namespace: "systemui"
  description: "[Minimal HUN] Enables the compact heads up notification feature"
  bug: "270709257"
}
+87 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2024 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
  -->
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/status_bar_latest_event_content"
    android:layout_width="match_parent"
    android:layout_height="@dimen/notification_header_height"
    android:clipChildren="false"
    android:tag="compactHUN"
    android:gravity="center_vertical"
    android:theme="@style/Theme.DeviceDefault.Notification"
    android:importantForAccessibility="no">
    <com.android.internal.widget.CachingIconView
        android:id="@+id/icon"
        android:layout_width="@dimen/notification_icon_circle_size"
        android:layout_height="@dimen/notification_icon_circle_size"
        android:layout_gravity="center_vertical|start"
        android:layout_marginStart="@dimen/notification_icon_circle_start"
        android:background="@drawable/notification_icon_circle"
        android:padding="@dimen/notification_icon_circle_padding"
        android:maxDrawableWidth="@dimen/notification_icon_circle_size"
        android:maxDrawableHeight="@dimen/notification_icon_circle_size"
        />
    <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"
        android:focusable="false"
        />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginStart="@dimen/notification_content_margin_start"
        android:orientation="horizontal"
        >
        <NotificationTopLineView
            android:id="@+id/notification_top_line"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_centerVertical="true"
            android:layout_weight="1"
            android:clipChildren="false"
            android:gravity="center_vertical"
            android:theme="@style/Theme.DeviceDefault.Notification"
            >
            <TextView
                android:id="@+id/title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="@dimen/notification_header_separating_margin"
                android:ellipsize="end"
                android:fadingEdge="horizontal"
                android:singleLine="true"
                android:textAlignment="viewStart"
                android:textAppearance="@style/TextAppearance.DeviceDefault.Notification.Title"
                />
            <include layout="@layout/notification_top_line_views" />
        </NotificationTopLineView>
        <FrameLayout
            android:id="@+id/expand_button_touch_container"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:minWidth="@dimen/notification_content_margin_end"
            >
            <include layout="@layout/notification_expand_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical|end"
                />
        </FrameLayout>
    </LinearLayout>
</FrameLayout>
+1 −0
Original line number Diff line number Diff line
@@ -2338,6 +2338,7 @@
  <java-symbol type="layout" name="notification_material_action_tombstone" />
  <java-symbol type="layout" name="notification_template_material_base" />
  <java-symbol type="layout" name="notification_template_material_heads_up_base" />
  <java-symbol type="layout" name="notification_template_material_compact_heads_up_base" />
  <java-symbol type="layout" name="notification_template_material_big_base" />
  <java-symbol type="layout" name="notification_template_material_big_picture" />
  <java-symbol type="layout" name="notification_template_material_inbox" />
+37 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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
 */

package com.android.systemui.statusbar.notification.row

import android.app.Flags
import javax.inject.Inject

/**
 * A class managing the heads up style to be applied based on user settings, immersive mode and
 * other factors.
 */
interface HeadsUpStyleProvider {
    fun shouldApplyCompactStyle(): Boolean
}

class HeadsUpStyleProviderImpl @Inject constructor() : HeadsUpStyleProvider {

    /**
     * TODO(b/270709257) This feature is under development. This method returns Compact when the
     *   flag is enabled for fish fooding purpose.
     */
    override fun shouldApplyCompactStyle(): Boolean = Flags.compactHeadsUpNotification()
}
Loading