diff --git a/app/src/main/java/eu/faircode/netguard/Receiver.java b/app/src/main/java/eu/faircode/netguard/Receiver.java index 5d13b142..6af59bfc 100644 --- a/app/src/main/java/eu/faircode/netguard/Receiver.java +++ b/app/src/main/java/eu/faircode/netguard/Receiver.java @@ -127,12 +127,17 @@ public class Receiver extends BroadcastReceiver { context.getTheme().resolveAttribute(R.attr.colorPrimary, tv, true); NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_security_white_24dp) - .setContentTitle(context.getString(R.string.app_name)) - .setContentText(context.getString(R.string.msg_installed, name)) .setContentIntent(pi) .setColor(tv.data) .setAutoCancel(true); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) + builder.setContentTitle(name) + .setContentText(context.getString(R.string.msg_installed_n)); + else + builder.setContentTitle(context.getString(R.string.app_name)) + .setContentText(context.getString(R.string.msg_installed, name)); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setCategory(Notification.CATEGORY_STATUS) .setVisibility(Notification.VISIBILITY_SECRET); @@ -178,7 +183,10 @@ public class Receiver extends BroadcastReceiver { NotificationManagerCompat.from(context).notify(uid, builder.build()); else { NotificationCompat.BigTextStyle expanded = new NotificationCompat.BigTextStyle(builder); - expanded.bigText(context.getString(R.string.msg_installed, name)); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) + expanded.bigText(context.getString(R.string.msg_installed_n)); + else + expanded.bigText(context.getString(R.string.msg_installed, name)); expanded.setSummaryText(context.getString(R.string.title_internet)); NotificationManagerCompat.from(context).notify(uid, expanded.build()); } diff --git a/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java b/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java index 405bbd19..b77de920 100644 --- a/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java +++ b/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java @@ -2097,13 +2097,18 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_cloud_upload_white_24dp) .setGroup("AccessAttempt") - .setContentTitle(getString(R.string.app_name)) - .setContentText(getString(R.string.msg_access, name)) .setContentIntent(pi) .setColor(colorOff) .setOngoing(false) .setAutoCancel(true); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) + builder.setContentTitle(name) + .setContentText(getString(R.string.msg_access_n)); + else + builder.setContentTitle(getString(R.string.app_name)) + .setContentText(getString(R.string.msg_access, name)); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setCategory(Notification.CATEGORY_STATUS) .setVisibility(Notification.VISIBILITY_SECRET); @@ -2112,11 +2117,15 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS DateFormat df = new SimpleDateFormat("dd HH:mm"); NotificationCompat.InboxStyle notification = new NotificationCompat.InboxStyle(builder); - String sname = getString(R.string.msg_access, name); - int pos = sname.indexOf(name); - Spannable sp = new SpannableString(sname); - sp.setSpan(new StyleSpan(Typeface.BOLD), pos, pos + name.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - notification.addLine(sp); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) + notification.addLine(getString(R.string.msg_access_n)); + else { + String sname = getString(R.string.msg_access, name); + int pos = sname.indexOf(name); + Spannable sp = new SpannableString(sname); + sp.setSpan(new StyleSpan(Typeface.BOLD), pos, pos + name.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + notification.addLine(sp); + } Cursor cursor = DatabaseHelper.getInstance(ServiceSinkhole.this).getAccessUnset(uid, 7); int colDAddr = cursor.getColumnIndex("daddr"); @@ -2136,13 +2145,13 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS int allowed = cursor.getInt(colAllowed); if (allowed >= 0) { - pos = sb.indexOf(daddr); - sp = new SpannableString(sb); + int pos = sb.indexOf(daddr); + Spannable sp = new SpannableString(sb); ForegroundColorSpan fgsp = new ForegroundColorSpan(allowed > 0 ? colorOn : colorOff); sp.setSpan(fgsp, pos, pos + daddr.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - } - - notification.addLine(sp); + notification.addLine(sp); + } else + notification.addLine(sb); } cursor.close(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3adee86a..dc5db80a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -146,13 +146,15 @@ however it is impossible to guarantee NetGuard will work correctly on every devi NetGuard is disabled, use the switch above to enable NetGuard NetGuard has been disabled, likely by using another VPN based application \'%1$s\' installed + Has been installed %1$s attempted internet access + Attempted internet access Action completed NetGuard uses a local VPN to filter internet traffic. For this reason, please allow a VPN connection in the next dialog. Your internet traffic is not being sent to a remote VPN server. - NetGuard could not be started automatically likely due to a bug in your Android version - An unexpected error has occurred: %s + NetGuard could not start automatically. This is likely because of a bug in your Android version. + An unexpected error has occurred: \'%s\' Try NetGuard By donating you agree to the terms & conditions If you cannot press OK in the next dialog, another (screen dimming) application is likely manipulating the screen.