aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/eu/siacs/conversations/services/NotificationService.java39
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java7
-rw-r--r--src/main/java/eu/siacs/conversations/utils/UIHelper.java42
-rw-r--r--src/main/res/drawable-hdpi/ic_stat_alert_warning.pngbin0 -> 757 bytes
-rw-r--r--src/main/res/drawable-mdpi/ic_stat_alert_warning.pngbin0 -> 425 bytes
-rw-r--r--src/main/res/drawable-xhdpi/ic_stat_alert_warning.pngbin0 -> 1175 bytes
-rw-r--r--src/main/res/drawable-xxhdpi/ic_stat_alert_warning.pngbin0 -> 2276 bytes
7 files changed, 42 insertions, 46 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java
index c23a95b9..f649f9d4 100644
--- a/src/main/java/eu/siacs/conversations/services/NotificationService.java
+++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java
@@ -20,6 +20,7 @@ import android.util.DisplayMetrics;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -31,6 +32,7 @@ import eu.siacs.conversations.entities.Downloadable;
import eu.siacs.conversations.entities.DownloadableFile;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.ui.ConversationActivity;
+import eu.siacs.conversations.ui.ManageAccountActivity;
public class NotificationService {
@@ -40,6 +42,8 @@ public class NotificationService {
public static int NOTIFICATION_ID = 0x2342;
public static int FOREGROUND_NOTIFICATION_ID = 0x8899;
+ public static int ERROR_NOTIFICATION_ID = 0x5678;
+
private Conversation mOpenConversation;
private boolean mIsInForeground;
private long mLastNotification;
@@ -380,4 +384,39 @@ public class NotificationService {
mBuilder.setPriority(NotificationCompat.PRIORITY_MIN);
return mBuilder.build();
}
+
+ public void updateErrorNotification() {
+ NotificationManager mNotificationManager = (NotificationManager) mXmppConnectionService.getSystemService(Context.NOTIFICATION_SERVICE);
+ List<Account> errors = new ArrayList<>();
+ for (Account account : mXmppConnectionService.getAccounts()) {
+ if (account.hasErrorStatus()) {
+ errors.add(account);
+ }
+ }
+ NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService);
+ if (errors.size() == 0) {
+ mNotificationManager.cancel(ERROR_NOTIFICATION_ID);
+ return;
+ } else if (errors.size() == 1) {
+ mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.problem_connecting_to_account));
+ mBuilder.setContentText(errors.get(0).getJid().toBareJid().toString());
+ } else {
+ mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.problem_connecting_to_accounts));
+ mBuilder.setContentText(mXmppConnectionService.getString(R.string.touch_to_fix));
+ }
+ mBuilder.setOngoing(true);
+ mBuilder.setLights(0xffffffff, 2000, 4000);
+ mBuilder.setSmallIcon(R.drawable.ic_stat_alert_warning);
+ TaskStackBuilder stackBuilder = TaskStackBuilder.create(mXmppConnectionService);
+ stackBuilder.addParentStack(ConversationActivity.class);
+
+ Intent manageAccountsIntent = new Intent(mXmppConnectionService,ManageAccountActivity.class);
+ stackBuilder.addNextIntent(manageAccountsIntent);
+
+ PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
+
+ mBuilder.setContentIntent(resultPendingIntent);
+ Notification notification = mBuilder.build();
+ mNotificationManager.notify(ERROR_NOTIFICATION_ID, notification);
+ }
}
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 2ff29b19..d181fac3 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -204,8 +204,7 @@ public class XmppConnectionService extends Service {
scheduleWakeupCall((int) (next * 1.2), false);
}
}
- UIHelper.showErrorNotification(getApplicationContext(),
- getAccounts());
+ getNotificationService().updateErrorNotification();
}
};
private Integer accountChangedListenerCount = 0;
@@ -1071,7 +1070,7 @@ public class XmppConnectionService extends Service {
databaseBackend.updateAccount(account);
reconnectAccount(account, false);
updateAccountUi();
- UIHelper.showErrorNotification(getApplicationContext(), getAccounts());
+ getNotificationService().updateErrorNotification();
}
public void deleteAccount(Account account) {
@@ -1092,7 +1091,7 @@ public class XmppConnectionService extends Service {
databaseBackend.deleteAccount(account);
this.accounts.remove(account);
updateAccountUi();
- UIHelper.showErrorNotification(getApplicationContext(), getAccounts());
+ getNotificationService().updateErrorNotification();
}
}
diff --git a/src/main/java/eu/siacs/conversations/utils/UIHelper.java b/src/main/java/eu/siacs/conversations/utils/UIHelper.java
index 0d43450d..ed6efd06 100644
--- a/src/main/java/eu/siacs/conversations/utils/UIHelper.java
+++ b/src/main/java/eu/siacs/conversations/utils/UIHelper.java
@@ -106,48 +106,6 @@ public class UIHelper {
}
}
- public static void showErrorNotification(Context context,
- List<Account> accounts) {
- NotificationManager mNotificationManager = (NotificationManager) context
- .getSystemService(Context.NOTIFICATION_SERVICE);
- List<Account> accountsWproblems = new ArrayList<>();
- for (Account account : accounts) {
- if (account.hasErrorStatus()) {
- accountsWproblems.add(account);
- }
- }
- NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
- context);
- if (accountsWproblems.size() == 0) {
- mNotificationManager.cancel(1111);
- return;
- } else if (accountsWproblems.size() == 1) {
- mBuilder.setContentTitle(context
- .getString(R.string.problem_connecting_to_account));
- mBuilder.setContentText(accountsWproblems.get(0).getJid().toBareJid().toString());
- } else {
- mBuilder.setContentTitle(context
- .getString(R.string.problem_connecting_to_accounts));
- mBuilder.setContentText(context.getString(R.string.touch_to_fix));
- }
- mBuilder.setOngoing(true);
- mBuilder.setLights(0xffffffff, 2000, 4000);
- mBuilder.setSmallIcon(R.drawable.ic_notification);
- TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
- stackBuilder.addParentStack(ConversationActivity.class);
-
- Intent manageAccountsIntent = new Intent(context,
- ManageAccountActivity.class);
- stackBuilder.addNextIntent(manageAccountsIntent);
-
- PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
- PendingIntent.FLAG_UPDATE_CURRENT);
-
- mBuilder.setContentIntent(resultPendingIntent);
- Notification notification = mBuilder.build();
- mNotificationManager.notify(1111, notification);
- }
-
private final static class EmoticonPattern {
Pattern pattern;
String replacement;
diff --git a/src/main/res/drawable-hdpi/ic_stat_alert_warning.png b/src/main/res/drawable-hdpi/ic_stat_alert_warning.png
new file mode 100644
index 00000000..a1f9917f
--- /dev/null
+++ b/src/main/res/drawable-hdpi/ic_stat_alert_warning.png
Binary files differ
diff --git a/src/main/res/drawable-mdpi/ic_stat_alert_warning.png b/src/main/res/drawable-mdpi/ic_stat_alert_warning.png
new file mode 100644
index 00000000..2e62841a
--- /dev/null
+++ b/src/main/res/drawable-mdpi/ic_stat_alert_warning.png
Binary files differ
diff --git a/src/main/res/drawable-xhdpi/ic_stat_alert_warning.png b/src/main/res/drawable-xhdpi/ic_stat_alert_warning.png
new file mode 100644
index 00000000..952a857f
--- /dev/null
+++ b/src/main/res/drawable-xhdpi/ic_stat_alert_warning.png
Binary files differ
diff --git a/src/main/res/drawable-xxhdpi/ic_stat_alert_warning.png b/src/main/res/drawable-xxhdpi/ic_stat_alert_warning.png
new file mode 100644
index 00000000..eb5dc029
--- /dev/null
+++ b/src/main/res/drawable-xxhdpi/ic_stat_alert_warning.png
Binary files differ