Skip to content

Commit 85e8b42

Browse files
committed
little fixes
1 parent 9a0aea1 commit 85e8b42

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

example/src/main/java/com/awareframework/example_accelerometer/MainActivity.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.awareframework.example_accelerometer
22

33
import android.Manifest
4+
import android.content.Context
5+
import android.content.SharedPreferences
46
import android.content.pm.PackageManager
57
import android.support.v7.app.AppCompatActivity
68
import android.os.Bundle
@@ -10,6 +12,7 @@ import android.support.v4.content.ContextCompat
1012
import com.awareframework.android.core.db.Engine
1113
import com.awareframework.android.core.manager.DbSyncManager
1214
import com.awareframework.android.sensor.accelerometer.Accelerometer
15+
import java.util.*
1316

1417
class MainActivity : AppCompatActivity() {
1518

@@ -38,11 +41,16 @@ class MainActivity : AppCompatActivity() {
3841
}
3942

4043
fun startSensors() {
44+
val prefs = getSharedPreferences("deviceId", Context.MODE_PRIVATE)
45+
val deviceId = prefs.getString("deviceId", UUID.randomUUID().toString())
46+
prefs.edit().putString("deviceId", deviceId).apply()
47+
4148
accelerometer = Accelerometer.Builder(this)
4249
.setDebug(true)
4350
.setDatabaseType(Engine.DatabaseType.ROOM)
4451
.setDatabasePath("database-name")
45-
.setDatabaseHost("http://100.70.109.77:3000/insert")
52+
.setDatabaseHost("https://node.awareframework.com/insert")
53+
.setDeviceId(deviceId)
4654
.build()
4755
syncManager = DbSyncManager.Builder(this)
4856
.setDebug(true)

library/src/main/java/com/awareframework/android/sensor/accelerometer/Accelerometer.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class Accelerometer private constructor(
3333
const val ACTION_AWARE_ACCELEROMETER_LABEL = "com.aware.android.sensor.accelerometer.SET_LABEL"
3434
const val ACTION_AWARE_ACCELEROMETER_SYNC = "com.aware.android.sensor.accelerometer.SYNC"
3535

36+
const val EXTRA_AWARE_ACCELEROMETER_LABEL = "label"
37+
3638
val defaultConfig: AccelerometerConfig = AccelerometerConfig()
3739
}
3840

@@ -123,10 +125,10 @@ class Accelerometer private constructor(
123125
*/
124126
fun setSensorObserver(sensorObserver: SensorObserver) = apply { config.sensorObserver = sensorObserver }
125127

126-
// /**
127-
// * @param deviceId id of the device that will be associated with the events and the sensor. (default = "")
128-
// */
129-
// fun setDeviceId(deviceId: String) = apply { CONFIG.deviceId = deviceId }
128+
/**
129+
* @param deviceId id of the device that will be associated with the events and the sensor. (default = "")
130+
*/
131+
fun setDeviceId(deviceId: String) = apply { config.deviceId = deviceId }
130132

131133
/**
132134
* @param wakeLock enable/disable wakelock, permissions needs to be handled by the client.

library/src/main/java/com/awareframework/android/sensor/accelerometer/AccelerometerSensor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class AccelerometerSensor : AwareSensor(), SensorEventListener {
247247
when (intent?.action) {
248248

249249
Accelerometer.ACTION_AWARE_ACCELEROMETER_LABEL -> {
250-
AccelerometerSensor.CONFIG.label = intent.getStringExtra(Accelerometer.ACTION_AWARE_ACCELEROMETER_LABEL)
250+
AccelerometerSensor.CONFIG.label = intent.getStringExtra(Accelerometer.EXTRA_AWARE_ACCELEROMETER_LABEL)
251251
}
252252

253253
Accelerometer.ACTION_AWARE_ACCELEROMETER_SYNC -> {

0 commit comments

Comments
 (0)