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"
|
<RelativeLayout android:id="@+id/trafficRow"
|
||||||
android:gravity="bottom"
|
android:gravity="bottom"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:visibility="invisible"
|
android:visibility="invisible"
|
||||||
android:layout_height="80dp"
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="6dp"
|
||||||
|
android:layout_marginTop="6dp"
|
||||||
android:background="#A0909090">
|
android:background="#A0909090">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/trafficDownLabel"
|
android:id="@+id/trafficDownLabel"
|
||||||
android:textColor="#FFFFFFFF"
|
android:textColor="#FFFFFFFF"
|
||||||
android:layout_width="150dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
|
@ -77,7 +78,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/trafficUpLabel"
|
android:id="@+id/trafficUpLabel"
|
||||||
android:textColor="#FFFFFFFF"
|
android:textColor="#FFFFFFFF"
|
||||||
android:layout_width="150dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:text="@string/main_layout_upload"
|
android:text="@string/main_layout_upload"
|
||||||
|
@ -87,7 +88,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/trafficDown"
|
android:id="@+id/trafficDown"
|
||||||
android:textColor="#FF00B627"
|
android:textColor="#FF00B627"
|
||||||
android:layout_width="150dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_below="@+id/trafficDownLabel"
|
android:layout_below="@+id/trafficDownLabel"
|
||||||
|
@ -96,8 +97,8 @@
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/trafficUp"
|
android:id="@+id/trafficUp"
|
||||||
android:textColor="#FFFF2211"
|
android:textColor="#FF00B627"
|
||||||
android:layout_width="150dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_below="@+id/trafficUpLabel"
|
android:layout_below="@+id/trafficUpLabel"
|
||||||
|
|
|
@ -31,8 +31,8 @@
|
||||||
<string name="menu_about">About</string>
|
<string name="menu_about">About</string>
|
||||||
<string name="menu_wizard">Wizard</string>
|
<string name="menu_wizard">Wizard</string>
|
||||||
|
|
||||||
<string name="main_layout_download">Download</string>
|
<string name="main_layout_download">Download (speed/total)</string>
|
||||||
<string name="main_layout_upload">Upload</string>
|
<string name="main_layout_upload">Upload (speed/total)</string>
|
||||||
|
|
||||||
<string name="button_help">Help</string>
|
<string name="button_help">Help</string>
|
||||||
<string name="button_close">Close</string>
|
<string name="button_close">Close</string>
|
||||||
|
|
|
@ -764,22 +764,23 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
||||||
trafficRow.setVisibility(RelativeLayout.VISIBLE);
|
trafficRow.setVisibility(RelativeLayout.VISIBLE);
|
||||||
Bundle data = msg.getData();
|
Bundle data = msg.getData();
|
||||||
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));
|
String TotalUpload = "";
|
||||||
uploadText.setText(formatCount(datacount.Upload));
|
String TotalDownload = "";
|
||||||
downloadText.invalidate();
|
|
||||||
uploadText.invalidate();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String TotalUpload = mService.getInfo("traffic/written");
|
TotalUpload = mService.getInfo("traffic/written");
|
||||||
String TotalDownload = mService.getInfo("traffic/read");
|
TotalDownload = mService.getInfo("traffic/read");
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("Total Upload " + TotalUpload);
|
|
||||||
sb.append("Total Download" + TotalDownload);
|
|
||||||
Log.d(TAG,sb.toString());
|
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.d(TAG,"Total bandwidth error"+e.getMessage());
|
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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -949,8 +950,19 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
||||||
// Under 2Mb, returns "xxx.xKb"
|
// Under 2Mb, returns "xxx.xKb"
|
||||||
// Over 2Mb, returns "xxx.xxMb"
|
// Over 2Mb, returns "xxx.xxMb"
|
||||||
if (count < 1e6 * 2)
|
if (count < 1e6 * 2)
|
||||||
return ((float)((int)(count*10/1024))/10 + " kbps");
|
return ((float)((int)(count*10/1024))/10 + "kbps");
|
||||||
return ((float)((int)(count*100/1024/1024))/100 + " mbps");
|
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";
|
//return count+" kB";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue