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

Commit cc10bfba authored by Selim Cinek's avatar Selim Cinek
Browse files

Added support for media notifications without expanded state

Bug: 26837953
Change-Id: I9fcf56013c44a2420367ef0a908dc45992c8a766
parent 01af334b
Loading
Loading
Loading
Loading
+24 −8
Original line number Diff line number Diff line
@@ -3353,13 +3353,9 @@ public class Notification implements Parcelable
                return mN.bigContentView;
            } else if (mStyle != null) {
                result = mStyle.makeBigContentView();
            } else if (mActions.size() == 0) {
                return null;
            }
            if (result == null) {
                result = applyStandardTemplateWithActions(getBigBaseLayoutResource());
            } else {
                hideLine1Text(result);
            } else if (mActions.size() != 0) {
                result = applyStandardTemplateWithActions(getBigBaseLayoutResource());
            }
            adaptNotificationHeaderForBigContentView(result);
            return result;
@@ -3379,12 +3375,16 @@ public class Notification implements Parcelable
        }

        private void hideLine1Text(RemoteViews result) {
            if (result != null) {
                result.setViewVisibility(R.id.text_line_1, View.GONE);
            }
        }

        private void adaptNotificationHeaderForBigContentView(RemoteViews result) {
            if (result != null) {
                result.setBoolean(R.id.notification_header, "setExpanded", true);
            }
        }

        /**
         * Construct a RemoteViews for the final heads-up notification layout.
@@ -4321,6 +4321,15 @@ public class Notification implements Parcelable
            return makeMediaBigContentView();
        }

        /**
         * @hide
         */
        @Override
        public RemoteViews makeHeadsUpContentView() {
            RemoteViews expanded = makeMediaBigContentView();
            return expanded != null ? expanded : makeMediaContentView();
        }

        /** @hide */
        @Override
        public void addExtras(Bundle extras) {
@@ -4402,6 +4411,13 @@ public class Notification implements Parcelable

        private RemoteViews makeMediaBigContentView() {
            final int actionCount = Math.min(mBuilder.mActions.size(), MAX_MEDIA_BUTTONS);
            // Dont add an expanded view if there is no more content to be revealed
            int actionsInCompact = mActionsToShowInCompact == null
                    ? 0
                    : Math.min(mActionsToShowInCompact.length, MAX_MEDIA_BUTTONS_IN_COMPACT);
            if (mBuilder.mN.mLargeIcon == null && actionCount <= actionsInCompact) {
                return null;
            }
            RemoteViews big = mBuilder.applyStandardTemplate(
                    R.layout.notification_template_material_big_media,
                    false);