Methods Summary |
---|
public static void | addBigPictureStyle(NotificationBuilderWithBuilderAccessor b, java.lang.CharSequence bigContentTitle, boolean useSummary, java.lang.CharSequence summaryText, android.graphics.Bitmap bigPicture, android.graphics.Bitmap bigLargeIcon, boolean bigLargeIconSet)
Notification.BigPictureStyle style = new Notification.BigPictureStyle(b.getBuilder())
.setBigContentTitle(bigContentTitle)
.bigPicture(bigPicture);
if (bigLargeIconSet) {
style.bigLargeIcon(bigLargeIcon);
}
if (useSummary) {
style.setSummaryText(summaryText);
}
|
public static void | addBigTextStyle(NotificationBuilderWithBuilderAccessor b, java.lang.CharSequence bigContentTitle, boolean useSummary, java.lang.CharSequence summaryText, java.lang.CharSequence bigText)
Notification.BigTextStyle style = new Notification.BigTextStyle(b.getBuilder())
.setBigContentTitle(bigContentTitle)
.bigText(bigText);
if (useSummary) {
style.setSummaryText(summaryText);
}
|
public static void | addInboxStyle(NotificationBuilderWithBuilderAccessor b, java.lang.CharSequence bigContentTitle, boolean useSummary, java.lang.CharSequence summaryText, java.util.ArrayList texts)
Notification.InboxStyle style = new Notification.InboxStyle(b.getBuilder())
.setBigContentTitle(bigContentTitle);
if (useSummary) {
style.setSummaryText(summaryText);
}
for (CharSequence text: texts) {
style.addLine(text);
}
|
public static android.util.SparseArray | buildActionExtrasMap(java.util.List actionExtrasList)Return an SparseArray for action extras or null if none was needed.
SparseArray<Bundle> actionExtrasMap = null;
for (int i = 0, count = actionExtrasList.size(); i < count; i++) {
Bundle actionExtras = actionExtrasList.get(i);
if (actionExtras != null) {
if (actionExtrasMap == null) {
actionExtrasMap = new SparseArray<Bundle>();
}
actionExtrasMap.put(i, actionExtras);
}
}
return actionExtrasMap;
|
private static boolean | ensureActionReflectionReadyLocked()
if (sActionsAccessFailed) {
return false;
}
try {
if (sActionsField == null) {
sActionClass = Class.forName("android.app.Notification$Action");
sActionIconField = sActionClass.getDeclaredField("icon");
sActionTitleField = sActionClass.getDeclaredField("title");
sActionIntentField = sActionClass.getDeclaredField("actionIntent");
sActionsField = Notification.class.getDeclaredField("actions");
sActionsField.setAccessible(true);
}
} catch (ClassNotFoundException e) {
Log.e(TAG, "Unable to access notification actions", e);
sActionsAccessFailed = true;
} catch (NoSuchFieldException e) {
Log.e(TAG, "Unable to access notification actions", e);
sActionsAccessFailed = true;
}
return !sActionsAccessFailed;
|
public static NotificationCompatBase.Action | getAction(android.app.Notification notif, int actionIndex, NotificationCompatBase.Action.Factory factory, RemoteInputCompatBase.RemoteInput.Factory remoteInputFactory)
synchronized (sActionsLock) {
try {
Object actionObject = getActionObjectsLocked(notif)[actionIndex];
Bundle actionExtras = null;
Bundle extras = getExtras(notif);
if (extras != null) {
SparseArray<Bundle> actionExtrasMap = extras.getSparseParcelableArray(
EXTRA_ACTION_EXTRAS);
if (actionExtrasMap != null) {
actionExtras = actionExtrasMap.get(actionIndex);
}
}
return readAction(factory, remoteInputFactory,
sActionIconField.getInt(actionObject),
(CharSequence) sActionTitleField.get(actionObject),
(PendingIntent) sActionIntentField.get(actionObject),
actionExtras);
} catch (IllegalAccessException e) {
Log.e(TAG, "Unable to access notification actions", e);
sActionsAccessFailed = true;
}
}
return null;
|
public static int | getActionCount(android.app.Notification notif)
synchronized (sActionsLock) {
Object[] actionObjects = getActionObjectsLocked(notif);
return actionObjects != null ? actionObjects.length : 0;
}
|
private static NotificationCompatBase.Action | getActionFromBundle(android.os.Bundle bundle, NotificationCompatBase.Action.Factory actionFactory, RemoteInputCompatBase.RemoteInput.Factory remoteInputFactory)
return actionFactory.build(
bundle.getInt(KEY_ICON),
bundle.getCharSequence(KEY_TITLE),
bundle.<PendingIntent>getParcelable(KEY_ACTION_INTENT),
bundle.getBundle(KEY_EXTRAS),
RemoteInputCompatJellybean.fromBundleArray(
BundleUtil.getBundleArrayFromBundle(bundle, KEY_REMOTE_INPUTS),
remoteInputFactory));
|
private static java.lang.Object[] | getActionObjectsLocked(android.app.Notification notif)
synchronized (sActionsLock) {
if (!ensureActionReflectionReadyLocked()) {
return null;
}
try {
return (Object[]) sActionsField.get(notif);
} catch (IllegalAccessException e) {
Log.e(TAG, "Unable to access notification actions", e);
sActionsAccessFailed = true;
return null;
}
}
|
public static NotificationCompatBase.Action[] | getActionsFromParcelableArrayList(java.util.ArrayList parcelables, NotificationCompatBase.Action.Factory actionFactory, RemoteInputCompatBase.RemoteInput.Factory remoteInputFactory)
if (parcelables == null) {
return null;
}
NotificationCompatBase.Action[] actions = actionFactory.newArray(parcelables.size());
for (int i = 0; i < actions.length; i++) {
actions[i] = getActionFromBundle((Bundle) parcelables.get(i),
actionFactory, remoteInputFactory);
}
return actions;
|
private static android.os.Bundle | getBundleForAction(NotificationCompatBase.Action action)
Bundle bundle = new Bundle();
bundle.putInt(KEY_ICON, action.getIcon());
bundle.putCharSequence(KEY_TITLE, action.getTitle());
bundle.putParcelable(KEY_ACTION_INTENT, action.getActionIntent());
bundle.putBundle(KEY_EXTRAS, action.getExtras());
bundle.putParcelableArray(KEY_REMOTE_INPUTS, RemoteInputCompatJellybean.toBundleArray(
action.getRemoteInputs()));
return bundle;
|
public static android.os.Bundle | getExtras(android.app.Notification notif)Get the extras Bundle from a notification using reflection. Extras were present in
Jellybean notifications, but the field was private until KitKat.
synchronized (sExtrasLock) {
if (sExtrasFieldAccessFailed) {
return null;
}
try {
if (sExtrasField == null) {
Field extrasField = Notification.class.getDeclaredField("extras");
if (!Bundle.class.isAssignableFrom(extrasField.getType())) {
Log.e(TAG, "Notification.extras field is not of type Bundle");
sExtrasFieldAccessFailed = true;
return null;
}
extrasField.setAccessible(true);
sExtrasField = extrasField;
}
Bundle extras = (Bundle) sExtrasField.get(notif);
if (extras == null) {
extras = new Bundle();
sExtrasField.set(notif, extras);
}
return extras;
} catch (IllegalAccessException e) {
Log.e(TAG, "Unable to access notification extras", e);
} catch (NoSuchFieldException e) {
Log.e(TAG, "Unable to access notification extras", e);
}
sExtrasFieldAccessFailed = true;
return null;
}
|
public static java.lang.String | getGroup(android.app.Notification n)
return getExtras(n).getString(EXTRA_GROUP_KEY);
|
public static boolean | getLocalOnly(android.app.Notification notif)
return getExtras(notif).getBoolean(EXTRA_LOCAL_ONLY);
|
public static java.util.ArrayList | getParcelableArrayListForActions(NotificationCompatBase.Action[] actions)
if (actions == null) {
return null;
}
ArrayList<Parcelable> parcelables = new ArrayList<Parcelable>(actions.length);
for (NotificationCompatBase.Action action : actions) {
parcelables.add(getBundleForAction(action));
}
return parcelables;
|
public static java.lang.String | getSortKey(android.app.Notification n)
return getExtras(n).getString(EXTRA_SORT_KEY);
|
public static boolean | isGroupSummary(android.app.Notification n)
return getExtras(n).getBoolean(EXTRA_GROUP_SUMMARY);
|
public static NotificationCompatBase.Action | readAction(NotificationCompatBase.Action.Factory factory, RemoteInputCompatBase.RemoteInput.Factory remoteInputFactory, int icon, java.lang.CharSequence title, android.app.PendingIntent actionIntent, android.os.Bundle extras)
RemoteInputCompatBase.RemoteInput[] remoteInputs = null;
if (extras != null) {
remoteInputs = RemoteInputCompatJellybean.fromBundleArray(
BundleUtil.getBundleArrayFromBundle(extras, EXTRA_REMOTE_INPUTS),
remoteInputFactory);
}
return factory.build(icon, title, actionIntent, extras, remoteInputs);
|
public static android.os.Bundle | writeActionAndGetExtras(Notification.Builder builder, NotificationCompatBase.Action action)
builder.addAction(action.getIcon(), action.getTitle(), action.getActionIntent());
Bundle actionExtras = new Bundle(action.getExtras());
if (action.getRemoteInputs() != null) {
actionExtras.putParcelableArray(EXTRA_REMOTE_INPUTS,
RemoteInputCompatJellybean.toBundleArray(action.getRemoteInputs()));
}
return actionExtras;
|