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

Commit 9d7381e2 authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Allow users to set app-wide Importance default"

parents 05c0cfcb a07af88b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ interface INotificationManager
    int getTopicPriority(String pkg, int uid, in Notification.Topic topic);
    void setTopicImportance(String pkg, int uid, in Notification.Topic topic, int importance);
    int getTopicImportance(String pkg, int uid, in Notification.Topic topic);
    void setAppImportance(String pkg, int uid, int importance);

    // TODO: Remove this when callers have been migrated to the equivalent
    // INotificationListener method.
+24 −32
Original line number Diff line number Diff line
@@ -24,35 +24,23 @@
        android:clickable="true"
        android:gravity="top|start"
        android:orientation="vertical"
        android:paddingEnd="8dp"
        android:paddingStart="@*android:dimen/notification_content_margin_start"
        android:paddingEnd="@*android:dimen/notification_content_margin_end"
        android:background="@color/notification_guts_text_color" >

    <!-- header -->
    <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingStart="@*android:dimen/notification_content_margin_start"
            android:paddingTop="8dp"
            android:paddingBottom="16dp" >
            android:paddingBottom="8dp" >

        <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/notification_guts_header"
                android:orientation="vertical"
                android:orientation="horizontal"
                android:layout_gravity="center_vertical|start"
                android:layout_marginEnd="52dp">

                <LinearLayout
                        android:id="@+id/notification_guts_app_details"
                        android:orientation="horizontal"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:clipChildren="false"
                        android:layout_gravity="start|top"
                        android:gravity="center_vertical"
                        >

                    <ImageView
                            android:id="@android:id/icon"
                            android:layout_width="18dp"
@@ -78,20 +66,10 @@
                            android:textColor="#ffffff" />
        </LinearLayout>

                <TextView
                        android:id="@+id/topic_details"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:textAppearance="@android:style/TextAppearance.Material.Notification.Title"
                        android:textColor="@color/notification_guts_text_color"
                        android:layout_alignParentBottom="true"
                        android:layout_alignParentStart="true" />
            </LinearLayout>

        <ImageButton style="@android:style/Widget.Material.Light.Button.Borderless.Small"
                android:id="@+id/notification_inspect_item"
                android:layout_width="52dp"
                android:layout_height="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0"
                android:gravity="center"
                android:layout_gravity="center_vertical|end"
@@ -103,7 +81,6 @@
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:paddingStart="@*android:dimen/notification_content_margin_start"
            android:orientation="vertical"
            android:clickable="false"
            android:focusable="false"
@@ -116,8 +93,7 @@
                android:textAppearance="@android:style/TextAppearance.Material.Subhead"
                android:textColor="@color/notification_guts_text_color"
                android:ellipsize="marquee"
                android:fadingEdge="horizontal"
                android:text="@*android:string/notification_importance_title"/>
                android:fadingEdge="horizontal"/>

        <TextView
                android:id="@+id/summary"
@@ -133,7 +109,7 @@
        <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingTop="6dp" >
                android:paddingTop="8dp" >

            <ImageView
                    android:id="@+id/low_importance"
@@ -162,5 +138,21 @@
                    android:layout_height="24dp"/>

        </FrameLayout>

        <RadioGroup android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingTop="8dp">
            <RadioButton android:id="@+id/apply_to_topic"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:textColor="@color/notification_guts_text_color"
                         android:visibility="gone"/>
            <RadioButton android:id="@+id/apply_to_app"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:text="@string/apply_to_app"
                         android:textColor="@color/notification_guts_text_color"
                         android:visibility="gone"/>
        </RadioGroup>
    </LinearLayout>
</com.android.systemui.statusbar.NotificationGuts>
+30 −0
Original line number Diff line number Diff line
@@ -1201,4 +1201,34 @@
    <!-- Bluetooth enablement ok text [CHAR LIMIT=40] -->
    <string name="enable_bluetooth_confirmation_ok">Turn on</string>

    <!-- Apply notification importance setting to a topic [CHAR LIMIT=NONE] -->
    <string name="apply_to_topic">Apply to <xliff:g id="topic_name" example="Friend Request">%1$s</xliff:g> notifications</string>
    <!-- Apply notification importance setting to an app [CHAR LIMIT=NONE] -->
    <string name="apply_to_app">Apply to all notifications from this app</string>
    <!-- Notification importance title, blocked status-->
    <string name="blocked_importance">Blocked</string>
    <!-- Notification importance title, low status-->
    <string name="low_importance">Low importance</string>
    <!-- Notification importance title, normal status-->
    <string name="default_importance">Normal importance</string>
    <!-- Notification importance title, high status-->
    <string name="high_importance">High importance</string>
    <!-- Notification importance title, max status-->
    <string name="max_importance">Urgent importance</string>

    <!-- [CHAR LIMIT=100] Notification Importance slider: blocked importance level description -->
    <string name="notification_importance_blocked">Never show these notifications</string>

    <!-- [CHAR LIMIT=100] Notification Importance slider: low importance level description -->
    <string name="notification_importance_low">Silently show at the bottom of the notification list</string>

    <!-- [CHAR LIMIT=100] Notification Importance slider: normal importance level description -->
    <string name="notification_importance_default">Silently show these notifications</string>

    <!-- [CHAR LIMIT=100] Notification Importance slider: high importance level description -->
    <string name="notification_importance_high">Show at the top of the notifications list and make sound</string>

    <!-- [CHAR LIMIT=100] Notification Importance slider: max importance level description -->
    <string name="notification_importance_max">Peek onto the screen and make sound</string>

</resources>
+2 −65
Original line number Diff line number Diff line
@@ -947,7 +947,7 @@ public abstract class BaseStatusBar extends SystemUI implements
        final StatusBarNotification sbn = row.getStatusBarNotification();
        PackageManager pmUser = getPackageManagerForUser(mContext, sbn.getUser().getIdentifier());
        row.setTag(sbn.getPackageName());
        final View guts = row.getGuts();
        final NotificationGuts guts = row.getGuts();
        final String pkg = sbn.getPackageName();
        String appname = pkg;
        Drawable pkgicon = null;
