Skip to content

Commit

Permalink
PebbleKit Android v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Pebble Build committed Mar 28, 2015
1 parent 803f78c commit 625e63b
Show file tree
Hide file tree
Showing 9 changed files with 237 additions and 33 deletions.
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2014 - 2015 Pebble Technology

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 changes: 9 additions & 10 deletions PebbleKit/PebbleKit/PebbleKit-PebbleKit.iml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="com.getpebble" external.system.module.version="2.5.0" type="JAVA_MODULE" version="4">
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand All @@ -10,9 +10,10 @@
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
Expand All @@ -31,33 +32,34 @@
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/test/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/docs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
Expand All @@ -77,14 +79,11 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/poms" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 16 Platform" jdkType="Android SDK" />
<orderEntry type="jdk" jdkName="Android API 14 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="guava-14.0.1" level="project" />
</component>
</module>

7 changes: 4 additions & 3 deletions PebbleKit/PebbleKit/build.gradle
@@ -1,11 +1,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 14
buildToolsVersion "20.0.0"
compileSdkVersion 21
buildToolsVersion '21.1.1'

defaultConfig {
applicationId "com.getpebble.android.kit"
minSdkVersion 14
targetSdkVersion 21
}

lintOptions {
Expand Down
@@ -1,5 +1,7 @@
package com.getpebble.android.kit;

import android.net.Uri;

import java.util.UUID;

/**
Expand Down Expand Up @@ -363,4 +365,8 @@ public static PebbleDataType fromByte(byte b) {
return null;
}
}

/* package */ static final Uri URI_CONTENT_PRIMARY = Uri.parse("content://com.getpebble.android.provider/state");

/* package */ static final Uri URI_CONTENT_BASALT = Uri.parse("content://com.getpebble.android.provider.basalt/state");
}
Expand Up @@ -98,9 +98,7 @@ public static void customizeWatchApp(final Context context, final PebbleAppType
public static boolean isWatchConnected(final Context context) {
Cursor c = null;
try {
c = context.getContentResolver().query(
Uri.parse("content://com.getpebble.android.provider/state"), null, null,
null, null);
c = queryProvider(context);
if (c == null || !c.moveToNext()) {
return false;
}
Expand All @@ -127,9 +125,7 @@ public static boolean isWatchConnected(final Context context) {
public static boolean areAppMessagesSupported(final Context context) {
Cursor c = null;
try {
c = context.getContentResolver().query(
Uri.parse("content://com.getpebble.android.provider/state"), null, null,
null, null);
c = queryProvider(context);
if (c == null || !c.moveToNext()) {
return false;
}
Expand All @@ -156,9 +152,7 @@ public static boolean areAppMessagesSupported(final Context context) {
public static FirmwareVersionInfo getWatchFWVersion(final Context context) {
Cursor c = null;
try {
c = context.getContentResolver().query(
Uri.parse("content://com.getpebble.android.provider/state"), null, null,
null, null);
c = queryProvider(context);
if (c == null || !c.moveToNext()) {
return null;
}
Expand Down Expand Up @@ -191,9 +185,7 @@ public static FirmwareVersionInfo getWatchFWVersion(final Context context) {
public static boolean isDataLoggingSupported(final Context context) {
Cursor c = null;
try {
c = context.getContentResolver().query(
Uri.parse("content://com.getpebble.android.provider/state"),
null, null, null, null);
c = queryProvider(context);
if (c == null || !c.moveToNext()) {
return false;
}
Expand Down Expand Up @@ -934,4 +926,29 @@ public final String getTag() {
return tag;
}
}

/**
* Query the Pebble ContentProvider - utility method for various PebbleKit helper methods
*
* This attempts first to query the Basalt app provider, then if that is non-existant or disconnected
* queries the primary (i.e. original) provider authority
*/
private static Cursor queryProvider(final Context context) {
Cursor c = context.getContentResolver().query(Constants.URI_CONTENT_BASALT, null, null, null, null);
if (c != null) {
if (c.moveToFirst()) {
// If Basalt app is connected, talk to that (return the open cursor)
if (c.getInt(KIT_STATE_COLUMN_CONNECTED) == 1) {
c.moveToPrevious();
return c;
}
}
// Else close the cursor and try the primary authority
c.close();
}

c = context.getContentResolver().query(Constants.URI_CONTENT_PRIMARY, null, null, null, null);
// Do nothing with this cursor - the calling method will check it for whatever it is looking for
return c;
}
}
2 changes: 1 addition & 1 deletion PebbleKit/build.gradle
Expand Up @@ -4,7 +4,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
classpath 'com.android.tools.build:gradle:1.0.0'
}
}

Expand Down
4 changes: 2 additions & 2 deletions PebbleKit/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Fri Jan 30 15:55:46 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
19 changes: 14 additions & 5 deletions README.md
Expand Up @@ -68,7 +68,7 @@ In Android Studio, or on any Gradle project, you can add PebbleKit Android in
your `app/build.gradle` file:

dependencies {
compile 'com.getpebble:pebblekit:2.6.0@aar'
compile 'com.getpebble:pebblekit:3.0.0@aar'
}

Make sure that you also include a reference to the Sonatype OSS Repository:
Expand All @@ -83,7 +83,7 @@ Make sure that you also include a reference to the Sonatype OSS Repository:
To use PebbleKit in the Eclipse IDE you must import the `.jar` file that
contains the PebbleKit Android SDK. To install, follow the instructions below:

1. Download the `pebblekit-2.6.0-eclipse.jar` file from
1. Download the `pebblekit-3.0.0-eclipse.jar` file from
[Sonatype][jar-download].

2. Add the file to your Android project in the `libs` folder alongside the
Expand All @@ -100,7 +100,7 @@ If you are using Maven, you can add the following dependency in your `pom.xml`:
<dependency>
<groupId>com.getpebble</groupId>
<artifactId>pebblekit</artifactId>
<version>2.6.0</version>
<version>3.0.0</version>
<type>aar</type>
</dependency>

Expand All @@ -113,6 +113,15 @@ and add it directly into your project.

## Changelog

### 3.0.0 - March 2015

This version provides support for the upcoming Pebble Time and Pebble Time Steel
watches. You must re-compile your application with this version of PebbleKit
otherwise you will not be able to detect (`PebbleKit.isWatchConnected()`) the
new Pebble watches.

There are no other changes in this version.

### 2.6.0 - November 2014

- The datalogging API has changed in this version. `receiveData()` now takes
Expand All @@ -136,6 +145,6 @@ channel](http://developer.getpebble.com/blog/2014/06/12/Android-Beta-Channel/)).

- First release of 2.0 SDK with the new DataLogging API

[jar-download]: https://oss.sonatype.org/service/local/repositories/releases/content/com/getpebble/pebblekit/2.6.0/pebblekit-2.6.0-eclipse.jar
[aar-download]: https://oss.sonatype.org/service/local/repositories/releases/content/com/getpebble/pebblekit/2.6.0/pebblekit-2.6.0.aar
[jar-download]: https://oss.sonatype.org/service/local/repositories/releases/content/com/getpebble/pebblekit/3.0.0/pebblekit-3.0.0-eclipse.jar
[aar-download]: https://oss.sonatype.org/service/local/repositories/releases/content/com/getpebble/pebblekit/3.0.0/pebblekit-3.0.0.aar
[readme-android]: https://github.com/pebble/pebble-sdk-examples/blob/master/README-ANDROID.txt

0 comments on commit 625e63b

Please sign in to comment.