From 5a18146cf0b83db5513f7a4fcd9deee3b371d702 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 27 Feb 2016 12:19:54 +0100 Subject: [PATCH] Replaced speed graph base line by scale --- .../eu/faircode/netguard/SinkholeService.java | 17 +++++++++++++---- app/src/main/res/layout/traffic.xml | 13 +++++++++++++ app/src/main/res/values/strings.xml | 1 - app/src/main/res/xml-v14/preferences.xml | 5 ----- app/src/main/res/xml-v21/preferences.xml | 5 ----- 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/eu/faircode/netguard/SinkholeService.java b/app/src/main/java/eu/faircode/netguard/SinkholeService.java index d0eeb8bd..d644d33e 100644 --- a/app/src/main/java/eu/faircode/netguard/SinkholeService.java +++ b/app/src/main/java/eu/faircode/netguard/SinkholeService.java @@ -660,7 +660,6 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(SinkholeService.this); long frequency = Long.parseLong(prefs.getString("stats_frequency", "1000")); long samples = Long.parseLong(prefs.getString("stats_samples", "90")); - float base = Long.parseLong(prefs.getString("stats_base", "5")) * 1000f; boolean filter = prefs.getBoolean("filter", false); boolean show_top = prefs.getBoolean("show_top", false); int loglevel = Integer.parseInt(prefs.getString("loglevel", Integer.toString(Log.WARN))); @@ -753,14 +752,19 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS canvas.drawColor(Color.TRANSPARENT); // Determine max + float max = 0; long xmax = 0; - float ymax = base * 1.5f; + float ymax = 0; for (int i = 0; i < gt.size(); i++) { long t = gt.get(i); float tx = gtx.get(i); float rx = grx.get(i); if (t > xmax) xmax = t; + if (tx > max) + max = tx; + if (rx > max) + max = rx; if (tx > ymax) ymax = tx; if (rx > ymax) @@ -789,8 +793,8 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS // Draw base line paint.setStrokeWidth(Util.dips2pixels(1, SinkholeService.this)); - paint.setColor(Color.GRAY); - float y = height - height * base / ymax; + paint.setColor(ContextCompat.getColor(SinkholeService.this, R.color.colorGrayed)); + float y = height / 2; canvas.drawLine(0, y, width, y, paint); // Draw paths @@ -812,6 +816,11 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS else remoteViews.setTextViewText(R.id.tvRx, getString(R.string.msg_mbsec, rxsec / 1000 / 1000)); + if (max < 1000 * 1000) + remoteViews.setTextViewText(R.id.tvMax, getString(R.string.msg_kbsec, max / 1000)); + else + remoteViews.setTextViewText(R.id.tvMax, getString(R.string.msg_mbsec, max / 1000 / 1000)); + // Show session/file count if (filter && loglevel <= Log.WARN) { int[] count = jni_get_stats(); diff --git a/app/src/main/res/layout/traffic.xml b/app/src/main/res/layout/traffic.xml index 3c923065..61483968 100644 --- a/app/src/main/res/layout/traffic.xml +++ b/app/src/main/res/layout/traffic.xml @@ -87,4 +87,17 @@ android:layout_alignParentStart="true" android:layout_alignParentTop="true" android:scaleType="fitXY" /> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4562723b..823fc3c5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -89,7 +89,6 @@ however it is impossible to guarantee NetGuard will work correctly on every devi Speed notification Show speed notification Show top applications - Speed baseline: %s KB/s Sample interval: %s ms Number of samples: %s s diff --git a/app/src/main/res/xml-v14/preferences.xml b/app/src/main/res/xml-v14/preferences.xml index 44c43d59..e75daddf 100644 --- a/app/src/main/res/xml-v14/preferences.xml +++ b/app/src/main/res/xml-v14/preferences.xml @@ -173,11 +173,6 @@ android:dependency="show_stats" android:key="show_top" android:title="@string/setting_stats_top" /> - -