use of android.support.v4.app.NotificationCompat.Builder in project meatspace-android by RomainPiel.
the class ChatService method showForeground.
/**
* place service in foreground or update its notification
*/
private void showForeground() {
Intent openIntent = new Intent(this, MainActivity.class);
openIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pi = PendingIntent.getActivity(this, 0, openIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
String description;
if (appInBackground && missedMessageCount > 0) {
description = getResources().getQuantityString(R.plurals.service_chat_running_description_missed_messages_, missedMessageCount, missedMessageCount);
if (PreferencesHelper.areNotificationsEnabled(this)) {
String lastMessage = chatList.get().last().getValue().getMessage();
builder.setTicker(lastMessage);
}
} else {
description = getString(R.string.service_chat_running_description);
}
RemoteViews notificationView = new RemoteViews(this.getPackageName(), R.layout.notification_template);
notificationView.setTextViewText(R.id.notification_template_title, getString(R.string.service_chat_running));
notificationView.setTextViewText(R.id.notification_template_text2, description);
notificationView.setOnClickPendingIntent(R.id.notification_template_cancel, PendingIntent.getBroadcast(this, 0, new Intent(Constants.FILTER_CHAT_CLOSE), 0));
Notification notification = builder.setContentIntent(pi).setSmallIcon(R.drawable.ic_stat_meatspace).setContent(notificationView).build();
notification.flags |= Notification.FLAG_NO_CLEAR;
startForeground(Constants.NOTIFICICATION_ID_CHAT, notification);
}
use of android.support.v4.app.NotificationCompat.Builder in project k-9 by k9mail.
the class AuthenticationErrorNotifications method showAuthenticationErrorNotification.
public void showAuthenticationErrorNotification(Account account, boolean incoming) {
int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming);
Context context = controller.getContext();
PendingIntent editServerSettingsPendingIntent = createContentIntent(context, account, incoming);
String title = context.getString(R.string.notification_authentication_error_title);
String text = context.getString(R.string.notification_authentication_error_text, account.getDescription());
NotificationCompat.Builder builder = controller.createNotificationBuilder().setSmallIcon(R.drawable.notification_icon_warning).setWhen(System.currentTimeMillis()).setAutoCancel(true).setTicker(title).setContentTitle(title).setContentText(text).setContentIntent(editServerSettingsPendingIntent).setStyle(new BigTextStyle().bigText(text)).setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setCategory(NotificationCompat.CATEGORY_ERROR);
controller.configureNotification(builder, null, null, NOTIFICATION_LED_FAILURE_COLOR, NOTIFICATION_LED_BLINK_FAST, true);
getNotificationManager().notify(notificationId, builder.build());
}
use of android.support.v4.app.NotificationCompat.Builder in project k-9 by k9mail.
the class CertificateErrorNotifications method showCertificateErrorNotification.
public void showCertificateErrorNotification(Account account, boolean incoming) {
int notificationId = NotificationIds.getCertificateErrorNotificationId(account, incoming);
Context context = controller.getContext();
PendingIntent editServerSettingsPendingIntent = createContentIntent(context, account, incoming);
String title = context.getString(R.string.notification_certificate_error_title, account.getDescription());
String text = context.getString(R.string.notification_certificate_error_text);
NotificationCompat.Builder builder = controller.createNotificationBuilder().setSmallIcon(getCertificateErrorNotificationIcon()).setWhen(System.currentTimeMillis()).setAutoCancel(true).setTicker(title).setContentTitle(title).setContentText(text).setContentIntent(editServerSettingsPendingIntent).setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setCategory(NotificationCompat.CATEGORY_ERROR);
controller.configureNotification(builder, null, null, NOTIFICATION_LED_FAILURE_COLOR, NOTIFICATION_LED_BLINK_FAST, true);
getNotificationManager().notify(notificationId, builder.build());
}
use of android.support.v4.app.NotificationCompat.Builder in project k-9 by k9mail.
the class DeviceNotifications method buildSummaryNotification.
public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) {
int unreadMessageCount = notificationData.getUnreadMessageCount();
NotificationCompat.Builder builder;
if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) {
builder = createSimpleSummaryNotification(account, unreadMessageCount);
} else if (notificationData.isSingleMessageNotification()) {
NotificationHolder holder = notificationData.getHolderForLatestNotification();
builder = createBigTextStyleSummaryNotification(account, holder);
} else {
builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount);
}
if (notificationData.containsStarredMessages()) {
builder.setPriority(NotificationCompat.PRIORITY_HIGH);
}
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent(account, notificationId);
builder.setDeleteIntent(deletePendingIntent);
lockScreenNotification.configureLockScreenNotification(builder, notificationData);
boolean ringAndVibrate = false;
if (!silent && !account.isRingNotified()) {
account.setRingNotified(true);
ringAndVibrate = true;
}
NotificationSetting notificationSetting = account.getNotificationSetting();
controller.configureNotification(builder, (notificationSetting.shouldRing()) ? notificationSetting.getRingtone() : null, (notificationSetting.shouldVibrate()) ? notificationSetting.getVibration() : null, (notificationSetting.isLed()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate);
return builder.build();
}
use of android.support.v4.app.NotificationCompat.Builder in project k-9 by k9mail.
the class LockScreenNotification method createPublicNotificationWithSenderList.
private Notification createPublicNotificationWithSenderList(NotificationData notificationData) {
Builder builder = createPublicNotification(notificationData);
int newMessages = notificationData.getNewMessagesCount();
if (newMessages == 1) {
NotificationHolder holder = notificationData.getHolderForLatestNotification();
builder.setContentText(holder.content.sender);
} else {
List<NotificationContent> contents = notificationData.getContentForSummaryNotification();
String senderList = createCommaSeparatedListOfSenders(contents);
builder.setContentText(senderList);
}
return builder.build();
}
Aggregations