ndt-dev - [ndt-dev] [ndt] r498 committed - Layout and populate summary results.
Subject: NDT-DEV email list created
List archive
- From:
- To:
- Subject: [ndt-dev] [ndt] r498 committed - Layout and populate summary results.
- Date: Tue, 16 Aug 2011 18:38:58 +0000
Revision: 498
Author:
Date: Tue Aug 16 11:38:31 2011
Log: Layout and populate summary results.
http://code.google.com/p/ndt/source/detail?r=498
Added:
/branches/android/Android/res/drawable/speed_box.xml
Modified:
/branches/android/Android/res/layout/results.xml
/branches/android/Android/res/layout/tests.xml
/branches/android/Android/res/values/strings.xml
/branches/android/Android/res/values/styles.xml
/branches/android/Android/src/net/measurementlab/ndt/NdtService.java
/branches/android/Android/src/net/measurementlab/ndt/ResultsActivity.java
/branches/android/Android/src/net/measurementlab/ndt/TestsActivity.java
=======================================
--- /dev/null
+++ /branches/android/Android/res/drawable/speed_box.xml Tue Aug 16 11:38:31 2011
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+ <stroke android:width="1dp" android:color="#FFFFFF" />
+ <solid android:color="#00aef0" />
+ <padding android:left="7dp" android:top="7dp"
+ android:right="7dp" android:bottom="7dp" />
+</shape>
=======================================
--- /branches/android/Android/res/layout/results.xml Tue Aug 16 09:54:15 2011
+++ /branches/android/Android/res/layout/results.xml Tue Aug 16 11:38:31 2011
@@ -3,14 +3,77 @@
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
- <LinearLayout android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <TextView android:layout_width="fill_parent"
+<LinearLayout
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+ <TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="15sp"
+ android:id="@+id/ResultsHeader"
+ android:text="@string/results_header"
+ style="@style/NdtHeader"/>
+ <LinearLayout android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:padding="15sp"
+ android:layout_marginTop="5sp"
+ android:layout_marginLeft="35sp"
+ android:layout_marginRight="35sp"
+ android:background="@drawable/speed_box"
+ android:layout_gravity="center_horizontal">
+ <TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:id="@+id/Statistics"
- android:text=""
- android:scrollbars="vertical"
- android:gravity="top" />
+ android:paddingTop="10sp"
+ android:id="@+id/UploadSpeedHeader"
+ android:text="@string/results_upload_speed_header"
+ style="@style/NdtResultsLabel" />
+ <LinearLayout android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="horizontal">
+ <TextView android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/UploadSpeed"
+ android:text="0"
+ android:layout_marginRight="5sp"
+ style="@style/NdtResults" />
+ <TextView android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/UploadSpeedMbps"
+ android:text="@string/results_mpbs"
+ style="@style/NdtResultsMbps" />
+ </LinearLayout>
</LinearLayout>
+ <LinearLayout android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:padding="5sp"
+ android:layout_marginTop="10sp"
+ android:layout_marginLeft="35sp"
+ android:layout_marginRight="35sp"
+ android:background="@drawable/speed_box"
+ android:layout_gravity="center_horizontal">
+ <TextView android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingTop="10sp"
+ android:id="@+id/DownloadSpeedHeader"
+ android:text="@string/results_download_speed_header"
+ style="@style/NdtResultsLabel" />
+ <LinearLayout android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="horizontal">
+ <TextView android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/DownloadSpeed"
+ android:text="0"
+ android:layout_marginRight="5sp"
+ style="@style/NdtResults" />
+ <TextView android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/DownloadSpeedMbps"
+ android:text="@string/results_mpbs"
+ style="@style/NdtResultsMbps" />
+ </LinearLayout>
+ </LinearLayout>
+</LinearLayout>
</ScrollView>
=======================================
--- /branches/android/Android/res/layout/tests.xml Mon Aug 15 12:55:43
2011
+++ /branches/android/Android/res/layout/tests.xml Tue Aug 16 11:38:31
2011
@@ -2,7 +2,8 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent" android:orientation="vertical">
+ android:layout_height="match_parent"
+ android:orientation="vertical">
<LinearLayout android:id="@+id/linearLayout1"
android:orientation="vertical"
android:layout_width="match_parent"
@@ -10,9 +11,9 @@
<TextView android:text="@string/tests_preparing_header"
android:id="@+id/NdtTestsHeader"
android:paddingTop="15sp"
- style="@style/NdtTestsHeader" />
+ style="@style/NdtHeader" />
<TextView android:id="@+id/NdtTestsInfo"
- style="@style/NdtTestsHeader.Info" />
+ style="@style/NdtHeader.Info" />
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/progress_bar"
=======================================
--- /branches/android/Android/res/values/strings.xml Mon Aug 15 12:24:06 2011
+++ /branches/android/Android/res/values/strings.xml Tue Aug 16 11:38:31 2011
@@ -34,6 +34,7 @@
<string name="email_title">NDT Mobile Client for Android Result on %1$s</string>
<string name="intent_error">Intent Error.</string>
<string name="test_again">Press Start to test again.</string>
+
<string name="mlab">M-Lab</string>
<string name="mlabdesc">Network Diagnostic Tool (NDT) provides a sophisticated speed and diagnostic test. An NDT test reports more than just the upload and download speeds — it also attempts to determine what, if any, problems limited these speeds, differentiating between computer configuration and network infrastructure problems. While the diagnostic messages are most useful for expert users, they can also help novice users by allowing them to provide detailed trouble reports to their network administrator.</string>
<string name="tests_preparing_header">PREPARING YOUR TESTS...</string>
@@ -43,5 +44,8 @@
<string name="tests_download_info">YOUR DOWNLOAD SPEED</string>
<string name="tests_test_server">TEST SERVER</string>
<string name="tests_your_computer">YOUR COMPUTER</string>
-
+ <string name="results_header">YOUR TEST RESULTS</string>
+ <string name="results_upload_speed_header">UPLOAD SPEED</string>
+ <string name="results_download_speed_header">DOWNLOAD SPEED</string>
+ <string name="results_mpbs">mb/s</string>
</resources>
=======================================
--- /branches/android/Android/res/values/styles.xml Tue Aug 16 09:53:54
2011
+++ /branches/android/Android/res/values/styles.xml Tue Aug 16 11:38:31
2011
@@ -14,7 +14,7 @@
<item name="android:layout_width">fill_parent</item>
<item name="android:padding">40sp</item>
</style>
- <style name="NdtTestsHeader" parent="@android:style/TextAppearance">
+ <style name="NdtHeader" parent="@android:style/TextAppearance">
<item name="android:textColor">#000</item>
<item name="android:textSize">32sp</item>
<item name="android:gravity">left</item>
@@ -22,7 +22,7 @@
<item name="android:layout_width">fill_parent</item>
<item name="android:paddingLeft">25sp</item>
</style>
- <style name="NdtTestsHeader.Info">
+ <style name="NdtHeader.Info">
<item name="android:textColor">#FFF</item>
</style>
<style name="NdtTestsDetail" parent="@android:style/TextAppearance">
@@ -41,6 +41,27 @@
<item name="android:layout_width">fill_parent</item>
<item name="android:paddingLeft">25sp</item>
</style>
+ <style name="NdtResultsLabel" parent="@android:style/TextAppearance">
+ <item name="android:textColor">#000</item>
+ <item name="android:textSize">24sp</item>
+ <item name="android:gravity">left</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_width">fill_parent</item>
+ </style>
+ <style name="NdtResults" parent="@android:style/TextAppearance">
+ <item name="android:textColor">#FFF</item>
+ <item name="android:textSize">72sp</item>
+ <item name="android:gravity">left</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_width">fill_parent</item>
+ </style>
+ <style name="NdtResultsMbps" parent="@android:style/TextAppearance">
+ <item name="android:textColor">#000</item>
+ <item name="android:textSize">24sp</item>
+ <item name="android:gravity">left</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_width">fill_parent</item>
+ </style>
<style name="NdtButton" parent="@android:style/Widget.Button">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/NdtService.java Tue Aug 16 09:54:15 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/NdtService.java Tue Aug 16 11:38:31 2011
@@ -1,5 +1,11 @@
package net.measurementlab.ndt;
+import static net.measurementlab.ndt.Constants.LOG_TAG;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -9,15 +15,18 @@
import android.util.Log;
public class NdtService extends Service {
-
- public static final int PREPARING = 0;
- public static final int UPLOADING = 1;
- public static final int DOWNLOADING = 2;
- public static final int COMPLETE = 3;
-
- public static final String INTENT_UPDATE_STATUS = "net.measurementlab.ndt.UpdateStatus";
- public static final String INTENT_STOP_TESTS = "net.measurementlab.ndt.StopTests";
- public static final String EXTRA_STATE = "status";
+ private static final String VARS_TAG = "variables";
+
+ static final int PREPARING = 0;
+ static final int UPLOADING = 1;
+ static final int DOWNLOADING = 2;
+ static final int COMPLETE = 3;
+
+ static final String INTENT_UPDATE_STATUS = "net.measurementlab.ndt.UpdateStatus";
+ static final String INTENT_STOP_TESTS = "net.measurementlab.ndt.StopTests";
+
+ static final String EXTRA_STATUS = "status";
+ static final String EXTRA_VARS = VARS_TAG;
private Intent intent;
@@ -35,13 +44,13 @@
@Override
public void onCreate() {
super.onCreate();
- Log.i("ndt", "Service created.");
+ Log.i(LOG_TAG, "Service created.");
intent = new Intent(INTENT_UPDATE_STATUS);
}
@Override
public void onStart(Intent intent, int startId) {
- Log.i("ndt", "Starting NDT service.");
+ Log.i(LOG_TAG, "Starting NDT service.");
super.onStart(intent, startId);
if (uiServices != null) {
return;
@@ -58,7 +67,7 @@
Constants.SERVER_HOST[Constants.DEFAULT_SERVER],
uiServices, networkType)).start();
} catch (Throwable tr) {
- Log.e("ndt", "Problem running tests.", tr);
+ Log.e(LOG_TAG, "Problem running tests.", tr);
}
}
@@ -70,7 +79,7 @@
}
uiServices = null;
unregisterReceiver(stopReceiver);
- Log.i("ndt", "Finishing NDT service.");
+ Log.i(LOG_TAG, "Finishing NDT service.");
}
private BroadcastReceiver createReceiver() {
@@ -78,7 +87,7 @@
@Override
public void onReceive(Context context, Intent intent)
{
- Log.i("ndt", "Stop request received.");
+ Log.i(LOG_TAG, "Stop request received.");
uiServices.requestStop();
}
};
@@ -92,106 +101,103 @@
int status = PREPARING;
- StringBuilder statistics = new StringBuilder();
-
+ private Map<String, Object> variables = new HashMap<String,
Object>();
+
@Override
public void appendString(String str, int viewId) {
- Log.d("ndt", String.format("Appended: (%1$d) %2$s.",
viewId, str
+ Log.d(LOG_TAG, String.format("Appended: (%1$d)
%2$s.", viewId, str
.trim()));
- switch(viewId) {
- case Constants.THREAD_STAT_APPEND:
- statistics.append(str);
- break;
- }
-
if (str.contains("client-to-server") && 0 == viewId) {
- Log.i("ndt", "Starting upload test.");
- intent.putExtra("status", UPLOADING);
+ Log.i(LOG_TAG, "Starting upload test.");
+ intent.putExtra(EXTRA_STATUS, UPLOADING);
sendBroadcast(intent);
status = UPLOADING;
- Log.i("ndt", "Broadcast status change.");
+ Log.i(LOG_TAG, "Broadcast status change.");
}
if (str.contains("server-to-client") && 0 == viewId) {
- Log.i("ndt", "Starting download test.");
- intent.putExtra("status", DOWNLOADING);
+ Log.i(LOG_TAG, "Starting download test.");
+ intent.putExtra(EXTRA_STATUS, DOWNLOADING);
sendBroadcast(intent);
status = DOWNLOADING;
- Log.i("ndt", "Broadcast status change.");
+ Log.i(LOG_TAG, "Broadcast status change.");
}
}
@Override
public void incrementProgress() {
- Log.d("ndt", "Incremented progress.");
+ Log.d(LOG_TAG, "Incremented progress.");
}
@Override
public void logError(String str) {
- Log.e("ndt", String.format("Error: %1$s.",
str.trim()));
+ Log.e(LOG_TAG, String.format("Error: %1$s.",
str.trim()));
}
@Override
public void onBeginTest() {
- Log.d("ndt", "Test begun.");
+ Log.d(LOG_TAG, "Test begun.");
wantToStop = false;
}
@Override
public void onEndTest() {
- Log.d("ndt", "Test ended.");
- intent.putExtra("status", COMPLETE);
- intent.putExtra("statistics", statistics.toString());
+ Log.d(LOG_TAG, "Test ended.");
+ intent.putExtra(EXTRA_STATUS, COMPLETE);
+ intent.putExtra(EXTRA_VARS, (Serializable) variables);
sendBroadcast(intent);
wantToStop = false;
status = COMPLETE;
- Log.i("ndt", "Broadcast status change.");
+ Log.i(LOG_TAG, "Broadcast status change.");
}
@Override
public void onFailure(String errorMessage) {
- Log.d("ndt", String.format("Failed: %1$s.",
errorMessage));
+ Log.d(LOG_TAG, String.format("Failed: %1$s.",
errorMessage));
wantToStop = false;
}
@Override
public void onLoginSent() {
- Log.d("ndt", "Login sent.");
+ Log.d(LOG_TAG, "Login sent.");
}
@Override
public void onPacketQueuingDetected() {
- Log.d("ndt", "Packet queuing detected.");
+ Log.d(LOG_TAG, "Packet queuing detected.");
}
@Override
public void setVariable(String name, int value) {
- Log.d("ndt", String.format(
+ Log.d(VARS_TAG, String.format(
"Setting variable, %1$s, to value,
%2$d.", name, value));
+ variables.put(name, value);
}
@Override
public void setVariable(String name, double value) {
- Log.d("ndt", String.format(
+ Log.d(VARS_TAG, String.format(
"Setting variable, %1$s, to value,
%2$f.", name, value));
+ variables.put(name, value);
}
@Override
public void setVariable(String name, Object value) {
- Log.d("ndt", String.format(
+ Log.d(VARS_TAG, String.format(
"Setting variable, %1$s, to value,
%2$s.", name,
(null == value) ? "null" :
value.toString()));
+ variables.put(name, value);
}
@Override
public void updateStatus(String status) {
- Log.d("ndt", String.format("Updating status: %1$s.",
status));
+ Log.d(LOG_TAG, String.format("Updating status:
%1$s.", status));
}
@Override
public void updateStatusPanel(String status) {
- Log.d("ndt", String.format("Updating status panel:
%1$s.", status));
+ Log.d(LOG_TAG, String.format("Updating status panel:
%1$s.", status));
}
@Override
=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/ResultsActivity.java Tue Aug 16 09:54:15 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/ResultsActivity.java Tue Aug 16 11:38:31 2011
@@ -1,6 +1,10 @@
package net.measurementlab.ndt;
+import java.text.DecimalFormat;
+import java.util.Map;
+
import android.app.Activity;
+import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;
@@ -10,13 +14,39 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.results);
+
+ Typeface typeFace = Typeface.createFromAsset(getAssets(), "fonts/League_Gothic.otf");
+ TextView textView = (TextView)
findViewById(R.id.ResultsHeader);
+ textView.setTypeface(typeFace);
+ textView = (TextView) findViewById(R.id.UploadSpeedHeader);
+ textView.setTypeface(typeFace);
+ textView = (TextView) findViewById(R.id.UploadSpeed);
+ textView.setTypeface(typeFace);
+ textView = (TextView) findViewById(R.id.UploadSpeedMbps);
+ textView.setTypeface(typeFace);
+ textView = (TextView) findViewById(R.id.DownloadSpeedHeader);
+ textView.setTypeface(typeFace);
+ textView = (TextView) findViewById(R.id.DownloadSpeed);
+ textView.setTypeface(typeFace);
+ textView = (TextView) findViewById(R.id.DownloadSpeedMbps);
+ textView.setTypeface(typeFace);
}
+ @SuppressWarnings("unchecked")
@Override
protected void onResume() {
super.onResume();
- String statistics = getIntent().getStringExtra("statistics");
- TextView textView = (TextView) findViewById(R.id.Statistics);
- textView.setText(statistics);
+ Map<String,Object> variables = (Map<String,Object>) getIntent().getSerializableExtra(NdtService.EXTRA_VARS);
+
+ DecimalFormat format = (DecimalFormat)
DecimalFormat.getInstance();
+ format.setMaximumFractionDigits(2);
+
+ Double uploadSpeed = (Double) variables.get("pub_c2sspd");
+ TextView textView = (TextView) findViewById(R.id.UploadSpeed);
+ textView.setText(format.format(uploadSpeed));
+
+ Double downloadSpeed = (Double) variables.get("pub_s2cspd");
+ textView = (TextView) findViewById(R.id.DownloadSpeed);
+ textView.setText(format.format(downloadSpeed));
}
}
=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/TestsActivity.java Tue Aug 16 09:54:15 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/TestsActivity.java Tue Aug 16 11:38:31 2011
@@ -124,11 +124,11 @@
// TODO show download animation
}
- private void complete(String statistics) {
+ private void complete(Intent status) {
Log.i(LOG_TAG, "Testing Complete.");
updateHeader(R.string.tests_complete_header);
Intent intent = new Intent(getApplicationContext(), ResultsActivity.class);
- intent.putExtra("statistics", statistics);
+ intent.putExtra(NdtService.EXTRA_VARS, status.getSerializableExtra(NdtService.EXTRA_VARS));
startActivity(intent);
}
@@ -138,7 +138,7 @@
@Override
public void onReceive(Context context, Intent intent)
{
Log.i(LOG_TAG, "Status change received.");
- int status = intent.getIntExtra("status",
NdtService.PREPARING);
+ int status = intent.getIntExtra(NdtService.EXTRA_STATUS, NdtService.PREPARING);
switch (status) {
case NdtService.PREPARING:
preparing();
@@ -150,7 +150,7 @@
downloading();
break;
case NdtService.COMPLETE:
-
complete(intent.getStringExtra("statistics"));
+ complete(intent);
break;
default:
Log.i(LOG_TAG, "Test reporter not
initialized.");
- [ndt-dev] [ndt] r498 committed - Layout and populate summary results., ndt, 08/16/2011
Archive powered by MHonArc 2.6.16.