2626
2727import org .w3c .dom .Text ;
2828
29+ import java .util .Locale ;
30+
2931import edu .umd .cmsc436 .sheets .Sheets ;
3032
3133public class Sway extends AppCompatActivity implements SensorEventListener , Sheets .Host {
@@ -114,17 +116,13 @@ public void onFinish() {
114116 for (int i = 1 ; i < 11 ; i ++) {
115117 x_pos = t1 [i ][0 ]*scaleFac ;
116118 y_pos = t1 [i ][1 ]*scaleFac ;
117- // x_pos = hardcodeX[i-1];
118- // y_pos = hardcodeY[i-1];
119119 mPath .lineTo (x_mid +x_pos ,y_mid +y_pos );
120120 }
121121
122122 mCanvas1 .drawPath (mPath , mPaint );
123123
124124 savePictureToGallery (mBitmap1 , 1 );
125125
126- //TODO; write average sway for each trial to Sheets
127-
128126 //calculate average distance from center
129127 float x = 0 ;
130128 float y = 0 ;
@@ -141,7 +139,6 @@ public void onFinish() {
141139 }
142140
143141 scores [0 ] = distance /10 ;
144- // tv.setText("x: " + x/10 + "\ny: " + y/10 + "\nz: " + z/10);
145142 tv .setText ("\n Trial 1 Done\n Score: " + scores [0 ]);
146143
147144
@@ -165,8 +162,6 @@ public void onFinish() {
165162
166163 savePictureToGallery (mBitmap2 , 2 );
167164
168- //TODO; write average sway for each trial to Sheets
169-
170165 //calculate average distance from center
171166 float x = 0 ;
172167 float y = 0 ;
@@ -183,7 +178,6 @@ public void onFinish() {
183178 }
184179
185180 scores [1 ] = distance /10 ;
186- // tv.setText("x: " + x/10 + "\ny: " + y/10 + "\nz: " + z/10);
187181 tv .setText ("\n Trial 2 Done\n Score: " + scores [1 ]);
188182
189183 } else if (trial == 3 ) {
@@ -205,8 +199,6 @@ public void onFinish() {
205199
206200 savePictureToGallery (mBitmap3 , 3 );
207201
208- //TODO; write average sway for each trial to Sheets
209-
210202 //calculate average distance from center
211203 float x = 0 ;
212204 float y = 0 ;
@@ -223,7 +215,6 @@ public void onFinish() {
223215 }
224216
225217 scores [2 ] = distance /10 ;
226- // tv.setText("x: " + x/10 + "\ny: " + y/10 + "\nz: " + z/10);
227218
228219 tv .setText ("Trial 3 Done\n Score: " + scores [2 ]);
229220
@@ -283,16 +274,10 @@ public void onAccuracyChanged(Sensor sensor, int accuracy) {
283274 public void onSensorChanged (SensorEvent event ) {
284275 if (trial == 1 ) {
285276 System .arraycopy (event .values , 0 , t1 [curIdx ], 0 , 3 );
286- //TextView tv = (TextView) findViewById(R.id.textView1);
287- //tv.setText(curIdx + " X: "+t1[curIdx][0]);
288277 } else if (trial == 2 ) {
289278 System .arraycopy (event .values , 0 , t2 [curIdx ], 0 , 3 );
290- //TextView tv = (TextView) findViewById(R.id.textView1);
291- //tv.setText(curIdx + " Y: "+t2[curIdx][1]);
292279 } else if (trial == 3 ) {
293280 System .arraycopy (event .values , 0 , t3 [curIdx ], 0 , 3 );
294- //TextView tv = (TextView) findViewById(R.id.textView1);
295- //tv.setText(curIdx + " Z: "+t3[curIdx][2]);
296281 }
297282
298283 }
@@ -310,7 +295,7 @@ public void initializePaint() {
310295 }
311296
312297 private void savePictureToGallery (Bitmap toSave , int trial ) {
313- String descript = String .format ("Trial %d" , trial );
298+ String descript = String .format (Locale . getDefault (), "Trial %d" , trial );
314299 String savedImageURL = MediaStore .Images .Media .insertImage (getContentResolver (), toSave , "Sway" , descript );
315300
316301 Context context = getApplicationContext ();
0 commit comments