Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r758 committed - Restore server selection feature.

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r758 committed - Restore server selection feature.


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r758 committed - Restore server selection feature.
  • Date: Thu, 15 Dec 2011 16:00:16 +0000

Revision: 758
Author:

Date: Thu Dec 15 07:59:31 2011
Log: Restore server selection feature.
http://code.google.com/p/ndt/source/detail?r=758

Modified:
/branches/android/Android/AndroidManifest.xml
/branches/android/Android/res/layout/initial.xml
/branches/android/Android/res/values/strings.xml
/branches/android/Android/src/net/measurementlab/ndt/Constants.java
/branches/android/Android/src/net/measurementlab/ndt/InitialActivity.java
/branches/android/Android/src/net/measurementlab/ndt/NdtService.java
/branches/android/Android/src/net/measurementlab/ndt/TestsActivity.java

=======================================
--- /branches/android/Android/AndroidManifest.xml Tue Aug 23 13:36:59
2011
+++ /branches/android/Android/AndroidManifest.xml Thu Dec 15 07:59:31
2011
@@ -11,6 +11,7 @@
</activity>
<activity android:name=".TestsActivity" android:label="@string/app_name" android:theme="@style/NdtTheme" />
<activity android:name=".ResultsActivity" android:label="@string/app_name" android:theme="@style/NdtTheme.Blue" />
+ <activity android:name=".SelectServerActivity" android:label="@string/app_name" />
<service android:name=".NdtService" />
</application>
<uses-sdk android:minSdkVersion="8" />
=======================================
--- /branches/android/Android/res/layout/initial.xml Tue Aug 16 09:54:15 2011
+++ /branches/android/Android/res/layout/initial.xml Thu Dec 15 07:59:31 2011
@@ -29,8 +29,5 @@
<Button android:text="@string/start"
android:id="@+id/ButtonStart"
style="@style/NdtButton" />
- <Button android:text="@string/about"
- android:id="@+id/ButtonAbout"
- style="@style/NdtButton" />
</LinearLayout>
</RelativeLayout>
=======================================
--- /branches/android/Android/res/values/strings.xml Thu Dec 15 06:33:50 2011
+++ /branches/android/Android/res/values/strings.xml Thu Dec 15 07:59:31 2011
@@ -5,7 +5,6 @@
<string name="start">Start</string>
<string name="label_about_description">This software is based in part on NDT: Copyright (c) 2003 University of Chicago.</string>
<string name="label_about_title">About NDT Mobile Client for Android</string>
- <string name="serverlist_corrupted_tip">Server list corrupted, please contact the publisher.</string>
<string name="from_header">From:</string>
<string name="to_header">To:</string>
<string name="server_indicator">Server: %1$s</string>
@@ -20,6 +19,8 @@

<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="initial_select_server">Select Server</string>
+ <string name="servers_save">Save Selected Server</string>
<string name="tests_preparing_header">PREPARING YOUR TESTS...</string>
<string name="tests_both_header">NOW TESTING</string>
<string name="tests_complete_header">Tests Complete</string>
=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/Constants.java Thu Dec 15 06:19:29 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/Constants.java Thu Dec 15 07:59:31 2011
@@ -17,32 +17,28 @@
// In future server list should be downloaded from some list servers
// dynamically.
public static final int DEFAULT_SERVER = 0;
- public static final String SERVER_NAME[] = { "Closest Server (DONAR)",
- "Mountain View, California", "Los Angeles,
California",
- "Seattle, Washington", "Dallas, Texas", "Chicago,
Illinois",
- "Atlanta, Georgia", "Miami, Florida", "New York City, New
York #1",
- "New York City, New York #2", "London, United
Kingdom",
- "Paris, France", "Amsterdam, The Netherlands #1", "Athens,
Greece",
- "Sydney, Australia" };
- public static final String SERVER_HOST[] = {
- "ndt.iupui.donar.measurement-lab.org",
- "ndt.iupui.nuq01.measurement-lab.org",
- "ndt.iupui.lax01.measurement-lab.org",
- "ndt.iupui.sea01.measurement-lab.org",
- "ndt.iupui.dfw01.measurement-lab.org",
- "ndt.iupui.ord01.measurement-lab.org",
- "ndt.iupui.atl01.measurement-lab.org",
- "ndt.iupui.mia01.measurement-lab.org",
- "ndt.iupui.lga01.measurement-lab.org",
- "ndt.iupui.lga02.measurement-lab.org",
- "ndt.iupui.lhr01.measurement-lab.org",
- "ndt.iupui.par01.measurement-lab.org",
- "ndt.iupui.ams01.measurement-lab.org",
- "ndt.iupui.ath01.measurement-lab.org",
- "ndt.iupui.syd01.measurement-lab.org" };
+ public static final String SERVER_LIST[][] = {
+ {"Closest Server (DONAR)",
"ndt.iupui.donar.measurement-lab.org"},
+ {"Amsterdam, The Netherlands", "ndt.iupui.ams.donar.measurement-lab.org"},
+ {"Athens, Greece", "ndt.iupui.ath.donar.measurement-lab.org"},
+ {"Atlanta, Georgia",
"ndt.iupui.atl.donar.measurement-lab.org"},
+ {"Chicago, Illinois",
"ndt.iupui.ord.donar.measurement-lab.org"},
+ {"Dallas, Texas", "ndt.iupui.dfw.donar.measurement-lab.org"},
+ {"Dulles, Virginia",
"ndt.iupui.iad.donar.measurement-lab.org"},
+ {"Los Angeles, California",
"ndt.iupui.lax.donar.measurement-lab.org"},
+ {"London, United Kingdom",
"ndt.iupui.lhr.donar.measurement-lab.org"},
+ {"Miami, Florida", "ndt.iupui.mia.donar.measurement-lab.org"},
+ {"New York City, New York",
"ndt.iupui.lga.donar.measurement-lab.org"},
+ {"Mountain View, California",
"ndt.iupui.nuq.donar.measurement-lab.org"},
+ {"Paris, France", "ndt.iupui.par.donar.measurement-lab.org"},
+ {"Seattle, Washington",
"ndt.iupui.sea.donar.measurement-lab.org"},
+ {"Sydney, Australia",
"ndt.iupui.syd.donar.measurement-lab.org"},
+ {"Tokyo, Japan", "ndt.iupui.hnd.donar.measurement-lab.org"},
+ {"Wellington, New Zealand",
"ndt.iupui.wlg.donar.measurement-lab.org"}
+ };

/**
* Number of servers. All the arrays should have the same length.
*/
- public static final int NUMBER_OF_SERVERS = SERVER_NAME.length;
-}
+ public static final int NUMBER_OF_SERVERS = SERVER_LIST.length;
+}
=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/InitialActivity.java Thu Dec 15 06:19:29 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/InitialActivity.java Thu Dec 15 07:59:31 2011
@@ -5,15 +5,21 @@
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
+import android.widget.Toast;

/**
* UI Thread and Entry Point of NDT mobile client.
*/
public class InitialActivity extends Activity {

+ private int serverNumber = Constants.DEFAULT_SERVER;
+
/**
* Initializes the activity.
*/
@@ -31,18 +37,58 @@
public void onClick(View v) {
Intent intent = new
Intent(getApplicationContext(),
TestsActivity.class);
+ intent.putExtra(NdtService.EXTRA_SERVER_HOST,
+
Constants.SERVER_LIST[serverNumber][1]);
startActivity(intent);
}
});
-
- Button aboutButton = (Button) findViewById(R.id.ButtonAbout);
- aboutButton.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://measurementlab.net";));
- startActivity(intent);
- }
- });
- }
-}
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.initial, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle item selection
+ switch (item.getItemId()) {
+ case R.id.SelectServers: {
+ Intent intent = new Intent(InitialActivity.this, SelectServerActivity.class);
+
intent.putExtra(SelectServerActivity.EXTRA_SERVER_NUMBER, serverNumber);
+ startActivityForResult(intent, SelectServerActivity.ACTIVITY_SELECT_SERVER);
+
+ return true;
+ }
+ case R.id.About: {
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri
+ .parse("http://measurementlab.net";));
+ startActivity(intent);
+ return true;
+ }
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ /**
+ *
{@inheritDoc}
+ */
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (resultCode == RESULT_OK
+ || requestCode ==
SelectServerActivity.ACTIVITY_SELECT_SERVER) {
+ if (data != null) {
+ serverNumber = data.getExtras().getInt(
+
SelectServerActivity.EXTRA_SERVER_NUMBER);
+ Toast serverSelected =
Toast.makeText(getApplicationContext(),
+ "Selected " +
Constants.SERVER_LIST[serverNumber][0],
+ 10);
+ serverSelected.show();
+ }
+ }
+ }
+
+}
=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/NdtService.java Tue Oct 11 10:32:07 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/NdtService.java Thu Dec 15 07:59:31 2011
@@ -77,6 +77,11 @@
*/
static final String EXTRA_DIAG_STATUS = "diagnosticStatus";

+ /**
+ * Server against which to perform the test.
+ */
+ static final String EXTRA_SERVER_HOST = "serverHost";
+
/**
* Label for variables captured during testing and used in
presentation of
* results in
{@link
ResultsActivity}.
@@ -126,10 +131,15 @@
// this interface is how the service is able to observe the
// tests as run by the core Java client code
uiServices = new CaptiveUiServices();
+
+ String serverHost = intent.getStringExtra(EXTRA_SERVER_HOST);
+ if (null == serverHost) {
+ serverHost =
Constants.SERVER_LIST[Constants.DEFAULT_SERVER][1];
+ }
+
try {
- new Thread(new NdtTests(
-
Constants.SERVER_HOST[Constants.DEFAULT_SERVER],
- uiServices, networkType)).start();
+ new Thread(new NdtTests(serverHost, uiServices,
networkType))
+ .start();
} catch (Throwable tr) {
Log.e(LOG_TAG, "Problem running tests.", tr);
intent.putExtra(EXTRA_STATUS, STATUS_ERROR);
@@ -181,8 +191,8 @@

CaptiveUiServices() {
// not needed now but may be useful in the future
-// statusBuffers.put(UiServices.MAIN_VIEW, new
StringBuilder());
-// statusBuffers.put(UiServices.STAT_VIEW, new
StringBuilder());
+ // statusBuffers.put(UiServices.MAIN_VIEW, new
StringBuilder());
+ // statusBuffers.put(UiServices.STAT_VIEW, new
StringBuilder());
statusBuffers.put(UiServices.DIAG_VIEW, new
StringBuilder());
}

=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/TestsActivity.java Thu Dec 15 06:19:29 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/TestsActivity.java Thu Dec 15 07:59:31 2011
@@ -70,7 +70,8 @@
NdtService.INTENT_UPDATE_STATUS));

Intent intent = new Intent(getApplicationContext(),
NdtService.class);
- intent.putExtra("networkType", getNetworkType());
+ intent.putExtra(NdtService.EXTRA_NETWORK_TYPE,
getNetworkType());
+ intent.putExtra(NdtService.EXTRA_SERVER_HOST, getIntent().getStringExtra(NdtService.EXTRA_SERVER_HOST));
startService(intent);

Log.i(LOG_TAG, "Tests activity resumed.");
@@ -219,7 +220,7 @@

private String getServerAddress() {
try {
- InetAddress server = InetAddress.getByName(Constants.SERVER_HOST[Constants.DEFAULT_SERVER]);
+ InetAddress server = InetAddress.getByName(Constants.SERVER_LIST[Constants.DEFAULT_SERVER][1]);
return server.getHostAddress();
} catch (UnknownHostException e) {
Log.e(LOG_TAG, "Error resolving server hosts.", e);


  • [ndt-dev] [ndt] r758 committed - Restore server selection feature., ndt, 12/15/2011

Archive powered by MHonArc 2.6.16.

Top of Page