add total display to data transfer UI
This commit is contained in:
parent
eceede30f9
commit
e8c3fdc1ed
|
@ -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"
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue