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

Commit fc90b6a7 authored by Daniel Sandler's avatar Daniel Sandler Committed by Android (Google) Code Review
Browse files

Merge "Add text labels to intruder actions."

parents 73667fe3 b2a1c23a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -3712,6 +3712,7 @@ package android.app {
    method public android.app.Notification.Builder setDefaults(int);
    method public android.app.Notification.Builder setDeleteIntent(android.app.PendingIntent);
    method public android.app.Notification.Builder setFullScreenIntent(android.app.PendingIntent, boolean);
    method public android.app.Notification.Builder setIntruderActionsShowText(boolean);
    method public android.app.Notification.Builder setLargeIcon(android.graphics.Bitmap);
    method public android.app.Notification.Builder setLights(int, int, int);
    method public android.app.Notification.Builder setNumber(int);
@@ -3725,6 +3726,7 @@ package android.app {
    method public android.app.Notification.Builder setSound(android.net.Uri, int);
    method public android.app.Notification.Builder setTicker(java.lang.CharSequence);
    method public android.app.Notification.Builder setTicker(java.lang.CharSequence, android.widget.RemoteViews);
    method public android.app.Notification.Builder setUsesIntruderAlert(boolean);
    method public android.app.Notification.Builder setVibrate(long[]);
    method public android.app.Notification.Builder setWhen(long);
  }
+40 −3
Original line number Diff line number Diff line
@@ -918,6 +918,8 @@ public class Notification implements Parcelable
        private Bundle mExtras;
        private int mPriority;
        private ArrayList<Action> mActions = new ArrayList<Action>(3);
        private boolean mCanHasIntruder;
        private boolean mIntruderActionsShowText;

        /**
         * Constructs a new Builder with the defaults:
@@ -1313,6 +1315,38 @@ public class Notification implements Parcelable
            return this;
        }

        /**
         * Specify whether this notification should pop up as an
         * "intruder alert" (a small window that shares the screen with the
         * current activity). This sort of notification is (as the name implies)
         * very intrusive, so use it sparingly for notifications that require
         * the user's attention.
         *
         * Notes:
         * <ul>
         * <li>Intruder alerts only show when the screen is on.</li>
         * <li>Intruder alerts take precedence over fullScreenIntents.</li>
         * </ul>
         *
         * @param intrude Whether to pop up an intruder alert (default false).
         */
        public Builder setUsesIntruderAlert(boolean intrude) {
            mCanHasIntruder = intrude;
            return this;
        }

        /**
         * Control text on intruder alert action buttons. By default, action
         * buttons in intruders do not show textual labels.
         * 
         * @param showActionText Whether to show text labels beneath action
         *            icons (default false).
         */
        public Builder setIntruderActionsShowText(boolean showActionText) {
            mIntruderActionsShowText = showActionText;
            return this;
        }

        private void setFlag(int mask, boolean value) {
            if (value) {
                mFlags |= mask;
@@ -1394,7 +1428,7 @@ public class Notification implements Parcelable
            }
        }

        private RemoteViews makeIntruderView() {
        private RemoteViews makeIntruderView(boolean showLabels) {
            RemoteViews intruderView = new RemoteViews(mContext.getPackageName(),
                    R.layout.notification_intruder_content);
            if (mLargeIcon != null) {
@@ -1422,7 +1456,8 @@ public class Notification implements Parcelable
                    final int buttonId = BUTTONS[i];

                    intruderView.setViewVisibility(buttonId, View.VISIBLE);
                    intruderView.setImageViewResource(buttonId, action.icon);
                    intruderView.setTextViewText(buttonId, showLabels ? action.title : null);
                    intruderView.setTextViewCompoundDrawables(buttonId, 0, action.icon, 0, 0);
                    intruderView.setContentDescription(buttonId, action.title);
                    intruderView.setOnClickPendingIntent(buttonId, action.actionIntent);
                }
@@ -1457,7 +1492,9 @@ public class Notification implements Parcelable
            n.ledOffMS = mLedOffMs;
            n.defaults = mDefaults;
            n.flags = mFlags;
            n.intruderView = makeIntruderView();
            if (mCanHasIntruder) {
                n.intruderView = makeIntruderView(mIntruderActionsShowText);
            }
            if (mLedOnMs != 0 && mLedOffMs != 0) {
                n.flags |= FLAG_SHOW_LIGHTS;
            }
+13 −8
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="#FF333333"
    android:padding="4dp"
    >
    <ImageView android:id="@+id/icon"
@@ -39,29 +38,35 @@
    <LinearLayout
        android:id="@+id/actions"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="48dp"
        android:orientation="horizontal"
        android:visibility="gone"
        >
        <ImageView
        <Button
            style="?android:attr/buttonBarButtonStyle"
            android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title"
            android:id="@+id/action0"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:visibility="gone"
            />
        <ImageView
        <Button
            style="?android:attr/buttonBarButtonStyle"
            android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title"
            android:id="@+id/action1"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:visibility="gone"
            />
        <ImageView
        <Button
            style="?android:attr/buttonBarButtonStyle"
            android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title"
            android:id="@+id/action2"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:visibility="gone"
            />