diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-07-01 19:28:40 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-07-01 19:28:40 +0200 |
commit | f14380ca53948784d3c8397d8eee882742fc1520 (patch) | |
tree | 17107fec4c5ef0e9c7ade9da5bb07bc101a43298 /src/main/java/eu/siacs/conversations | |
parent | 419cf1f835df0e97da573aa429c9f38ecdc8ddcc (diff) |
show online status in foreground service
Diffstat (limited to 'src/main/java/eu/siacs/conversations')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/NotificationService.java | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index 47cdc4f3b..f95408ca2 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -6,6 +6,7 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.Resources; import android.graphics.Bitmap; import android.net.Uri; import android.os.Build; @@ -54,6 +55,7 @@ public class NotificationService { private Conversation mOpenConversation; private boolean mIsInForeground; private long mLastNotification; + private Resources resources; public NotificationService(final XmppConnectionService service) { this.mXmppConnectionService = service; @@ -523,10 +525,19 @@ public class NotificationService { public Notification createForegroundNotification() { final NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService); - - mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.conversations_foreground_service)); + List<Account> accounts = mXmppConnectionService.getAccounts(); + Account mAccount = accounts.get(0); + String status = ""; + if (mAccount.getStatus() == Account.State.ONLINE) { + status = mXmppConnectionService.getString(R.string.account_status_online); + } else if (mAccount.getStatus() == Account.State.CONNECTING) { + status = mXmppConnectionService.getString(R.string.account_status_connecting); + } else { + status = mXmppConnectionService.getString(R.string.account_status_offline); + } + Log.d(Config.LOGTAG, "Status: " + status); + mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.conversations_foreground_service) + " (" + status + ")"); if (Config.SHOW_CONNECTED_ACCOUNTS) { - List<Account> accounts = mXmppConnectionService.getAccounts(); int enabled = 0; int connected = 0; for (Account account : accounts) { |