1
0
Fork 0
mirror of https://github.com/M66B/NetGuard.git synced 2024-12-26 09:48:46 +00:00

Replaced speed graph base line by scale

This commit is contained in:
M66B 2016-02-27 12:19:54 +01:00
parent 25043c4864
commit 5a18146cf0
5 changed files with 26 additions and 15 deletions

View file

@ -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();

View file

@ -87,4 +87,17 @@
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:scaleType="fitXY" />
<TextView
android:id="@+id/tvMax"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:paddingTop="10sp"
android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Info"
android:textColor="@color/colorGrayed"
android:textSize="10sp"
android:typeface="monospace" />
</RelativeLayout>

View file

@ -89,7 +89,6 @@ however it is impossible to guarantee NetGuard will work correctly on every devi
<string name="setting_stats_category">Speed notification</string>
<string name="setting_stats">Show speed notification</string>
<string name="setting_stats_top">Show top applications</string>
<string name="setting_stats_base">Speed baseline: %s KB/s</string>
<string name="setting_stats_frequency">Sample interval: %s ms</string>
<string name="setting_stats_samples">Number of samples: %s s</string>

View file

@ -173,11 +173,6 @@
android:dependency="show_stats"
android:key="show_top"
android:title="@string/setting_stats_top" />
<EditTextPreference
android:defaultValue="5"
android:dependency="show_stats"
android:inputType="number"
android:key="stats_base" />
<EditTextPreference
android:defaultValue="1000"
android:dependency="show_stats"

View file

@ -173,11 +173,6 @@
android:dependency="show_stats"
android:key="show_top"
android:title="@string/setting_stats_top" />
<EditTextPreference
android:defaultValue="5"
android:dependency="show_stats"
android:inputType="number"
android:key="stats_base" />
<EditTextPreference
android:defaultValue="1000"
android:dependency="show_stats"