Skip to content

Commit

Permalink
Merge branch 'master' into cjk_withings_device_integration
Browse files Browse the repository at this point in the history
  • Loading branch information
audaciouscode committed Apr 17, 2017
2 parents 1b79282 + 24898e2 commit 450f255
Show file tree
Hide file tree
Showing 12 changed files with 496 additions and 238 deletions.
19 changes: 9 additions & 10 deletions build.gradle
Expand Up @@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:2.3.1'
}
}

Expand Down Expand Up @@ -51,15 +51,14 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:recyclerview-v7:25.3.0'
compile 'com.android.support:cardview-v7:25.3.0'
compile 'com.google.android.gms:play-services-location:10.2.0'
compile 'com.google.android.gms:play-services-maps:10.2.0'
compile 'com.google.android.gms:play-services-nearby:10.2.0'
compile 'com.google.android.gms:play-services-places:10.2.0'
compile 'com.google.android.gms:play-services-awareness:10.2.0'
compile 'com.android.support:customtabs:23.3.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.google.android.gms:play-services-location:10.2.1'
compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'com.google.android.gms:play-services-nearby:10.2.1'
compile 'com.google.android.gms:play-services-places:10.2.1'
compile 'com.google.android.gms:play-services-awareness:10.2.1'
compile 'com.google.maps.android:android-maps-utils:0.4'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'commons-io:commons-io:2.4'
Expand Down
63 changes: 63 additions & 0 deletions res/layout/card_generator_app_event.xml
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="4dp"
android:layout_margin="8dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#607D8B"
android:padding="8dp"
android:baselineAligned="false">
<ImageView android:src="@drawable/ic_screen_state"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginRight="8dp" />
<TextView android:text="@string/generator_app_event"
android:gravity="center_vertical|start"
android:layout_width="0dp"
android:layout_height="24dp"
android:layout_weight="1"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@android:color/white" />
<TextView android:id="@+id/generator_data_point_date"
android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:textSize="12sp"
android:textColor="@android:color/white"
android:layout_marginRight="8dp"/>
</LinearLayout>
<LinearLayout android:id="@+id/card_content"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">
<TextView android:id="@+id/card_app_event_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="16dp" />
</LinearLayout>
<TextView android:id="@+id/card_empty"
android:text="@string/message_generator_device_app_event_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="16dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
63 changes: 63 additions & 0 deletions res/layout/card_generator_device_battery.xml
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="4dp"
android:layout_margin="8dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#607D8B"
android:padding="8dp"
android:baselineAligned="false">
<ImageView android:src="@drawable/ic_screen_state"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginRight="8dp" />
<TextView android:text="@string/generator_device_battery"
android:gravity="center_vertical|start"
android:layout_width="0dp"
android:layout_height="24dp"
android:layout_weight="1"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@android:color/white" />
<TextView android:id="@+id/generator_data_point_date"
android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:textSize="12sp"
android:textColor="@android:color/white"
android:layout_marginRight="8dp"/>
</LinearLayout>
<LinearLayout android:id="@+id/card_content"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">
<TextView android:id="@+id/card_last_battery_level"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="16dp" />
</LinearLayout>
<TextView android:id="@+id/card_empty"
android:text="@string/message_generator_device_battery_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="16dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
4 changes: 4 additions & 0 deletions res/values/databases.xml
Expand Up @@ -23,4 +23,8 @@
<string name="pdk_generator_withings_create_sleep_measure_history_table">CREATE TABLE sleep_measure_history(_id INTEGER PRIMARY KEY AUTOINCREMENT, fetched INTEGER, transmitted INTEGER, observed INTEGER, start_date REAL, end_date REAL, state TEXT, measurement_device TEXT);</string>
<string name="pdk_generator_withings_create_sleep_summary_history_table">CREATE TABLE sleep_summary_history(_id INTEGER PRIMARY KEY AUTOINCREMENT, fetched INTEGER, transmitted INTEGER, observed INTEGER, start_date REAL, end_date REAL, timezone TEXT, measurement_device TEXT, wake_duration REAL, light_sleep_duration REAL, deep_sleep_duration REAL, rem_sleep_duration REAL, wake_count INTEGER, to_sleep_duration REAL, to_wake_duration REAL);</string>
<string name="pdk_generator_withings_create_workout_history_table">CREATE TABLE workout_history(_id INTEGER PRIMARY KEY AUTOINCREMENT, fetched INTEGER, transmitted INTEGER, observed INTEGER, start_date REAL, end_date REAL, measurement_device TEXT, workout_category TEXT, caolories REAL, effective_duration REAL, raw_data TEXT);</string>

<!-- Battery Generator -->
<string name="pdk_generator_device_battery_create_history_table">CREATE TABLE history(_id INTEGER PRIMARY KEY AUTOINCREMENT, fetched INTEGER, transmitted INTEGER, observed INTEGER, health TEXT, level INTERGER, plugged TEXT, present INTEGER, scale INTEGER, temperature INTEGER, voltage INTEGER, technology TEXT, status TEXT);</string>

</resources>
1 change: 0 additions & 1 deletion res/values/diagnostics.xml
Expand Up @@ -19,5 +19,4 @@

<string name="diagnostic_withings_auth_required_title">Access to Withing Account Required</string>
<string name="diagnostic_withings_auth_required">Permission is required to fetch data from the Withings server. Please grant this application the requested permissions.</string>

</resources>
8 changes: 8 additions & 0 deletions res/values/generators.xml
Expand Up @@ -120,4 +120,12 @@

<!-- Withings Device Resources -->
<string name="generator_withings_device">Withings Device</string>

<!-- Device Battery -->
<string name="generator_device_battery">Device Battery</string>
<string name="message_generator_device_battery_empty">No battery levels have been reported yet.</string>

<!-- App Event History -->
<string name="generator_app_event">App Event History</string>
<string name="message_generator_device_app_event_empty">No app events have been logged yet.</string>
</resources>
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;

Expand Down
Expand Up @@ -250,8 +250,10 @@ public void notifyGeneratorUpdated(String identifier, long timestamp, Bundle bun
public void notifyGeneratorUpdated(String identifier, Bundle bundle) {
long timestamp = System.currentTimeMillis();

for (GeneratorUpdatedListener listener : this.mGeneratorUpdatedListeners) {
listener.onGeneratorUpdated(identifier, timestamp, bundle);
synchronized(this.mGeneratorUpdatedListeners) {
for (GeneratorUpdatedListener listener : this.mGeneratorUpdatedListeners) {
listener.onGeneratorUpdated(identifier, timestamp, bundle);
}
}
}

Expand All @@ -273,11 +275,15 @@ private void setContext(Context context) {
}

public void addNewGeneratorUpdatedListener(Generators.GeneratorUpdatedListener listener) {
this.mGeneratorUpdatedListeners.add(listener);
synchronized(this.mGeneratorUpdatedListeners) {
this.mGeneratorUpdatedListeners.add(listener);
}
}

public void removeGeneratorUpdatedListener(Generators.GeneratorUpdatedListener listener) {
this.mGeneratorUpdatedListeners.remove(listener);
synchronized (this.mGeneratorUpdatedListeners) {
this.mGeneratorUpdatedListeners.remove(listener);
}
}

public interface GeneratorUpdatedListener {
Expand Down

0 comments on commit 450f255

Please sign in to comment.