diff --git a/app/src/main/java/eu/faircode/netguard/SinkholeService.java b/app/src/main/java/eu/faircode/netguard/SinkholeService.java index 8c6d770a..b5a43658 100644 --- a/app/src/main/java/eu/faircode/netguard/SinkholeService.java +++ b/app/src/main/java/eu/faircode/netguard/SinkholeService.java @@ -20,6 +20,7 @@ package eu.faircode.netguard; */ import android.app.Notification; +import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; @@ -104,7 +105,7 @@ public class SinkholeService extends VpnService { Log.i(TAG, "Executing intent=" + intent + " command=" + cmd + " vpn=" + (vpn != null)); switch (cmd) { case start: - startForeground(NOTIFY_FOREGROUND, getForegroundNotification()); + startForeground(NOTIFY_FOREGROUND, getForegroundNotification(0, 0)); if (vpn == null) { vpn = startVPN(); startDebug(vpn); @@ -163,11 +164,12 @@ public class SinkholeService extends VpnService { builder.addRoute("0:0:0:0:0:0:0:0", 0); // Add list of allowed applications - int allowed = 0; + int nAllowed = 0; + int nBlocked = 0; for (Rule rule : Rule.getRules(true, TAG, this)) { boolean blocked = (metered ? rule.other_blocked : rule.wifi_blocked); if ((!blocked || (rule.unused && interactive)) && (!metered || !(rule.roaming && last_roaming))) { - allowed++; + nAllowed++; if (debug) Log.i(TAG, "Allowing " + rule.info.packageName); try { @@ -175,9 +177,15 @@ public class SinkholeService extends VpnService { } catch (PackageManager.NameNotFoundException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } - } + } else + nBlocked++; } - Log.i(TAG, "Allowed count=" + allowed); + Log.i(TAG, "Allowed=" + nAllowed + " blocked=" + nBlocked); + + // Update notification + Notification notification = getForegroundNotification(nAllowed, nBlocked); + NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + nm.notify(NOTIFY_FOREGROUND, notification); // Build configure intent Intent configure = new Intent(this, ActivityMain.class); @@ -427,11 +435,11 @@ public class SinkholeService extends VpnService { super.onRevoke(); } - private Notification getForegroundNotification() { + private Notification getForegroundNotification(int allowed, int blocked) { Intent main = new Intent(this, ActivityMain.class); PendingIntent pi = PendingIntent.getActivity(this, 0, main, PendingIntent.FLAG_CANCEL_CURRENT); - NotificationCompat.Builder notification = new NotificationCompat.Builder(this) + NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_security_white_24dp) .setContentTitle(getString(R.string.app_name)) .setContentText(getString(R.string.msg_started)) @@ -442,7 +450,13 @@ public class SinkholeService extends VpnService { .setColor(ContextCompat.getColor(this, R.color.colorPrimary)) .setAutoCancel(true); - return notification.build(); + if (allowed > 0 || blocked > 0) { + NotificationCompat.BigTextStyle notification = new NotificationCompat.BigTextStyle(builder); + notification.bigText(getString(R.string.msg_started)); + notification.setSummaryText(getString(R.string.msg_packages, allowed, blocked)); + return notification.build(); + } else + return builder.build(); } private void showDisabledNotification() { diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 99857fd5..e176a488 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -29,6 +29,7 @@ These issues are caused by bugs in Android, or in the software provided by the m هل أنت متأكد؟ Enforcing rules + %1$d allowed, %2$d blocked التطبيق غير مُفعّل, قم بتفعيل التطبيق من الخيار أعلاه. NetGuard has been disabled, likely by using another VPN based application Action completed diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index fb5aeb3e..c404ba82 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -28,6 +28,7 @@ Das wird von Fehlern in Android oder in Software vom Hersteller verursacht. Bitt Sind Sie sicher? Regeln werden angewendet + %1$d allowed, %2$d blocked NetGuard ist deaktiviert. Verwenden Sie den Schalter, um NetGuard zu aktivieren NetGuard wurde deaktiviert. Wahrscheinlich durch Verwendung einer VPN-Anwendung Aktion abgeschlossen diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 9d4c6d9f..936fab07 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -29,6 +29,7 @@ Esto es causado por errores en Android, o por el software proporcionado por el f ¿Estás seguro? Aplicando reglas + %1$d allowed, %2$d blocked NetGuard está deshabilitado, utiliza el interruptor de arriba para habilitar a NetGuard NetGuard has been disabled, likely by using another VPN based application Acción completada diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index c94377e6..8eee5ed0 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -29,6 +29,7 @@ Ceci est causé par des bugs dans Android, ou dans le logiciel fourni par le con Etes-vous sûr ? Enforcing rules + %1$d allowed, %2$d blocked NetGuard est désactivé, utilisez le bouton ci-dessus pour activer NetGuard NetGuard has been disabled, likely by using another VPN based application Action completé diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 9861cee7..726813ca 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -30,6 +30,7 @@ Ció è causato da alcuni bug contenuti in Android, o in programmi forniti dal p Sei sicuro? Regole applicate + %1$d allowed, %2$d blocked NetGuard è disabilitata, usa lo switch per abilitarla nuovamente NetGuard è stata disabilitata, probabilmente a causa di un\'altra applicazione che usa il servizio VPN Azione completata diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 22c4ab0c..29d7a832 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -32,6 +32,7 @@ よろしいですか? Enforcing rules + %1$d allowed, %2$d blocked NetGuard は無効です。NetGuard を有効にするには上のスイッチを使用してください NetGuard has been disabled, likely by using another VPN based application 操作を完了しました diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 18a630a3..39890be2 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -29,6 +29,7 @@ These issues are caused by bugs in Android, or in the software provided by the m 계속 하시겠습니까? Enforcing rules + %1$d allowed, %2$d blocked 넷가드가 해제되어 있습니다. 상단 스위치를 사용해 넷가드를 활성화하세요. NetGuard has been disabled, likely by using another VPN based application Action completed diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index a516ac4c..a73dbc99 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -29,6 +29,7 @@ These issues are caused by bugs in Android, or in the software provided by the m Weet u het zeker? Regels worden afgedwongen + %1$d allowed, %2$d blocked NetGuard staat uit, gebruik de schakelaar boven om NetGuard aan te zetten NetGuard is uitgezet, waarschijnlijk door een andere VPN applicatie Actie uitgevoerd diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 751026c6..35b4a358 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -29,6 +29,7 @@ Problemy te są spowodowane błędami w samym Androidzie, lub oprogramowaniu dos Na pewno? Wymuś Reguły + %1$d allowed, %2$d blocked NetGuard jest wyłączony, użyj przełącznika u góry by go uruchomić NetGuard has been disabled, likely by using another VPN based application Wykonano diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index 44571427..06f6e853 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -29,6 +29,7 @@ Acest lucru este cauzat de bug-uri in Android sau in software-ul pus la dispozit Esti sigur? Limitari activate + %1$d allowed, %2$d blocked NetGuard este momentan dezactivat, foloseste comutatorul de mai sus pentru a il activa NetGuard a fost dezactivat, probabil de o alta aplicatie ce foloseste o conexiune VPN Setari aplicate diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 047e253a..9f4760da 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -27,6 +27,7 @@ Вы уверены? Определить правила + %1$d allowed, %2$d blocked NetGuard отключен, используйте переключатель выше для включения NetGuard был отключен, скорее всего, из-за применения другого VPN-подключения Действие завершено diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 730f0787..f0866f80 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -29,6 +29,7 @@ Je to spôsobené chybami v Androide alebo v softvéri poskytovanom výrobcom, p Ste si istý? Pravidlá vynútenia + %1$d allowed, %2$d blocked NetGuard je vypnutý, použite prepínač vyššie na zapnutie NetGuard NetGuard has been disabled, likely by using another VPN based application Akcia bola dokončená diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index da0cb8d9..87571864 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -25,6 +25,7 @@ Ви впевнені? Визначити правила + %1$d allowed, %2$d blocked NetGuard вимкнено, аби увімкнути, використовуй перемикач, що знаходиться вище NetGuard has been disabled, likely by using another VPN based application Дію завершено diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 31dd8a8f..c5d1d119 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -29,6 +29,7 @@ 是否确认? 规则加载中 + %1$d allowed, %2$d blocked NetGuard已被停用, 请使用上方的开关启用NetGuard NetGuard已被停用, 可能是由于您启动了另一个基于VPN的应用 操作完成 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c76624ba..99c095d7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -30,6 +30,7 @@ These issues are caused by bugs in Android, or in the software provided by the m Are you sure? Enforcing rules + %1$d allowed, %2$d blocked NetGuard is disabled, use the switch above to enable NetGuard NetGuard has been disabled, likely by using another VPN based application Action completed diff --git a/strings.sh b/strings.sh index 5029bfe9..22fc0548 100644 --- a/strings.sh +++ b/strings.sh @@ -1,12 +1,9 @@ #!/bin/bash -grep -RIl "\Handle metered WiFi networks' +grep -RIl "\%1$d allowed, %2$d blocked' -grep -RIl "\Apply mobile network rules to metered (paid, tethered) WiFi networks' #grep -RIl "\