diff --git a/.idea/misc.xml b/.idea/misc.xml index 75dac502959ec4f6e5232282499067f85aa716f5..39638799269d0193201b39e5276d8236659f97fe 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -24,7 +24,7 @@ </value> </option> </component> - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK"> + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/build/classes" /> </component> <component name="ProjectType"> diff --git a/common/build.gradle b/common/build.gradle index 8e95a6bf671e9eef5dc252ba417278bf1aa0e0e4..0b1a1f1db0e798707940a79a2787938800b3bd62 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -6,7 +6,7 @@ android { defaultConfig { - minSdkVersion 24 + minSdkVersion 23 targetSdkVersion 26 versionCode 1 versionName "1.0" diff --git a/wear/build.gradle b/wear/build.gradle index 5f5d0fdbf2f0a806d137349124cf1d10e0a2d03a..268701951a9cc89f3e9a20ad33341bcb2e9e9800 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -4,7 +4,7 @@ android { compileSdkVersion 26 defaultConfig { applicationId "de.tudresden.inf.st.sensorsharing" - minSdkVersion 25 + minSdkVersion 23 targetSdkVersion 26 versionCode 1 versionName "1.0" @@ -22,11 +22,11 @@ dependencies { implementation project(':common') - implementation 'com.google.android.support:wearable:2.2.0' - implementation 'com.google.android.gms:play-services-wearable:11.8.0' + implementation 'com.google.android.support:wearable:2.3.0' + implementation 'com.google.android.gms:play-services-wearable:15.0.1' implementation 'com.android.support:percent:26.1.0' implementation 'com.android.support:support-v4:26.1.0' implementation 'com.android.support:recyclerview-v7:26.1.0' implementation 'com.android.support:wear:26.1.0' - compileOnly 'com.google.android.wearable:wearable:2.2.0' + compileOnly 'com.google.android.wearable:wearable:2.3.0' } diff --git a/wear/src/main/java/de/tudresden/inf/st/sensorsharing/MainActivity.java b/wear/src/main/java/de/tudresden/inf/st/sensorsharing/MainActivity.java index c6e71f471b180c17b4fad8173994fbcec3eb33f9..ec74faf0a94f15d88242507e1d328b7ff138466a 100644 --- a/wear/src/main/java/de/tudresden/inf/st/sensorsharing/MainActivity.java +++ b/wear/src/main/java/de/tudresden/inf/st/sensorsharing/MainActivity.java @@ -62,7 +62,27 @@ public class MainActivity extends WearableActivity implements SensorEventListene // initialize sensors mLight = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT); mLinearAcceleration = mSensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION); + if (mLinearAcceleration == null) { + mLinearAcceleration = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); + if (mRotationVector == null) { + Log.e(TAG, "Couldn't find acceleration sensor!"); + TextView textView = findViewById(R.id.acceleration_value); + textView.setText("ERROR"); + } else { + Log.w(TAG, "Using alternative accelerometer sensor!"); + } + } mRotationVector = mSensorManager.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR); + if (mRotationVector == null) { + mRotationVector = mSensorManager.getDefaultSensor(Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR); + if (mRotationVector == null) { + TextView textView = findViewById(R.id.rotation_value); + textView.setText("ERROR"); + Log.e(TAG, "Couldn't find rotation sensor!"); + } else { + Log.w(TAG, "Using alternative rotation sensor!"); + } + } // initialize sensor values mLinearAccelerationValues = new float[3]; @@ -84,11 +104,13 @@ public class MainActivity extends WearableActivity implements SensorEventListene sendCurrentValueToAllConnectedNodes(); break; case Sensor.TYPE_LINEAR_ACCELERATION: + case Sensor.TYPE_ACCELEROMETER: mLinearAccelerationValues = sensorEvent.values; textView = findViewById(R.id.acceleration_value); textView.setText(formatArray3(mLinearAccelerationValues)); break; case Sensor.TYPE_GAME_ROTATION_VECTOR: + case Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR: mRotationVectorValues = sensorEvent.values; textView = findViewById(R.id.rotation_value); textView.setText(formatArray3(mRotationVectorValues));