diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2015-12-02 12:54:55 +0100 |
---|---|---|
committer | Christian S <christian@pix-art.de> | 2015-12-04 20:13:12 +0100 |
commit | 170162d9dde6fac6db3f2cf261da9b1b2c851da6 (patch) | |
tree | 5ad67093e5e496b60cd156157e30cac1dd93cecf /src/main | |
parent | e9c184fbce5e3bfaa25a0ecca6d1942014e4d977 (diff) |
hide message content in notifications in paranoia mode
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/NotificationService.java | 50 | ||||
-rw-r--r-- | src/main/res/values/strings.xml | 4 |
2 files changed, 34 insertions, 20 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index 2d7b8e27d..744ca1506 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -234,8 +234,13 @@ public class NotificationService { if (messages.size() > 0) { conversation = messages.get(0).getConversation(); final String name = conversation.getName(); - style.addLine(Html.fromHtml("<b>" + name + "</b> " - + UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first)); + if (Config.PARANOID_MODE) { + int count = messages.size(); + style.addLine(Html.fromHtml("<b>"+name+"</b> "+mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages,count,count))); + } else { + style.addLine(Html.fromHtml("<b>" + name + "</b> " + + UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first)); + } names.append(name); names.append(", "); } @@ -264,25 +269,30 @@ public class NotificationService { mBuilder.setLargeIcon(mXmppConnectionService.getAvatarService() .get(conversation, getPixel(64))); mBuilder.setContentTitle(conversation.getName()); - Message message; - if ((message = getImage(messages)) != null) { - modifyForImage(mBuilder, message, messages, notify); + if (Config.PARANOID_MODE) { + int count = messages.size(); + mBuilder.setContentText(mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages,count,count)); } else { - modifyForTextOnly(mBuilder, messages, notify); - } - if ((message = getFirstDownloadableMessage(messages)) != null) { - mBuilder.addAction( - Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? - R.drawable.ic_file_download_white_24dp : R.drawable.ic_action_download, - mXmppConnectionService.getResources().getString(R.string.download_x_file, - UIHelper.getFileDescriptionString(mXmppConnectionService, message)), - createDownloadIntent(message) - ); - } - if ((message = getFirstLocationMessage(messages)) != null) { - mBuilder.addAction(R.drawable.ic_room_white_24dp, - mXmppConnectionService.getString(R.string.show_location), - createShowLocationIntent(message)); + Message message; + if ((message = getImage(messages)) != null) { + modifyForImage(mBuilder, message, messages, notify); + } else { + modifyForTextOnly(mBuilder, messages, notify); + } + if ((message = getFirstDownloadableMessage(messages)) != null) { + mBuilder.addAction( + Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? + R.drawable.ic_file_download_white_24dp : R.drawable.ic_action_download, + mXmppConnectionService.getResources().getString(R.string.download_x_file, + UIHelper.getFileDescriptionString(mXmppConnectionService, message)), + createDownloadIntent(message) + ); + } + if ((message = getFirstLocationMessage(messages)) != null) { + mBuilder.addAction(R.drawable.ic_room_white_24dp, + mXmppConnectionService.getString(R.string.show_location), + createShowLocationIntent(message)); + } } mBuilder.setContentIntent(createContentIntent(conversation)); } diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 27cf34dad..644c805c0 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -569,4 +569,8 @@ <string name="not_a_valid_port">This is not a valid port number</string> <string name="not_valid_hostname">This is not a valid hostname</string> <string name="connected_accounts">%1$d of %2$d accounts connected</string> + <plurals name="x_messages"> + <item quantity="one">%d message</item> + <item quantity="other">%d messages</item> + </plurals> </resources> |