Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #8 from empatica/repo-update
Browse files Browse the repository at this point in the history
Update for Empalink 2.1
  • Loading branch information
pregno authored Jan 13, 2017
2 parents 8d1b6ab + 2d18671 commit f801eef
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 25 deletions.
17 changes: 12 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ gen/
build/

# IntelliJ Idea
/.idea/workspace.xml
/.idea/tasks.xml
/.idea/dataSources.ids
/.idea/datasources.xml
.idea/
*.iml

# OSX stuff
# OS-specific files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Proguard folder
proguard/
Expand All @@ -38,3 +42,6 @@ proguard/

# EmpaLink lib
empalink*.aar

gradlew*
gradle/*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The sample application implemented in the project has very simple functionalitie
- Make sure you have a valid API key. You can request one for your Empatica Connect account from our [Developer Area][1].
- Edit `MainActivity.java` and assign your API key to the `EMPATICA_API_KEY` constant .
- Download the Android SDK from our [Developer Area][1].
- Unzip the archive you've downloaded and copy the `.aar` file you'll find inside into the `empalink-2.0` folder contained in the sample project.
- Unzip the archive you've downloaded and copy the `.aar` file you'll find inside into the `libs` folder contained in the sample project.
- Build and run the project.
- If a device is in range and its light is blinking green, but the app doesn't connect, please check that the discovered device can be used with your API key. If the `allowed` parameter is always false, the device is not linked to your API key. Please check your [Developer Area][1].

Expand Down
12 changes: 6 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
applicationId 'com.empatica.empalinksample'
minSdkVersion 19
targetSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
Expand All @@ -22,7 +22,7 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.loopj.android:android-async-http:1.4.6'
compile project(':empalink-2.0')
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.empatica.empalink:empalink:2.1@aar'
compile 'com.squareup.okhttp:okhttp:2.5.0'
}
1 change: 1 addition & 0 deletions app/libs/<COPY HERE EMPALINK>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
COPY HERE THE EMPALINK LIBRARY
14 changes: 8 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.empatica.sample" >
package="com.empatica.sample">

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:theme="@style/AppTheme">
<activity
android:screenOrientation="portrait"
android:name=".MainActivity"
android:label="@string/app_name" >
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
Expand Down
20 changes: 18 additions & 2 deletions app/src/main/java/com/empatica/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
Expand All @@ -34,6 +35,7 @@ public class MainActivity extends AppCompatActivity implements EmpaDataDelegate,

private static final int REQUEST_ENABLE_BT = 1;
private static final int REQUEST_PERMISSION_ACCESS_COARSE_LOCATION = 1;

private static final long STREAMING_TIME = 10000; // Stops streaming 10 seconds after connection

private static final String EMPATICA_API_KEY = ""; // TODO insert your API Key here
Expand Down Expand Up @@ -121,6 +123,20 @@ private void initEmpaticaDeviceManager() {
} else {
// Create a new EmpaDeviceManager. MainActivity is both its data and status delegate.
deviceManager = new EmpaDeviceManager(getApplicationContext(), this, this);

if (TextUtils.isEmpty(EMPATICA_API_KEY)) {
new AlertDialog.Builder(this)
.setTitle("Warning")
.setMessage("Please insert your API KEY")
.setNegativeButton("Close", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// without permission exit is the only way
finish();
}
})
.show();
return;
}
// Initialize the Device Manager using your API key. You need to have Internet access at this point.
deviceManager.authenticateWithAPIKey(EMPATICA_API_KEY);
}
Expand Down Expand Up @@ -193,7 +209,7 @@ public void didUpdateStatus(EmpaStatus status) {
updateLabel(statusLabel, status.name() + " - Turn on your device");
// Start scanning
deviceManager.startScanning();
// The device manager has established a connection
// The device manager has established a connection
} else if (status == EmpaStatus.CONNECTED) {
// Stop streaming after STREAMING_TIME
runOnUiThread(new Runnable() {
Expand All @@ -209,7 +225,7 @@ public void run() {
}, STREAMING_TIME);
}
});
// The device manager disconnected from a device
// The device manager disconnected from a device
} else if (status == EmpaStatus.DISCONNECTED) {
updateLabel(deviceNameLabel, "");
}
Expand Down
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'

classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand All @@ -15,5 +14,8 @@ buildscript {
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}
2 changes: 0 additions & 2 deletions empalink-2.0/build.gradle

This file was deleted.

2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':app', ':empalink-2.0'
include ':app'

0 comments on commit f801eef

Please sign in to comment.