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

Commit 6743c0bd authored by Selim Cinek's avatar Selim Cinek
Browse files

Started visual hierarchy for min priority notifications

Min priority notifications are now greyed out and in an
even smaller form-factor then before.

Test: add low-priority notifications - observe visuals
Bug: 34469375
Change-Id: I3ce2cbf22dbc3276ac738224a16c1b10165964f3
parent ec30d6e1
Loading
Loading
Loading
Loading
+61 −2
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.text.BidiFormatter;
import android.text.SpannableStringBuilder;
@@ -2407,6 +2408,9 @@ public class Notification implements Parcelable

        private static final int MAX_ACTION_BUTTONS = 3;

        private static final boolean USE_ONLY_TITLE_IN_LOW_PRIORITY_SUMMARY =
                SystemProperties.getBoolean("notifications.only_title", true);

        private Context mContext;
        private Notification mN;
        private Bundle mUserExtras = new Bundle();
@@ -3731,7 +3735,7 @@ public class Notification implements Parcelable
            } else if (mActions.size() != 0) {
                result = applyStandardTemplateWithActions(getBigBaseLayoutResource());
            }
            adaptNotificationHeaderForBigContentView(result);
            makeHeaderExpanded(result);
            return result;
        }

@@ -3766,7 +3770,12 @@ public class Notification implements Parcelable
            }
        }

        private void adaptNotificationHeaderForBigContentView(RemoteViews result) {
        /**
         * Adapt the Notification header if this view is used as an expanded view.
         *
         * @hide
         */
        public static void makeHeaderExpanded(RemoteViews result) {
            if (result != null) {
                result.setBoolean(R.id.notification_header, "setExpanded", true);
            }
@@ -3826,7 +3835,57 @@ public class Notification implements Parcelable
            return publicView;
        }

        /**
         * Construct a content view for the display when low - priority
         *
         * @param useRegularSubtext uses the normal subtext set if there is one available. Otherwise
         *                          a new subtext is created consisting of the content of the
         *                          notification.
         * @hide
         */
        public RemoteViews makeLowPriorityContentView(boolean useRegularSubtext) {
            int color = mN.color;
            mN.color = COLOR_DEFAULT;
            CharSequence summary = mN.extras.getCharSequence(EXTRA_SUB_TEXT);
            if (!useRegularSubtext || TextUtils.isEmpty(summary)) {
                CharSequence newSummary = createSummaryText();
                if (!TextUtils.isEmpty(newSummary)) {
                    mN.extras.putCharSequence(EXTRA_SUB_TEXT, newSummary);
                }
            }
            RemoteViews header = makeNotificationHeader();
            if (summary != null) {
                mN.extras.putCharSequence(EXTRA_SUB_TEXT, summary);
            } else {
                mN.extras.remove(EXTRA_SUB_TEXT);
            }
            mN.color = color;
            return header;
        }

        private CharSequence createSummaryText() {
            CharSequence titleText = mN.extras.getCharSequence(Notification.EXTRA_TITLE);
            if (USE_ONLY_TITLE_IN_LOW_PRIORITY_SUMMARY) {
                return titleText;
            }
            SpannableStringBuilder summary = new SpannableStringBuilder();
            if (titleText == null) {
                titleText = mN.extras.getCharSequence(Notification.EXTRA_TITLE_BIG);
            }
            BidiFormatter bidi = BidiFormatter.getInstance();
            if (titleText != null) {
                summary.append(bidi.unicodeWrap(titleText));
            }
            CharSequence contentText = mN.extras.getCharSequence(Notification.EXTRA_TEXT);
            if (titleText != null && contentText != null) {
                summary.append(bidi.unicodeWrap(mContext.getText(
                        R.string.notification_header_divider_symbol_with_spaces)));
            }
            if (contentText != null) {
                summary.append(bidi.unicodeWrap(contentText));
            }
            return summary;
        }

        private RemoteViews generateActionButton(Action action, boolean emphazisedMode,
                boolean oddAction, boolean ambient) {
+3 −2
Original line number Diff line number Diff line
@@ -20,10 +20,11 @@
    android:id="@+id/notification_header"
    android:orientation="horizontal"
    android:layout_width="wrap_content"
    android:layout_height="53dp"
    android:layout_height="48dp"
    android:clipChildren="false"
    android:paddingTop="10dp"
    android:paddingBottom="16dp"
    android:paddingBottom="11dp"
    android:layout_marginBottom="5dp"
    android:paddingStart="@dimen/notification_content_margin_start"
    android:paddingEnd="16dp">
    <com.android.internal.widget.CachingIconView
+3 −0
Original line number Diff line number Diff line
@@ -578,6 +578,9 @@
    <!-- The divider symbol between different parts of the notification header. not translatable [CHAR LIMIT=1] -->
    <string name="notification_header_divider_symbol" translatable="false"></string>

    <!-- The divider symbol between different parts of the notification header including spaces. not translatable [CHAR LIMIT=3] -->
    <string name="notification_header_divider_symbol_with_spaces" translatable="false">" • "</string>

    <!-- Text shown in place of notification contents when the notification is hidden on a secure lockscreen -->
    <string name="notification_hidden_text">Contents hidden</string>

+1 −0
Original line number Diff line number Diff line
@@ -2783,6 +2783,7 @@
  <java-symbol type="drawable" name="lockscreen_notselected" />
  <java-symbol type="drawable" name="lockscreen_selected" />

  <java-symbol type="string" name="notification_header_divider_symbol_with_spaces" />
  <java-symbol type="string" name="config_defaultCellBroadcastReceiverComponent" />

  <java-symbol type="string" name="app_category_game" />
+5 −3
Original line number Diff line number Diff line
@@ -100,7 +100,6 @@ import com.android.systemui.SystemUI;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.recents.Recents;
import com.android.systemui.statusbar.NotificationData.Entry;
import com.android.systemui.statusbar.NotificationGuts.OnGutsClosedListener;
import com.android.systemui.statusbar.notification.VisualStabilityManager;
import com.android.systemui.statusbar.phone.NavigationBarView;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
@@ -1513,8 +1512,9 @@ public abstract class BaseStatusBar extends SystemUI implements
                entry.notification.getUser().getIdentifier());

        final StatusBarNotification sbn = entry.notification;
        boolean isLowPriority = mNotificationData.isAmbient(sbn.getKey());
        try {
            entry.cacheContentViews(mContext, null);
            entry.cacheContentViews(mContext, null, isLowPriority);
        } catch (RuntimeException e) {
            Log.e(TAG, "Unable to get notification remote views", e);
            return false;
@@ -1586,6 +1586,7 @@ public abstract class BaseStatusBar extends SystemUI implements

        workAroundBadLayerDrawableOpacity(row);
        bindDismissRunnable(row);
        row.setIsLowPriority(isLowPriority);

        // NB: the large icon is now handled entirely by the template

@@ -2263,7 +2264,8 @@ public abstract class BaseStatusBar extends SystemUI implements

        boolean applyInPlace;
        try {
            applyInPlace = entry.cacheContentViews(mContext, notification.getNotification());
            applyInPlace = entry.cacheContentViews(mContext, notification.getNotification(),
                    mNotificationData.isAmbient(key));
        } catch (RuntimeException e) {
            Log.e(TAG, "Unable to get notification remote views", e);
            applyInPlace = false;
Loading