use of android.support.v4.app.NotificationCompat.InboxStyle in project mobile-android by photo.
the class AbstractUploaderService method updateSuccessNotification.
private void updateSuccessNotification(NotificationCompat.Builder builder, int uploaded, int skipped, ArrayList<Photo> photos, List<PhotoUploadDetails> uploadDetails, int notificationId) {
CharSequence contentMessageTitle;
CharSequence titleText;
if (photos.size() == 1) {
PhotoUploadDetails pud = uploadDetails.get(0);
titleText = getString(pud.skipped ? R.string.notification_upload_skipped_title : R.string.notification_upload_success_title);
contentMessageTitle = getUploadTitle(pud);
} else {
contentMessageTitle = getString(R.string.notification_upload_multiple_text, uploaded, skipped);
titleText = getString(R.string.notification_upload_multiple_title);
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
// Sets a title for the Inbox style big view
inboxStyle.setBigContentTitle(getString(R.string.notification_upload_multiple_details));
// Moves events into the big view
for (int i = 0; i < uploadDetails.size(); i++) {
PhotoUploadDetails pud = uploadDetails.get(i);
String title = getUploadTitle(pud);
String line = getString(pud.skipped ? R.string.notification_upload_multiple_detail_skipped : R.string.notification_upload_multiple_detail_done, title);
inboxStyle.addLine(Html.fromHtml(line));
}
// Moves the big view style object into the notification object.
builder.setStyle(inboxStyle);
}
long when = System.currentTimeMillis();
PendingIntent contentIntent = getSuccessPendingIntent(photos);
if (contentIntent != null) {
builder.setContentIntent(contentIntent);
}
builder.setContentTitle(titleText).setContentText(contentMessageTitle).setWhen(when);
mNotificationManager.notify(notificationId, builder.build());
}
use of android.support.v4.app.NotificationCompat.InboxStyle in project mobile-android by photo.
the class AbstractUploaderService method updateErrorNotification.
private void updateErrorNotification(NotificationCompat.Builder builder, ArrayList<PhotoUpload> photos, List<PhotoUploadDetails> uploadDetails, int notificationId) {
CharSequence contentMessageTitle;
CharSequence titleText;
if (photos.size() == 1) {
PhotoUploadDetails pud = uploadDetails.get(0);
titleText = pud.photoUpload.getError() == null ? getString(R.string.notification_upload_failed_title) : getString(R.string.notification_upload_failed_title_with_reason, pud.photoUpload.getError());
contentMessageTitle = getString(R.string.notification_upload_failed_text, pud.file.getName());
} else {
contentMessageTitle = getString(R.string.notification_upload_failed_multiple_text, uploadDetails.size());
titleText = getString(R.string.notification_upload_failed_multiple_title);
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
// Sets a title for the Inbox style big view
inboxStyle.setBigContentTitle(getString(R.string.notification_upload_failed_multiple_details));
// Moves events into the big view
for (int i = 0; i < uploadDetails.size(); i++) {
PhotoUploadDetails pud = uploadDetails.get(i);
String title = pud.file.getName();
String line = getString(pud.photoUpload.getError() == null ? R.string.notification_upload_failed_multiple_detail : R.string.notification_upload_failed_multiple_detail_with_reason, title, pud.photoUpload.getError());
inboxStyle.addLine(Html.fromHtml(line));
}
// Moves the big view style object into the notification object.
builder.setStyle(inboxStyle);
}
long when = System.currentTimeMillis();
PendingIntent contentIntent = getErrorPendingIntent(photos);
if (contentIntent != null) {
builder.setContentIntent(contentIntent);
}
builder.setContentTitle(titleText).setContentText(contentMessageTitle).setWhen(when);
mNotificationManager.notify(notificationId, builder.build());
}
use of android.support.v4.app.NotificationCompat.InboxStyle in project ChatExchange by HueToYou.
the class FirebaseMessaging method sendNotification.
//this won't work until we use the API
private void sendNotification(String messageBody) {
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.mipmap.ic_launcher).setContentTitle("Event tracker").setContentText("Events received");
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
String[] events = new String[6];
events[0] = messageBody;
inboxStyle.setBigContentTitle("Event tracker details:");
for (String s : events) {
inboxStyle.addLine(s);
}
mBuilder.setStyle(inboxStyle);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(NOTIF_ID, mBuilder.build());
}
use of android.support.v4.app.NotificationCompat.InboxStyle in project qksms by moezbhatti.
the class NotificationManager method singleSender.
/**
* Creates a notification that contains several messages that are all part of the same conversation
*/
private static void singleSender(final Context context, ArrayList<MessageItem> messages, long threadId, final NotificationCompat.Builder builder, ConversationPrefsHelper conversationPrefs, final Integer privateNotifications) {
MessageItem message = messages.get(0);
Intent threadIntent = new Intent(context, MainActivity.class);
threadIntent.putExtra(MessageListActivity.ARG_THREAD_ID, threadId);
PendingIntent threadPI = PendingIntent.getActivity(context, buildRequestCode(threadId, 1), threadIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Intent readIntent = new Intent(ACTION_MARK_READ);
readIntent.putExtra("thread_id", threadId);
PendingIntent readPI = PendingIntent.getBroadcast(context, buildRequestCode(threadId, 2), readIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Intent seenIntent = new Intent(ACTION_MARK_SEEN);
PendingIntent seenPI = PendingIntent.getBroadcast(context, buildRequestCode(threadId, 4), seenIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
for (MessageItem message1 : messages) {
inboxStyle.addLine(message1.mBody);
}
String notificationTitle = message.mContact;
if (!(privateNotifications == 0))
inboxStyle = null;
if (privateNotifications == 2)
notificationTitle = "QKSMS";
int unreadMessageCount = SmsHelper.getUnreadMessageCount(context);
builder.setContentTitle(notificationTitle).setContentText(SmsHelper.getUnseenSMSCount(context, threadId) + " " + sRes.getString(R.string.new_messages)).setLargeIcon(getLargeIcon(context, Contact.get(message.mAddress, false), privateNotifications)).setContentIntent(threadPI).setNumber(unreadMessageCount).setStyle(inboxStyle).setColor(ThemeManager.getColor()).addAction(R.drawable.ic_accept, sRes.getString(R.string.read), readPI).extend(RemoteMessagingReceiver.getConversationExtender(context, message.mContact, message.mAddress, threadId)).setDeleteIntent(seenPI);
if (Build.VERSION.SDK_INT < 24) {
Intent replyIntent = new Intent(context, QKReplyActivity.class);
replyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
replyIntent.putExtra(QKReplyActivity.EXTRA_THREAD_ID, threadId);
replyIntent.putExtra(QKReplyActivity.EXTRA_SHOW_KEYBOARD, true);
PendingIntent replyPI = PendingIntent.getActivity(context, buildRequestCode(threadId, 0), replyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.addAction(R.drawable.ic_reply, sRes.getString(R.string.reply), replyPI);
} else {
builder.addAction(RemoteMessagingReceiver.getReplyAction(context, message.mAddress, threadId));
}
if (conversationPrefs.getCallButtonEnabled()) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + message.mAddress));
PendingIntent callPI = PendingIntent.getActivity(context, buildRequestCode(threadId, 3), callIntent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.addAction(R.drawable.ic_call, sRes.getString(R.string.call), callPI);
}
notify(context, (int) threadId, builder.build());
}
Aggregations