summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2017-05-29 12:08:01 +0200
committerArne Schwabe <arne@rfc2549.org>2017-05-29 12:08:01 +0200
commit84a4743c6b294a53053abddd748b2c3de08eb91d (patch)
treef4cc67e73e4e3874a02250360fcbf298f2c12bdd /main
parent667f43958389d46c06b98632b69619c15b24c249 (diff)
Further graph fine-tuning
Diffstat (limited to 'main')
-rw-r--r--main/src/main/java/de/blinkt/openvpn/fragments/GraphFragment.java50
-rwxr-xr-xmain/src/main/res/values/strings.xml2
2 files changed, 31 insertions, 21 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/GraphFragment.java b/main/src/main/java/de/blinkt/openvpn/fragments/GraphFragment.java
index c3a63fa2..e9e6fa47 100644
--- a/main/src/main/java/de/blinkt/openvpn/fragments/GraphFragment.java
+++ b/main/src/main/java/de/blinkt/openvpn/fragments/GraphFragment.java
@@ -53,8 +53,9 @@ public class GraphFragment extends Fragment implements VpnStatus.ByteCountListen
private ListView mListView;
private ChartDataAdapter mChartAdapter;
- private int mColorIn;
- private int mColorOut;
+ private int mColourIn;
+ private int mColourOut;
+ private int mColourPoint;
private long firstTs;
private TextView mSpeedStatus;
@@ -83,9 +84,9 @@ public class GraphFragment extends Fragment implements VpnStatus.ByteCountListen
mChartAdapter = new ChartDataAdapter(getActivity(), charts);
mListView.setAdapter(mChartAdapter);
- mColorIn = getActivity().getResources().getColor(R.color.dataIn);
- mColorOut = getActivity().getResources().getColor(R.color.dataOut);
-
+ mColourIn = getActivity().getResources().getColor(R.color.dataIn);
+ mColourOut = getActivity().getResources().getColor(R.color.dataOut);
+ mColourPoint = getActivity().getResources().getColor(android.R.color.black);
logScaleView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
@@ -228,11 +229,11 @@ public class GraphFragment extends Fragment implements VpnStatus.ByteCountListen
@Override
public String getFormattedValue(float value, AxisBase axis) {
if (mLogScale && value < 2.1f)
- return "< 100\u2009bit";
+ return "< 100\u2009bit/s";
if (mLogScale)
value = (float) Math.pow(10, value)/8;
- return humanReadableByteCount((long) value, true);
+ return humanReadableByteCount((long) value, true) + "/s";
}
});
@@ -302,6 +303,11 @@ public class GraphFragment extends Fragment implements VpnStatus.ByteCountListen
long lastBytecountOut = list.peek().out;
long lastts=0;
+ float zeroValue;
+ if (mLogScale)
+ zeroValue=2;
+ else
+ zeroValue=0;
for (TrafficHistory.TrafficDatapoint tdp: list){
float t = (tdp.timestamp - firstTimestamp) / 100f;
@@ -318,11 +324,11 @@ public class GraphFragment extends Fragment implements VpnStatus.ByteCountListen
}
if (lastts > 0 && ( tdp.timestamp -lastts> 2 * interval*1000)){
- dataIn.add(new Entry((lastts- firstTimestamp+ interval)/100f, 0));
- dataOut.add(new Entry((lastts- firstTimestamp+ interval)/100f, 0));
+ dataIn.add(new Entry((lastts- firstTimestamp + interval*1000)/100f, zeroValue));
+ dataOut.add(new Entry((lastts- firstTimestamp + interval*1000)/100f, zeroValue));
- dataIn.add(new Entry(t - interval/100f, 0));
- dataOut.add(new Entry(t - interval/100f, 0));
+ dataIn.add(new Entry(t - interval*10f, zeroValue));
+ dataOut.add(new Entry(t - interval*10f, zeroValue));
}
lastts = tdp.timestamp;
@@ -332,24 +338,25 @@ public class GraphFragment extends Fragment implements VpnStatus.ByteCountListen
}
long now = System.currentTimeMillis();
- if (list.peekLast().timestamp < now-interval*1000l) {
- dataIn.add(new Entry((now-firstTimestamp)/100, 0));
- dataOut.add(new Entry((now-firstTimestamp) /100, 0));
+ if (lastts < now-interval* 1000L) {
if (now -lastts > 2 * interval*1000) {
- dataIn.add(new Entry((lastts- firstTimestamp+ interval)/100f, 0));
- dataOut.add(new Entry((lastts- firstTimestamp+ interval)/100f, 0));
+ dataIn.add(new Entry((lastts- firstTimestamp+ interval*1000)/100f, zeroValue));
+ dataOut.add(new Entry((lastts- firstTimestamp+ interval*1000)/100f, zeroValue));
}
+
+ dataIn.add(new Entry((now-firstTimestamp)/100, zeroValue));
+ dataOut.add(new Entry((now-firstTimestamp) /100, zeroValue));
}
ArrayList<ILineDataSet> dataSets = new ArrayList<>();
- LineDataSet indata = new LineDataSet(dataIn, "In");
- LineDataSet outdata = new LineDataSet(dataOut, "Out");
+ LineDataSet indata = new LineDataSet(dataIn, getString(R.string.data_in));
+ LineDataSet outdata = new LineDataSet(dataOut, getString(R.string.data_out));
- setLineDataAttributes(indata, mColorIn);
- setLineDataAttributes(outdata, mColorOut);
+ setLineDataAttributes(indata, mColourIn);
+ setLineDataAttributes(outdata, mColourOut);
dataSets.add(indata);
dataSets.add(outdata);
@@ -360,7 +367,8 @@ public class GraphFragment extends Fragment implements VpnStatus.ByteCountListen
private void setLineDataAttributes(LineDataSet dataSet, int colour) {
dataSet.setLineWidth(2);
dataSet.setCircleRadius(1);
- dataSet.setDrawCircles(false);
+ dataSet.setDrawCircles(true);
+ dataSet.setCircleColor(mColourPoint);
dataSet.setDrawFilled(true);
dataSet.setFillAlpha(42);
dataSet.setFillColor(colour);
diff --git a/main/src/main/res/values/strings.xml b/main/src/main/res/values/strings.xml
index 2077d02e..c450a00a 100755
--- a/main/src/main/res/values/strings.xml
+++ b/main/src/main/res/values/strings.xml
@@ -430,5 +430,7 @@
<string name="avghour">Average per hour</string>
<string name="avgmin">Average per minute</string>
<string name="last5minutes">Last 5 minutes</string>
+ <string name="data_in">In</string>
+ <string name="data_out">Out</string>
</resources>