introduce config.java variable to optionally show number of connected accounts in notification
This commit is contained in:
parent
2cd43f7042
commit
65b5504e68
|
@ -16,6 +16,8 @@ public final class Config {
|
||||||
public static final String DOMAIN_LOCK = null; //only allow account creation for this domain
|
public static final String DOMAIN_LOCK = null; //only allow account creation for this domain
|
||||||
public static final boolean DISALLOW_REGISTRATION_IN_UI = false; //hide the register checkbox
|
public static final boolean DISALLOW_REGISTRATION_IN_UI = false; //hide the register checkbox
|
||||||
public static final boolean HIDE_PGP_IN_UI = false; //some more consumer focused clients might want to disable OpenPGP
|
public static final boolean HIDE_PGP_IN_UI = false; //some more consumer focused clients might want to disable OpenPGP
|
||||||
|
public static final boolean PARANOID_MODE = false; //disables ability to send unencrypted 1-on-1 chats and forces TOR
|
||||||
|
public static final boolean SHOW_CONNECTED_ACCOUNTS = true; //show number of connected accounts in foreground notification
|
||||||
|
|
||||||
public static final boolean LEGACY_NAMESPACE_HTTP_UPLOAD = false;
|
public static final boolean LEGACY_NAMESPACE_HTTP_UPLOAD = false;
|
||||||
|
|
||||||
|
|
|
@ -486,10 +486,25 @@ public class NotificationService {
|
||||||
final NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService);
|
final NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService);
|
||||||
|
|
||||||
mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.conversations_foreground_service));
|
mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.conversations_foreground_service));
|
||||||
|
if (Config.SHOW_CONNECTED_ACCOUNTS) {
|
||||||
|
List<Account> accounts = mXmppConnectionService.getAccounts();
|
||||||
|
int enabled = 0;
|
||||||
|
int connected = 0;
|
||||||
|
for (Account account : accounts) {
|
||||||
|
if (account.isOnlineAndConnected()) {
|
||||||
|
connected++;
|
||||||
|
enabled++;
|
||||||
|
} else if (!account.isOptionSet(Account.OPTION_DISABLED)) {
|
||||||
|
enabled++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mBuilder.setContentText(mXmppConnectionService.getString(R.string.connected_accounts, connected, enabled));
|
||||||
|
} else {
|
||||||
mBuilder.setContentText(mXmppConnectionService.getString(R.string.touch_to_open_conversations));
|
mBuilder.setContentText(mXmppConnectionService.getString(R.string.touch_to_open_conversations));
|
||||||
|
}
|
||||||
mBuilder.setContentIntent(createOpenConversationsIntent());
|
mBuilder.setContentIntent(createOpenConversationsIntent());
|
||||||
mBuilder.setWhen(0);
|
mBuilder.setWhen(0);
|
||||||
mBuilder.setPriority(NotificationCompat.PRIORITY_MIN);
|
mBuilder.setPriority(Config.SHOW_CONNECTED_ACCOUNTS ? NotificationCompat.PRIORITY_DEFAULT : NotificationCompat.PRIORITY_MIN);
|
||||||
final int cancelIcon;
|
final int cancelIcon;
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
mBuilder.setCategory(Notification.CATEGORY_SERVICE);
|
mBuilder.setCategory(Notification.CATEGORY_SERVICE);
|
||||||
|
@ -509,16 +524,19 @@ public class NotificationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateErrorNotification() {
|
public void updateErrorNotification() {
|
||||||
final NotificationManager mNotificationManager = (NotificationManager) mXmppConnectionService.getSystemService(Context.NOTIFICATION_SERVICE);
|
final NotificationManager notificationManager = (NotificationManager) mXmppConnectionService.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
final List<Account> errors = new ArrayList<>();
|
final List<Account> errors = new ArrayList<>();
|
||||||
for (final Account account : mXmppConnectionService.getAccounts()) {
|
for (final Account account : mXmppConnectionService.getAccounts()) {
|
||||||
if (account.hasErrorStatus()) {
|
if (account.hasErrorStatus()) {
|
||||||
errors.add(account);
|
errors.add(account);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (mXmppConnectionService.getPreferences().getBoolean("keep_foreground_service", false)) {
|
||||||
|
notificationManager.notify(FOREGROUND_NOTIFICATION_ID, createForegroundNotification());
|
||||||
|
}
|
||||||
final NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService);
|
final NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService);
|
||||||
if (errors.size() == 0) {
|
if (errors.size() == 0) {
|
||||||
mNotificationManager.cancel(ERROR_NOTIFICATION_ID);
|
notificationManager.cancel(ERROR_NOTIFICATION_ID);
|
||||||
return;
|
return;
|
||||||
} else if (errors.size() == 1) {
|
} else if (errors.size() == 1) {
|
||||||
mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.problem_connecting_to_account));
|
mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.problem_connecting_to_account));
|
||||||
|
@ -551,6 +569,6 @@ public class NotificationService {
|
||||||
final PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
|
final PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
|
||||||
mBuilder.setContentIntent(resultPendingIntent);
|
mBuilder.setContentIntent(resultPendingIntent);
|
||||||
mNotificationManager.notify(ERROR_NOTIFICATION_ID, mBuilder.build());
|
notificationManager.notify(ERROR_NOTIFICATION_ID, mBuilder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -548,4 +548,5 @@
|
||||||
<string name="hostname_or_onion">Server- or .onion-Address</string>
|
<string name="hostname_or_onion">Server- or .onion-Address</string>
|
||||||
<string name="not_a_valid_port">This is not a valid port number</string>
|
<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="not_valid_hostname">This is not a valid hostname</string>
|
||||||
|
<string name="connected_accounts">%1$d of %2$d accounts connected</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue