Skip to content

Commit

Permalink
Add consumer proguard rules. Add posibility to not automatically hand…
Browse files Browse the repository at this point in the history
…le resolutions.
  • Loading branch information
patloew committed Nov 24, 2016
1 parent 03efb8b commit 8ee9ed4
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 21 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# Changelog

## Version 2.0.1

* Add consumer ProGuard rules.
* Add possibility to disable the automatic handling of resolutions, by passing a boolean parameter when creating an RxFit instance.
* Update RxJava (2.0.1) and Google Play Services (10.0.0).
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ An `RxFitOnExceptionResumeNext` Transformer is available in the lib, which resum

An optional global default timeout for all Fit API requests made through the library can be set via `rxFit.setDefaultTimeout(...)`. In addition, timeouts can be set when creating a new Observable by providing timeout parameters, e.g. `rxFit.history().read(dataReadRequest, 15, TimeUnit.SECONDS)`. These parameters override the default timeout. When a timeout occurs, a StatusException is provided via `onError()`. The RxJava timeout operators can be used instead, but these do not cancel the Fit API request immediately.

If you don't want the library to automatically handle resolutions (e.g. for usage in a background service), you can disable this behavior when creating an RxFit instance by passing in `false` to the `handleResolutions` parameter: `new RxFit(ctx, apiArray, scopeArray, false)`.

You can also obtain a `Single<GoogleApiClient>`, which connects on subscribe and disconnects on unsubscribe via `GoogleAPIClientSingle.create(...)`.

The following Exceptions are thrown in the lib and provided via `onError()`:
Expand All @@ -54,7 +56,7 @@ A basic sample app is available in the `sample` project. You need to create an O
The lib is available on jCenter. Add the following to your `build.gradle`:

dependencies {
compile 'com.patloew.rxfit:rxfit2:2.0.0'
compile 'com.patloew.rxfit:rxfit2:2.0.1'
}

# Testing
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'

classpath 'me.tatarka:gradle-retrolambda:3.3.1'
classpath 'me.tatarka:gradle-retrolambda:3.4.0'

classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1'
classpath "com.github.dcendents:android-maven-gradle-plugin:1.5"
Expand Down
9 changes: 5 additions & 4 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'

group = 'com.patloew.rxfit'
version = '2.0.0'
version = '2.0.1'
project.archivesBaseName = 'rxfit2'

