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

Commit e8f090d7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Allow resid notification channel group labels."

parents 99f8f805 d5286843
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -5519,12 +5519,14 @@ package android.app {
  public final class NotificationChannelGroup implements android.os.Parcelable {
    ctor public NotificationChannelGroup(java.lang.String, java.lang.CharSequence);
    ctor public NotificationChannelGroup(java.lang.String, int);
    ctor protected NotificationChannelGroup(android.os.Parcel);
    method public android.app.NotificationChannelGroup clone();
    method public int describeContents();
    method public java.util.List<android.app.NotificationChannel> getChannels();
    method public java.lang.String getId();
    method public java.lang.CharSequence getName();
    method public int getNameResId();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.NotificationChannelGroup> CREATOR;
  }
+2 −0
Original line number Diff line number Diff line
@@ -5712,6 +5712,7 @@ package android.app {
  public final class NotificationChannelGroup implements android.os.Parcelable {
    ctor public NotificationChannelGroup(java.lang.String, java.lang.CharSequence);
    ctor public NotificationChannelGroup(java.lang.String, int);
    ctor protected NotificationChannelGroup(android.os.Parcel);
    method public void addChannel(android.app.NotificationChannel);
    method public android.app.NotificationChannelGroup clone();
@@ -5719,6 +5720,7 @@ package android.app {
    method public java.util.List<android.app.NotificationChannel> getChannels();
    method public java.lang.String getId();
    method public java.lang.CharSequence getName();
    method public int getNameResId();
    method public org.json.JSONObject toJson() throws org.json.JSONException;
    method public void writeToParcel(android.os.Parcel, int);
    method public void writeXml(org.xmlpull.v1.XmlSerializer) throws java.io.IOException;
+2 −0
Original line number Diff line number Diff line
@@ -5529,12 +5529,14 @@ package android.app {
  public final class NotificationChannelGroup implements android.os.Parcelable {
    ctor public NotificationChannelGroup(java.lang.String, java.lang.CharSequence);
    ctor public NotificationChannelGroup(java.lang.String, int);
    ctor protected NotificationChannelGroup(android.os.Parcel);
    method public android.app.NotificationChannelGroup clone();
    method public int describeContents();
    method public java.util.List<android.app.NotificationChannel> getChannels();
    method public java.lang.String getId();
    method public java.lang.CharSequence getName();
    method public int getNameResId();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.NotificationChannelGroup> CREATOR;
  }
+42 −3
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package android.app;

import android.annotation.StringRes;
import android.annotation.SystemApi;
import android.net.Uri;
import android.os.Parcel;
@@ -40,23 +41,38 @@ public final class NotificationChannelGroup implements Parcelable {

    private static final String TAG_GROUP = "channelGroup";
    private static final String ATT_NAME = "name";
    private static final String ATT_NAME_RES_ID = "name_res_id";
    private static final String ATT_ID = "id";

    private final String mId;
    private CharSequence mName;
    private int mNameResId = 0;
    private List<NotificationChannel> mChannels = new ArrayList<>();

    /**
     * Creates a notification channel.
     *
     * @param id The id of the group. Must be unique per package.
     * @param name The user visible name of the group.
     * @param name The user visible name of the group. Unchangeable once created; use this
     *             constructor if the group represents something user-defined that does not
     *             need to be translated.
     */
    public NotificationChannelGroup(String id, CharSequence name) {
        this.mId = id;
        this.mName = name;
    }

    /**
     * Creates a notification channel.
     *
     * @param id The id of the group. Must be unique per package.
     * @param nameResId String resource id of the user visible name of the group.
     */
    public NotificationChannelGroup(String id, @StringRes int nameResId) {
        this.mId = id;
        this.mNameResId = nameResId;
    }

    protected NotificationChannelGroup(Parcel in) {
        if (in.readByte() != 0) {
            mId = in.readString();
@@ -64,6 +80,7 @@ public final class NotificationChannelGroup implements Parcelable {
            mId = null;
        }
        mName = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
        mNameResId = in.readInt();
        in.readParcelableList(mChannels, NotificationChannel.class.getClassLoader());
    }

@@ -76,6 +93,7 @@ public final class NotificationChannelGroup implements Parcelable {
            dest.writeByte((byte) 0);
        }
        TextUtils.writeToParcel(mName, dest, flags);
        dest.writeInt(mNameResId);
        dest.writeParcelableList(mChannels, flags);
    }

@@ -93,6 +111,13 @@ public final class NotificationChannelGroup implements Parcelable {
        return mName;
    }

    /**
     * Returns the resource id of the user visible name of this group.
     */
    public @StringRes int getNameResId() {
        return mNameResId;
    }

    /*
     * Returns the list of channels that belong to this group
     *
@@ -119,7 +144,12 @@ public final class NotificationChannelGroup implements Parcelable {
        out.startTag(null, TAG_GROUP);

        out.attribute(null, ATT_ID, getId());
        if (getName() != null) {
            out.attribute(null, ATT_NAME, getName().toString());
        }
        if (getNameResId() != 0) {
            out.attribute(null, ATT_NAME_RES_ID, Integer.toString(getNameResId()));
        }

        out.endTag(null, TAG_GROUP);
    }
@@ -132,6 +162,7 @@ public final class NotificationChannelGroup implements Parcelable {
        JSONObject record = new JSONObject();
        record.put(ATT_ID, getId());
        record.put(ATT_NAME, getName());
        record.put(ATT_NAME_RES_ID, getNameResId());
        return record;
    }

@@ -160,6 +191,7 @@ public final class NotificationChannelGroup implements Parcelable {

        NotificationChannelGroup that = (NotificationChannelGroup) o;

        if (getNameResId() != that.getNameResId()) return false;
        if (getId() != null ? !getId().equals(that.getId()) : that.getId() != null) return false;
        if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) {
            return false;
@@ -171,13 +203,18 @@ public final class NotificationChannelGroup implements Parcelable {

    @Override
    public NotificationChannelGroup clone() {
        if (getName() != null) {
            return new NotificationChannelGroup(getId(), getName());
        } else {
            return new NotificationChannelGroup(getId(), getNameResId());
        }
    }

    @Override
    public int hashCode() {
        int result = getId() != null ? getId().hashCode() : 0;
        result = 31 * result + (getName() != null ? getName().hashCode() : 0);
        result = 31 * result + getNameResId();
        result = 31 * result + (getChannels() != null ? getChannels().hashCode() : 0);
        return result;
    }
@@ -187,6 +224,8 @@ public final class NotificationChannelGroup implements Parcelable {
        return "NotificationChannelGroup{" +
                "mId='" + mId + '\'' +
                ", mName=" + mName +
                ", mNameResId=" + mNameResId +
                ", mChannels=" + mChannels +
                '}';
    }
}
+6 −1
Original line number Diff line number Diff line
@@ -154,8 +154,13 @@ public class NotificationInfo extends LinearLayout implements GutsContent {
                        iNotificationManager.getNotificationChannelGroupForPackage(
                                channel.getGroup(), pkg, appUid);
                if (notificationChannelGroup != null) {
                    if (info != null && notificationChannelGroup.getNameResId() != 0) {
                        groupName = pm.getText(pkg, notificationChannelGroup.getNameResId(), info);
                    }
                    if (notificationChannelGroup.getName() != null) {
                        groupName = notificationChannelGroup.getName();
                    }
                }
            } catch (RemoteException e) {
                Log.e(TAG, e.toString());
            }
Loading