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

Commit f1f26c2c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Plugin interface for PeopleHub"

parents ff53253c 984cfec7
Loading
Loading
Loading
Loading
+72 −0
Original line number Diff line number Diff line
/*
 * 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.
 */

package com.android.systemui.plugins;

import android.annotation.Nullable;
import android.app.PendingIntent;
import android.graphics.drawable.Drawable;
import android.service.notification.StatusBarNotification;

import com.android.systemui.plugins.annotations.DependsOn;
import com.android.systemui.plugins.annotations.ProvidesInterface;

/** Custom logic that can extract a PeopleHub "person" from a notification. */
@ProvidesInterface(
        action = NotificationPersonExtractorPlugin.ACTION,
        version = NotificationPersonExtractorPlugin.VERSION)
@DependsOn(target = NotificationPersonExtractorPlugin.PersonData.class)
public interface NotificationPersonExtractorPlugin extends Plugin {

    String ACTION = "com.android.systemui.action.PEOPLE_HUB_PERSON_EXTRACTOR";
    int VERSION = 0;

    /**
     * Attempts to extract a person from a notification. Returns {@code null} if one is not found.
     */
    @Nullable PersonData extractPerson(StatusBarNotification sbn);

    /**
     * Attempts to extract a person id from a notification. Returns {@code null} if one is not
     * found.
     *
     * This method can be overridden in order to provide a faster implementation.
     */
    @Nullable
    default String extractPersonKey(StatusBarNotification sbn) {
        return extractPerson(sbn).key;
    }

    /** A person to be surfaced in PeopleHub. */
    @ProvidesInterface(version = PersonData.VERSION)
    final class PersonData {

        public static final int VERSION = 0;

        public final String key;
        public final CharSequence name;
        public final Drawable avatar;
        public final PendingIntent clickIntent;

        public PersonData(String key, CharSequence name, Drawable avatar,
                PendingIntent clickIntent) {
            this.key = key;
            this.name = name;
            this.avatar = avatar;
            this.clickIntent = clickIntent;
        }
    }
}
+8 −9
Original line number Diff line number Diff line
@@ -33,10 +33,9 @@
    <LinearLayout
        android:id="@+id/people_list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:paddingTop="8dp"
        android:paddingBottom="8dp"
        android:layout_height="match_parent"
        android:paddingTop="12dp"
        android:paddingBottom="12dp"
        android:gravity="center"
        android:orientation="horizontal">

@@ -49,7 +48,7 @@
        <LinearLayout
            android:layout_width="70dp"
            android:layout_height="match_parent"
            android:gravity="center"
            android:gravity="center_horizontal"
            android:orientation="vertical"
            android:visibility="invisible">

@@ -87,7 +86,7 @@
        <LinearLayout
            android:layout_width="70dp"
            android:layout_height="match_parent"
            android:gravity="center"
            android:gravity="center_horizontal"
            android:orientation="vertical"
            android:visibility="invisible">

@@ -125,7 +124,7 @@
        <LinearLayout
            android:layout_width="70dp"
            android:layout_height="match_parent"
            android:gravity="center"
            android:gravity="center_horizontal"
            android:orientation="vertical"
            android:visibility="invisible">

@@ -163,7 +162,7 @@
        <LinearLayout
            android:layout_width="70dp"
            android:layout_height="match_parent"
            android:gravity="center"
            android:gravity="center_horizontal"
            android:orientation="vertical"
            android:visibility="invisible">

@@ -201,7 +200,7 @@
        <LinearLayout
            android:layout_width="70dp"
            android:layout_height="match_parent"
            android:gravity="center"
            android:gravity="center_horizontal"
            android:orientation="vertical"
            android:visibility="invisible">

+8 −0
Original line number Diff line number Diff line
@@ -138,6 +138,14 @@ public class NotificationEntryManager implements
        mNotificationEntryListeners.add(listener);
    }

    /**
     * Removes a {@link NotificationEntryListener} previously registered via
     * {@link #addNotificationEntryListener(NotificationEntryListener)}.
     */
    public void removeNotificationEntryListener(NotificationEntryListener listener) {
        mNotificationEntryListeners.remove(listener);
    }

    /** Sets the {@link NotificationRemoveInterceptor}. */
    public void setNotificationRemoveInterceptor(NotificationRemoveInterceptor interceptor) {
        mRemoveInterceptor = interceptor;
+8 −4
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import com.android.systemui.statusbar.notification.NotificationFilter;
import com.android.systemui.statusbar.notification.NotificationSectionsFeatureManager;
import com.android.systemui.statusbar.notification.logging.NotifEvent;
import com.android.systemui.statusbar.notification.logging.NotifLog;
import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.policy.HeadsUpManager;

@@ -76,12 +77,16 @@ public class NotificationData {
    private final Ranking mTmpRanking = new Ranking();
    private final boolean mUsePeopleFiltering;
    private final NotifLog mNotifLog;
    private final PeopleNotificationIdentifier mPeopleNotificationIdentifier;

    @Inject
    public NotificationData(NotificationSectionsFeatureManager sectionsFeatureManager,
            NotifLog notifLog) {
    public NotificationData(
            NotificationSectionsFeatureManager sectionsFeatureManager,
            NotifLog notifLog,
            PeopleNotificationIdentifier peopleNotificationIdentifier) {
        mUsePeopleFiltering = sectionsFeatureManager.isFilteringEnabled();
        mNotifLog = notifLog;
        mPeopleNotificationIdentifier = peopleNotificationIdentifier;
    }

    public void setHeadsUpManager(HeadsUpManager headsUpManager) {
@@ -460,8 +465,7 @@ public class NotificationData {
    }

    private boolean isPeopleNotification(NotificationEntry e) {
        return e.getSbn().getNotification().getNotificationStyle()
                == Notification.MessagingStyle.class;
        return mPeopleNotificationIdentifier.isPeopleNotification(e.getSbn());
    }

    public void dump(PrintWriter pw, String indent) {
+13 −3
Original line number Diff line number Diff line
@@ -24,14 +24,24 @@ abstract class PeopleHubModule {

    @Binds
    abstract fun peopleHubSectionFooterViewController(
        viewAdapter: PeopleHubSectionFooterViewAdapterImpl
        impl: PeopleHubSectionFooterViewAdapterImpl
    ): PeopleHubSectionFooterViewAdapter

    @Binds
    abstract fun peopleHubDataSource(s: PeopleHubDataSourceImpl): DataSource<PeopleHubModel>
    abstract fun peopleHubDataSource(impl: PeopleHubDataSourceImpl): DataSource<PeopleHubModel>

    @Binds
    abstract fun peopleHubViewModelFactoryDataSource(
        dataSource: PeopleHubViewModelFactoryDataSourceImpl
        impl: PeopleHubViewModelFactoryDataSourceImpl
    ): DataSource<PeopleHubViewModelFactory>

    @Binds
    abstract fun peopleNotificationIdentifier(
        impl: PeopleNotificationIdentifierImpl
    ): PeopleNotificationIdentifier

    @Binds
    abstract fun notificationPersonExtractor(
        pluginImpl: NotificationPersonExtractorPluginBoundary
    ): NotificationPersonExtractor
}
 No newline at end of file
Loading