Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r762 committed - Clean up sources, eliminating need for Constants interface.

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r762 committed - Clean up sources, eliminating need for Constants interface.


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r762 committed - Clean up sources, eliminating need for Constants interface.
  • Date: Thu, 15 Dec 2011 16:19:23 +0000

Revision: 762
Author:

Date: Thu Dec 15 08:12:46 2011
Log: Clean up sources, eliminating need for Constants interface.
http://code.google.com/p/ndt/source/detail?r=762

Modified:
/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/NdtSupport.java
/branches/android/Android/src/net/measurementlab/ndt/SelectServerActivity.java
/branches/android/Android/src/net/measurementlab/ndt/TestsActivity.java

=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/InitialActivity.java Thu Dec 15 08:06:20 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/InitialActivity.java Thu Dec 15 08:12:46 2011
@@ -18,7 +18,7 @@
*/
public class InitialActivity extends Activity {

- private int serverNumber = Constants.DEFAULT_SERVER;
+ private int serverNumber = SelectServerActivity.DEFAULT_SERVER;

/**
* Initializes the activity.
@@ -38,7 +38,7 @@
Intent intent = new
Intent(getApplicationContext(),
TestsActivity.class);
intent.putExtra(NdtService.EXTRA_SERVER_HOST,
-
Constants.SERVER_LIST[serverNumber][1]);
+
SelectServerActivity.SERVER_LIST[serverNumber][1]);
startActivity(intent);
}
});
@@ -84,7 +84,7 @@
serverNumber = data.getExtras().getInt(

SelectServerActivity.EXTRA_SERVER_NUMBER);
Toast serverSelected =
Toast.makeText(getApplicationContext(),
- "Selected " +
Constants.SERVER_LIST[serverNumber][0],
+ "Selected " +
SelectServerActivity.SERVER_LIST[serverNumber][0],
10);
serverSelected.show();
}
=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/NdtService.java Thu Dec 15 07:59:31 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/NdtService.java Thu Dec 15 08:12:46 2011
@@ -1,7 +1,5 @@
package net.measurementlab.ndt;

-import static net.measurementlab.ndt.Constants.LOG_TAG;
-
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@@ -104,13 +102,13 @@
@Override
public void onCreate() {
super.onCreate();
- Log.i(LOG_TAG, "Service created.");
+ Log.i(NdtSupport.LOG_TAG, "Service created.");
intent = new Intent(INTENT_UPDATE_STATUS);
}

@Override
public void onStart(Intent intent, int startId) {
- Log.i(LOG_TAG, "Starting NDT service.");
+ Log.i(NdtSupport.LOG_TAG, "Starting NDT service.");
super.onStart(intent, startId);

// this means the service is already started
@@ -134,14 +132,14 @@

String serverHost = intent.getStringExtra(EXTRA_SERVER_HOST);
if (null == serverHost) {
- serverHost =
Constants.SERVER_LIST[Constants.DEFAULT_SERVER][1];
+ serverHost = SelectServerActivity.SERVER_LIST[SelectServerActivity.DEFAULT_SERVER][1];
}

try {
new Thread(new NdtTests(serverHost, uiServices,
networkType))
.start();
} catch (Throwable tr) {
- Log.e(LOG_TAG, "Problem running tests.", tr);
+ Log.e(NdtSupport.LOG_TAG, "Problem running tests.",
tr);
intent.putExtra(EXTRA_STATUS, STATUS_ERROR);
}
}
@@ -155,7 +153,7 @@
}
uiServices = null;
unregisterReceiver(stopReceiver);
- Log.i(LOG_TAG, "Finishing NDT service.");
+ Log.i(NdtSupport.LOG_TAG, "Finishing NDT service.");
}

private BroadcastReceiver createReceiver() {
@@ -163,7 +161,7 @@

@Override
public void onReceive(Context context, Intent intent)
{
- Log.i(LOG_TAG, "Stop request received.");
+ Log.i(NdtSupport.LOG_TAG, "Stop request
received.");
uiServices.requestStop();
}
};
@@ -201,7 +199,7 @@
*/
@Override
public void appendString(String message, int viewId) {
- Log.d(LOG_TAG, String.format("Appended: (%1$d)
%2$s.", viewId,
+ Log.d(NdtSupport.LOG_TAG, String.format("Appended: (%1$d) %2$s.", viewId,
message.trim()));

if (statusBuffers.containsKey(viewId)) {
@@ -213,20 +211,20 @@

if (message.contains(C2S_MSG_FRAGMENT)
&& UiServices.MAIN_VIEW == viewId) {
- Log.i(LOG_TAG, "Starting upload test.");
+ Log.i(NdtSupport.LOG_TAG, "Starting upload
test.");
intent.putExtra(EXTRA_STATUS,
STATUS_UPLOADING);
sendBroadcast(intent);
status = STATUS_UPLOADING;
- Log.i(LOG_TAG, "Broadcast status change.");
+ Log.i(NdtSupport.LOG_TAG, "Broadcast status
change.");
}

if (message.contains(S2C_MSG_FRAGMENT)
&& UiServices.MAIN_VIEW == viewId) {
- Log.i(LOG_TAG, "Starting download test.");
+ Log.i(NdtSupport.LOG_TAG, "Starting download
test.");
intent.putExtra(EXTRA_STATUS,
STATUS_DOWNLOADING);
sendBroadcast(intent);
status = STATUS_DOWNLOADING;
- Log.i(LOG_TAG, "Broadcast status change.");
+ Log.i(NdtSupport.LOG_TAG, "Broadcast status
change.");
}
}

@@ -235,7 +233,7 @@
*/
@Override
public void incrementProgress() {
- Log.d(LOG_TAG, "Incremented progress.");
+ Log.d(NdtSupport.LOG_TAG, "Incremented progress.");
}

/**
@@ -243,7 +241,7 @@
*/
@Override
public void logError(String str) {
- Log.e(LOG_TAG, String.format("Error: %1$s.",
str.trim()));
+ Log.e(NdtSupport.LOG_TAG, String.format("Error:
%1$s.", str.trim()));
}

/**
@@ -251,7 +249,7 @@
*/
@Override
public void onBeginTest() {
- Log.d(LOG_TAG, "Test begun.");
+ Log.d(NdtSupport.LOG_TAG, "Test begun.");
wantToStop = false;
}

@@ -260,7 +258,7 @@
*/
@Override
public void onEndTest() {
- Log.d(LOG_TAG, "Test ended.");
+ Log.d(NdtSupport.LOG_TAG, "Test ended.");
intent.putExtra(EXTRA_STATUS, STATUS_COMPLETE);
intent.putExtra(EXTRA_DIAG_STATUS, statusBuffers.get(
UiServices.DIAG_VIEW).toString());
@@ -268,7 +266,7 @@
sendBroadcast(intent);
status = STATUS_COMPLETE;
wantToStop = false;
- Log.i(LOG_TAG, "Broadcast status change.");
+ Log.i(NdtSupport.LOG_TAG, "Broadcast status change.");
}

/**
@@ -276,7 +274,7 @@
*/
@Override
public void onFailure(String errorMessage) {
- Log.d(LOG_TAG, String.format("Failed: %1$s.",
errorMessage));
+ Log.d(NdtSupport.LOG_TAG, String.format("Failed:
%1$s.", errorMessage));
intent.putExtra(EXTRA_STATUS, STATUS_ERROR);
sendBroadcast(intent);
status = STATUS_ERROR;
@@ -288,7 +286,7 @@
*/
@Override
public void onLoginSent() {
- Log.d(LOG_TAG, "Login sent.");
+ Log.d(NdtSupport.LOG_TAG, "Login sent.");
}

/**
@@ -296,7 +294,7 @@
*/
@Override
public void onPacketQueuingDetected() {
- Log.d(LOG_TAG, "Packet queuing detected.");
+ Log.d(NdtSupport.LOG_TAG, "Packet queuing detected.");
}

/**
@@ -335,7 +333,7 @@
*/
@Override
public void updateStatus(String status) {
- Log.d(LOG_TAG, String.format("Updating status:
%1$s.", status));
+ Log.d(NdtSupport.LOG_TAG, String.format("Updating status: %1$s.", status));
}

/**
@@ -343,7 +341,7 @@
*/
@Override
public void updateStatusPanel(String status) {
- Log.d(LOG_TAG, String
+ Log.d(NdtSupport.LOG_TAG, String
.format("Updating status panel:
%1$s.", status));
}

=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/NdtSupport.java Wed Aug 24 09:02:56 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/NdtSupport.java Thu Dec 15 08:12:46 2011
@@ -55,4 +55,9 @@
textView.setTypeface(typeface);
}
}
-}
+
+ /**
+ * TAG constant for logging.
+ */
+ static final String LOG_TAG = "NDT";
+}
=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/SelectServerActivity.java Thu Dec 15 08:08:02 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/SelectServerActivity.java Thu Dec 15 08:12:46 2011
@@ -20,10 +20,43 @@

public static final int ACTIVITY_SELECT_SERVER = 1;
private int serverNo = 0;
- private RadioButton server[] = new RadioButton[Constants.NUMBER_OF_SERVERS];
+ private RadioButton server[] = new RadioButton[SelectServerActivity.NUMBER_OF_SERVERS];
private Button buttonOptionSave;
private RadioGroup radioGroup;

+ 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.
+ */
+ static final int NUMBER_OF_SERVERS = SERVER_LIST.length;
+
+ // Options
+ // See newest server list here:
+ // http://www.measurementlab.net/measurement-lab-tools#ndt
+ // All the data here should be kept sync with the published list
+ // In future server list should be downloaded from some list servers
+ // dynamically.
+ static final int DEFAULT_SERVER = 0;
+
/**
* Reads the server list from Constants class. Records the user's choice and
* send it back to the main activity.
@@ -39,9 +72,9 @@
}
radioGroup = (RadioGroup) findViewById(R.id.servergroup);
buttonOptionSave = (Button)
findViewById(R.id.ButtonServerSave);
- for (int i = 0; i < Constants.NUMBER_OF_SERVERS; i++) {
+ for (int i = 0; i < SelectServerActivity.NUMBER_OF_SERVERS;
i++) {
server[i] = new RadioButton(this);
- server[i].setText(Constants.SERVER_LIST[i][0]);
+
server[i].setText(SelectServerActivity.SERVER_LIST[i][0]);
radioGroup.addView(server[i]);
}
server[serverNo].setChecked(true);
@@ -62,7 +95,7 @@
*/
@Override
public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
- for (int i = 0; i < Constants.NUMBER_OF_SERVERS; i++) {
+ for (int i = 0; i < SelectServerActivity.NUMBER_OF_SERVERS;
i++) {
if (server[i].getId() == checkedId) {
serverNo = i;
}
=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/TestsActivity.java Thu Dec 15 07:59:31 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/TestsActivity.java Thu Dec 15 08:12:46 2011
@@ -21,8 +21,6 @@
import android.widget.ImageView;
import android.widget.TextView;

-import static net.measurementlab.ndt.Constants.LOG_TAG;
-
/**
* Animated progress while selecting server location.
*/
@@ -36,7 +34,7 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tests);
- Log.i(LOG_TAG, "Loaded!");
+ Log.i(NdtSupport.LOG_TAG, "Loaded!");
Typeface typeFace = Typeface.createFromAsset(getAssets(),
"fonts/League_Gothic.otf");
TextView textView = (TextView)
findViewById(R.id.NdtTestsHeader);
@@ -56,7 +54,7 @@
@Override
protected void onStart() {
super.onStart();
- Log.i(LOG_TAG, "Tests activity started.");
+ Log.i(NdtSupport.LOG_TAG, "Tests activity started.");
}

@Override
@@ -74,7 +72,7 @@
intent.putExtra(NdtService.EXTRA_SERVER_HOST, getIntent().getStringExtra(NdtService.EXTRA_SERVER_HOST));
startService(intent);

- Log.i(LOG_TAG, "Tests activity resumed.");
+ Log.i(NdtSupport.LOG_TAG, "Tests activity resumed.");
}

@Override
@@ -93,7 +91,7 @@
}

private void preparing() {
- Log.i(LOG_TAG, "Preparing Your Tests...");
+ Log.i(NdtSupport.LOG_TAG, "Preparing Your Tests...");
updateHeader(R.string.tests_preparing_header);

String localAddress = getLocalAddress();
@@ -113,7 +111,7 @@
}

private void uploading() {
- Log.i(LOG_TAG, "Testing Upload...");
+ Log.i(NdtSupport.LOG_TAG, "Testing Upload...");
updateHeader(R.string.tests_both_header,
R.string.tests_upload_info);
ImageView imageView = (ImageView)
findViewById(R.id.NdtTestsProgress);
imageView.setImageDrawable(getResources().getDrawable(R.drawable.progress_bar_left));
@@ -122,7 +120,7 @@
}

private void downloading() {
- Log.i(LOG_TAG, "Testing Download...");
+ Log.i(NdtSupport.LOG_TAG, "Testing Download...");
updateHeader(R.string.tests_both_header,
R.string.tests_download_info);
ImageView imageView = (ImageView)
findViewById(R.id.NdtTestsProgress);
imageView.setImageDrawable(getResources().getDrawable(R.drawable.progress_bar_right));
@@ -131,7 +129,7 @@
}

private void complete(Intent status) {
- Log.i(LOG_TAG, "Testing Complete.");
+ Log.i(NdtSupport.LOG_TAG, "Testing Complete.");
updateHeader(R.string.tests_complete_header);
ImageView imageView = (ImageView)
findViewById(R.id.NdtTestsProgress);
imageView.setImageDrawable(null);
@@ -146,7 +144,7 @@

@Override
public void onReceive(Context context, Intent intent)
{
- Log.i(LOG_TAG, "Status change received.");
+ Log.i(NdtSupport.LOG_TAG, "Status change
received.");
int status = intent.getIntExtra(NdtService.EXTRA_STATUS, NdtService.STATUS_PREPARING);
switch (status) {
case NdtService.STATUS_PREPARING:
@@ -162,12 +160,12 @@
complete(intent);
break;
default:
- Log.i(LOG_TAG, "Test reporter not
initialized.");
+ Log.i(NdtSupport.LOG_TAG, "Test reporter
not initialized.");
break;
}
}
};
- Log.i(LOG_TAG, "Status receiver created.");
+ Log.i(NdtSupport.LOG_TAG, "Status receiver created.");
return receiver;

}
@@ -213,17 +211,17 @@
}
}
} catch (SocketException ex) {
- Log.e(LOG_TAG, ex.toString());
+ Log.e(NdtSupport.LOG_TAG, ex.toString());
}
return null;
}

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


  • [ndt-dev] [ndt] r762 committed - Clean up sources, eliminating need for Constants interface., ndt, 12/15/2011

Archive powered by MHonArc 2.6.16.

Top of Page