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

Commit 04373664 authored by Evan Laird's avatar Evan Laird
Browse files

Allow the visual dismissal of foreground service notifs

This CL adds support for a new feature flag
(notifications_allow_fgs_dismissal) that enables a user to visually
dismiss a notificationg that represents FLAG_ONGOING_EVENT or
FLAG_FOREGROUND_SERVICE into a new bottom section of the shade. Tapping
on the list items in the new section reinstantiates them back to the
shade.

In this CL:
- the new device_config flag + feature controller for it
- ForegroundServiceSectionController that can track dismissed FGS
notifications and then show them in its own decor view
- ForegroundServiceDungeonView that is optionally added at the bottom of
the shade
- Changes to the logic for NotificationEntry#isClearable to take into
account the new flag

Todo:
- Minify the dungeon view before first tap
- pin the dungeon view to the bottom of the notification shade

Test: atest SystemUITests
Test: adb shell device_config put systemui notifications_use_people_filtering false && adb shell kill $(pid com.android.systemui)
Bug: 136562823
Change-Id: I8359e8c3ad9de89cd867f5ac147d62e22b9cf816
parent be15e3e2
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -253,6 +253,13 @@ public final class SystemUiDeviceConfigFlags {
    public static final String NOTIFICATIONS_USE_PEOPLE_FILTERING =
            "notifications_use_people_filtering";

    /**
     * (boolean) Whether or not to enable user dismissing of foreground service notifications
     * into a new section at the bottom of the notification shade.
     */
    public static final String NOTIFICATIONS_ALLOW_FGS_DISMISSAL =
            "notifications_allow_fgs_dismissal";

    // Flags related to brightline falsing

    /**
+25 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2020 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.
  -->
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:angle="90"
        android:startColor="#ff000000"
        android:endColor="#00000000"
        android:type="linear" />
</shape>
+61 −0
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2020 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.
  -->

<com.android.systemui.statusbar.notification.row.ForegroundServiceDungeonView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/foreground_service_dungeon"
    android:layout_width="@dimen/qs_panel_width"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal|bottom"
    android:visibility="visible"
>
    <LinearLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:gravity="bottom"
        android:visibility="visible"
        android:background="@drawable/notif_dungeon_bg_gradient"
    >

        <!-- divider view -->
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/GM2_grey_200"
            android:visibility="visible"
        />

        <TextView
            android:id="@+id/dungeon_title"
            android:layout_height="48dp"
            android:layout_width="match_parent"
            android:padding="8dp"
            android:text="Apps active in background"
            android:textColor="@color/GM2_grey_200"
        />

        <!--  List containing the actual foreground service notifications  -->
        <LinearLayout
            android:id="@+id/entry_list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="bottom"
            android:orientation="vertical" >
        </LinearLayout>

    </LinearLayout>
</com.android.systemui.statusbar.notification.row.ForegroundServiceDungeonView>
+43 −0
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2020 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.
  -->

<com.android.systemui.statusbar.notification.row.DungeonRow
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/foreground_service_dungeon_row"
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:padding="8dp"
    android:clickable="true"
    android:orientation="horizontal" >

    <com.android.systemui.statusbar.StatusBarIconView
        android:id="@+id/icon"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:padding="4dp" />

    <TextView
        android:id="@+id/app_name"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:paddingStart="4dp"
        android:gravity="center_vertical"
        android:layout_gravity="center_vertical"
        android:textColor="@color/GM2_grey_200"
    />

</com.android.systemui.statusbar.notification.row.DungeonRow>
+3 −4
Original line number Diff line number Diff line
@@ -429,12 +429,11 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
                    }
                });

        mNotificationEntryManager.setNotificationRemoveInterceptor(
        mNotificationEntryManager.addNotificationRemoveInterceptor(
                new NotificationRemoveInterceptor() {
                    @Override
                    public boolean onNotificationRemoveRequested(String key, int reason) {
                        NotificationEntry entry =
                                mNotificationEntryManager.getActiveNotificationUnfiltered(key);
                    public boolean onNotificationRemoveRequested(
                            String key, NotificationEntry entry, int reason) {
                        return shouldInterceptDismissal(entry, reason);
                    }
                });
Loading