@@ -969,8 +969,6 @@ public abstract class BaseStatusBar extends SystemUI implements
        ((ImageView) row.findViewById(android.R.id.icon)).setImageDrawable(pkgicon);
        ((TextView) row.findViewById(R.id.pkgname)).setText(appname);

        bindTopicImportance(sbn, row);

        final View settingsButton = guts.findViewById(R.id.notification_inspect_item);
        if (appUid >= 0) {
            final int appUidF = appUid;
@@ -983,69 +981,8 @@ public abstract class BaseStatusBar extends SystemUI implements
        } else {
            settingsButton.setVisibility(View.GONE);
        }
    }

    private void bindTopicImportance(final StatusBarNotification sbn,
            ExpandableNotificationRow row) {
        final INotificationManager sINM = INotificationManager.Stub.asInterface(
                ServiceManager.getService(Context.NOTIFICATION_SERVICE));
        final Notification.Topic topic = sbn.getNotification().getTopic() == null
                ? new Notification.Topic(Notification.TOPIC_DEFAULT, mContext.getString(
                        com.android.internal.R.string.default_notification_topic_label))
                : sbn.getNotification().getTopic();

        ((TextView) row.findViewById(R.id.topic_details)).setText(topic.getLabel());
        final TextView topicSummary = ((TextView) row.findViewById(R.id.summary));
        int importance = mNotificationData.getImportance(sbn.getKey());
        SeekBar seekBar = (SeekBar) row.findViewById(R.id.seekbar);
        seekBar.setMax(4);
        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                topicSummary.setText(getProgressSummary(progress));
                if (fromUser) {
                    try {
                        sINM.setTopicImportance(sbn.getPackageName(), sbn.getUid(), topic,
                                progress);
                    } catch (RemoteException e) {
                        // :(
                    }
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                // no-op
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                // no-op
            }

            private String getProgressSummary(int progress) {
                switch (progress) {
                    case NotificationListenerService.Ranking.IMPORTANCE_NONE:
                        return mContext.getString(
                                com.android.internal.R.string.notification_importance_blocked);
                    case NotificationListenerService.Ranking.IMPORTANCE_LOW:
                        return mContext.getString(
                                com.android.internal.R.string.notification_importance_low);
                    case NotificationListenerService.Ranking.IMPORTANCE_DEFAULT:
                        return mContext.getString(
                                com.android.internal.R.string.notification_importance_default);
                    case NotificationListenerService.Ranking.IMPORTANCE_HIGH:
                        return mContext.getString(
                                com.android.internal.R.string.notification_importance_high);
                    case NotificationListenerService.Ranking.IMPORTANCE_MAX:
                        return mContext.getString(
                                com.android.internal.R.string.notification_importance_max);
                    default:
                        return "";
                }
            }
        });
        seekBar.setProgress(importance);
        guts.bindImportance(sbn, row, mNotificationData.getImportance(sbn.getKey()));
    }

    protected SwipeHelper.LongPressListener getNotificationLongClicker() {
+92 −0
Original line number Diff line number Diff line
@@ -16,12 +16,22 @@

package com.android.systemui.statusbar;

import android.app.INotificationManager;
import android.app.Notification;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.SeekBar;
import android.widget.TextView;

import com.android.systemui.R;

@@ -83,6 +93,88 @@ public class NotificationGuts extends LinearLayout {
        }
    }

    void bindImportance(final StatusBarNotification sbn, final ExpandableNotificationRow row,
            final int importance) {
        final INotificationManager sINM = INotificationManager.Stub.asInterface(
                ServiceManager.getService(Context.NOTIFICATION_SERVICE));
        final Notification.Topic topic = sbn.getNotification().getTopic() == null
                ? new Notification.Topic(Notification.TOPIC_DEFAULT, mContext.getString(
                com.android.internal.R.string.default_notification_topic_label))
                : sbn.getNotification().getTopic();

        final RadioButton applyToTopic = (RadioButton) row.findViewById(R.id.apply_to_topic);
        if (sbn.getNotification().getTopic() != null) {
            applyToTopic.setVisibility(View.VISIBLE);
            applyToTopic.setChecked(true);
            applyToTopic.setText(mContext.getString(R.string.apply_to_topic, topic.getLabel()));
            row.findViewById(R.id.apply_to_app).setVisibility(View.VISIBLE);
        }

        final TextView topicSummary = ((TextView) row.findViewById(R.id.summary));
        final TextView topicTitle = ((TextView) row.findViewById(R.id.title));
        SeekBar seekBar = (SeekBar) row.findViewById(R.id.seekbar);
        seekBar.setMax(4);
        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                updateTitleAndSummary(progress);
                if (fromUser) {
                    try {
                        if (applyToTopic.isChecked()) {
                            sINM.setTopicImportance(sbn.getPackageName(), sbn.getUid(), topic,
                                    progress);
                        } else {
                            sINM.setAppImportance(sbn.getPackageName(), sbn.getUid(), progress);
                        }
                    } catch (RemoteException e) {
                        // :(
                    }
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                // no-op
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                // no-op
            }

            private void updateTitleAndSummary(int progress) {
                switch (progress) {
                    case NotificationListenerService.Ranking.IMPORTANCE_NONE:
                        topicSummary.setText(mContext.getString(
                                R.string.notification_importance_blocked));
                        topicTitle.setText(mContext.getString(R.string.blocked_importance));
                        break;
                    case NotificationListenerService.Ranking.IMPORTANCE_LOW:
                        topicSummary.setText(mContext.getString(
                                R.string.notification_importance_low));
                        topicTitle.setText(mContext.getString(R.string.low_importance));
                        break;
                    case NotificationListenerService.Ranking.IMPORTANCE_DEFAULT:
                        topicSummary.setText(mContext.getString(
                                R.string.notification_importance_default));
                        topicTitle.setText(mContext.getString(R.string.default_importance));
                        break;
                    case NotificationListenerService.Ranking.IMPORTANCE_HIGH:
                        topicSummary.setText(mContext.getString(
                                R.string.notification_importance_high));
                        topicTitle.setText(mContext.getString(R.string.high_importance));
                        break;
                    case NotificationListenerService.Ranking.IMPORTANCE_MAX:
                        topicSummary.setText(mContext.getString(
                                R.string.notification_importance_max));
                        topicTitle.setText(mContext.getString(R.string.max_importance));
                        break;
                }
            }
        });
        seekBar.setProgress(importance);
    }

    public void setActualHeight(int actualHeight) {
        mActualHeight = actualHeight;
        invalidate();
Loading