Commit 7de8ebff authored by leslie0216's avatar leslie0216
Browse files

-close logger when exit

-add popup window when block finish
-show block# and trial# on the screen
parent 32f80afe
......@@ -144,6 +144,7 @@ public class MainActivity extends ActionBarActivity implements NfcAdapter.Create
if (!m_mainView.isFinished()) {
m_mainView.startBlock();
} else {
m_mainView.closeLogger();
finish();
System.exit(0);
}
......
package ca.usask.chl848.nfc;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
......@@ -99,6 +101,7 @@ public class MainView extends View {
showBoundary(canvas);
showMessage(canvas);
showBalls(canvas);
showProgress(canvas);
}
public void showBoundary(Canvas canvas) {
......@@ -143,6 +146,20 @@ public class MainView extends View {
}
}
public void showProgress(Canvas canvas) {
m_paint.setTextSize(m_messageTextSize);
m_paint.setColor(Color.BLUE);
m_paint.setStrokeWidth(m_textStrokeWidth);
m_paint.setStyle(Paint.Style.FILL_AND_STROKE);
DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
String block = "Block: " + m_currentBlock +"/" + m_maxBlocks;
canvas.drawText(block, (int) (displayMetrics.widthPixels * 0.75), (int) (displayMetrics.heightPixels * 0.1), m_paint);
String trial = "Trial: " + m_currentTrail +"/" + m_maxTrails;
canvas.drawText(trial, (int) (displayMetrics.widthPixels * 0.75), (int) (displayMetrics.heightPixels * 0.15), m_paint);
}
public int getBallCount() {
return m_balls.size();
}
......@@ -424,6 +441,7 @@ public class MainView extends View {
@Override
public void run() {
((MainActivity) getContext()).setStartButtonEnabled(true);
((MainActivity) getContext()).setContinueButtonEnabled(false);
}
});
}
......@@ -471,13 +489,22 @@ public class MainView extends View {
resetBlock();
startTrial();
((MainActivity)getContext()).setStartButtonEnabled(false);
((MainActivity)getContext()).setContinueButtonEnabled(false);
}
public void endBlock() {
if (isFinished() && (m_logger != null)) {
m_logger.close();
closeLogger();
}
new AlertDialog.Builder(getContext()).setTitle("Warning").setMessage("You have completed block " + m_currentBlock + ", please wait for other participants.").setNeutralButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).show();
((MainActivity) getContext()).setContinueButtonEnabled(true);
((MainActivity)getContext()).setStartButtonEnabled(false);
m_currentTrail = 0;
}
......@@ -492,6 +519,14 @@ public class MainView extends View {
long trailEndTime = System.currentTimeMillis();
long timeElapse = trailEndTime - m_trailStartTime;
if (m_currentBlock == 0) {
++m_currentBlock;
}
if (m_currentTrail == 0) {
++m_currentTrail;
}
//<participantID> <participantName> <condition> <block#> <trial#> <elapsed time for this trial> <transactionId> <timestamp>
if (m_logger != null) {
m_logger.write(m_id + "," + m_name + "," + getResources().getString(R.string.app_name) + "," + m_currentBlock + "," + m_currentTrail + "," + timeElapse + "," + m_transactionId + "," + trailEndTime, true);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment