Source code
package android.support.v4.app;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.app.NotificationCompatBase.Action;
import android.support.v4.app.NotificationCompatBase.UnreadConversation;
import android.support.v4.app.NotificationCompatBase.UnreadConversation.Factory;
import android.support.v4.app.RemoteInputCompatBase.RemoteInput;
import android.widget.RemoteViews;
import java.util.ArrayList;
import java.util.Iterator;
class NotificationCompatApi21 {
public static final String CATEGORY_ALARM = "alarm";
public static final String CATEGORY_CALL = "call";
public static final String CATEGORY_EMAIL = "email";
public static final String CATEGORY_ERROR = "err";
public static final String CATEGORY_EVENT = "event";
public static final String CATEGORY_MESSAGE = "msg";
public static final String CATEGORY_PROGRESS = "progress";
public static final String CATEGORY_PROMO = "promo";
public static final String CATEGORY_RECOMMENDATION = "recommendation";
public static final String CATEGORY_SERVICE = "service";
public static final String CATEGORY_SOCIAL = "social";
public static final String CATEGORY_STATUS = "status";
public static final String CATEGORY_SYSTEM = "sys";
public static final String CATEGORY_TRANSPORT = "transport";
private static final String KEY_AUTHOR = "author";
private static final String KEY_MESSAGES = "messages";
private static final String KEY_ON_READ = "on_read";
private static final String KEY_ON_REPLY = "on_reply";
private static final String KEY_PARTICIPANTS = "participants";
private static final String KEY_REMOTE_INPUT = "remote_input";
private static final String KEY_TEXT = "text";
private static final String KEY_TIMESTAMP = "timestamp";
public static class Builder implements NotificationBuilderWithBuilderAccessor, NotificationBuilderWithActions {
private android.app.Notification.Builder b;
public Builder(Context context, Notification n, CharSequence contentTitle, CharSequence contentText, CharSequence contentInfo, RemoteViews tickerView, int number, PendingIntent contentIntent, PendingIntent fullScreenIntent, Bitmap largeIcon, int progressMax, int progress, boolean progressIndeterminate, boolean showWhen, boolean useChronometer, int priority, CharSequence subText, boolean localOnly, String category, ArrayList<String> people, Bundle extras, int color, int visibility, Notification publicVersion, String groupKey, boolean groupSummary, String sortKey) {
boolean z;
android.app.Notification.Builder lights = new android.app.Notification.Builder(context).setWhen(n.when).setShowWhen(showWhen).setSmallIcon(n.icon, n.iconLevel).setContent(n.contentView).setTicker(n.tickerText, tickerView).setSound(n.sound, n.audioStreamType).setVibrate(n.vibrate).setLights(n.ledARGB, n.ledOnMS, n.ledOffMS);
if ((n.flags & 2) != 0) {
z = true;
} else {
z = false;
}
lights = lights.setOngoing(z);
if ((n.flags & 8) != 0) {
z = true;
} else {
z = false;
}
lights = lights.setOnlyAlertOnce(z);
if ((n.flags & 16) != 0) {
z = true;
} else {
z = false;
}
lights = lights.setAutoCancel(z).setDefaults(n.defaults).setContentTitle(contentTitle).setContentText(contentText).setSubText(subText).setContentInfo(contentInfo).setContentIntent(contentIntent).setDeleteIntent(n.deleteIntent);
if ((n.flags & 128) != 0) {
z = true;
} else {
z = false;
}
this.b = lights.setFullScreenIntent(fullScreenIntent, z).setLargeIcon(largeIcon).setNumber(number).setUsesChronometer(useChronometer).setPriority(priority).setProgress(progressMax, progress, progressIndeterminate).setLocalOnly(localOnly).setExtras(extras).setGroup(groupKey).setGroupSummary(groupSummary).setSortKey(sortKey).setCategory(category).setColor(color).setVisibility(visibility).setPublicVersion(publicVersion);
Iterator i$ = people.iterator();
while (i$.hasNext()) {
this.b.addPerson((String) i$.next());
}
}
public void addAction(Action action) {
NotificationCompatApi20.addAction(this.b, action);
}
public android.app.Notification.Builder getBuilder() {
return this.b;
}
public Notification build() {
return this.b.build();
}
}
NotificationCompatApi21() {
}
public static String getCategory(Notification notif) {
return notif.category;
}
static Bundle getBundleForUnreadConversation(UnreadConversation uc) {
if (uc == null) {
return null;
}
Bundle b = new Bundle();
String author = null;
if (uc.getParticipants() != null && uc.getParticipants().length > 1) {
author = uc.getParticipants()[0];
}
Parcelable[] messages = new Parcelable[uc.getMessages().length];
for (int i = 0; i < messages.length; i++) {
Bundle m = new Bundle();
m.putString(KEY_TEXT, uc.getMessages()[i]);
m.putString(KEY_AUTHOR, author);
messages[i] = m;
}
b.putParcelableArray(KEY_MESSAGES, messages);
RemoteInput remoteInput = uc.getRemoteInput();
if (remoteInput != null) {
b.putParcelable(KEY_REMOTE_INPUT, fromCompatRemoteInput(remoteInput));
}
b.putParcelable(KEY_ON_REPLY, uc.getReplyPendingIntent());
b.putParcelable(KEY_ON_READ, uc.getReadPendingIntent());
b.putStringArray(KEY_PARTICIPANTS, uc.getParticipants());
b.putLong(KEY_TIMESTAMP, uc.getLatestTimestamp());
return b;
}
static UnreadConversation getUnreadConversationFromBundle(Bundle b, Factory factory, RemoteInput.Factory remoteInputFactory) {
RemoteInput remoteInput = null;
if (b == null) {
return null;
}
Parcelable[] parcelableMessages = b.getParcelableArray(KEY_MESSAGES);
String[] messages = null;
if (parcelableMessages != null) {
String[] tmp = new String[parcelableMessages.length];
boolean success = true;
for (int i = 0; i < tmp.length; i++) {
if (!(parcelableMessages[i] instanceof Bundle)) {
success = false;
break;
}
tmp[i] = ((Bundle) parcelableMessages[i]).getString(KEY_TEXT);
if (tmp[i] == null) {
success = false;
break;
}
}
if (!success) {
return null;
}
messages = tmp;
}
PendingIntent onRead = (PendingIntent) b.getParcelable(KEY_ON_READ);
PendingIntent onReply = (PendingIntent) b.getParcelable(KEY_ON_REPLY);
android.app.RemoteInput remoteInput2 = (android.app.RemoteInput) b.getParcelable(KEY_REMOTE_INPUT);
String[] participants = b.getStringArray(KEY_PARTICIPANTS);
if (participants == null || participants.length != 1) {
return null;
}
if (remoteInput2 != null) {
remoteInput = toCompatRemoteInput(remoteInput2, remoteInputFactory);
}
return factory.build(messages, remoteInput, onReply, onRead, participants, b.getLong(KEY_TIMESTAMP));
}
private static android.app.RemoteInput fromCompatRemoteInput(RemoteInput src) {
return new android.app.RemoteInput.Builder(src.getResultKey()).setLabel(src.getLabel()).setChoices(src.getChoices()).setAllowFreeFormInput(src.getAllowFreeFormInput()).addExtras(src.getExtras()).build();
}
private static RemoteInput toCompatRemoteInput(android.app.RemoteInput remoteInput, RemoteInput.Factory factory) {
return factory.build(remoteInput.getResultKey(), remoteInput.getLabel(), remoteInput.getChoices(), remoteInput.getAllowFreeFormInput(), remoteInput.getExtras());
}
}