From 4004979cb06f5000a05cb6f3394bd5216a6a71fa Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 9 Dec 2015 20:05:25 +0100 Subject: [PATCH] Color coded network speed --- app/build.gradle | 2 +- .../eu/faircode/netguard/SinkholeService.java | 13 +++--- app/src/main/res/layout/traffic.xml | 41 +++++++++++++++++-- app/src/main/res/values/strings.xml | 2 + 4 files changed, 48 insertions(+), 10 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f8276616..9db7ca43 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,7 +9,7 @@ model { applicationId = "eu.faircode.netguard" minSdkVersion.apiLevel = 21 targetSdkVersion.apiLevel = 23 - versionCode = 2015120904 + versionCode = 2015120905 versionName = "0.55" archivesBaseName = "NetGuard-v$versionName-$versionCode" } diff --git a/app/src/main/java/eu/faircode/netguard/SinkholeService.java b/app/src/main/java/eu/faircode/netguard/SinkholeService.java index c102d834..f4b80b68 100644 --- a/app/src/main/java/eu/faircode/netguard/SinkholeService.java +++ b/app/src/main/java/eu/faircode/netguard/SinkholeService.java @@ -371,12 +371,15 @@ public class SinkholeService extends VpnService { // Update remote view RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.traffic); remoteViews.setImageViewBitmap(R.id.ivTraffic, bitmap); - if (txsec < 1024 && rxsec < 1024) - remoteViews.setTextViewText(R.id.tvTraffic, String.format("▲ %.0f ▼ %.0f B/sec", txsec, rxsec)); - else if (txsec < 1024 * 1024 && rxsec < 1024 * 1024) - remoteViews.setTextViewText(R.id.tvTraffic, String.format("▲ %.1f ▼ %.1f KiB/sec", txsec / 1024, rxsec / 1024)); + if (txsec < 1000 * 1000) + remoteViews.setTextViewText(R.id.tvTx, getString(R.string.msg_kbsec, txsec / 1000)); else - remoteViews.setTextViewText(R.id.tvTraffic, String.format("▲ %.1f ▼ %.1f MiB/sec", txsec / 1024 / 1024, rxsec / 1024 / 1024)); + remoteViews.setTextViewText(R.id.tvTx, getString(R.string.msg_mbsec, txsec / 1000 / 1000)); + + if (rxsec < 1000 * 1000) + remoteViews.setTextViewText(R.id.tvRx, getString(R.string.msg_kbsec, rxsec / 1000)); + else + remoteViews.setTextViewText(R.id.tvRx, getString(R.string.msg_mbsec, rxsec / 1000 / 1000)); // Show notification Intent main = new Intent(SinkholeService.this, ActivityMain.class); diff --git a/app/src/main/res/layout/traffic.xml b/app/src/main/res/layout/traffic.xml index 3859e258..7ee00de0 100644 --- a/app/src/main/res/layout/traffic.xml +++ b/app/src/main/res/layout/traffic.xml @@ -12,11 +12,44 @@ android:layout_alignParentTop="true" android:scaleType="fitXY" /> - + android:gravity="center_horizontal"> + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fed8f687..f9fe1987 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -65,6 +65,8 @@ Since NetGuard has no internet permission, you know your internet traffic is not 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. %1$.1f/%2$.1f KiB since %3$s + %7.3f KB/s + %7.3f MB/s All Allow Wi-Fi when screen is on