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

Commit 53162c13 authored by Mady Mellor's avatar Mady Mellor
Browse files

Add Bubble as an option in NotificationInfo longpress menu

- If the content is able to bubble, the bubble option will show in
  the menu
- If that notif is able to bubble (either via bubble metadata or via
  notification contents), then show the menu
- Adds tests for the bubble menu option, also tests selection for alert
  and silence buttons; removes unused test code

Test: atest NotificationInfoTest NotificationGutsManagerTest
Test: manual - post a bubble with bubbles test app, longpress on notif
               and demote it via menu => bubble is gone
             - long press on notif and promote it via menu => bubble is
               created
Bug: 138116133
Bug: 143173197
Change-Id: I2f2767ec12c49e5d3a8d2a7b86db5457d062275c
parent ec3c03ea
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -3203,6 +3203,14 @@ public class Notification implements Parcelable
        return mBubbleMetadata;
    }

    /**
     * Sets the {@link BubbleMetadata} for this notification.
     * @hide
     */
    public void setBubbleMetadata(BubbleMetadata data) {
        mBubbleMetadata = data;
    }

    /**
     * Returns whether the platform is allowed (by the app developer) to generate contextual actions
     * for this notification.
+29 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (C) 2019 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.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24"
        android:viewportHeight="24">
    <path
        android:pathData="M12,3c-4.97,0 -9,4.03 -9,9c0,1.39 0.32,2.69 0.88,3.86l1.53,-1.53C5.15,13.6 5,12.82 5,12c0,-3.86 3.14,-7 7,-7s7,3.14 7,7s-3.14,7 -7,7c-0.83,0 -1.62,-0.15 -2.35,-0.42l-1.53,1.53C9.3,20.67 10.61,21 12,21c4.97,0 9,-4.03 9,-9C21,7.03 16.97,3 12,3z"
        android:fillColor="#000000"/>
    <path
        android:pathData="M12.99,15.99l2,0l0,-7l-7,0l0,2l3.59,0l-8.79,8.8l1.41,1.41l8.79,-8.79z"
        android:fillColor="#000000"/>
</vector>
+52 −0
Original line number Diff line number Diff line
@@ -219,6 +219,58 @@ asked for it -->
            android:gravity="center"
            android:orientation="vertical">

            <com.android.systemui.statusbar.notification.row.ButtonLinearLayout
                android:id="@+id/bubble"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="@dimen/notification_importance_button_padding"
                android:layout_marginBottom="@dimen/notification_importance_button_separation"
                android:clickable="true"
                android:focusable="true"
                android:background="@drawable/notification_guts_priority_button_bg"
                android:orientation="vertical">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:gravity="center"
                >
                    <ImageView
                        android:id="@+id/bubble_icon"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_create_bubble"
                        android:background="@android:color/transparent"
                        android:tint="@color/notification_guts_priority_contents"
                        android:clickable="false"
                        android:focusable="false"/>
                    <TextView
                        android:id="@+id/bubble_label"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="@dimen/notification_importance_drawable_padding"
                        android:layout_weight="1"
                        android:ellipsize="end"
                        android:maxLines="1"
                        android:clickable="false"
                        android:focusable="false"
                        android:textAppearance="@style/TextAppearance.NotificationImportanceButton"
                        android:text="@string/notification_bubble_title"/>
                </LinearLayout>
                <TextView
                    android:id="@+id/bubble_summary"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/notification_importance_button_description_top_margin"
                    android:visibility="gone"
                    android:text="@string/notification_channel_summary_bubble"
                    android:clickable="false"
                    android:focusable="false"
                    android:ellipsize="end"
                    android:maxLines="2"
                    android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"/>
            </com.android.systemui.statusbar.notification.row.ButtonLinearLayout>

            <com.android.systemui.statusbar.notification.row.ButtonLinearLayout
                android:id="@+id/alert"
                android:layout_width="match_parent"
+6 −0
Original line number Diff line number Diff line
@@ -1717,12 +1717,18 @@
    <!-- [CHAR LIMIT=100] Notification Importance title -->
    <string name="notification_alert_title">Alerting</string>

    <!-- [CHAR LIMIT=100] Notification Importance title -->
    <string name="notification_bubble_title">Bubble</string>

    <!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary -->
    <string name="notification_channel_summary_low">Helps you focus without sound or vibration.</string>

    <!-- [CHAR LIMIT=150] Notification Importance title: normal importance level summary -->
    <string name="notification_channel_summary_default">Gets your attention with sound or vibration.</string>

    <!-- [CHAR LIMIT=150] Notification Importance title: bubble level summary -->
    <string name="notification_channel_summary_bubble">Keeps your attention with a floating shortcut to this content.</string>

    <!-- Notification: Control panel: Label that displays when the app's notifications cannot be blocked. -->
    <string name="notification_unblockable_desc">These notifications can\'t be modified.</string>

+1 −1
Original line number Diff line number Diff line
@@ -319,7 +319,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx
                packageName,
                row.getEntry().getChannel(),
                row.getUniqueChannels(),
                sbn,
                row.getEntry(),
                mCheckSaveListener,
                onSettingsClick,
                onAppSettingsClick,
Loading