Commit 51860f26 authored by Kristin Muterspaw's avatar Kristin Muterspaw
Browse files

Fixed the problem where documents under 'note pad' wouldn't show up if they...

Fixed the problem where documents under 'note pad' wouldn't show up if they already existed. took out 1 second sampling interval and replaced it with 3.
parent 1c815415
......@@ -89,8 +89,10 @@ public class BluetoothSensor implements Parcelable {
Log.d("Bluetooth Sensor", "On characteristic read");
String d = "";
try {
d = new String(data, "UTF-8").replaceAll("[^\\x00-\\x7F]", "");
} catch (UnsupportedEncodingException e) {
for (byte b : data) {
d += (char) b;
}
} catch (Exception e) {
throw new RuntimeException(e);
}
Log.d("Bluetooth Sensor", "Data:" + d);
......
......@@ -603,6 +603,8 @@ public class DatabaseActionsActivity extends Activity {
}
public void makeToast(String message) {
Toast t = Toast.makeText(DatabaseActionsActivity.this, message, Toast.LENGTH_LONG);
t.setGravity(Gravity.CENTER, 0, 0);
......
package fieldscience.cs.earlham.edu.fieldday;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
......@@ -37,7 +36,7 @@ import java.util.List;
public class MyDocumentsActivity extends Activity {
public static final String directory = Environment.getExternalStorageDirectory().toString() +
File.separator + "FieldDay" + File.separator + "myDocuments";
File.separator + "FieldDay";
Button downloadFiles;
private static final String TAG = "MyDocumentsActivity";
public static List<String> downloadList, dirList;
......@@ -70,10 +69,10 @@ public class MyDocumentsActivity extends Activity {
localDirList = new ArrayList<File>();
// Check to see if the root directory exists. If it does, get the list of files in it to
// use for the ListView of files
final File rootDir = createDirectory(directory);
// use for the ListView of file
final File rootDir = createDirectory("myDocuments");
if (rootDir.listFiles() != null) {
if (rootDir.listFiles().length == 0) {
if (rootDir.listFiles().length != 0) {
localDirList = getFilesInDir(rootDir);
}
}
......@@ -150,6 +149,7 @@ public class MyDocumentsActivity extends Activity {
public File createDirectory(String dirName) {
try {
File sd = Environment.getExternalStorageDirectory();
Log.d(TAG, "here");
if (sd.canWrite()) {
File baseDir = new File(directory);
if (!baseDir.exists()){
......@@ -300,7 +300,7 @@ public class MyDocumentsActivity extends Activity {
private class downloadListOfFiles extends AsyncTask<Void, Void, Boolean> {
@Override
protected Boolean doInBackground(Void... params){
protected Boolean doInBackground(Void... params) {
URL fileHost = null;
for (String file : downloadList) {
if (file.matches("^(\\w+)(/)$")) {
......
......@@ -102,10 +102,6 @@ public class SensorSampleActivity extends Activity {
Log.d("SensorSampleActivity", "Received Connected Message!");
enableButtons();
ArrayList<aSensor> sensors = intent.getParcelableArrayListExtra(SensorSampleService.SENSOR_LIST);
for (aSensor s: sensors) {
Log.d("SensorSampleActivity", "Sensor: " + s.getName());
Log.d("SensorSampleActivity", "Sensor Value: " + s.getLastValueString());
}
adapter.clear();
adapter.addAll(sensors);
adapter.notifyDataSetChanged();
......@@ -341,8 +337,8 @@ public class SensorSampleActivity extends Activity {
public void changeInterval(View v) {
switch(v.getId()){
case R.id.oneSecond:
logInterval = 1000;
case R.id.threeSeconds:
logInterval = 1000 * 3;
break;
case R.id.fiveSeconds:
logInterval = 1000 * 5;
......@@ -569,7 +565,7 @@ public class SensorSampleActivity extends Activity {
startActivityForResult(i, 0);
}
// By default android pictures using the Media.Image_capture are not full size when returning from
// By default android pictures using the Media.IMAGE_CAPTURE are not full size when returning from
// the activity. I crete a temporary directory to save the file in and retrieve it later.
public File createTempFile() throws Exception {
File temp = new File(baseDir, "tmp");
......
......@@ -98,15 +98,19 @@ public class SensorSampleService extends Service implements SensorEventListener
} else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) {
btService = null;
dbHandler.removeCallbacksAndMessages(dbRunner);
btHandler.removeCallbacksAndMessages(btRunNames);
btHandler.removeCallbacksAndMessages(btRunValues);
broadcastUpdate(ACTION_DISCONNECTED);
} else if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) {
btService.readMessage();
btHandler.postDelayed(btRunNames, 5000);
btHandler.removeCallbacksAndMessages(btRunNames);
if (!registered) {
btHandler.postDelayed(btRunNames, 5000);
btHandler.removeCallbacksAndMessages(btRunNames);
} else {
btHandler.postDelayed(btRunValues, 5000);
}
} else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) {
if (btService != null) {
Log.d(TAG, "HERE");
Log.d(TAG, response);
if (BluetoothLeService.current_request.equals(BluetoothLeService.LIST_OF_SENSORS)) {
parseResponse(intent.getStringExtra(BluetoothLeService.EXTRA_DATA));
} else if (BluetoothLeService.current_request.equals(BluetoothLeService.SENSOR_VALUES)){
......@@ -141,7 +145,7 @@ public class SensorSampleService extends Service implements SensorEventListener
@Override
public void run() {
getSensorValues();
btHandler.postDelayed(this, 2000);
btHandler.postDelayed(this, 5000);
}
};
......@@ -156,7 +160,7 @@ public class SensorSampleService extends Service implements SensorEventListener
response = "";
pictureName = "";
loggingInterval = 1000;
loggingInterval = 5000;
sensorList = new ArrayList<aSensor>();
builtinList = new ArrayList<Sensor>();
......@@ -274,9 +278,8 @@ public class SensorSampleService extends Service implements SensorEventListener
private final IBinder mBinder = new LocalBinder();
public void parseResponse(String d){
public void parseResponse(String d) {
response += d;
Log.d(TAG, "HERE");
Log.d(TAG, response);
if (response.endsWith("done")) {
if (BluetoothLeService.current_request.equals(BluetoothLeService.LIST_OF_SENSORS)) {
......@@ -284,6 +287,7 @@ public class SensorSampleService extends Service implements SensorEventListener
} else {
updateSensorValues();
}
response = "";
}
}
......@@ -297,15 +301,15 @@ public class SensorSampleService extends Service implements SensorEventListener
String[] tokens = sensor.split(delims);
aSensor sens = new aSensor(tokens[1], tokens[0]);
sens.setPlatform(bluetoothSensor.getDeviceName());
Log.d(TAG, sens.getName());
sensorList.add(sens);
sensor = "";
} else {
sensor += c;
}
}
btHandler.removeMessages(0);
btHandler.removeCallbacksAndMessages(btRunNames);
btHandler.postDelayed(btRunValues, 1000);
btHandler.postDelayed(btRunValues, 3000);
}
response = "";
}
......@@ -336,6 +340,7 @@ public class SensorSampleService extends Service implements SensorEventListener
broadcastUpdate(ACTION_CONNECTED);
}
response = "";
//getSensorValues();
}
public void connectSensor(String sensor, BluetoothSensor btSensor) {
......@@ -351,8 +356,6 @@ public class SensorSampleService extends Service implements SensorEventListener
builtinList = mSensorManager.getSensorList(Sensor.TYPE_ALL);
for (Sensor s : builtinList){
Log.d(TAG, "sensor in built in list: " + s.getName());
Log.d(TAG, "sensor in built in list type: " + s.getStringType());
if (s.getStringType().contains("android")){
if (!s.getName().contains("Secondary")){
mSensorManager.registerListener(this, s, 100000000);
......@@ -368,8 +371,6 @@ public class SensorSampleService extends Service implements SensorEventListener
aSensor sens = new aSensor(builtinList.get(i));
String[] tokens = sens.getStringType().split(delims);
sens.setName(tokens[2]);
Log.d(TAG, "Setting aSensor name: " + tokens[2]);
Log.d(TAG, "aSensor type: " + sens.getStringType());
sensorList.add(sens);
}
}
......
......@@ -90,11 +90,11 @@
android:layout_height="wrap_content"
android:background="@drawable/intervalbuttonselector"
android:button="@android:color/transparent"
android:id="@+id/oneSecond"
android:id="@+id/threeSeconds"
android:onClick="changeInterval"
android:checked="true"
android:padding="10dp"
android:text="@string/oneSecond" />
android:text="@string/threeSeconds" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
......@@ -90,11 +90,11 @@
android:layout_height="wrap_content"
android:background="@drawable/intervalbuttonselector"
android:button="@android:color/transparent"
android:id="@+id/oneSecond"
android:id="@+id/threeSeconds"
android:onClick="changeInterval"
android:checked="true"
android:padding="10dp"
android:text="@string/oneSecond" />
android:text="@string/threeSeconds" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
......@@ -49,7 +49,7 @@
<string name="Site">Site</string>
<string name="Sector">Sector</string>
<string name="Spot">Spot</string>
<string name="oneSecond">1</string>
<string name="threeSeconds">3</string>
<string name="fiveSeconds">5</string>
<string name="tenSeconds">10</string>
<string name="thirtySeconds">30</string>
......
Markdown is supported
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