diff --git a/build.gradle b/build.gradle index 08b39ff8afa79b87131140bddba4c83dd31058c8..9f74a2f81733a10992e1d252558fa2d2c74d0950 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { } } 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 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7790ebb0f8abec4022daf725dd87537a01cf525b..ed81f1e51f238601260890dc6681e885424e7251 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri May 11 14:09:11 CEST 2018 +#Wed Nov 28 11:04:23 CET 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME 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 diff --git a/mobile/build.gradle b/mobile/build.gradle index 428345b68595f3c571333ba1149aa8a474b8fc36..410affdaa936cd26b19b9034249163641fcb29d3 100644 --- a/mobile/build.gradle +++ b/mobile/build.gradle @@ -41,4 +41,6 @@ dependencies { // Wear services wearApp project(':wear') implementation 'com.google.android.gms:play-services-wearable:15.0.1' + //Rest API + implementation 'com.android.volley:volley:1.1.1' } diff --git a/mobile/src/main/AndroidManifest.xml b/mobile/src/main/AndroidManifest.xml index 0e00c6aecc724cc3d7c73764039c4d89577bd0b7..d64d37f08d50c19f721a28a553bcfdae306d3b21 100644 --- a/mobile/src/main/AndroidManifest.xml +++ b/mobile/src/main/AndroidManifest.xml @@ -7,6 +7,8 @@ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> + <uses-permission android:name="android.permission.BLUETOOTH"/> + <application android:allowBackup="true" android:icon="@mipmap/openlicht_launcher" diff --git a/mobile/src/main/java/de/tudresden/inf/st/sensorsharing/MainActivity.java b/mobile/src/main/java/de/tudresden/inf/st/sensorsharing/MainActivity.java index 95806dad132f887d806cc22c262434aa1fef7ced..7ccdbbd07ea3e6cc4ec7c30d3873599f0eb9c65c 100644 --- a/mobile/src/main/java/de/tudresden/inf/st/sensorsharing/MainActivity.java +++ b/mobile/src/main/java/de/tudresden/inf/st/sensorsharing/MainActivity.java @@ -1,5 +1,6 @@ package de.tudresden.inf.st.sensorsharing; +import android.bluetooth.BluetoothAdapter; import android.content.Context; import android.hardware.Sensor; import android.hardware.SensorEvent; @@ -14,6 +15,7 @@ import android.util.Log; import android.view.View; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; +import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.EditText; @@ -21,6 +23,12 @@ import android.widget.TextView; import android.widget.Toast; import android.widget.ToggleButton; +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.Response; +import com.android.volley.VolleyError; +import com.android.volley.toolbox.StringRequest; +import com.android.volley.toolbox.Volley; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.android.gms.wearable.MessageClient; @@ -36,8 +44,12 @@ import org.eclipse.paho.client.mqttv3.MqttConnectOptions; import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttMessage; +import java.lang.reflect.Array; +import java.lang.reflect.Method; import java.nio.ByteBuffer; import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.Locale; @@ -49,6 +61,7 @@ import de.tudresden.inf.st.sensorsharing.common.MqttUtils; import de.tudresden.inf.st.sensorsharing.common.Utils; import de.tudresden.inf.st.sensorsharing.settings.AppSettings; + import static de.tudresden.inf.st.sensorsharing.common.Constants.BASE_KEY; import static de.tudresden.inf.st.sensorsharing.common.Constants.BASE_KEY_LENGTH; import static de.tudresden.inf.st.sensorsharing.common.Constants.MQTT_CHARSET; @@ -58,6 +71,9 @@ import static de.tudresden.inf.st.sensorsharing.common.Constants.SUB_KEY_NAME; import static de.tudresden.inf.st.sensorsharing.common.Constants.SUB_KEY_ROTATION_VECTOR; import static de.tudresden.inf.st.sensorsharing.settings.AppSettings.SETTINGS_MQTT_SERVER; import static java.lang.Math.atan2; +//bbq + + public class MainActivity extends AppCompatActivity implements SensorEventListener, @@ -65,7 +81,22 @@ public class MainActivity extends AppCompatActivity implements private static final String TAG = "SensorSharing"; // private static final String MQTT_TOPIC_SAMSUNG = "sensors/samsung/brightness"; - + //boqi add + private static final String MQTT_TOPIC_USER1 = "oh2/in/user1/state"; + private static final String MQTT_TOPIC_USER2 = "oh2/in/user2/state"; + //private static final String MQTT_TOPIC_USER1_BRIGHTNESS = "oh2/in/user1_brightness/state"; + //private static final String MQTT_TOPIC_USER2_BRIGHTNESS = "oh2/in/user1_brightness/state"; + private static final String MQTT_TOPIC_IRIS1_ITEM = "oh2/in/iris1_item/state"; + private static final String MQTT_TOPIC_DATETIME_MONTH = "oh2/in/datetime/month"; + private static final String MQTT_TOPIC_DATETIME_DAY = "oh2/in/datetime/day"; + private static final String MQTT_TOPIC_DATETIME_HOUR = "oh2/in/datetime/hour"; + private static final String MQTT_TOPIC_DATETIME_MINUTE = "oh2/in/datetime/minute"; + //variable for the on/off user + private static String user1_status = "off"; + private static String user2_status = "off"; + //for shake action + private static int i = 0; //user 1 shake action + private static int j = 0; //user 2 shake action // sensor management private SensorManager mSensorManager; private Sensor mLight; @@ -101,6 +132,13 @@ public class MainActivity extends AppCompatActivity implements private AppSettings settings; MadgwickAHRS filter; ToggleButton switchLight; + //BOQI ADD + ToggleButton user1; + ToggleButton user2; + Button sendbutton1; + Button sendbutton2; + EditText edittext1; + EditText edittext2; private EditText valueServerURI; @@ -143,8 +181,6 @@ public class MainActivity extends AppCompatActivity implements Log.w(TAG, "Using alternative rotation sensor!"); } } - - // initialize sensor values mLightValue = -1; mRotationVectorValues = new float[3]; @@ -169,14 +205,12 @@ public class MainActivity extends AppCompatActivity implements } }; handler.post(runnable); - - } private void initViews() { setName(); - valueServerURI = findViewById(R.id.value_server_uri); + String mqttServer = settings.get(SETTINGS_MQTT_SERVER, getResources().getString(R.string.default_mqtt_server_uri)); valueServerURI.setText(mqttServer); @@ -193,9 +227,176 @@ public class MainActivity extends AppCompatActivity implements } }); + //bbq + user1=findViewById(R.id.user_1_button); + user2=findViewById(R.id.user_2_button); + sendbutton1 =findViewById(R.id.send_button_1); + sendbutton2=findViewById(R.id.send_button_2); + edittext1=findViewById(R.id.edit_text_1); + edittext2=findViewById(R.id.edit_text_2); + edittext1.setEnabled(false); + edittext2.setEnabled(false); + sendbutton1.setEnabled(false); + sendbutton2.setEnabled(false); + + user1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (isChecked){ + user1_status="on"; + sendMqttUpdates.put(MQTT_TOPIC_USER1,true); + sendUpdate(MQTT_TOPIC_USER1, "ON"); + sendMqttUpdates.put(MQTT_TOPIC_DATETIME_MONTH,true); + sendUpdate(MQTT_TOPIC_DATETIME_MONTH,getDateTime()[0]); + sendMqttUpdates.put(MQTT_TOPIC_DATETIME_DAY,true); + sendUpdate(MQTT_TOPIC_DATETIME_DAY,getDateTime()[1]); + sendMqttUpdates.put(MQTT_TOPIC_DATETIME_HOUR,true); + sendUpdate(MQTT_TOPIC_DATETIME_HOUR,getDateTime()[2]); + sendMqttUpdates.put(MQTT_TOPIC_DATETIME_MINUTE,true); + sendUpdate(MQTT_TOPIC_DATETIME_MINUTE,getDateTime()[3]); + //set up for buttons + user2.setEnabled(false); + sendbutton2.setEnabled(false); + sendbutton1.setEnabled(true); + edittext1.setEnabled(true); + System.out.println(accelVectorValues[0]); + System.out.println(accelVectorValues[1]); + System.out.println(accelVectorValues[2]); + sendbutton1.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + sendMqttUpdates.put(MQTT_TOPIC_DATETIME_MONTH,true); + sendUpdate(MQTT_TOPIC_DATETIME_MONTH,getDateTime()[0]); + sendMqttUpdates.put(MQTT_TOPIC_DATETIME_DAY,true); + sendUpdate(MQTT_TOPIC_DATETIME_DAY,getDateTime()[1]); + sendMqttUpdates.put(MQTT_TOPIC_DATETIME_HOUR,true); + sendUpdate(MQTT_TOPIC_DATETIME_HOUR,getDateTime()[2]); + sendMqttUpdates.put(MQTT_TOPIC_DATETIME_MINUTE,true); + sendUpdate(MQTT_TOPIC_DATETIME_MINUTE,getDateTime()[3]); + //send datetime + String userBrightness= edittext1.getText().toString(); + //sendUserId("user1",edittext1.getText().toString()); + sendMqttUpdates.put(MQTT_TOPIC_IRIS1_ITEM,true); + sendUpdate(MQTT_TOPIC_IRIS1_ITEM, getBrigtnessValue(userBrightness)); + } + }); + + }else{ + user1_status="off"; + sendMqttUpdates.put(MQTT_TOPIC_USER1,true); + sendUpdate(MQTT_TOPIC_USER1, "OFF"); + user2.setEnabled(true); + edittext1.setEnabled(false); + edittext2.setEnabled(false); + sendbutton1.setEnabled(false); + sendbutton2.setEnabled(false);} + } + + + }); + user2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (isChecked){ + user2_status="on"; + sendMqttUpdates.put(MQTT_TOPIC_USER2,true); + sendUpdate(MQTT_TOPIC_USER2, "ON"); + sendMqttUpdates.put(MQTT_TOPIC_DATETIME_MONTH,true); + sendUpdate(MQTT_TOPIC_DATETIME_MONTH,getDateTime()[0]); + sendMqttUpdates.put(MQTT_TOPIC_DATETIME_DAY,true); + sendUpdate(MQTT_TOPIC_DATETIME_DAY,getDateTime()[1]); + sendMqttUpdates.put(MQTT_TOPIC_DATETIME_HOUR,true); + sendUpdate(MQTT_TOPIC_DATETIME_HOUR,getDateTime()[2]); + sendMqttUpdates.put(MQTT_TOPIC_DATETIME_MINUTE,true); + sendUpdate(MQTT_TOPIC_DATETIME_MINUTE,getDateTime()[3]); + user1.setEnabled(false); + sendbutton1.setEnabled(false); + sendbutton2.setEnabled(true); + edittext2.setEnabled(true); + sendbutton2.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + sendMqttUpdates.put(MQTT_TOPIC_DATETIME_MONTH,true); + sendUpdate(MQTT_TOPIC_DATETIME_MONTH,getDateTime()[0]); + sendMqttUpdates.put(MQTT_TOPIC_DATETIME_DAY,true); + sendUpdate(MQTT_TOPIC_DATETIME_DAY,getDateTime()[1]); + sendMqttUpdates.put(MQTT_TOPIC_DATETIME_HOUR,true); + sendUpdate(MQTT_TOPIC_DATETIME_HOUR,getDateTime()[2]); + sendMqttUpdates.put(MQTT_TOPIC_DATETIME_MINUTE,true); + sendUpdate(MQTT_TOPIC_DATETIME_MINUTE,getDateTime()[3]); + //send preferences + String userBrightness= edittext2.getText().toString(); + System.out.println(userBrightness); + sendMqttUpdates.put(MQTT_TOPIC_IRIS1_ITEM,true); + sendUpdate(MQTT_TOPIC_IRIS1_ITEM, getBrigtnessValue(userBrightness)); + } + }); + }else { + user2_status="off"; + sendMqttUpdates.put(MQTT_TOPIC_USER2,true); + sendUpdate(MQTT_TOPIC_USER2, "OFF"); + user1.setEnabled(true); + edittext1.setEnabled(false); + edittext2.setEnabled(false); + sendbutton1.setEnabled(false); + sendbutton2.setEnabled(false);} + } + }); setupSendUpdatesCheckbox(); } + //boqi + private String getBrigtnessValue(String Brightness){ + String BrightnessValue= ""; + if(Brightness.equals("OFF")){ + BrightnessValue="0"; + }else if(Brightness.equals("DIM")){ + BrightnessValue="25"; + } + else if(Brightness.equals("MEDIUM")){ + BrightnessValue="60"; + } + else if(Brightness.equals("BRIGHT")) { + BrightnessValue="90";} + return BrightnessValue; + } + //boqi + private String [] getDateTime(){ + DateFormat df = new SimpleDateFormat("yy:MM:dd:HH:mm"); + String date = df.format(Calendar.getInstance().getTime()); + String[] datetime_split= new String[5]; + datetime_split=date.split(":"); + return datetime_split; + } +//boqi + private void sendUserId(String userId, String Text){ + String userid=userId; + String text = Text; + System.out.println(userid); + System.out.println(text); + RequestQueue queue= Volley.newRequestQueue(this); + String url ="http://192.168.99.1:5000/user/1";//must in the same wifi phone and host + // Request a string response from the provided URL. + StringRequest stringRequest = new StringRequest(Request.Method.GET, url, + new Response.Listener<String>() { + @Override + public void onResponse(String response) { + System.out.println("request working -------------------------------"); + System.out.println(response.getClass()); + + } + }, new Response.ErrorListener(){ + @Override + public void onErrorResponse(VolleyError error) { + System.out.println("That didnt work"); + System.out.println(error); + } + }); + // Add the request to the RequestQueue. + queue.add(stringRequest); + + } + private void sendLightOnOffUpdateOfSmartphone(boolean state) { ObjectMapper mapper = new ObjectMapper(); HashMap<String, Boolean> dataLight = new HashMap<>(); @@ -229,10 +430,19 @@ public class MainActivity extends AppCompatActivity implements final CheckBox sendUpdates = findViewById(R.id.checkBox_send_brightness); final CheckBox sendUpdatesRotation = findViewById(R.id.checkBox_send_rotation_ahrs); final CheckBox sendUpdatesRotationQuat = findViewById(R.id.checkBox_send_rotation_quaternion); + //checkbox for wearable + final CheckBox sendUpdatesWearBrightness = findViewById(R.id.checkBox_send_wear_brightness); + final CheckBox sendUpdatesWearAcc= findViewById(R.id.checkBox_send_wear_acceleration); + final CheckBox sendUpdatesWearRotation= findViewById(R.id.checkBox_send_wear_rotation); sendMqttUpdates.put(phoneTopics.mqtt_topic_brightness, sendUpdates.isChecked()); sendMqttUpdates.put(phoneTopics.mqtt_topic_rotation_ahrs, sendUpdatesRotation.isChecked()); sendMqttUpdates.put(phoneTopics.mqtt_topic_rotation, sendUpdatesRotationQuat.isChecked()); + //checkbox for wearable + sendMqttUpdates.put(wearTopics.mqtt_topic_brightness, sendUpdatesWearBrightness.isChecked()); + sendMqttUpdates.put(wearTopics.mqtt_topic_acceleration, sendUpdatesWearAcc.isChecked()); + sendMqttUpdates.put(wearTopics.mqtt_topic_rotation, sendUpdatesWearRotation.isChecked()); + CompoundButton.OnCheckedChangeListener onCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() { @Override @@ -247,16 +457,30 @@ public class MainActivity extends AppCompatActivity implements case R.id.checkBox_send_rotation_quaternion: sendMqttUpdates.put(phoneTopics.mqtt_topic_rotation, sendUpdatesRotationQuat.isChecked()); break; + //test wear + case R.id.checkBox_send_wear_brightness: + sendMqttUpdates.put(wearTopics.mqtt_topic_brightness, sendUpdatesWearBrightness.isChecked()); + break; + case R.id.checkBox_send_wear_acceleration: + sendMqttUpdates.put(wearTopics.mqtt_topic_acceleration, sendUpdatesWearBrightness.isChecked()); + break; + case R.id.checkBox_send_wear_rotation: + sendMqttUpdates.put(wearTopics.mqtt_topic_rotation, sendUpdatesWearBrightness.isChecked()); + break; } } }; sendUpdates.setOnCheckedChangeListener(onCheckedChangeListener); sendUpdatesRotation.setOnCheckedChangeListener(onCheckedChangeListener); sendUpdatesRotationQuat.setOnCheckedChangeListener(onCheckedChangeListener); + sendUpdatesWearBrightness.setOnCheckedChangeListener(onCheckedChangeListener); + sendUpdatesWearAcc.setOnCheckedChangeListener(onCheckedChangeListener); + sendUpdatesWearRotation.setOnCheckedChangeListener(onCheckedChangeListener); } private void setName() { TextView ownName = findViewById(R.id.value_own_name); + TextView wearName = findViewById(R.id.value_wear_name); ownName.setText(Build.MODEL); } @@ -361,6 +585,64 @@ public class MainActivity extends AppCompatActivity implements break; case Sensor.TYPE_ACCELEROMETER: accelVectorValues = sensorEvent.values; + //boqi + System.out.println("com in case"); + System.out.println(i); + System.out.println(j); + float x = accelVectorValues[0]; + float y = accelVectorValues[1]; + float z = accelVectorValues[2]; + if (Math.abs(x) > 17 || Math.abs(y) > 17 || Math + .abs(z) > 17){ + System.out.println("com in loop"); + System.out.println(i); + System.out.println(j); + edittext1=findViewById(R.id.edit_text_1); + edittext2=findViewById(R.id.edit_text_2); + if (user1_status.equals("on")){ + i++; + if (i==1){ + edittext1.setText("OFF"); + }else if(i==2){ + edittext1.setText("DIM"); + } + else if (i==3){ + edittext1.setText("MEDIUM"); + } + else if (i==4){ + edittext1.setText("BRIGHT"); + } + else { + i=0; + edittext1.setText("OFF");} + }else if (user1_status.equals("off")){ + i=0; + edittext1.setText("OFF"); + } + if(user2_status.equals("on")){ + j++; + if (j == 1){ + edittext2.setText("OFF"); + + }else if(j == 2){ + edittext2.setText("DIM"); + + } + else if (j == 3){ + edittext2.setText("MEDIUM"); + + } + else if (j == 4){ + edittext2.setText("BRIGHT"); + } + else {j=0; + edittext2.setText("OFF");} + + }else if (user2_status.equals("off")){ + j = 0; + edittext2.setText("OFF"); + } + } break; case Sensor.TYPE_GYROSCOPE: gyroVectorValues = sensorEvent.values; @@ -380,7 +662,6 @@ public class MainActivity extends AppCompatActivity implements public void onAccuracyChanged(Sensor sensor, int i) { // ignore accuracy changes } - @Override protected void onResume() { super.onResume(); @@ -423,14 +704,16 @@ public class MainActivity extends AppCompatActivity implements updatedValue = Float.toString(mWearBrightness); textViewToUpdate = findViewById(R.id.value_wear_brightness); topic = wearTopics.mqtt_topic_brightness; + //updateMqttTopics(updatedValue); break; case SUB_KEY_LINEAR_ACCELERATION: // float[] accelerationData = new float[3]; // writeFloatArray(ByteBuffer.wrap(messageEvent.getData()), accelerationData); -// updatedValue = Arrays.toString(accelerationData); +// updatedValue = Arrays.toString(accelerationData) updatedValue = formatByteFloatArray(ByteBuffer.wrap(messageEvent.getData())); textViewToUpdate = findViewById(R.id.value_wear_acceleration); topic = wearTopics.mqtt_topic_acceleration; + //updateMqttTopics(updatedValue); break; case SUB_KEY_ROTATION_VECTOR: // float[] rotationData = new float[3]; @@ -439,6 +722,7 @@ public class MainActivity extends AppCompatActivity implements updatedValue = formatByteFloatArray(ByteBuffer.wrap(messageEvent.getData())); textViewToUpdate = findViewById(R.id.value_wear_rotation); topic = wearTopics.mqtt_topic_rotation; + //updateMqttTopics(updatedValue); break; case SUB_KEY_NAME: updatedValue = new String(messageEvent.getData(), MQTT_CHARSET); @@ -458,13 +742,20 @@ public class MainActivity extends AppCompatActivity implements } }); if (topic != null) { - sendUpdateOfWearable(topic, bytesToSendViaMqtt); + //sendUpdateOfWearable(topic, bytesToSendViaMqtt); + sendUpdateOfWearable(topic, updatedValue); + } } } private String formatByteFloatArray(ByteBuffer buffer) { - return formatFloatArray(buffer.asFloatBuffer().array()); + + float[] arr = new float[3]; + arr[0]=buffer.asFloatBuffer().get(0); + arr[1]=buffer.asFloatBuffer().get(1); + arr[2]=buffer.asFloatBuffer().get(2); + return formatFloatArray(arr); } private String formatFloatArray(float... values) { @@ -484,10 +775,9 @@ public class MainActivity extends AppCompatActivity implements } } - private void sendUpdateOfWearable(String topic, byte[] newValue) { + private void sendUpdateOfWearable(String topic, String newValue) { sendUpdate(topic, newValue); } - /** * Method to initiate the mqtt publish action of the required sensor data. * Whether the data is really published depends on the checkboxes. @@ -499,9 +789,10 @@ public class MainActivity extends AppCompatActivity implements // Brightness data HashMap<String, Float> dataLight = new HashMap<>(); dataLight.put("brightness", mLightValue); + try { String s = mapper.writeValueAsString(dataLight); - sendUpdate(phoneTopics.mqtt_topic_brightness, s); + sendUpdate(phoneTopics.mqtt_topic_brightness, String.valueOf(mLightValue) ); } catch (JsonProcessingException e) { e.printStackTrace(); } @@ -521,7 +812,7 @@ public class MainActivity extends AppCompatActivity implements data.put("roll", roll); try { String s = mapper.writeValueAsString(data); - sendUpdate(phoneTopics.mqtt_topic_rotation_ahrs, s); + sendUpdate(phoneTopics.mqtt_topic_rotation_ahrs, String.valueOf(data)); } catch (JsonProcessingException e) { e.printStackTrace(); } @@ -534,7 +825,7 @@ public class MainActivity extends AppCompatActivity implements //dataQuat.put("w", mRotationVectorValues[3]); try { String s = mapper.writeValueAsString(dataQuat); - sendUpdate(phoneTopics.mqtt_topic_rotation, s); + sendUpdate(phoneTopics.mqtt_topic_rotation, String.valueOf(dataQuat)); } catch (JsonProcessingException e) { e.printStackTrace(); } diff --git a/mobile/src/main/res/layout/activity_main.xml b/mobile/src/main/res/layout/activity_main.xml index e68e0a09b339c881bdc70aa2d7230c69712c8ce0..50d31c129a0e838b31d7c08b90c3c0aeb03e49ee 100644 --- a/mobile/src/main/res/layout/activity_main.xml +++ b/mobile/src/main/res/layout/activity_main.xml @@ -6,288 +6,417 @@ android:layout_height="match_parent" tools:context="de.tudresden.inf.st.sensorsharing.MainActivity"> -<android.support.constraint.ConstraintLayout - android:layout_width="match_parent" - android:layout_height="wrap_content"> - - <TextView - android:id="@+id/label_own_rotation" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@string/text_rotation" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/label_own_brightness" /> - - <TextView - android:id="@+id/value_own_rotation" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@android:string/unknownName" - app:layout_constraintStart_toEndOf="@+id/label_own_rotation" - app:layout_constraintTop_toBottomOf="@+id/value_own_brightness" /> - - <TextView - android:id="@+id/label_wear_name" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@string/text_name" - app:layout_constraintLeft_toLeftOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/label_wear_status" /> - - <TextView - android:id="@+id/value_wear_name" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@android:string/unknownName" - app:layout_constraintStart_toEndOf="@+id/label_wear_name" - app:layout_constraintTop_toBottomOf="@+id/label_wear_status" /> - - <TextView - android:id="@+id/label_own_name" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@string/text_name" - app:layout_constraintLeft_toLeftOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/separator_own" /> - - <TextView - android:id="@+id/value_own_name" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@android:string/unknownName" - app:layout_constraintStart_toEndOf="@+id/label_own_name" - app:layout_constraintTop_toBottomOf="@+id/separator_own" /> - - <TextView - android:id="@+id/separator_own" - 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/text_separator_smartphone_values" - 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/separator_wear" - style="?android:attr/listSeparatorTextViewStyle" - android:layout_width="match_parent" - android:layout_height="21dp" - android:layout_marginTop="32dp" - android:background="@android:color/darker_gray" - android:text="@string/text_separator_wear_values" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.0" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/label_own_brightness" /> - - <TextView - android:id="@+id/separator_mqtt" - style="?android:attr/listSeparatorTextViewStyle" + <android.support.constraint.ConstraintLayout android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="8dp" - android:background="@android:color/darker_gray" - android:text="@string/text_separator_mqtt_settings" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.0" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/label_wear_rotation" /> - - <TextView - android:id="@+id/label_server_uri" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="24dp" - android:text="@string/text_mqtt_server_uri" - app:layout_constraintLeft_toLeftOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/separator_mqtt" /> - - <TextView - android:id="@+id/label_own_brightness" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@string/text_brightness" - app:layout_constraintLeft_toLeftOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/label_own_name" /> - - <TextView - android:id="@+id/label_wear_brightness" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@string/text_brightness" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/label_wear_name" /> - - <TextView - android:id="@+id/label_wear_acceleration" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@string/text_acceleration" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/label_wear_brightness" /> - - <TextView - android:id="@+id/label_wear_rotation" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@string/text_rotation" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/label_wear_acceleration" /> - - <TextView - android:id="@+id/value_own_brightness" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="12dp" - android:layout_marginTop="8dp" - android:text="@android:string/unknownName" - app:layout_constraintStart_toEndOf="@+id/label_own_brightness" - app:layout_constraintTop_toBottomOf="@+id/label_own_name" /> - - <TextView - android:id="@+id/value_wear_brightness" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@android:string/unknownName" - app:layout_constraintStart_toEndOf="@+id/label_wear_brightness" - app:layout_constraintTop_toBottomOf="@+id/label_wear_name" /> - - <TextView - android:id="@+id/value_wear_acceleration" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@android:string/unknownName" - app:layout_constraintStart_toEndOf="@+id/label_wear_acceleration" - app:layout_constraintTop_toBottomOf="@+id/label_wear_brightness" /> - - <TextView - android:id="@+id/value_wear_rotation" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@android:string/unknownName" - app:layout_constraintStart_toEndOf="@+id/label_wear_rotation" - app:layout_constraintTop_toBottomOf="@+id/label_wear_acceleration" /> - - <EditText - android:id="@+id/value_server_uri" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_marginEnd="8dp" - android:layout_marginStart="8dp" - android:ems="10" - android:inputType="text|textUri" - android:text="@string/default_mqtt_server_uri" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/label_server_uri" /> - - <Button - android:id="@+id/button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginEnd="8dp" - android:layout_marginTop="8dp" - android:onClick="connectMqtt" - android:text="@android:string/ok" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toBottomOf="@+id/separator_mqtt" /> - - <TextView - android:id="@+id/value_wear_status" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@android:string/unknownName" - app:layout_constraintStart_toEndOf="@+id/label_wear_status" - app:layout_constraintTop_toBottomOf="@+id/separator_wear" /> - - <CheckBox - android:id="@+id/checkBox_send_brightness" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@string/text_send_updates_brightness" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/value_server_uri" /> - - <CheckBox - android:id="@+id/checkBox_send_rotation_ahrs" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@string/text_send_updates_rotationahrs" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/checkBox_send_brightness" /> - - <CheckBox - android:id="@+id/checkBox_send_rotation_quaternion" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@string/send_updates_rotation_quaternion" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/checkBox_send_rotation_ahrs" /> - - <TextView - android:id="@+id/label_wear_status" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@string/status" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/separator_wear" /> - - <ToggleButton - android:id="@+id/toggleButton-lightonoff" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="@string/switch_on" - android:textOff="@string/switch_light_on" - android:textOn="@string/switch_light_off" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/checkBox_send_rotation_quaternion" /> - -</android.support.constraint.ConstraintLayout> + android:layout_height="wrap_content"> + + + <TextView + android:id="@+id/label_own_rotation" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:text="@string/text_rotation" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/label_own_brightness" /> + + <TextView + android:id="@+id/value_own_rotation" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:text="@android:string/unknownName" + app:layout_constraintStart_toEndOf="@+id/label_own_rotation" + app:layout_constraintTop_toBottomOf="@+id/value_own_brightness" /> + + <TextView + android:id="@+id/label_wear_name" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:text="@string/text_name" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/label_wear_status" /> + + <TextView + android:id="@+id/value_wear_name" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:text="@android:string/unknownName" + app:layout_constraintStart_toEndOf="@+id/label_wear_name" + app:layout_constraintTop_toBottomOf="@+id/label_wear_status" /> + + <TextView + android:id="@+id/label_own_name" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:text="@string/text_name" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/separator_own" /> + + <TextView + android:id="@+id/value_own_name" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:text="@android:string/unknownName" + app:layout_constraintStart_toEndOf="@+id/label_own_name" + app:layout_constraintTop_toBottomOf="@+id/separator_own" /> + + <TextView + android:id="@+id/separator_own" + 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/text_separator_smartphone_values" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/user_2_button" /> + + <TextView + android:id="@+id/separator_wear" + style="?android:attr/listSeparatorTextViewStyle" + android:layout_width="match_parent" + android:layout_height="21dp" + android:layout_marginTop="32dp" + android:background="@android:color/darker_gray" + android:text="@string/text_separator_wear_values" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/label_own_brightness" /> + + <TextView + android:id="@+id/separator_mqtt" + 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/text_separator_mqtt_settings" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/label_wear_rotation" /> + + <TextView + android:id="@+id/label_server_uri" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="24dp" + android:text="@string/text_mqtt_server_uri" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/separator_mqtt" /> + + <TextView + android:id="@+id/label_own_brightness" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:text="@string/text_brightness" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/label_own_name" /> + + <TextView + android:id="@+id/label_wear_brightness" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:text="@string/text_brightness" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/label_wear_name" /> + + <TextView + android:id="@+id/label_wear_acceleration" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:text="@string/text_acceleration" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/label_wear_brightness" /> + + <TextView + android:id="@+id/label_wear_rotation" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:text="@string/text_rotation" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/label_wear_acceleration" /> + + <TextView + android:id="@+id/value_own_brightness" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="12dp" + android:layout_marginTop="8dp" + android:text="@android:string/unknownName" + app:layout_constraintStart_toEndOf="@+id/label_own_brightness" + app:layout_constraintTop_toBottomOf="@+id/label_own_name" /> + + <TextView + android:id="@+id/value_wear_brightness" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:text="@android:string/unknownName" + app:layout_constraintStart_toEndOf="@+id/label_wear_brightness" + app:layout_constraintTop_toBottomOf="@+id/label_wear_name" /> + + <TextView + android:id="@+id/value_wear_acceleration" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:text="@android:string/unknownName" + app:layout_constraintStart_toEndOf="@+id/label_wear_acceleration" + app:layout_constraintTop_toBottomOf="@+id/label_wear_brightness" /> + + <TextView + android:id="@+id/value_wear_rotation" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:text="@android:string/unknownName" + app:layout_constraintStart_toEndOf="@+id/label_wear_rotation" + app:layout_constraintTop_toBottomOf="@+id/label_wear_acceleration" /> + + <EditText + android:id="@+id/value_server_uri" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginEnd="8dp" + android:ems="10" + android:inputType="text|textUri" + android:text="@string/default_mqtt_server_uri" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/label_server_uri" /> + + <Button + android:id="@+id/button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:layout_marginEnd="8dp" + android:onClick="connectMqtt" + android:text="@android:string/ok" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toBottomOf="@+id/separator_mqtt" /> + + <TextView + android:id="@+id/value_wear_status" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:text="@android:string/unknownName" + app:layout_constraintStart_toEndOf="@+id/label_wear_status" + app:layout_constraintTop_toBottomOf="@+id/separator_wear" /> + + <CheckBox + android:id="@+id/checkBox_send_brightness" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:text="@string/text_send_updates_brightness" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/value_server_uri" /> + + <CheckBox + android:id="@+id/checkBox_send_rotation_ahrs" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:text="@string/text_send_updates_rotationahrs" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/checkBox_send_brightness" /> + + <CheckBox + android:id="@+id/checkBox_send_rotation_quaternion" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:text="@string/send_updates_rotation_quaternion" + app:layout_constraintStart_toStartOf="parent" + 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 + android:id="@+id/label_wear_status" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:text="@string/status" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/separator_wear" /> + + <ToggleButton + android:id="@+id/toggleButton-lightonoff" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:text="@string/switch_on" + android:textOff="@string/switch_light_on" + android:textOn="@string/switch_light_off" + app:layout_constraintStart_toStartOf="parent" + 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> </ScrollView> diff --git a/mobile/src/main/res/values/strings.xml b/mobile/src/main/res/values/strings.xml index 14a7d53eb04539a2b6b72f52df34a2a0a2b31319..bde1d2daf1f2ef427321d50a5d6be000b2f5a47e 100644 --- a/mobile/src/main/res/values/strings.xml +++ b/mobile/src/main/res/values/strings.xml @@ -12,9 +12,13 @@ <string name="text_separator_mqtt_settings">MQTT Settings</string> <string name="text_send_updates_brightness">Send Updates Brightness</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="switch_on">Switch On</string> <string name="switch_light_on">Switch Light ON</string> <string name="switch_light_off">Switch Light OFF</string> <string name="send_updates_rotation_quaternion">Send Updates Rotation (Quaternion)</string> + <string name="user_identification">User Identification</string> </resources> 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 53b1d2a2f7c3054f258f6540d36ef2c05171b2c1..e9e2348beb0a0bb58fb4de29850bc4d187d34656 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 @@ -61,6 +61,8 @@ public class MainActivity extends WearableActivity implements SensorEventListene for (Sensor sensor : allSensors) { sb.append(sensor.getName()).append(":").append(sensor.getStringType()).append(";"); } + + Log.i(TAG, "Available sensors: " + sb.toString()); // initialize sensors @@ -87,7 +89,6 @@ public class MainActivity extends WearableActivity implements SensorEventListene Log.w(TAG, "Using alternative rotation sensor!"); } } - // initialize sensor values mLinearAccelerationValues = new float[3]; mRotationVectorValues = new float[3]; @@ -110,6 +111,8 @@ public class MainActivity extends WearableActivity implements SensorEventListene case Sensor.TYPE_LINEAR_ACCELERATION: case Sensor.TYPE_ACCELEROMETER: mLinearAccelerationValues = sensorEvent.values; + System.out.println("-----------------------------"); + System.out.println(Utils.formatArray3(mLinearAccelerationValues)); textView = findViewById(R.id.acceleration_value); textView.setText(Utils.formatArray3(mLinearAccelerationValues)); break; @@ -135,7 +138,7 @@ public class MainActivity extends WearableActivity implements SensorEventListene if (sendName) { final byte[] nameData = Build.MODEL.getBytes(MQTT_CHARSET); messageClient.sendMessage(node.getId(), KEY_NAME, nameData); - sendName = false; + //sendName = false; } messageClient.sendMessage(node.getId(), KEY_BRIGHTNESS, brightnessData); messageClient.sendMessage(node.getId(), KEY_LINEAR_ACCELERATION, accelerationData); diff --git a/wear/src/main/res/layout/activity_main.xml b/wear/src/main/res/layout/activity_main.xml index 65aecaad378b51eb87aa2117aba2aa93430486b7..7e7e1d80e197d6ff16938e1e6caca98c8e97acad 100644 --- a/wear/src/main/res/layout/activity_main.xml +++ b/wear/src/main/res/layout/activity_main.xml @@ -5,7 +5,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@color/dark_grey" + android:background="@color/white" android:padding="@dimen/box_inset_layout_padding" tools:context="de.tudresden.inf.st.sensorsharing.MainActivity" tools:deviceIds="wear"> @@ -20,12 +20,14 @@ android:id="@+id/brightness_value" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textColor="@color/black" android:layout_gravity="top|end" /> <TextView android:id="@+id/brightness_label" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textColor="@color/black" android:layout_gravity="top|start" android:text="@string/text_brightness" /> @@ -33,12 +35,14 @@ android:id="@+id/acceleration_value" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textColor="@color/black" android:layout_gravity="center|end" /> <TextView android:id="@+id/acceleration_label" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textColor="@color/black" android:layout_gravity="center|start" android:text="@string/text_acceleration" /> @@ -46,12 +50,14 @@ android:id="@+id/rotation_value" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textColor="@color/black" android:layout_gravity="bottom|end" /> <TextView android:id="@+id/rotation_label" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textColor="@color/black" android:layout_gravity="bottom|start" android:text="@string/text_rotation" /> </FrameLayout> diff --git a/wear/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml index 876cafdad169210741470f8d573f95893b2f5757..27a4d87f210ac4d357a9ca9126c67b61456a3a43 100644 --- a/wear/src/main/res/values/strings.xml +++ b/wear/src/main/res/values/strings.xml @@ -8,5 +8,6 @@ <string name="text_brightness">Bri</string> <string name="text_acceleration">Acc</string> <string name="text_rotation">Rot</string> + <string name="pose">Pose</string> <string name="error_sensormanager_null">Could not fetch sensor manager</string> </resources>