Skip to content

Commit e3ee9e1

Browse files
committed
Initial Commit
0 parents  commit e3ee9e1

32 files changed

+793
-0
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
.externalNativeBuild

.idea/dictionaries/Praveen.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

+45
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+49
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BridgeDemo/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

BridgeDemo/build.gradle

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 26
5+
defaultConfig {
6+
applicationId "com.droidinfinity.heartratebridgedemo"
7+
minSdkVersion 17
8+
targetSdkVersion 26
9+
versionCode 2
10+
versionName "1.0.2"
11+
}
12+
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
}
20+
21+
dependencies {
22+
implementation fileTree(dir: 'libs', include: ['*.jar'])
23+
implementation 'com.android.support:appcompat-v7:26.1.0'
24+
implementation 'com.android.support:design:26.1.0'
25+
}

BridgeDemo/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="com.droidinfinity.heartratebridgedemo">
5+
6+
<application
7+
android:allowBackup="false"
8+
android:icon="@mipmap/ic_launcher"
9+
android:label="@string/app_name"
10+
android:roundIcon="@mipmap/ic_launcher"
11+
android:supportsRtl="true"
12+
android:theme="@style/AppTheme"
13+
tools:ignore="GoogleAppIndexingWarning">
14+
<activity
15+
android:name=".MainActivity"
16+
android:label="@string/app_name"
17+
android:theme="@style/AppTheme.NoActionBar">
18+
<intent-filter>
19+
<action android:name="android.intent.action.MAIN" />
20+
21+
<category android:name="android.intent.category.LAUNCHER" />
22+
</intent-filter>
23+
</activity>
24+
</application>
25+
26+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package com.droidinfinity.heartratebridgedemo;
2+
3+
import android.content.Intent;
4+
import android.net.Uri;
5+
import android.os.Bundle;
6+
import android.support.design.widget.FloatingActionButton;
7+
import android.support.design.widget.Snackbar;
8+
import android.support.v7.app.AppCompatActivity;
9+
import android.support.v7.widget.Toolbar;
10+
import android.view.View;
11+
import android.view.Menu;
12+
import android.view.MenuItem;
13+
14+
import com.droidinfinity.heartratemonitor.bridge.HeartRateBridge;
15+
16+
public class MainActivity extends AppCompatActivity {
17+
18+
private HeartRateBridge heartRateBridge;
19+
20+
@Override
21+
protected void onCreate(Bundle savedInstanceState) {
22+
super.onCreate(savedInstanceState);
23+
setContentView(R.layout.activity_main);
24+
Toolbar toolbar = findViewById(R.id.toolbar);
25+
setSupportActionBar(toolbar);
26+
27+
final FloatingActionButton fab = findViewById(R.id.fab);
28+
fab.setOnClickListener(new View.OnClickListener() {
29+
@Override
30+
public void onClick(View view) {
31+
if (!HeartRateBridge.isHeartRateMonitorInstalled(MainActivity.this)) {
32+
Snackbar.make(view, "Heart Rate Monitor app is not installed. ", Snackbar.LENGTH_LONG)
33+
.setAction("INSTALL", new View.OnClickListener() {
34+
@Override
35+
public void onClick(View v) {
36+
HeartRateBridge.startInstallIntent(MainActivity.this);
37+
}
38+
}).show();
39+
40+
return;
41+
}
42+
43+
heartRateBridge.openHeartRateBridge(MainActivity.this);
44+
}
45+
});
46+
47+
heartRateBridge = new HeartRateBridge();
48+
heartRateBridge.setHeartRateListener(new HeartRateBridge.HeartRateListener() {
49+
@Override
50+
public void onHeartRateMeasured(int heartRate) {
51+
if (heartRate > 0) {
52+
Snackbar.make(fab, "Measured Heart Rate: " + heartRate, Snackbar.LENGTH_LONG).show();
53+
} else {
54+
Snackbar.make(fab, "Measurement is not accurate or incorrect. No data is returned", Snackbar.LENGTH_LONG).show();
55+
}
56+
}
57+
});
58+
}
59+
60+
@SuppressWarnings("StatementWithEmptyBody")
61+
@Override
62+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
63+
super.onActivityResult(requestCode, resultCode, data);
64+
65+
if (!heartRateBridge.onActivityResult(requestCode, resultCode, data)) {
66+
//Handle any other logic here.
67+
}
68+
}
69+
70+
@Override
71+
public boolean onCreateOptionsMenu(Menu menu) {
72+
getMenuInflater().inflate(R.menu.menu_main, menu);
73+
return super.onCreateOptionsMenu(menu);
74+
}
75+
76+
@Override
77+
public boolean onOptionsItemSelected(MenuItem item) {
78+
if (item.getItemId() == R.id.action_github) {
79+
final Uri uri = Uri.parse("https://github.com/Praveen2106/HeartRateBridgeDemo");
80+
final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
81+
startActivity(intent);
82+
}
83+
84+
return super.onOptionsItemSelected(item);
85+
}
86+
}

0 commit comments

Comments
 (0)