[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [orbot/master] add total display to data transfer UI
commit e8c3fdc1edbeda9fc1f002ffb51a62a1fbe8874b
Author: n8fr8 <nathan@xxxxxxxxxxx>
Date: Sun Sep 30 18:37:37 2012 +0530
add total display to data transfer UI
---
res/layout/layout_main.xml | 15 ++++++-----
res/values/strings.xml | 4 +-
src/org/torproject/android/Orbot.java | 40 +++++++++++++++++++++-----------
3 files changed, 36 insertions(+), 23 deletions(-)
diff --git a/res/layout/layout_main.xml b/res/layout/layout_main.xml
index a9444e1..f73d79c 100644
--- a/res/layout/layout_main.xml
+++ b/res/layout/layout_main.xml
@@ -60,14 +60,15 @@
<RelativeLayout android:id="@+id/trafficRow"
android:gravity="bottom"
android:layout_width="fill_parent"
- android:layout_alignParentBottom="true"
android:visibility="invisible"
- android:layout_height="80dp"
+ android:layout_height="wrap_content"
+ android:padding="6dp"
+ android:layout_marginTop="6dp"
android:background="#A0909090">
<TextView
android:id="@+id/trafficDownLabel"
android:textColor="#FFFFFFFF"
- android:layout_width="150dp"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textSize="16sp"
@@ -77,7 +78,7 @@
<TextView
android:id="@+id/trafficUpLabel"
android:textColor="#FFFFFFFF"
- android:layout_width="150dp"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="@string/main_layout_upload"
@@ -87,7 +88,7 @@
<TextView
android:id="@+id/trafficDown"
android:textColor="#FF00B627"
- android:layout_width="150dp"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/trafficDownLabel"
@@ -96,8 +97,8 @@
android:textStyle="bold" />
<TextView
android:id="@+id/trafficUp"
- android:textColor="#FFFF2211"
- android:layout_width="150dp"
+ android:textColor="#FF00B627"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/trafficUpLabel"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9fa461d..d733b32 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -31,8 +31,8 @@
<string name="menu_about">About</string>
<string name="menu_wizard">Wizard</string>
-<string name="main_layout_download">Download</string>
-<string name="main_layout_upload">Upload</string>
+<string name="main_layout_download">Download (speed/total)</string>
+<string name="main_layout_upload">Upload (speed/total)</string>
<string name="button_help">Help</string>
<string name="button_close">Close</string>
diff --git a/src/org/torproject/android/Orbot.java b/src/org/torproject/android/Orbot.java
index c51b104..59112da 100644
--- a/src/org/torproject/android/Orbot.java
+++ b/src/org/torproject/android/Orbot.java
@@ -763,22 +763,23 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
trafficRow.setVisibility(RelativeLayout.VISIBLE);
Bundle data = msg.getData();
- DataCount datacount = new DataCount(data.getLong("upload"),data.getLong("download"));
- downloadText.setText(formatCount(datacount.Download));
- uploadText.setText(formatCount(datacount.Upload));
- downloadText.invalidate();
- uploadText.invalidate();
-
+ DataCount datacount = new DataCount(data.getLong("upload"),data.getLong("download"));
+ String TotalUpload = "";
+ String TotalDownload = "";
+
try {
- String TotalUpload = mService.getInfo("traffic/written");
- String TotalDownload = mService.getInfo("traffic/read");
- StringBuilder sb = new StringBuilder();
- sb.append("Total Upload " + TotalUpload);
- sb.append("Total Download" + TotalDownload);
- Log.d(TAG,sb.toString());
+ TotalUpload = mService.getInfo("traffic/written");
+ TotalDownload = mService.getInfo("traffic/read");
+
} catch (RemoteException e) {
Log.d(TAG,"Total bandwidth error"+e.getMessage());
}
+
+ downloadText.setText(formatCount(datacount.Download) + " / " + formatTotal(Long.parseLong(TotalDownload)));
+ uploadText.setText(formatCount(datacount.Upload) + " / " + formatTotal(Long.parseLong(TotalUpload)));
+
+ downloadText.invalidate();
+ uploadText.invalidate();
break;
@@ -949,8 +950,19 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
// Under 2Mb, returns "xxx.xKb"
// Over 2Mb, returns "xxx.xxMb"
if (count < 1e6 * 2)
- return ((float)((int)(count*10/1024))/10 + " kbps");
- return ((float)((int)(count*100/1024/1024))/100 + " mbps");
+ return ((float)((int)(count*10/1024))/10 + "kbps");
+ return ((float)((int)(count*100/1024/1024))/100 + "mbps");
+
+ //return count+" kB";
+ }
+
+ private String formatTotal(long count) {
+ // Converts the supplied argument into a string.
+ // Under 2Mb, returns "xxx.xKb"
+ // Over 2Mb, returns "xxx.xxMb"
+ if (count < 1e6)
+ return ((float)((int)(count*10/1024))/10 + "KB");
+ return ((float)((int)(count*100/1024/1024))/100 + "MB");
//return count+" kB";
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits