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

Commit cdea2a3e authored by Chris Wren's avatar Chris Wren Committed by Android Git Automerger
Browse files

am d213524d: Merge "Add an alternate title that can be used in the overflow of...

am d213524d: Merge "Add an alternate title that can be used in the overflow of a InboxStyle. Always hide contentText for BigTextStyle and InboxStyle. Style cannot be used without specialization, it should be abstract." into jb-dev

* commit 'd213524d':
  Add an alternate title that can be used in the overflow of a InboxStyle. Always hide contentText for BigTextStyle and InboxStyle. Style cannot be used without specialization, it should be abstract.
parents 74f64d78 d213524d
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -3770,12 +3770,18 @@ package android.app {
    ctor public Notification.BigPictureStyle();
    ctor public Notification.BigPictureStyle(android.app.Notification.Builder);
    method public android.app.Notification.BigPictureStyle bigPicture(android.graphics.Bitmap);
    method public android.app.Notification build();
    method public android.app.Notification.BigPictureStyle setBigContentTitle(java.lang.CharSequence);
    method public android.app.Notification.BigPictureStyle setSummaryText(java.lang.CharSequence);
  }
  public static class Notification.BigTextStyle extends android.app.Notification.Style {
    ctor public Notification.BigTextStyle();
    ctor public Notification.BigTextStyle(android.app.Notification.Builder);
    method public android.app.Notification.BigTextStyle bigText(java.lang.CharSequence);
    method public android.app.Notification build();
    method public android.app.Notification.BigTextStyle setBigContentTitle(java.lang.CharSequence);
    method public android.app.Notification.BigTextStyle setSummaryText(java.lang.CharSequence);
  }
  public static class Notification.Builder {
@@ -3817,11 +3823,18 @@ package android.app {
    ctor public Notification.InboxStyle();
    ctor public Notification.InboxStyle(android.app.Notification.Builder);
    method public android.app.Notification.InboxStyle addLine(java.lang.CharSequence);
    method public android.app.Notification build();
    method public android.app.Notification.InboxStyle setBigContentTitle(java.lang.CharSequence);
    method public android.app.Notification.InboxStyle setSummaryText(java.lang.CharSequence);
  }
  public static class Notification.Style {
  public static abstract class Notification.Style {
    ctor public Notification.Style();
    method public android.app.Notification build();
    method public abstract android.app.Notification build();
    method protected void checkBuilder();
    method protected android.widget.RemoteViews getStandardView(int);
    method protected void internalSetBigContentTitle(java.lang.CharSequence);
    method protected void internalSetSummaryText(java.lang.CharSequence);
    method public void setBuilder(android.app.Notification.Builder);
    field protected android.app.Notification.Builder mBuilder;
  }
+120 −23
Original line number Diff line number Diff line
@@ -1397,7 +1397,8 @@ public class Notification implements Parcelable

            if (mSubText != null) {
                contentView.setTextViewText(R.id.text, mSubText);
                contentView.setViewVisibility(R.id.text2, View.VISIBLE);
                contentView.setViewVisibility(R.id.text2,
                        mContentText != null ? View.VISIBLE : View.GONE);
            } else {
                contentView.setViewVisibility(R.id.text2, View.GONE);
                if (mProgressMax != 0 || mProgressIndeterminate) {
@@ -1428,12 +1429,12 @@ public class Notification implements Parcelable

            int N = mActions.size();
            if (N > 0) {
                Log.d("Notification", "has actions: " + mContentText);
                // Log.d("Notification", "has actions: " + mContentText);
                big.setViewVisibility(R.id.actions, View.VISIBLE);
                if (N>3) N=3;
                for (int i=0; i<N; i++) {
                    final RemoteViews button = generateActionButton(mActions.get(i));
                    Log.d("Notification", "adding action " + i + ": " + mActions.get(i).title);
                    //Log.d("Notification", "adding action " + i + ": " + mActions.get(i).title);
                    big.addView(R.id.actions, button);
                }
            }
@@ -1549,9 +1550,28 @@ public class Notification implements Parcelable
     * An object that can apply a rich notification style to a {@link Notification.Builder}
     * object.
     */
    public static class Style {
    public static abstract class Style
    {
        private CharSequence mBigContentTitle;
        private CharSequence mSummaryText = null;

        protected Builder mBuilder;

        /**
         * Overrides ContentTitle in the big form of the template.
         * This defaults to the value passed to setContentTitle().
         */
        protected void internalSetBigContentTitle(CharSequence title) {
            mBigContentTitle = title;
        }

        /**
         * Set the first line of text after the detail section in the big form of the template.
         */
        protected void internalSetSummaryText(CharSequence cs) {
            mSummaryText = cs;
        }

        public void setBuilder(Builder builder) {
            if (mBuilder != builder) {
                mBuilder = builder;
@@ -1559,12 +1579,42 @@ public class Notification implements Parcelable
            }
        }

        public Notification build() {
        protected void checkBuilder() {
            if (mBuilder == null) {
                throw new IllegalArgumentException("Style requires a valid Builder object");
            }
            return mBuilder.buildUnstyled();
        }

        protected RemoteViews getStandardView(int layoutId) {
            checkBuilder();

            if (mBigContentTitle != null) {
                mBuilder.setContentTitle(mBigContentTitle);
            }

            if (mBuilder.mSubText == null) {
                mBuilder.setContentText(null);
            }

            RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(layoutId);

            if (mBuilder.mSubText == null) {
                contentView.setViewVisibility(R.id.line3, View.GONE);
            }

            if (mBigContentTitle != null && mBigContentTitle.equals("")) {
                contentView.setViewVisibility(R.id.line1, View.GONE);
            }

            if (mSummaryText != null && !mSummaryText.equals("")) {
                contentView.setViewVisibility(R.id.overflow_title, View.VISIBLE);
                contentView.setTextViewText(R.id.overflow_title, mSummaryText);
            }

            return contentView;
        }

        public abstract Notification build();
    }

    /**
@@ -1594,13 +1644,30 @@ public class Notification implements Parcelable
            setBuilder(builder);
        }

        /**
         * Overrides ContentTitle in the big form of the template.
         * This defaults to the value passed to setContentTitle().
         */
        public BigPictureStyle setBigContentTitle(CharSequence title) {
            internalSetBigContentTitle(title);
            return this;
        }

        /**
         * Set the first line of text after the detail section in the big form of the template.
         */
        public BigPictureStyle setSummaryText(CharSequence cs) {
            internalSetSummaryText(cs);
            return this;
        }

        public BigPictureStyle bigPicture(Bitmap b) {
            mPicture = b;
            return this;
        }

        private RemoteViews makeBigContentView() {
            RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(R.layout.notification_template_big_picture);
            RemoteViews contentView = getStandardView(R.layout.notification_template_big_picture);

            contentView.setImageViewBitmap(R.id.big_picture, mPicture);

@@ -1609,9 +1676,7 @@ public class Notification implements Parcelable

        @Override
        public Notification build() {
            if (mBuilder == null) {
                throw new IllegalArgumentException("Style requires a valid Builder object");
            }
            checkBuilder();
            Notification wip = mBuilder.buildUnstyled();
            wip.bigContentView = makeBigContentView();
            return wip;
@@ -1645,26 +1710,39 @@ public class Notification implements Parcelable
            setBuilder(builder);
        }

        /**
         * Overrides ContentTitle in the big form of the template.
         * This defaults to the value passed to setContentTitle().
         */
        public BigTextStyle setBigContentTitle(CharSequence title) {
            internalSetBigContentTitle(title);
            return this;
        }

        /**
         * Set the first line of text after the detail section in the big form of the template.
         */
        public BigTextStyle setSummaryText(CharSequence cs) {
            internalSetSummaryText(cs);
            return this;
        }

        public BigTextStyle bigText(CharSequence cs) {
            mBigText = cs;
            return this;
        }

        private RemoteViews makeBigContentView() {
            int bigTextId = R.layout.notification_template_big_text;
            RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(bigTextId);
            RemoteViews contentView = getStandardView(R.layout.notification_template_big_text);
            contentView.setTextViewText(R.id.big_text, mBigText);
            contentView.setViewVisibility(R.id.big_text, View.VISIBLE);
            contentView.setViewVisibility(R.id.text2, View.GONE);

            return contentView;
        }

        @Override
        public Notification build() {
            if (mBuilder == null) {
                throw new IllegalArgumentException("Style requires a valid Builder object");
            }
            checkBuilder();
            Notification wip = mBuilder.buildUnstyled();
            wip.bigContentView = makeBigContentView();
            return wip;
@@ -1678,12 +1756,14 @@ public class Notification implements Parcelable
     * <pre class="prettyprint">
     * Notification noti = new Notification.InboxStyle(
     *      new Notification.Builder()
     *         .setContentTitle(&quot;New mail from &quot; + sender.toString())
     *         .setContentTitle(&quot;5 New mails from &quot; + sender.toString())
     *         .setContentText(subject)
     *         .setSmallIcon(R.drawable.new_mail)
     *         .setLargeIcon(aBitmap))
     *      .addLine(str1)
     *      .addLine(str2)
     *      .setContentTitle("")
     *      .setSummaryText(&quot;+3 more&quot;)
     *      .build();
     * </pre>
     * 
@@ -1699,15 +1779,34 @@ public class Notification implements Parcelable
            setBuilder(builder);
        }

        /**
         * Overrides ContentTitle in the big form of the template.
         * This defaults to the value passed to setContentTitle().
         */
        public InboxStyle setBigContentTitle(CharSequence title) {
            internalSetBigContentTitle(title);
            return this;
        }

        /**
         * Set the first line of text after the detail section in the big form of the template.
         */
        public InboxStyle setSummaryText(CharSequence cs) {
            internalSetSummaryText(cs);
            return this;
        }

        public InboxStyle addLine(CharSequence cs) {
            mTexts.add(cs);
            return this;
        }

        private RemoteViews makeBigContentView() {
            RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(R.layout.notification_template_inbox);
            RemoteViews contentView = getStandardView(R.layout.notification_template_inbox);
            contentView.setViewVisibility(R.id.text2, View.GONE);

            int[] rowIds = {R.id.inbox_text0, R.id.inbox_text1, R.id.inbox_text2, R.id.inbox_text3, R.id.inbox_text4};
            int[] rowIds = {R.id.inbox_text0, R.id.inbox_text1, R.id.inbox_text2, R.id.inbox_text3,
                    R.id.inbox_text4};

            int i=0;
            while (i < mTexts.size() && i < rowIds.length) {
@@ -1724,9 +1823,7 @@ public class Notification implements Parcelable

        @Override
        public Notification build() {
            if (mBuilder == null) {
                throw new IllegalArgumentException("Style requires a valid Builder object");
            }
            checkBuilder();
            Notification wip = mBuilder.buildUnstyled();
            wip.bigContentView = makeBigContentView();
            return wip;
+10 −9
Original line number Diff line number Diff line
@@ -85,6 +85,16 @@
            android:ellipsize="marquee"
            android:visibility="gone"
            />
        <TextView android:id="@+id/overflow_title"
            android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:ellipsize="marquee"
            android:fadingEdge="horizontal"
            android:visibility="gone"
            android:layout_weight="1"
            />
        <LinearLayout
            android:id="@+id/line3"
            android:layout_width="match_parent"
@@ -129,14 +139,5 @@
            android:visibility="gone"
            style="?android:attr/progressBarStyleHorizontal"
            />
        <LinearLayout
                android:id="@+id/actions"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:visibility="gone"
                >
                <!-- actions will be added here -->
        </LinearLayout>
    </LinearLayout>
</FrameLayout>
+4 −3
Original line number Diff line number Diff line
@@ -140,6 +140,7 @@
            android:id="@+id/actions"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:visibility="gone"
                >
                <!-- actions will be added here -->
+11 −1
Original line number Diff line number Diff line
@@ -108,6 +108,16 @@
                >
                <!-- actions will be added here -->
        </LinearLayout>
        <TextView android:id="@+id/overflow_title"
            android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:ellipsize="marquee"
            android:fadingEdge="horizontal"
            android:visibility="gone"
            android:layout_weight="1"
            />
        <LinearLayout
            android:id="@+id/line3"
            android:layout_width="match_parent"
Loading