android {
Expand All @@ -16,12 +16,13 @@ android {
minSdkVersion 9
targetSdkVersion 25
versionCode 1
versionName "2.0.0"
versionName "2.0.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
consumerProguardFiles 'proguard-rules-consumer.pro'
}
}
compileOptions {
Expand All @@ -42,8 +43,8 @@ retrolambda {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'io.reactivex.rxjava2:rxjava:2.0.0'
compile 'com.google.android.gms:play-services-fitness:9.8.0'
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
compile 'com.google.android.gms:play-services-fitness:10.0.0'

testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
Expand Down
1 change: 1 addition & 0 deletions library/proguard-rules-consumer.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-dontwarn java.lang.invoke.*
3 changes: 0 additions & 3 deletions library/src/main/java/com/patloew/rxfit/BaseObservable.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,15 @@
*
*/
abstract class BaseObservable<T> extends BaseRx<T> implements ObservableOnSubscribe<T> {
private final boolean handleResolution;

private final Map<GoogleApiClient, ObservableEmitter<T>> subscriptionInfoMap = new ConcurrentHashMap<>();

protected BaseObservable(@NonNull RxFit rxFit, Long timeout, TimeUnit timeUnit) {
super(rxFit, timeout, timeUnit);
handleResolution = true;
}

protected BaseObservable(@NonNull Context ctx, @NonNull Api<? extends Api.ApiOptions.NotRequiredOptions>[] services, Scope[] scopes) {
super(ctx, services, scopes);
handleResolution = false;
}

@Override
Expand Down
3 changes: 3 additions & 0 deletions library/src/main/java/com/patloew/rxfit/BaseRx.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ abstract class BaseRx<T> {
protected final Context ctx;
private final Api<? extends Api.ApiOptions.NotRequiredOptions>[] services;
private final Scope[] scopes;
protected final boolean handleResolution;
final Long timeoutTime;
final TimeUnit timeoutUnit;

protected BaseRx(@NonNull RxFit rxFit, Long timeout, TimeUnit timeUnit) {
this.ctx = rxFit.ctx;
this.services = rxFit.apis;
this.scopes = rxFit.scopes;
this.handleResolution = rxFit.handleResolutions;

if(timeout != null && timeUnit != null) {
this.timeoutTime = timeout;
Expand All @@ -61,6 +63,7 @@ protected BaseRx(@NonNull Context ctx, @NonNull Api<? extends Api.ApiOptions.Not
this.ctx = ctx;
this.services = services;
this.scopes = scopes;
this.handleResolution = false;
timeoutTime = null;
timeoutUnit = null;
}
Expand Down
3 changes: 0 additions & 3 deletions library/src/main/java/com/patloew/rxfit/BaseSingle.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,15 @@
*
*/
abstract class BaseSingle<T> extends BaseRx<T> implements SingleOnSubscribe<T> {
private final boolean handleResolution;

final Map<GoogleApiClient, SingleEmitter<T>> subscriptionInfoMap = new ConcurrentHashMap<>();

protected BaseSingle(@NonNull RxFit rxFit, Long timeout, TimeUnit timeUnit) {
super(rxFit, timeout, timeUnit);
handleResolution = true;
}

protected BaseSingle(@NonNull Context ctx, @NonNull Api<? extends Api.ApiOptions.NotRequiredOptions>[] services, Scope[] scopes) {
super(ctx, services, scopes);
handleResolution = false;
}

@Override
Expand Down
20 changes: 19 additions & 1 deletion library/src/main/java/com/patloew/rxfit/RxFit.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class RxFit {
final Context ctx;
final Api<? extends Api.ApiOptions.NotRequiredOptions>[] apis;
final Scope[] scopes;
final boolean handleResolutions;

private final Ble ble = new Ble(this);
private final Config config = new Config(this);
Expand All @@ -49,7 +50,7 @@ public class RxFit {
private final Sessions sessions = new Sessions(this);


/* Creates a new RxFit instance.
/* Creates a new RxFit instance, which handles resolutions.
*
* @param ctx Context.
* @param apis An array of Fitness APIs to be used in your app.
Expand All @@ -59,6 +60,23 @@ public RxFit(@NonNull Context ctx, @NonNull Api<? extends Api.ApiOptions.NotRequ
this.ctx = ctx.getApplicationContext();
this.apis = apis;
this.scopes = scopes;
this.handleResolutions = true;
}

/* Creates a new RxFit instance.
*
* @param ctx Context.
* @param apis An array of Fitness APIs to be used in your app.
* @param scopes An array of the Scopes to be requested for your app.
* @param handleResolutions Set whether the library should try to handle resolutions
* (by showing the resolution dialog) or not. Setting this
* to false can be useful for background services.
*/
public RxFit(@NonNull Context ctx, @NonNull Api<? extends Api.ApiOptions.NotRequiredOptions>[] apis, @NonNull Scope[] scopes, boolean handleResolutions) {
this.ctx = ctx.getApplicationContext();
this.apis = apis;
this.scopes = scopes;
this.handleResolutions = handleResolutions;
}

/* Set a default timeout for all requests to the Fit API made in the lib.
Expand Down
16 changes: 8 additions & 8 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ retrolambda {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.0.0'
compile "com.android.support:design:25.0.0"
compile "com.android.support:recyclerview-v7:25.0.0"
compile "com.android.support:gridlayout-v7:25.0.0"
compile 'com.android.support:appcompat-v7:25.0.1'
compile "com.android.support:design:25.0.1"
compile "com.android.support:recyclerview-v7:25.0.1"
compile "com.android.support:gridlayout-v7:25.0.1"

compile project(':library')
//compile 'com.patloew.rxfit:rxfit2:2.0.0'
//compile 'com.patloew.rxfit:rxfit2:2.0.1'

compile 'io.reactivex.rxjava2:rxandroid:2.0.0-RC1'
compile 'io.reactivex.rxjava2:rxjava:2.0.0'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.0.1'

compile 'com.google.android.gms:play-services-fitness:9.8.0'
compile 'com.google.android.gms:play-services-fitness:10.0.0'

testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
Expand Down

0 comments on commit 8ee9ed4

Please sign in to comment.