aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/eu/siacs/conversations/services/NotificationService.java34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java
index adfd96fe6..84ee633d6 100644
--- a/src/main/java/eu/siacs/conversations/services/NotificationService.java
+++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java
@@ -119,7 +119,7 @@ public class NotificationService {
@SuppressWarnings("deprecation")
private boolean isInteractive() {
final PowerManager pm = (PowerManager) mXmppConnectionService
- .getSystemService(Context.POWER_SERVICE);
+ .getSystemService(Context.POWER_SERVICE);
final boolean isScreenOn;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
@@ -153,7 +153,9 @@ public class NotificationService {
notifications.put(conversationUuid, mList);
}
final Account account = message.getConversation().getAccount();
- final boolean doNotify = !account.inGracePeriod() && !this.inMiniGracePeriod(account);
+ final boolean doNotify = (!(this.mIsInForeground && this.mOpenConversation == null) || !isScreenOn)
+ && !account.inGracePeriod()
+ && !this.inMiniGracePeriod(account);
updateNotification(doNotify);
if (doNotify) {
notifyPebble(message);
@@ -181,7 +183,7 @@ public class NotificationService {
private void updateNotification(final boolean notify) {
final NotificationManager notificationManager = (NotificationManager) mXmppConnectionService
- .getSystemService(Context.NOTIFICATION_SERVICE);
+ .getSystemService(Context.NOTIFICATION_SERVICE);
final SharedPreferences preferences = mXmppConnectionService.getPreferences();
final String ringtone = preferences.getString("notification_ringtone", null);
@@ -237,7 +239,7 @@ public class NotificationService {
conversation = messages.get(0).getConversation();
final String name = conversation.getName();
style.addLine(Html.fromHtml("<b>" + name + "</b> "
- + UIHelper.getMessagePreview(mXmppConnectionService,messages.get(0)).first));
+ + UIHelper.getMessagePreview(mXmppConnectionService,messages.get(0)).first));
names.append(name);
names.append(", ");
}
@@ -277,9 +279,9 @@ public class NotificationService {
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)),
+ UIHelper.getFileDescriptionString(mXmppConnectionService, message)),
createDownloadIntent(message)
- );
+ );
}
if ((message = getFirstLocationMessage(messages)) != null) {
mBuilder.addAction(R.drawable.ic_room_white_24dp,
@@ -292,16 +294,16 @@ public class NotificationService {
}
private void modifyForImage(final Builder builder, final Message message,
- final ArrayList<Message> messages, final boolean notify) {
+ final ArrayList<Message> messages, final boolean notify) {
try {
final Bitmap bitmap = mXmppConnectionService.getFileBackend()
- .getThumbnail(message, getPixel(200), false);
+ .getThumbnail(message, getPixel(288), false);
final ArrayList<Message> tmp = new ArrayList<>();
for (final Message msg : messages) {
if (msg.getType() == Message.TYPE_TEXT
&& msg.getTransferable() == null) {
tmp.add(msg);
- }
+ }
}
final BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
bigPictureStyle.bigPicture(bitmap);
@@ -320,7 +322,7 @@ public class NotificationService {
}
private void modifyForTextOnly(final Builder builder,
- final ArrayList<Message> messages, final boolean notify) {
+ final ArrayList<Message> messages, final boolean notify) {
builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getMergedBodies(messages)));
builder.setContentText(UIHelper.getMessagePreview(mXmppConnectionService,messages.get(0)).first);
if (notify) {
@@ -335,7 +337,7 @@ public class NotificationService {
&& message.getEncryption() != Message.ENCRYPTION_PGP
&& message.getFileParams().height > 0) {
return message;
- }
+ }
}
return null;
}
@@ -382,7 +384,7 @@ public class NotificationService {
private PendingIntent createContentIntent(final String conversationUuid, final String downloadMessageUuid) {
final TaskStackBuilder stackBuilder = TaskStackBuilder
- .create(mXmppConnectionService);
+ .create(mXmppConnectionService);
stackBuilder.addParentStack(ConversationActivity.class);
final Intent viewConversationIntent = new Intent(mXmppConnectionService,
@@ -436,7 +438,7 @@ public class NotificationService {
private PendingIntent createDisableAccountIntent(final Account account) {
final Intent intent = new Intent(mXmppConnectionService,XmppConnectionService.class);
intent.setAction(XmppConnectionService.ACTION_DISABLE_ACCOUNT);
- intent.putExtra("account", account.getJid().toBareJid().toString());
+ intent.putExtra("account",account.getJid().toBareJid().toString());
return PendingIntent.getService(mXmppConnectionService,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
}
@@ -470,7 +472,7 @@ public class NotificationService {
private int getPixel(final int dp) {
final DisplayMetrics metrics = mXmppConnectionService.getResources()
- .getDisplayMetrics();
+ .getDisplayMetrics();
return ((int) (dp * metrics.density));
}
@@ -480,7 +482,7 @@ public class NotificationService {
private boolean inMiniGracePeriod(final Account account) {
final int miniGrace = account.getStatus() == Account.State.ONLINE ? Config.MINI_GRACE_PERIOD
- : Config.MINI_GRACE_PERIOD * 2;
+ : Config.MINI_GRACE_PERIOD * 2;
return SystemClock.elapsedRealtime() < (this.mLastNotification + miniGrace);
}
@@ -557,4 +559,4 @@ public class NotificationService {
mBuilder.setContentIntent(resultPendingIntent);
mNotificationManager.notify(ERROR_NOTIFICATION_ID, mBuilder.build());
}
-}
+} \ No newline at end of file