forked from mirror/monocles_chat_clean
replace string with variables in NotificationService
This commit is contained in:
parent
38f0c26c81
commit
8cfdef8115
1 changed files with 19 additions and 15 deletions
|
@ -80,7 +80,11 @@ public class NotificationService {
|
||||||
public static final String MESSAGES_CHANNEL_ID = "messages";
|
public static final String MESSAGES_CHANNEL_ID = "messages";
|
||||||
public static final String SILENT_MESSAGES_CHANNEL_ID = "silent_messages";
|
public static final String SILENT_MESSAGES_CHANNEL_ID = "silent_messages";
|
||||||
public static final String INCOMING_CALLS_CHANNEL_ID = "incoming_calls";
|
public static final String INCOMING_CALLS_CHANNEL_ID = "incoming_calls";
|
||||||
|
public static final String ONGOING_CALLS_CHANNEL_ID = "ongoing_calls";
|
||||||
|
public static final String MISSED_CALLS_CHANNEL_ID = "missed_calls";
|
||||||
public static final String FOREGROUND_CHANNEL_ID = "foreground";
|
public static final String FOREGROUND_CHANNEL_ID = "foreground";
|
||||||
|
public static final String QUIET_HOURS_CHANNEL_ID = "quiet_hours";
|
||||||
|
public static final String DELIVERY_FAILED_CHANNEL_ID = "delivery_failed";
|
||||||
public static final String BACKUP_CHANNEL_ID = "backup";
|
public static final String BACKUP_CHANNEL_ID = "backup";
|
||||||
public static final String UPDATE_CHANNEL_ID = "appupdate";
|
public static final String UPDATE_CHANNEL_ID = "appupdate";
|
||||||
public static final String VIDEOCOMPRESSION_CHANNEL_ID = "compression";
|
public static final String VIDEOCOMPRESSION_CHANNEL_ID = "compression";
|
||||||
|
@ -185,9 +189,9 @@ public class NotificationService {
|
||||||
notificationManager.createNotificationChannel(AppUpdateChannel);
|
notificationManager.createNotificationChannel(AppUpdateChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationChannel ongoingCallsChannel = notificationManager.getNotificationChannel("ongoing_calls");
|
NotificationChannel ongoingCallsChannel = notificationManager.getNotificationChannel(ONGOING_CALLS_CHANNEL_ID);
|
||||||
if (ongoingCallsChannel == null) {
|
if (ongoingCallsChannel == null) {
|
||||||
ongoingCallsChannel = new NotificationChannel("ongoing_calls",
|
ongoingCallsChannel = new NotificationChannel(ONGOING_CALLS_CHANNEL_ID,
|
||||||
c.getString(R.string.ongoing_calls_channel_name),
|
c.getString(R.string.ongoing_calls_channel_name),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
ongoingCallsChannel.setShowBadge(false);
|
ongoingCallsChannel.setShowBadge(false);
|
||||||
|
@ -195,9 +199,9 @@ public class NotificationService {
|
||||||
notificationManager.createNotificationChannel(ongoingCallsChannel);
|
notificationManager.createNotificationChannel(ongoingCallsChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationChannel missedCallsChannel = notificationManager.getNotificationChannel("missed_calls");
|
NotificationChannel missedCallsChannel = notificationManager.getNotificationChannel(MISSED_CALLS_CHANNEL_ID);
|
||||||
if (missedCallsChannel == null) {
|
if (missedCallsChannel == null) {
|
||||||
missedCallsChannel = new NotificationChannel("missed_calls",
|
missedCallsChannel = new NotificationChannel(MISSED_CALLS_CHANNEL_ID,
|
||||||
c.getString(R.string.missed_calls_channel_name),
|
c.getString(R.string.missed_calls_channel_name),
|
||||||
NotificationManager.IMPORTANCE_HIGH);
|
NotificationManager.IMPORTANCE_HIGH);
|
||||||
missedCallsChannel.setShowBadge(true);
|
missedCallsChannel.setShowBadge(true);
|
||||||
|
@ -221,9 +225,9 @@ public class NotificationService {
|
||||||
notificationManager.createNotificationChannel(silentMessagesChannel);
|
notificationManager.createNotificationChannel(silentMessagesChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationChannel quietHoursChannel = notificationManager.getNotificationChannel("quiet_hours");
|
NotificationChannel quietHoursChannel = notificationManager.getNotificationChannel(QUIET_HOURS_CHANNEL_ID);
|
||||||
if (quietHoursChannel == null) {
|
if (quietHoursChannel == null) {
|
||||||
quietHoursChannel = new NotificationChannel("quiet_hours",
|
quietHoursChannel = new NotificationChannel(QUIET_HOURS_CHANNEL_ID,
|
||||||
c.getString(R.string.title_pref_quiet_hours),
|
c.getString(R.string.title_pref_quiet_hours),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
quietHoursChannel.setShowBadge(true);
|
quietHoursChannel.setShowBadge(true);
|
||||||
|
@ -235,9 +239,9 @@ public class NotificationService {
|
||||||
notificationManager.createNotificationChannel(quietHoursChannel);
|
notificationManager.createNotificationChannel(quietHoursChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationChannel deliveryFailedChannel = notificationManager.getNotificationChannel("delivery_failed");
|
NotificationChannel deliveryFailedChannel = notificationManager.getNotificationChannel(DELIVERY_FAILED_CHANNEL_ID);
|
||||||
if (deliveryFailedChannel == null) {
|
if (deliveryFailedChannel == null) {
|
||||||
deliveryFailedChannel = new NotificationChannel("delivery_failed",
|
deliveryFailedChannel = new NotificationChannel(DELIVERY_FAILED_CHANNEL_ID,
|
||||||
c.getString(R.string.delivery_failed_channel_name),
|
c.getString(R.string.delivery_failed_channel_name),
|
||||||
NotificationManager.IMPORTANCE_DEFAULT);
|
NotificationManager.IMPORTANCE_DEFAULT);
|
||||||
deliveryFailedChannel.setShowBadge(false);
|
deliveryFailedChannel.setShowBadge(false);
|
||||||
|
@ -526,7 +530,7 @@ public class NotificationService {
|
||||||
final int notificationId = generateRequestCode(conversation, 0) + DELIVERY_FAILED_NOTIFICATION_ID;
|
final int notificationId = generateRequestCode(conversation, 0) + DELIVERY_FAILED_NOTIFICATION_ID;
|
||||||
final int failedDeliveries = conversation.countFailedDeliveries();
|
final int failedDeliveries = conversation.countFailedDeliveries();
|
||||||
final Notification notification =
|
final Notification notification =
|
||||||
new Builder(mXmppConnectionService, "delivery_failed")
|
new Builder(mXmppConnectionService, DELIVERY_FAILED_CHANNEL_ID)
|
||||||
.setContentTitle(conversation.getName())
|
.setContentTitle(conversation.getName())
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setSmallIcon(R.drawable.ic_error_white_24dp)
|
.setSmallIcon(R.drawable.ic_error_white_24dp)
|
||||||
|
@ -534,7 +538,7 @@ public class NotificationService {
|
||||||
.setGroup("delivery_failed")
|
.setGroup("delivery_failed")
|
||||||
.setContentIntent(pendingIntent).build();
|
.setContentIntent(pendingIntent).build();
|
||||||
final Notification summaryNotification =
|
final Notification summaryNotification =
|
||||||
new Builder(mXmppConnectionService, "delivery_failed")
|
new Builder(mXmppConnectionService, DELIVERY_FAILED_CHANNEL_ID)
|
||||||
.setContentTitle(mXmppConnectionService.getString(R.string.failed_deliveries))
|
.setContentTitle(mXmppConnectionService.getString(R.string.failed_deliveries))
|
||||||
.setContentText(mXmppConnectionService.getResources().getQuantityText(R.plurals.some_messages_could_not_be_delivered, 1024))
|
.setContentText(mXmppConnectionService.getResources().getQuantityText(R.plurals.some_messages_could_not_be_delivered, 1024))
|
||||||
.setSmallIcon(R.drawable.ic_error_white_24dp)
|
.setSmallIcon(R.drawable.ic_error_white_24dp)
|
||||||
|
@ -611,7 +615,7 @@ public class NotificationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Notification getOngoingCallNotification(final AbstractJingleConnection.Id id, final Set<Media> media) {
|
public Notification getOngoingCallNotification(final AbstractJingleConnection.Id id, final Set<Media> media) {
|
||||||
final NotificationCompat.Builder builder = new NotificationCompat.Builder(mXmppConnectionService, "ongoing_calls");
|
final NotificationCompat.Builder builder = new NotificationCompat.Builder(mXmppConnectionService, ONGOING_CALLS_CHANNEL_ID);
|
||||||
if (media.contains(Media.VIDEO)) {
|
if (media.contains(Media.VIDEO)) {
|
||||||
builder.setSmallIcon(R.drawable.ic_videocam_white_24dp);
|
builder.setSmallIcon(R.drawable.ic_videocam_white_24dp);
|
||||||
builder.setContentTitle(mXmppConnectionService.getString(R.string.ongoing_video_call));
|
builder.setContentTitle(mXmppConnectionService.getString(R.string.ongoing_video_call));
|
||||||
|
@ -912,7 +916,7 @@ public class NotificationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Builder buildMissedCallsSummary(boolean publicVersion) {
|
private Builder buildMissedCallsSummary(boolean publicVersion) {
|
||||||
final Builder builder = new NotificationCompat.Builder(mXmppConnectionService, "missed_calls");
|
final Builder builder = new NotificationCompat.Builder(mXmppConnectionService, MISSED_CALLS_CHANNEL_ID);
|
||||||
int totalCalls = 0;
|
int totalCalls = 0;
|
||||||
final StringBuilder names = new StringBuilder();
|
final StringBuilder names = new StringBuilder();
|
||||||
long lastTime = 0;
|
long lastTime = 0;
|
||||||
|
@ -958,7 +962,7 @@ public class NotificationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Builder buildMissedCall(final Conversational conversation, final MissedCallsInfo info, boolean publicVersion) {
|
private Builder buildMissedCall(final Conversational conversation, final MissedCallsInfo info, boolean publicVersion) {
|
||||||
final Builder builder = new NotificationCompat.Builder(mXmppConnectionService, "missed_calls");
|
final Builder builder = new NotificationCompat.Builder(mXmppConnectionService, MISSED_CALLS_CHANNEL_ID);
|
||||||
final String title = (info.getNumberOfCalls() == 1) ? mXmppConnectionService.getString(R.string.missed_call) :
|
final String title = (info.getNumberOfCalls() == 1) ? mXmppConnectionService.getString(R.string.missed_call) :
|
||||||
mXmppConnectionService.getString(R.string.n_missed_calls, info.getNumberOfCalls());
|
mXmppConnectionService.getString(R.string.n_missed_calls, info.getNumberOfCalls());
|
||||||
builder.setContentTitle(title);
|
builder.setContentTitle(title);
|
||||||
|
@ -1008,7 +1012,7 @@ public class NotificationService {
|
||||||
for (final ArrayList<Message> messages : notifications.values()) {
|
for (final ArrayList<Message> messages : notifications.values()) {
|
||||||
if (messages.size() > 0) {
|
if (messages.size() > 0) {
|
||||||
conversation = (Conversation) messages.get(0).getConversation();
|
conversation = (Conversation) messages.get(0).getConversation();
|
||||||
mBuilder = new NotificationCompat.Builder(mXmppConnectionService, quietHours ? "quiet_hours" : (notify ? (INDIVIDUAL_NOTIFICATION_PREFIX + MESSAGES_CHANNEL_ID + '_' + conversation.getUuid()) : SILENT_MESSAGES_CHANNEL_ID));
|
mBuilder = new NotificationCompat.Builder(mXmppConnectionService, quietHours ? QUIET_HOURS_CHANNEL_ID : (notify ? (INDIVIDUAL_NOTIFICATION_PREFIX + MESSAGES_CHANNEL_ID + '_' + conversation.getUuid()) : SILENT_MESSAGES_CHANNEL_ID));
|
||||||
final String name = conversation.getName().toString();
|
final String name = conversation.getName().toString();
|
||||||
SpannableString styledString;
|
SpannableString styledString;
|
||||||
if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
|
if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
|
||||||
|
@ -1047,7 +1051,7 @@ public class NotificationService {
|
||||||
Builder mBuilder = null;
|
Builder mBuilder = null;
|
||||||
if (messages.size() >= 1) {
|
if (messages.size() >= 1) {
|
||||||
final Conversation conversation = (Conversation) messages.get(0).getConversation();
|
final Conversation conversation = (Conversation) messages.get(0).getConversation();
|
||||||
mBuilder = new NotificationCompat.Builder(mXmppConnectionService, quietHours ? "quiet_hours" : (notify ? (INDIVIDUAL_NOTIFICATION_PREFIX + MESSAGES_CHANNEL_ID + '_' + conversation.getUuid()) : SILENT_MESSAGES_CHANNEL_ID));
|
mBuilder = new NotificationCompat.Builder(mXmppConnectionService, quietHours ? QUIET_HOURS_CHANNEL_ID : (notify ? (INDIVIDUAL_NOTIFICATION_PREFIX + MESSAGES_CHANNEL_ID + '_' + conversation.getUuid()) : SILENT_MESSAGES_CHANNEL_ID));
|
||||||
mBuilder.setLargeIcon(mXmppConnectionService.getAvatarService().get(conversation, AvatarService.getSystemUiAvatarSize(mXmppConnectionService)));
|
mBuilder.setLargeIcon(mXmppConnectionService.getAvatarService().get(conversation, AvatarService.getSystemUiAvatarSize(mXmppConnectionService)));
|
||||||
mBuilder.setContentTitle(conversation.getName());
|
mBuilder.setContentTitle(conversation.getName());
|
||||||
if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
|
if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue