ndt-dev - [ndt-dev] [ndt] r403 committed - Add logging impl of ui services to better figure out how to fire activ...
Subject: NDT-DEV email list created
List archive
[ndt-dev] [ndt] r403 committed - Add logging impl of ui services to better figure out how to fire activ...
Chronological Thread
- From:
- To:
- Subject: [ndt-dev] [ndt] r403 committed - Add logging impl of ui services to better figure out how to fire activ...
- Date: Mon, 20 Jun 2011 16:24:00 +0000
Revision: 403
Author:
Date: Mon Jun 20 09:23:24 2011
Log: Add logging impl of ui services to better figure out how to fire activities in response to test progression.
http://code.google.com/p/ndt/source/detail?r=403
Added:
/branches/android/Android/res/layout/server_location.xml
/branches/android/Android/src/net/measurementlab/ndt/Android2UiServices.java
/branches/android/Android/src/net/measurementlab/ndt/ServerLocation.java
Modified:
/branches/android/Android/res/values/strings.xml
/branches/android/Android/res/values/styles.xml
/branches/android/Android/src/net/measurementlab/ndt/AndroidNdt2.java
=======================================
--- /dev/null
+++ /branches/android/Android/res/layout/server_location.xml Mon Jun 20 09:23:24 2011
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" android:orientation="vertical">
+ <LinearLayout android:id="@+id/linearLayout1"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <TextView android:layout_width="match_parent"
+ android:text="@string/server_location_header"
+ android:layout_height="wrap_content"
+ android:id="@+id/NdtServerLocationLabel"
+ android:layout_gravity="top"
+ style="@style/NdtHeader" />
+ <ImageView android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/progress_bar"
+ android:id="@+id/NdtServerLocationProgress"></ImageView>
+ </LinearLayout>
+</LinearLayout>
=======================================
--- /dev/null
+++ /branches/android/Android/src/net/measurementlab/ndt/Android2UiServices.java Mon Jun 20 09:23:24 2011
@@ -0,0 +1,80 @@
+package net.measurementlab.ndt;
+
+import android.util.Log;
+
+public class Android2UiServices implements UiServices {
+
+ @Override
+ public void appendString(String str, int viewId) {
+ Log.i("ndt", String.format("Appended: (%1$d) %2$s.", viewId,
str));
+ }
+
+ @Override
+ public void incrementProgress() {
+ Log.i("ndt", "Incremented progress.");
+ }
+
+ @Override
+ public void logError(String str) {
+ Log.e("ndt", String.format("Error: %1$s.", str));
+ }
+
+ @Override
+ public void onBeginTest() {
+ Log.i("ndt", "Test begun.");
+ }
+
+ @Override
+ public void onEndTest() {
+ Log.i("ndt", "Test ended.");
+ }
+
+ @Override
+ public void onFailure(String errorMessage) {
+ Log.i("ndt", String.format("Failed: %1$s.", errorMessage));
+ }
+
+ @Override
+ public void onLoginSent() {
+ Log.i("ndt", "Login sent.");
+ }
+
+ @Override
+ public void onPacketQueuingDetected() {
+ Log.i("ndt", "Packet queuing detected.");
+ }
+
+ @Override
+ public void setVariable(String name, int value) {
+ Log.i("ndt", String.format("Setting variable, %1$s, to value,
%2$d.",
+ name, value));
+ }
+
+ @Override
+ public void setVariable(String name, double value) {
+ Log.i("ndt", String.format("Setting variable, %1$s, to value,
%2$f.",
+ name, value));
+ }
+
+ @Override
+ public void setVariable(String name, Object value) {
+ Log.i("ndt", String.format("Setting variable, %1$s, to value,
%2$s.",
+ name, (null == value) ? "null" :
value.toString()));
+ }
+
+ @Override
+ public void updateStatus(String status) {
+ Log.i("ndt", String.format("Updating status: %1$s.", status));
+ }
+
+ @Override
+ public void updateStatusPanel(String status) {
+ Log.i("ndt", String.format("Updating status panel: %1$s.",
status));
+ }
+
+ @Override
+ public boolean wantToStop() {
+ return false;
+ }
+
+}
=======================================
--- /dev/null
+++ /branches/android/Android/src/net/measurementlab/ndt/ServerLocation.java Mon Jun 20 09:23:24 2011
@@ -0,0 +1,29 @@
+// Copyright 2009 Google Inc. All Rights Reserved.
+
+package net.measurementlab.ndt;
+
+import android.app.Activity;
+import android.graphics.Typeface;
+import android.os.Bundle;
+import android.util.Log;
+import android.widget.TextView;
+
+/**
+ * Animated progress while selecting server location.
+ */
+public class ServerLocation extends Activity {
+
+ /**
+ * Initializes the activity.
+ */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.server_location);
+ Log.i("ndt", "Loaded!");
+ Typeface typeFace = Typeface.createFromAsset(getAssets(),
+ "fonts/League_Gothic.otf");
+ TextView textView = (TextView) findViewById(R.id.NdtServerLocationLabel);
+ textView.setTypeface(typeFace);
+ }
+}
=======================================
--- /branches/android/Android/res/values/strings.xml Fri Jun 10 12:49:15 2011
+++ /branches/android/Android/res/values/strings.xml Mon Jun 20 09:23:24 2011
@@ -36,5 +36,6 @@
<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="server_location_header">Preparing Your Tests...</string>
</resources>
=======================================
--- /branches/android/Android/res/values/styles.xml Fri Jun 17 11:09:30
2011
+++ /branches/android/Android/res/values/styles.xml Mon Jun 20 09:23:24
2011
@@ -11,6 +11,13 @@
<item name="android:layout_width">fill_parent</item>
<item name="android:padding">40sp</item>
</style>
+ <style name="NdtHeader" parent="@android:style/TextAppearance">
+ <item name="android:textColor">#000000</item>
+ <item name="android:textSize">32sp</item>
+ <item name="android:gravity">center_horizontal</item>
+ <item name="android:layout_width">fill_parent</item>
+ <item name="android:padding">15sp</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/AndroidNdt2.java Mon Jun 20 07:02:17 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/AndroidNdt2.java Mon Jun 20 09:23:24 2011
@@ -5,6 +5,8 @@
import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
@@ -16,7 +18,7 @@
* UI Thread and Entry Point of NDT mobile client.
*/
public class AndroidNdt2 extends Activity {
-
+
/**
* Initializes the activity.
*/
@@ -25,17 +27,22 @@
super.onCreate(savedInstanceState);
setContentView(R.layout.start);
Log.i("ndt", "Loaded!");
- Typeface typeFace = Typeface.createFromAsset(getAssets(),
- "fonts/League_Gothic.otf");
- TextView textView = (TextView) findViewById(R.id.MLabDesc);
- textView.setTypeface(typeFace);
-
- Button startButton = (Button) findViewById(R.id.ButtonStart);
- startButton.setOnClickListener(new OnClickListener() {
-
+ Typeface typeFace = Typeface.createFromAsset(getAssets(),
+ "fonts/League_Gothic.otf");
+ TextView textView = (TextView) findViewById(R.id.MLabDesc);
+ textView.setTypeface(typeFace);
+
+ Button startButton = (Button) findViewById(R.id.ButtonStart);
+ startButton.setOnClickListener(new OnClickListener() {
+
@Override
public void onClick(View v) {
try {
+ Thread netWorker = new Thread(new
NdtTests(
+
Constants.SERVER_HOST[Constants.DEFAULT_SERVER],
+ new
Android2UiServices(), getNetworkType()));
+ netWorker.start();
+
Intent intent = new
Intent(Constants.SERVER_LOCATION);
startActivity(intent);
} catch (Throwable t) {
@@ -44,4 +51,20 @@
}
});
}
-}
+
+ private String getNetworkType() {
+ ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
+ NetworkInfo networkInfo =
connectivityManager.getActiveNetworkInfo();
+ if (null == networkInfo) {
+ return NdtTests.NETWORK_UNKNOWN;
+ }
+ switch (networkInfo.getType()) {
+ case ConnectivityManager.TYPE_MOBILE:
+ return NdtTests.NETWORK_MOBILE;
+ case ConnectivityManager.TYPE_WIFI:
+ return NdtTests.NETWORK_WIFI;
+ default:
+ return NdtTests.NETWORK_UNKNOWN;
+ }
+ }
+}
- [ndt-dev] [ndt] r403 committed - Add logging impl of ui services to better figure out how to fire activ..., ndt, 06/20/2011
Archive powered by MHonArc 2.6.16.