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

new GUI for App

parent 1799eef9
No related branches found
No related tags found
No related merge requests found
Showing
with 48 additions and 17 deletions
File added
include ':mobile', ':wear', ':common'
include ':mobile', ':wear', ':common', ':gui'
......@@ -6,8 +6,8 @@ android {
applicationId "de.tudresden.inf.st.sensorsharing"
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
versionCode 4
versionName "0.1"
}
buildTypes {
release {
......@@ -29,4 +29,8 @@ dependencies {
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:wear:26.1.0'
compileOnly 'com.google.android.wearable:wearable:2.3.0'
// MQTT
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.0'
implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
}
......@@ -5,10 +5,11 @@
<uses-feature android:name="android.hardware.type.watch" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.BODY_SENSORS"/>
<application
android:allowBackup="true"
android:icon="@mipmap/openlicht_launcher"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.DeviceDefault">
......@@ -29,6 +30,15 @@
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Main2Activity"
android:label="@string/title_activity_main2">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
......
......@@ -29,6 +29,16 @@ import static de.tudresden.inf.st.sensorsharing.common.Constants.KEY_NAME;
import static de.tudresden.inf.st.sensorsharing.common.Constants.KEY_ROTATION_VECTOR;
import static de.tudresden.inf.st.sensorsharing.common.Constants.MQTT_CHARSET;
import org.eclipse.paho.android.service.MqttAndroidClient;
import org.eclipse.paho.client.mqttv3.IMqttActionListener;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.IMqttToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
public class MainActivity extends WearableActivity implements SensorEventListener {
private static final String TAG = "SensorSharing";
......@@ -41,7 +51,8 @@ public class MainActivity extends WearableActivity implements SensorEventListene
private Sensor mRotationVector;
private float[] mRotationVectorValues;
private boolean sendName = true;
private Sensor mHeartRates;
private float mHeartRateVaules;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -58,16 +69,16 @@ public class MainActivity extends WearableActivity implements SensorEventListene
// log available sensors
List<Sensor> allSensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
StringBuilder sb = new StringBuilder();
for (Sensor sensor : allSensors) {
sb.append(sensor.getName()).append(":").append(sensor.getStringType()).append(";");
}
Log.i(TAG, "Available sensors: " + sb.toString());
Log.i(TAG, "Avail: able sensors: " + sb.toString());
// initialize sensors
mLight = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
mLinearAcceleration = mSensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION);
mHeartRates = mSensorManager.getDefaultSensor(Sensor.TYPE_HEART_RATE);
if (mLinearAcceleration == null) {
mLinearAcceleration = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
if (mRotationVector == null) {
......@@ -101,6 +112,10 @@ public class MainActivity extends WearableActivity implements SensorEventListene
public void onSensorChanged(SensorEvent sensorEvent) {
TextView textView;
switch(sensorEvent.sensor.getType()) {
case Sensor.TYPE_HEART_RATE:
mHeartRateVaules = sensorEvent.values[0];
System.out.println("HeartBeatValue:" + mHeartRateVaules);
case Sensor.TYPE_LIGHT:
mLightValue = sensorEvent.values[0];
textView = findViewById(R.id.brightness_value);
......@@ -111,8 +126,6 @@ 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;
......@@ -122,6 +135,7 @@ public class MainActivity extends WearableActivity implements SensorEventListene
textView = findViewById(R.id.rotation_value);
textView.setText(Utils.formatArray3(mRotationVectorValues));
break;
}
}
......
......@@ -5,8 +5,9 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:background="@color/black"
android:padding="@dimen/box_inset_layout_padding"
tools:ignore="MissingPrefix"
tools:context="de.tudresden.inf.st.sensorsharing.MainActivity"
tools:deviceIds="wear">
......@@ -14,20 +15,21 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/inner_frame_layout_padding"
app:layout_box="all"
app:boxedEdges="all">
<TextView
android:id="@+id/brightness_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textColor="@color/white"
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:textColor="@color/white"
android:layout_gravity="top|start"
android:text="@string/text_brightness" />
......@@ -35,14 +37,14 @@
android:id="@+id/acceleration_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textColor="@color/white"
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:textColor="@color/white"
android:layout_gravity="center|start"
android:text="@string/text_acceleration" />
......@@ -50,14 +52,14 @@
android:id="@+id/rotation_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textColor="@color/white"
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:textColor="@color/white"
android:layout_gravity="bottom|start"
android:text="@string/text_rotation" />
</FrameLayout>
......
wear/src/main/res/mipmap-hdpi/ic_launcher.png

3.34 KiB

wear/src/main/res/mipmap-hdpi/openlicht_launcher.png

1.78 KiB

wear/src/main/res/mipmap-mdpi/ic_launcher.png

2.15 KiB

wear/src/main/res/mipmap-mdpi/openlicht_launcher.png

1.17 KiB

wear/src/main/res/mipmap-xhdpi/ic_launcher.png

4.73 KiB

wear/src/main/res/mipmap-xhdpi/openlicht_launcher.png

2.52 KiB

wear/src/main/res/mipmap-xxhdpi/ic_launcher.png

7.54 KiB

wear/src/main/res/mipmap-xxhdpi/openlicht_launcher.png

4.05 KiB

wear/src/main/res/mipmap-xxxhdpi/openlicht_launcher.png

5.69 KiB

......@@ -10,4 +10,5 @@
<string name="text_rotation">Rot</string>
<string name="pose">Pose</string>
<string name="error_sensormanager_null">Could not fetch sensor manager</string>
<string name="title_activity_main2">Main2Activity</string>
</resources>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment