|
|
|
@ -73,7 +73,7 @@ public class ActivitySelectSensor extends AppCompatActivity
|
|
|
|
|
private ListView listView;
|
|
|
|
|
private SensorManager sensorManager;
|
|
|
|
|
private ArrayList<Sensor> sensors = new ArrayList<>();
|
|
|
|
|
private EditText sessionIdText;
|
|
|
|
|
// private EditText sessionIdText;
|
|
|
|
|
private RealTimeSensorReader sensorReader = null;
|
|
|
|
|
private RealTimeSensorChangeReceiver realTimeSensorChangeReceiver = new RealTimeSensorChangeReceiver();
|
|
|
|
|
private SupportedSensors supportedSensors = SupportedSensors.getInstance();
|
|
|
|
@ -87,21 +87,21 @@ public class ActivitySelectSensor extends AppCompatActivity
|
|
|
|
|
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
|
|
|
|
setSupportActionBar(toolbar);
|
|
|
|
|
sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
|
|
|
|
|
sessionIdText = (EditText) findViewById(R.id.sessionId);
|
|
|
|
|
sessionIdText.setCursorVisible(false);
|
|
|
|
|
//sessionIdText = (EditText) findViewById(R.id.sessionId);
|
|
|
|
|
// sessionIdText.setCursorVisible(false);
|
|
|
|
|
|
|
|
|
|
listView = (ListView) findViewById(R.id.senseListContainer);
|
|
|
|
|
verifyBluetooth();
|
|
|
|
|
//verifyBluetooth();
|
|
|
|
|
|
|
|
|
|
registerReceiver(realTimeSensorChangeReceiver, new IntentFilter("sensorDataMap"));
|
|
|
|
|
|
|
|
|
|
sessionIdText.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
sessionIdText.setCursorVisible(true);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// sessionIdText.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onClick(View v) {
|
|
|
|
|
// sessionIdText.setCursorVisible(true);
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
//Publish data
|
|
|
|
|
FloatingActionButton fbtnPublishData = (FloatingActionButton) findViewById(R.id.publish);
|
|
|
|
@ -126,33 +126,33 @@ public class ActivitySelectSensor extends AppCompatActivity
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
FloatingActionButton fbtnSpeechRecongnizer = (FloatingActionButton) findViewById(R.id.speech);
|
|
|
|
|
fbtnSpeechRecongnizer.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
String sessionId = sessionIdText.getText().toString();
|
|
|
|
|
if (!sessionId.isEmpty()) {
|
|
|
|
|
Intent intent = new Intent(getApplicationContext(), WordRecognitionActivity.class);
|
|
|
|
|
intent.putExtra("sessionId", sessionId);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
} else {
|
|
|
|
|
Toast.makeText(ActivitySelectSensor.this, "Please type a session id value", Toast.LENGTH_SHORT)
|
|
|
|
|
.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
FloatingActionButton fbtnBeaconMonitor = (FloatingActionButton) findViewById(R.id.beacon);
|
|
|
|
|
fbtnBeaconMonitor.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
Intent intent = new Intent(getApplicationContext(), BeaconMonitoringActivity.class);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
//FloatingActionButton fbtnSpeechRecongnizer = (FloatingActionButton) findViewById(R.id.speech);
|
|
|
|
|
// fbtnSpeechRecongnizer.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onClick(View v) {
|
|
|
|
|
// String sessionId = sessionIdText.getText().toString();
|
|
|
|
|
// if (!sessionId.isEmpty()) {
|
|
|
|
|
// Intent intent = new Intent(getApplicationContext(), WordRecognitionActivity.class);
|
|
|
|
|
// intent.putExtra("sessionId", sessionId);
|
|
|
|
|
// startActivity(intent);
|
|
|
|
|
// } else {
|
|
|
|
|
// Toast.makeText(ActivitySelectSensor.this, "Please type a session id value", Toast.LENGTH_SHORT)
|
|
|
|
|
// .show();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// FloatingActionButton fbtnBeaconMonitor = (FloatingActionButton) findViewById(R.id.beacon);
|
|
|
|
|
// fbtnBeaconMonitor.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onClick(View v) {
|
|
|
|
|
// Intent intent = new Intent(getApplicationContext(), BeaconMonitoringActivity.class);
|
|
|
|
|
// startActivity(intent);
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sharedPreferences = getSharedPreferences(SupportedSensors.SELECTED_SENSORS, 0);
|
|
|
|
@ -313,43 +313,43 @@ public class ActivitySelectSensor extends AppCompatActivity
|
|
|
|
|
unregisterReceiver(realTimeSensorChangeReceiver);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void verifyBluetooth() {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if (!BeaconManager.getInstanceForApplication(this).checkAvailability()) {
|
|
|
|
|
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
|
builder.setTitle("Bluetooth not enabled");
|
|
|
|
|
builder.setMessage("Please enable bluetooth in settings and restart this application.");
|
|
|
|
|
builder.setPositiveButton(android.R.string.ok, null);
|
|
|
|
|
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDismiss(DialogInterface dialog) {
|
|
|
|
|
finish();
|
|
|
|
|
System.exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
builder.show();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} catch (RuntimeException e) {
|
|
|
|
|
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
|
builder.setTitle("Bluetooth LE not available");
|
|
|
|
|
builder.setMessage("Sorry, this device does not support Bluetooth LE.");
|
|
|
|
|
builder.setPositiveButton(android.R.string.ok, null);
|
|
|
|
|
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDismiss(DialogInterface dialog) {
|
|
|
|
|
finish();
|
|
|
|
|
System.exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
builder.show();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// private void verifyBluetooth() {
|
|
|
|
|
//
|
|
|
|
|
// try {
|
|
|
|
|
// if (!BeaconManager.getInstanceForApplication(this).checkAvailability()) {
|
|
|
|
|
// final AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
|
// builder.setTitle("Bluetooth not enabled");
|
|
|
|
|
// builder.setMessage("Please enable bluetooth in settings and restart this application.");
|
|
|
|
|
// builder.setPositiveButton(android.R.string.ok, null);
|
|
|
|
|
// builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
|
|
|
|
//
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onDismiss(DialogInterface dialog) {
|
|
|
|
|
// finish();
|
|
|
|
|
// System.exit(0);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// });
|
|
|
|
|
// builder.show();
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// } catch (RuntimeException e) {
|
|
|
|
|
// final AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
|
// builder.setTitle("Bluetooth LE not available");
|
|
|
|
|
// builder.setMessage("Sorry, this device does not support Bluetooth LE.");
|
|
|
|
|
// builder.setPositiveButton(android.R.string.ok, null);
|
|
|
|
|
// builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
|
|
|
|
//
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onDismiss(DialogInterface dialog) {
|
|
|
|
|
// finish();
|
|
|
|
|
// System.exit(0);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// });
|
|
|
|
|
// builder.show();
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|