Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
feat: Migrate to RxJava 3 and RxBinding 4 (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
galuszkak authored Jul 12, 2020
1 parent 2d1a4d8 commit 405050e
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 70 deletions.
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}

Expand All @@ -22,8 +22,8 @@ ext {
compileSdkVersion = 29
targetSdkVersion = compileSdkVersion

rxJava = 'io.reactivex.rxjava2:rxjava:2.2.19'
junit = 'junit:junit:4.12'
rxJava = 'io.reactivex.rxjava3:rxjava:3.0.4'
junit = 'junit:junit:4.13'
mockito = 'org.mockito:mockito-core:3.3.3'

androidXFragment = 'androidx.fragment:fragment:1.2.5'
Expand All @@ -37,9 +37,9 @@ ext {
khronosOpenGLApi = "org.khronos:opengl-api:gl1.1-android-2.1_r1"

bintrayRepo = 'tbruyelle'
bintrayName = 'RxPermissions2'
bintrayName = 'RxPermissions3'

publishedGroupId = 'com.tbruyelle.rxpermissions2'
publishedGroupId = 'com.tbruyelle.rxpermissions3'
artifact = 'rxpermissions'
libraryName = 'RxPermissions'
libraryVersion = '0.9.5'
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jun 26 11:49:33 CEST 2020
#Thu Jul 09 16:45:02 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
4 changes: 2 additions & 2 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ android {
compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
Expand Down
2 changes: 1 addition & 1 deletion lib/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.tbruyelle.rxpermissions2">
<manifest package="com.tbruyelle.rxpermissions3">

<application />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.tbruyelle.rxpermissions2;
package com.tbruyelle.rxpermissions3;

import java.util.List;

import io.reactivex.Observable;
import io.reactivex.functions.BiConsumer;
import io.reactivex.functions.Function;
import io.reactivex.functions.Predicate;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.functions.BiConsumer;
import io.reactivex.rxjava3.functions.Function;
import io.reactivex.rxjava3.functions.Predicate;

public class Permission {
public final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* limitations under the License.
*/

package com.tbruyelle.rxpermissions2;
package com.tbruyelle.rxpermissions3;

import android.annotation.TargetApi;
import android.app.Activity;
Expand All @@ -28,11 +28,11 @@
import java.util.ArrayList;
import java.util.List;

import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.ObservableTransformer;
import io.reactivex.functions.Function;
import io.reactivex.subjects.PublishSubject;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.ObservableSource;
import io.reactivex.rxjava3.core.ObservableTransformer;
import io.reactivex.rxjava3.functions.Function;
import io.reactivex.rxjava3.subjects.PublishSubject;

public class RxPermissions {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tbruyelle.rxpermissions2;
package com.tbruyelle.rxpermissions3;

import android.annotation.TargetApi;
import android.content.pm.PackageManager;
Expand All @@ -13,7 +13,8 @@
import java.util.HashMap;
import java.util.Map;

import io.reactivex.subjects.PublishSubject;
import io.reactivex.rxjava3.subjects.PublishSubject;


public class RxPermissionsFragment extends Fragment {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* limitations under the License.
*/

package com.tbruyelle.rxpermissions2;
package com.tbruyelle.rxpermissions3;

import android.Manifest;
import android.annotation.TargetApi;
Expand All @@ -32,9 +32,10 @@
import org.robolectric.android.controller.ActivityController;
import org.robolectric.annotation.Config;

import io.reactivex.Observable;
import io.reactivex.observers.TestObserver;
import io.reactivex.subjects.PublishSubject;

import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.observers.TestObserver;
import io.reactivex.rxjava3.subjects.PublishSubject;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand Down Expand Up @@ -85,7 +86,6 @@ public void subscription_preM() {
trigger().compose(mRxPermissions.ensure(permission)).subscribe(sub);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(true);
}

Expand All @@ -101,7 +101,6 @@ public void subscription_granted() {
mRxPermissions.onRequestPermissionsResult(new String[]{permission}, result);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(true);
}

Expand All @@ -117,7 +116,6 @@ public void eachSubscription_granted() {
mRxPermissions.onRequestPermissionsResult(new String[]{permission}, result);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(new Permission(permission, true));
}

Expand All @@ -133,7 +131,6 @@ public void eachSubscriptionCombined_granted() {
mRxPermissions.onRequestPermissionsResult(new String[]{permission}, result);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(new Permission(permission, true));
}

Expand All @@ -147,7 +144,6 @@ public void eachSubscription_preM() {
trigger().compose(mRxPermissions.ensureEach(permission)).subscribe(sub);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(new Permission(permission, true));
}

Expand All @@ -161,7 +157,6 @@ public void eachSubscriptionCombined_preM() {
trigger().compose(mRxPermissions.ensureEachCombined(permission)).subscribe(sub);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(new Permission(permission, true));
}

Expand All @@ -175,7 +170,6 @@ public void subscription_alreadyGranted() {
trigger().compose(mRxPermissions.ensure(permission)).subscribe(sub);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(true);
}

Expand All @@ -191,7 +185,6 @@ public void subscription_denied() {
mRxPermissions.onRequestPermissionsResult(new String[]{permission}, result);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(false);
}

Expand All @@ -207,7 +200,6 @@ public void eachSubscription_denied() {
mRxPermissions.onRequestPermissionsResult(new String[]{permission}, result);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(new Permission(permission, false));
}

Expand All @@ -223,7 +215,6 @@ public void eachSubscriptionCombined_denied() {
mRxPermissions.onRequestPermissionsResult(new String[]{permission}, result);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(new Permission(permission, false));
}

Expand All @@ -237,7 +228,6 @@ public void subscription_revoked() {
trigger().compose(mRxPermissions.ensure(permission)).subscribe(sub);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(false);
}

Expand All @@ -251,7 +241,6 @@ public void eachSubscription_revoked() {
trigger().compose(mRxPermissions.ensureEach(permission)).subscribe(sub);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(new Permission(permission, false));
}

Expand All @@ -265,7 +254,6 @@ public void eachSubscriptionCombined_revoked() {
trigger().compose(mRxPermissions.ensureEachCombined(permission)).subscribe(sub);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(new Permission(permission, false));
}

Expand All @@ -281,7 +269,6 @@ public void subscription_severalPermissions_granted() {
mRxPermissions.onRequestPermissionsResult(permissions, result);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(true);
}

Expand All @@ -297,7 +284,6 @@ public void eachSubscription_severalPermissions_granted() {
mRxPermissions.onRequestPermissionsResult(permissions, result);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValues(new Permission(permissions[0], true), new Permission(permissions[1], true));
}

Expand All @@ -313,7 +299,6 @@ public void eachSubscriptionCombined_severalPermissions_granted() {
mRxPermissions.onRequestPermissionsResult(permissions, result);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValues(new Permission(permissions[0] + ", " + permissions[1], true));
}

Expand All @@ -329,7 +314,6 @@ public void subscription_severalPermissions_oneDenied() {
mRxPermissions.onRequestPermissionsResult(permissions, result);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(false);
}

Expand All @@ -347,7 +331,6 @@ public void subscription_severalPermissions_oneRevoked() {
new int[]{PackageManager.PERMISSION_GRANTED});

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(false);
}

Expand All @@ -365,7 +348,6 @@ public void eachSubscription_severalPermissions_oneAlreadyGranted() {
new int[]{PackageManager.PERMISSION_GRANTED});

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValues(new Permission(permissions[0], true), new Permission(permissions[1], true));
ArgumentCaptor<String[]> requestedPermissions = ArgumentCaptor.forClass(String[].class);
verify(mRxPermissions).requestPermissionsFromFragment(requestedPermissions.capture());
Expand All @@ -387,7 +369,6 @@ public void eachSubscriptionCombined_severalPermissions_oneAlreadyGranted() {
new int[]{PackageManager.PERMISSION_GRANTED});

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValues(new Permission(permissions[0] + ", " + permissions[1], true));
ArgumentCaptor<String[]> requestedPermissions = ArgumentCaptor.forClass(String[].class);
verify(mRxPermissions).requestPermissionsFromFragment(requestedPermissions.capture());
Expand All @@ -407,7 +388,6 @@ public void eachSubscription_severalPermissions_oneDenied() {
mRxPermissions.onRequestPermissionsResult(permissions, result);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValues(new Permission(permissions[0], true), new Permission(permissions[1], false));
}

Expand All @@ -423,7 +403,6 @@ public void eachSubscriptionCombined_severalPermissions_oneDenied() {
mRxPermissions.onRequestPermissionsResult(permissions, result);

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValues(new Permission(permissions[0] + ", " + permissions[1], false));
}

Expand All @@ -441,7 +420,6 @@ public void eachSubscription_severalPermissions_oneRevoked() {
new int[]{PackageManager.PERMISSION_GRANTED});

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValues(new Permission(permissions[0], true), new Permission(permissions[1], false));
}

Expand All @@ -459,7 +437,6 @@ public void eachSubscriptionCombined_severalPermissions_oneRevoked() {
new int[]{PackageManager.PERMISSION_GRANTED});

sub.assertNoErrors();
sub.assertTerminated();
sub.assertValues(new Permission(permissions[0] + ", " + permissions[1], false));
}

Expand All @@ -477,7 +454,6 @@ public void subscription_trigger_granted() {
mRxPermissions.onRequestPermissionsResult(new String[]{permission}, result);

sub.assertNoErrors();
sub.assertNotTerminated();
sub.assertValue(true);
}

Expand All @@ -495,7 +471,6 @@ public void eachSubscription_trigger_granted() {
mRxPermissions.onRequestPermissionsResult(new String[]{permission}, result);

sub.assertNoErrors();
sub.assertNotTerminated();
sub.assertValue(new Permission(permission, true));
}

Expand All @@ -513,7 +488,6 @@ public void eachSubscriptionCombined_trigger_granted() {
mRxPermissions.onRequestPermissionsResult(new String[]{permission}, result);

sub.assertNoErrors();
sub.assertNotTerminated();
sub.assertValue(new Permission(permission, true));
}

Expand Down
7 changes: 6 additions & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
applicationId "com.tbruyelle.rxpermissions.sample"
minSdkVersion 14
Expand All @@ -20,7 +25,7 @@ android {
dependencies {
implementation project(':rxpermissions')

implementation 'com.jakewharton.rxbinding2:rxbinding:2.2.0'
implementation 'com.jakewharton.rxbinding4:rxbinding:4.0.0'
implementation rootProject.ext.androidXAppcompat

testImplementation 'junit:junit:4.13'
Expand Down
4 changes: 2 additions & 2 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="com.tbruyelle.rxpermissions2.sample"
package="com.tbruyelle.rxpermissions3.sample"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
>
Expand All @@ -16,7 +16,7 @@
tools:ignore="GoogleAppIndexingWarning"
>
<activity
android:name="com.tbruyelle.rxpermissions2.sample.MainActivity"
android:name="com.tbruyelle.rxpermissions3.sample.MainActivity"
android:label="@string/app_name"
>
<intent-filter>
Expand Down
Loading

0 comments on commit 405050e

Please sign in to comment.