Skip to content
Snippets Groups Projects
Commit 2a557954 authored by boqiren's avatar boqiren
Browse files

1. make the connection (mobil and watch) work,2 changed the mobil ui, add ui...

1. make the connection (mobil and watch) work,2 changed the mobil ui, add ui component for user identification and justy the brightness
parent 90a8501c
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ buildscript { ...@@ -10,7 +10,7 @@ buildscript {
} }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.1.3' classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
......
#Fri May 11 14:09:11 CEST 2018 #Wed Nov 28 11:04:23 CET 2018
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
...@@ -41,4 +41,6 @@ dependencies { ...@@ -41,4 +41,6 @@ dependencies {
// Wear services // Wear services
wearApp project(':wear') wearApp project(':wear')
implementation 'com.google.android.gms:play-services-wearable:15.0.1' implementation 'com.google.android.gms:play-services-wearable:15.0.1'
//Rest API
implementation 'com.android.volley:volley:1.1.1'
} }
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<application <application
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/openlicht_launcher" android:icon="@mipmap/openlicht_launcher"
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<TextView <TextView
android:id="@+id/label_own_rotation" android:id="@+id/label_own_rotation"
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -83,7 +84,7 @@ ...@@ -83,7 +84,7 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0" app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toBottomOf="@+id/user_2_button" />
<TextView <TextView
android:id="@+id/separator_wear" android:id="@+id/separator_wear"
...@@ -207,8 +208,8 @@ ...@@ -207,8 +208,8 @@
android:id="@+id/value_server_uri" android:id="@+id/value_server_uri"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:ems="10" android:ems="10"
android:inputType="text|textUri" android:inputType="text|textUri"
android:text="@string/default_mqtt_server_uri" android:text="@string/default_mqtt_server_uri"
...@@ -220,8 +221,8 @@ ...@@ -220,8 +221,8 @@
android:id="@+id/button" android:id="@+id/button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:onClick="connectMqtt" android:onClick="connectMqtt"
android:text="@android:string/ok" android:text="@android:string/ok"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
...@@ -242,7 +243,6 @@ ...@@ -242,7 +243,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/text_send_updates_brightness" android:text="@string/text_send_updates_brightness"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/value_server_uri" /> app:layout_constraintTop_toBottomOf="@+id/value_server_uri" />
...@@ -252,7 +252,6 @@ ...@@ -252,7 +252,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/text_send_updates_rotationahrs" android:text="@string/text_send_updates_rotationahrs"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/checkBox_send_brightness" /> app:layout_constraintTop_toBottomOf="@+id/checkBox_send_brightness" />
...@@ -262,11 +261,38 @@ ...@@ -262,11 +261,38 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/send_updates_rotation_quaternion" android:text="@string/send_updates_rotation_quaternion"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/checkBox_send_rotation_ahrs" /> app:layout_constraintTop_toBottomOf="@+id/checkBox_send_rotation_ahrs" />
<CheckBox
android:id="@+id/checkBox_send_wear_brightness"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="@string/send_updates_wear_brightness"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/checkBox_send_rotation_quaternion" />
<CheckBox
android:id="@+id/checkBox_send_wear_acceleration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="@string/send_updates_wear_acceleration"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/checkBox_send_wear_brightness" />
<CheckBox
android:id="@+id/checkBox_send_wear_rotation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="@string/send_updates_wear_rotation"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/checkBox_send_wear_acceleration" />
<TextView <TextView
android:id="@+id/label_wear_status" android:id="@+id/label_wear_status"
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -287,7 +313,110 @@ ...@@ -287,7 +313,110 @@
android:textOff="@string/switch_light_on" android:textOff="@string/switch_light_on"
android:textOn="@string/switch_light_off" android:textOn="@string/switch_light_off"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/checkBox_send_rotation_quaternion" /> app:layout_constraintTop_toBottomOf="@+id/checkBox_send_wear_rotation" />
<TextView
android:id="@+id/user_identification"
style="?android:attr/listSeparatorTextViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="@android:color/darker_gray"
android:text="@string/user_identification"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/label_user_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="User 1: "
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/user_identification" />
<ToggleButton
android:id="@+id/user_1_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="172dp"
android:text="User 1"
android:textOff="on"
android:textOn="off"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="@+id/label_user_1"
app:layout_constraintTop_toBottomOf="@+id/user_identification" />
<TextView
android:id="@+id/label_user_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="User 2: "
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/label_user_1" />
<ToggleButton
android:id="@+id/user_2_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="172dp"
android:text="User 2"
android:textOff="on"
android:textOn="off"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toRightOf="@+id/label_user_2"
app:layout_constraintTop_toBottomOf="@+id/user_1_button" />
<EditText
android:id="@+id/edit_text_1"
android:layout_width="71dp"
android:layout_height="46dp"
android:ems="10"
android:inputType="number"
app:layout_constraintEnd_toStartOf="@id/send_button_1"
app:layout_constraintStart_toEndOf="@id/user_1_button"
app:layout_constraintLeft_toLeftOf="@+id/user_1_button"
app:layout_constraintTop_toBottomOf="@+id/user_identification"/>
<EditText
android:id="@+id/edit_text_2"
android:layout_width="71dp"
android:layout_height="46dp"
android:layout_marginTop="48dp"
android:ems="10"
android:inputType="number"
app:layout_constraintEnd_toStartOf="@id/send_button_1"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="@+id/user_1_button"
app:layout_constraintStart_toEndOf="@id/user_1_button"
app:layout_constraintTop_toBottomOf="@+id/user_identification" />
<Button
android:id="@+id/send_button_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="172dp"
android:text="SEND"
app:layout_constraintStart_toEndOf="@id/edit_text_1"
app:layout_constraintLeft_toRightOf="@+id/edit_text_1"
app:layout_constraintTop_toBottomOf="@+id/user_identification" />
<Button
android:id="@+id/send_button_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="44dp"
android:text="SEND"
app:layout_constraintLeft_toRightOf="@+id/edit_text_1"
app:layout_constraintStart_toEndOf="@id/edit_text_1"
app:layout_constraintTop_toBottomOf="@+id/user_identification" />
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>
</ScrollView> </ScrollView>
...@@ -12,9 +12,13 @@ ...@@ -12,9 +12,13 @@
<string name="text_separator_mqtt_settings">MQTT Settings</string> <string name="text_separator_mqtt_settings">MQTT Settings</string>
<string name="text_send_updates_brightness">Send Updates Brightness</string> <string name="text_send_updates_brightness">Send Updates Brightness</string>
<string name="text_send_updates_rotationahrs">Send Updates Rotation (AHRS)</string> <string name="text_send_updates_rotationahrs">Send Updates Rotation (AHRS)</string>
<string name="send_updates_wear_brightness">Send Updates Wearable Brightness</string>
<string name="send_updates_wear_acceleration">Send Updates Wearable Acceleration</string>
<string name="send_updates_wear_rotation">Send Updates Wearable Rotation</string>
<string name="status">Status</string> <string name="status">Status</string>
<string name="switch_on">Switch On</string> <string name="switch_on">Switch On</string>
<string name="switch_light_on">Switch Light ON</string> <string name="switch_light_on">Switch Light ON</string>
<string name="switch_light_off">Switch Light OFF</string> <string name="switch_light_off">Switch Light OFF</string>
<string name="send_updates_rotation_quaternion">Send Updates Rotation (Quaternion)</string> <string name="send_updates_rotation_quaternion">Send Updates Rotation (Quaternion)</string>
<string name="user_identification">User Identification</string>
</resources> </resources>
...@@ -61,6 +61,8 @@ public class MainActivity extends WearableActivity implements SensorEventListene ...@@ -61,6 +61,8 @@ public class MainActivity extends WearableActivity implements SensorEventListene
for (Sensor sensor : allSensors) { for (Sensor sensor : allSensors) {
sb.append(sensor.getName()).append(":").append(sensor.getStringType()).append(";"); sb.append(sensor.getName()).append(":").append(sensor.getStringType()).append(";");
} }
Log.i(TAG, "Available sensors: " + sb.toString()); Log.i(TAG, "Available sensors: " + sb.toString());
// initialize sensors // initialize sensors
...@@ -87,7 +89,6 @@ public class MainActivity extends WearableActivity implements SensorEventListene ...@@ -87,7 +89,6 @@ public class MainActivity extends WearableActivity implements SensorEventListene
Log.w(TAG, "Using alternative rotation sensor!"); Log.w(TAG, "Using alternative rotation sensor!");
} }
} }
// initialize sensor values // initialize sensor values
mLinearAccelerationValues = new float[3]; mLinearAccelerationValues = new float[3];
mRotationVectorValues = new float[3]; mRotationVectorValues = new float[3];
...@@ -110,6 +111,8 @@ public class MainActivity extends WearableActivity implements SensorEventListene ...@@ -110,6 +111,8 @@ public class MainActivity extends WearableActivity implements SensorEventListene
case Sensor.TYPE_LINEAR_ACCELERATION: case Sensor.TYPE_LINEAR_ACCELERATION:
case Sensor.TYPE_ACCELEROMETER: case Sensor.TYPE_ACCELEROMETER:
mLinearAccelerationValues = sensorEvent.values; mLinearAccelerationValues = sensorEvent.values;
System.out.println("-----------------------------");
System.out.println(Utils.formatArray3(mLinearAccelerationValues));
textView = findViewById(R.id.acceleration_value); textView = findViewById(R.id.acceleration_value);
textView.setText(Utils.formatArray3(mLinearAccelerationValues)); textView.setText(Utils.formatArray3(mLinearAccelerationValues));
break; break;
...@@ -135,7 +138,7 @@ public class MainActivity extends WearableActivity implements SensorEventListene ...@@ -135,7 +138,7 @@ public class MainActivity extends WearableActivity implements SensorEventListene
if (sendName) { if (sendName) {
final byte[] nameData = Build.MODEL.getBytes(MQTT_CHARSET); final byte[] nameData = Build.MODEL.getBytes(MQTT_CHARSET);
messageClient.sendMessage(node.getId(), KEY_NAME, nameData); messageClient.sendMessage(node.getId(), KEY_NAME, nameData);
sendName = false; //sendName = false;
} }
messageClient.sendMessage(node.getId(), KEY_BRIGHTNESS, brightnessData); messageClient.sendMessage(node.getId(), KEY_BRIGHTNESS, brightnessData);
messageClient.sendMessage(node.getId(), KEY_LINEAR_ACCELERATION, accelerationData); messageClient.sendMessage(node.getId(), KEY_LINEAR_ACCELERATION, accelerationData);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/dark_grey" android:background="@color/white"
android:padding="@dimen/box_inset_layout_padding" android:padding="@dimen/box_inset_layout_padding"
tools:context="de.tudresden.inf.st.sensorsharing.MainActivity" tools:context="de.tudresden.inf.st.sensorsharing.MainActivity"
tools:deviceIds="wear"> tools:deviceIds="wear">
...@@ -20,12 +20,14 @@ ...@@ -20,12 +20,14 @@
android:id="@+id/brightness_value" android:id="@+id/brightness_value"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/black"
android:layout_gravity="top|end" /> android:layout_gravity="top|end" />
<TextView <TextView
android:id="@+id/brightness_label" android:id="@+id/brightness_label"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/black"
android:layout_gravity="top|start" android:layout_gravity="top|start"
android:text="@string/text_brightness" /> android:text="@string/text_brightness" />
...@@ -33,12 +35,14 @@ ...@@ -33,12 +35,14 @@
android:id="@+id/acceleration_value" android:id="@+id/acceleration_value"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/black"
android:layout_gravity="center|end" /> android:layout_gravity="center|end" />
<TextView <TextView
android:id="@+id/acceleration_label" android:id="@+id/acceleration_label"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/black"
android:layout_gravity="center|start" android:layout_gravity="center|start"
android:text="@string/text_acceleration" /> android:text="@string/text_acceleration" />
...@@ -46,12 +50,14 @@ ...@@ -46,12 +50,14 @@
android:id="@+id/rotation_value" android:id="@+id/rotation_value"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/black"
android:layout_gravity="bottom|end" /> android:layout_gravity="bottom|end" />
<TextView <TextView
android:id="@+id/rotation_label" android:id="@+id/rotation_label"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/black"
android:layout_gravity="bottom|start" android:layout_gravity="bottom|start"
android:text="@string/text_rotation" /> android:text="@string/text_rotation" />
</FrameLayout> </FrameLayout>
......
...@@ -8,5 +8,6 @@ ...@@ -8,5 +8,6 @@
<string name="text_brightness">Bri</string> <string name="text_brightness">Bri</string>
<string name="text_acceleration">Acc</string> <string name="text_acceleration">Acc</string>
<string name="text_rotation">Rot</string> <string name="text_rotation">Rot</string>
<string name="pose">Pose</string>
<string name="error_sensormanager_null">Could not fetch sensor manager</string> <string name="error_sensormanager_null">Could not fetch sensor manager</string>
</resources> </resources>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment