diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/HotspotService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/HotspotService.kt index 6bffdbfb..f555e7bb 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/HotspotService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/HotspotService.kt @@ -153,17 +153,21 @@ class HotspotService : Service(), WifiP2pManager.ChannelListener { status = Status.ACTIVE showNotification(group) } - private fun showNotification(group: WifiP2pGroup? = null) = startForeground(1, - NotificationCompat.Builder(this@HotspotService, CHANNEL) - .setWhen(0) - .setColor(ContextCompat.getColor(this@HotspotService, R.color.colorPrimary)) - .setContentTitle(group?.networkName) - .setContentText(group?.passphrase) - .setSubText("${group?.clientList?.size ?: 0} connected device(s)") - .setSmallIcon(R.drawable.ic_device_wifi_tethering) - .setContentIntent(PendingIntent.getActivity(this, 0, - Intent(this, MainActivity::class.java), PendingIntent.FLAG_UPDATE_CURRENT)) - .build()) + private fun showNotification(group: WifiP2pGroup? = null) { + val deviceCount = group?.clientList?.size ?: 0 + startForeground(1, + NotificationCompat.Builder(this@HotspotService, CHANNEL) + .setWhen(0) + .setColor(ContextCompat.getColor(this@HotspotService, R.color.colorPrimary)) + .setContentTitle(group?.networkName) + .setContentText(group?.passphrase) + .setSubText(resources.getQuantityString(R.plurals.notification_connected_devices, + deviceCount, deviceCount)) + .setSmallIcon(R.drawable.ic_device_wifi_tethering) + .setContentIntent(PendingIntent.getActivity(this, 0, + Intent(this, MainActivity::class.java), PendingIntent.FLAG_UPDATE_CURRENT)) + .build()) + } private fun onGroupCreated(info: WifiP2pInfo, group: WifiP2pGroup) { val owner = info.groupOwnerAddress diff --git a/mobile/src/main/res/values/strings.xml b/mobile/src/main/res/values/strings.xml index ce3658d4..6a5b8c98 100644 --- a/mobile/src/main/res/values/strings.xml +++ b/mobile/src/main/res/values/strings.xml @@ -1,4 +1,8 @@ VPN Hotspot Settings + + 1 connected device + %d connected devices +