Commit 7a9e3b8a authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Only set the text when the servers have already been loaded

parent ca49654c
......@@ -561,44 +561,50 @@ class DnsVpnService : VpnService(), Runnable {
}
private fun setNotificationText() {
val primaryServer: String
val secondaryServer: String?
if (serverConfig.httpsConfiguration != null) {
notificationBuilder.setContentTitle(getString(R.string.notification_main_title_https))
primaryServer = serverConfig.httpsConfiguration!![0].urlCreator.address.getUrl(true)
secondaryServer =
serverConfig.httpsConfiguration!!.getOrNull(1)?.urlCreator?.address?.getUrl(true)
} else {
notificationBuilder.setContentTitle(getString(R.string.notification_main_title_tls))
primaryServer = serverConfig.tlsConfiguration!![0].formatToString()
secondaryServer = serverConfig.tlsConfiguration!!.getOrNull(1)?.formatToString()
}
val text =
when {
getPreferences().simpleNotification -> getString(R.string.notification_simple_text, serverConfig.name)
secondaryServer != null -> getString(
if (getPreferences().isBypassBlacklist) R.string.notification_main_text_with_secondary else R.string.notification_main_text_with_secondary_whitelist,
primaryServer,
secondaryServer,
packageBypassAmount,
dnsProxy?.cache?.livingCachedEntries() ?: 0
)
else -> getString(
if (getPreferences().isBypassBlacklist) R.string.notification_main_text else R.string.notification_main_text_whitelist,
primaryServer,
packageBypassAmount,
dnsProxy?.cache?.livingCachedEntries() ?: 0
)
if (this::serverConfig.isInitialized) {
val primaryServer: String
val secondaryServer: String?
if (serverConfig.httpsConfiguration != null) {
notificationBuilder.setContentTitle(getString(R.string.notification_main_title_https))
primaryServer = serverConfig.httpsConfiguration!![0].urlCreator.address.getUrl(true)
secondaryServer =
serverConfig.httpsConfiguration!!.getOrNull(1)
?.urlCreator?.address?.getUrl(true)
} else {
notificationBuilder.setContentTitle(getString(R.string.notification_main_title_tls))
primaryServer = serverConfig.tlsConfiguration!![0].formatToString()
secondaryServer = serverConfig.tlsConfiguration!!.getOrNull(1)?.formatToString()
}
if(simpleNotification) {
notificationBuilder.setStyle(null)
notificationBuilder.setContentText(text)
} else {
notificationBuilder.setStyle(
NotificationCompat.BigTextStyle(notificationBuilder).bigText(
text
val text =
when {
getPreferences().simpleNotification -> getString(
R.string.notification_simple_text,
serverConfig.name
)
secondaryServer != null -> getString(
if (getPreferences().isBypassBlacklist) R.string.notification_main_text_with_secondary else R.string.notification_main_text_with_secondary_whitelist,
primaryServer,
secondaryServer,
packageBypassAmount,
dnsProxy?.cache?.livingCachedEntries() ?: 0
)
else -> getString(
if (getPreferences().isBypassBlacklist) R.string.notification_main_text else R.string.notification_main_text_whitelist,
primaryServer,
packageBypassAmount,
dnsProxy?.cache?.livingCachedEntries() ?: 0
)
}
if (simpleNotification) {
notificationBuilder.setStyle(null)
notificationBuilder.setContentText(text)
} else {
notificationBuilder.setStyle(
NotificationCompat.BigTextStyle(notificationBuilder).bigText(
text
)
)
)
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment