Improved Formatting
Now shows the data with upto 2 decimal places. If under 2Mb, shows "xxx.xKb", else shows "xxx.xxMb"
This commit is contained in:
parent
a2981152a7
commit
e114be51d0
|
@ -749,7 +749,8 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
||||||
DataCount datacount = new DataCount(data.getLong("upload"),data.getLong("download"));
|
DataCount datacount = new DataCount(data.getLong("upload"),data.getLong("download"));
|
||||||
downloadText.setText(formatCount(datacount.Download));
|
downloadText.setText(formatCount(datacount.Download));
|
||||||
uploadText.setText(formatCount(datacount.Upload));
|
uploadText.setText(formatCount(datacount.Upload));
|
||||||
|
downloadText.invalidate();
|
||||||
|
uploadText.invalidate();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -916,8 +917,14 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatCount(long count) {
|
private String formatCount(long count) {
|
||||||
|
// Converts the supplied argument into a string.
|
||||||
return count+" kB";
|
// Under 2Mb, returns "xxx.xKb"
|
||||||
|
// Over 2Mb, returns "xxx.xxMb"
|
||||||
|
if (count < 1e6 * 2)
|
||||||
|
return ((float)((int)(count*10/1024))/10 + "kB");
|
||||||
|
return ((float)((int)(count*100/1024/1024))/100 + "MB");
|
||||||
|
|
||||||
|
//return count+" kB";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1122,10 +1122,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
sb.append("kb written");
|
sb.append("kb written");
|
||||||
|
|
||||||
logNotice(sb.toString());
|
logNotice(sb.toString());
|
||||||
DataCount datacount = new DataCount();
|
DataCount datacount = new DataCount(written,read);
|
||||||
|
|
||||||
datacount.Download = read/1000;
|
|
||||||
datacount.Upload = written/1000;
|
|
||||||
|
|
||||||
Message msg = Message.obtain();
|
Message msg = Message.obtain();
|
||||||
msg.what = MESSAGE_TRAFFIC_COUNT;
|
msg.what = MESSAGE_TRAFFIC_COUNT;
|
||||||
|
@ -1149,6 +1146,12 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
public long Upload;
|
public long Upload;
|
||||||
// data downloaded
|
// data downloaded
|
||||||
public long Download;
|
public long Download;
|
||||||
|
|
||||||
|
|
||||||
|
DataCount(long Upload, long Download){
|
||||||
|
this.Upload = Upload;
|
||||||
|
this.Download = Download;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void circuitStatus(String status, String circID, String path) {
|
public void circuitStatus(String status, String circID, String path) {
|
||||||
|
|
Loading…
Reference in New Issue