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

feat: Migrate to Jetpack (AndroidX) #325

Merged
merged 1 commit into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
language: android
dist: trusty

android:
components:
- tools
- build-tools-27.0.3
- android-27
- build-tools-29.0.3
- android-29
- extra-android-m2repository

jdk: oraclejdk8
Expand All @@ -14,6 +15,10 @@ notifications:

sudo: false

before_script:
- mkdir "$ANDROID_HOME/licenses" || true
- echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" > "$ANDROID_HOME/licenses/android-sdk-license"

cache:
directories:
- $HOME/.gradle
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This library allows the usage of RxJava with the new Android M permission model.

## Setup

To use this library your `minSdkVersion` must be >= 11.
To use this library your `minSdkVersion` must be >= 14.

```gradle
allprojects {
Expand Down
20 changes: 10 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
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'
}
Expand All @@ -18,19 +18,19 @@ allprojects {
}

ext {
minSdkVersion = 11
compileSdkVersion = 27
minSdkVersion = 14
compileSdkVersion = 29
targetSdkVersion = compileSdkVersion

rxJava = 'io.reactivex.rxjava2:rxjava:2.1.16'
supportLibraryVersion = '27.1.1'
appCompat = "com.android.support:appcompat-v7:$supportLibraryVersion"
supportAnnotations = "com.android.support:support-annotations:$supportLibraryVersion"
supportFragment = "com.android.support:support-fragment:$supportLibraryVersion"
rxJava = 'io.reactivex.rxjava2:rxjava:2.2.19'
junit = 'junit:junit:4.12'
mockito = 'org.mockito:mockito-core:1.10.19'
mockito = 'org.mockito:mockito-core:3.3.3'

robolectricVersion = '3.3.2'
androidXFragment = 'androidx.fragment:fragment:1.2.5'
androidXAnnotation = 'androidx.annotation:annotation:1.1.0'
androidXAppcompat = 'androidx.appcompat:appcompat:1.1.0'

robolectricVersion = '4.3.1'
robolectric = "org.robolectric:robolectric:$robolectricVersion"
robolectricShadowsSupport = "org.robolectric:shadows-support-v4:$robolectricVersion"
// Workaround for https://github.com/robolectric/robolectric/issues/1932
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

android.useAndroidX = true
android.enableJetifier=true
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 @@
#Thu Jun 28 09:30:08 CDT 2018
#Fri Jun 26 11:49:33 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
14 changes: 9 additions & 5 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ apply from: 'jitpack.gradle'
android {
compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
Expand All @@ -14,7 +18,7 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

testOptions.unitTests.includeAndroidResources = true
epool marked this conversation as resolved.
Show resolved Hide resolved
testOptions.unitTests.all {
// unitTests.returnDefaultValues = true
// Always show the result of every unit test, even if it passes.
Expand All @@ -26,13 +30,13 @@ android {

dependencies {
implementation rootProject.ext.rxJava
implementation rootProject.ext.supportAnnotations
implementation rootProject.ext.supportFragment
implementation rootProject.ext.androidXFragment
implementation rootProject.ext.androidXAnnotation
implementation rootProject.ext.androidXAppcompat

testImplementation rootProject.ext.junit
testImplementation 'junit:junit:4.13'
testImplementation rootProject.ext.mockito
testImplementation rootProject.ext.robolectric
testImplementation rootProject.ext.robolectricShadowsSupport
testImplementation rootProject.ext.khronosOpenGLApi
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -322,7 +323,7 @@ boolean isMarshmallow() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
}

void onRequestPermissionsResult(String permissions[], int[] grantResults) {
void onRequestPermissionsResult(String[] permissions, int[] grantResults) {
mRxPermissionsFragment.get().onRequestPermissionsResult(permissions, grantResults, new boolean[permissions.length]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;

import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -38,7 +39,7 @@ void requestPermissions(@NonNull String[] permissions) {
}

@TargetApi(Build.VERSION_CODES.M)
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);

if (requestCode != PERMISSIONS_REQUEST_CODE) return;
Expand All @@ -52,7 +53,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String permissi
onRequestPermissionsResult(permissions, grantResults, shouldShowRequestPermissionRationale);
}

void onRequestPermissionsResult(String permissions[], int[] grantResults, boolean[] shouldShowRequestPermissionRationale) {
void onRequestPermissionsResult(String[] permissions, int[] grantResults, boolean[] shouldShowRequestPermissionRationale) {
for (int i = 0, size = permissions.length; i < size; i++) {
log("onRequestPermissionsResult " + permissions[i]);
// Find the corresponding subject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.v4.app.FragmentActivity;

import androidx.fragment.app.FragmentActivity;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Matchers;
import org.mockito.ArgumentMatchers;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.android.controller.ActivityController;
Expand All @@ -48,7 +49,7 @@
import static org.mockito.Mockito.when;

@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.M)
@Config(sdk = Build.VERSION_CODES.M)
public class RxPermissionsTest {

private FragmentActivity mActivity;
Expand Down Expand Up @@ -273,7 +274,7 @@ public void eachSubscriptionCombined_revoked() {
public void subscription_severalPermissions_granted() {
TestObserver<Boolean> sub = new TestObserver<>();
String[] permissions = new String[]{Manifest.permission.READ_PHONE_STATE, Manifest.permission.CAMERA};
when(mRxPermissions.isGranted(Matchers.<String>anyVararg())).thenReturn(false);
when(mRxPermissions.isGranted(ArgumentMatchers.anyString())).thenReturn(false);
int[] result = new int[]{PackageManager.PERMISSION_GRANTED, PackageManager.PERMISSION_GRANTED};

trigger().compose(mRxPermissions.ensure(permissions)).subscribe(sub);
Expand All @@ -289,7 +290,7 @@ public void subscription_severalPermissions_granted() {
public void eachSubscription_severalPermissions_granted() {
TestObserver<Permission> sub = new TestObserver<>();
String[] permissions = new String[]{Manifest.permission.READ_PHONE_STATE, Manifest.permission.CAMERA};
when(mRxPermissions.isGranted(Matchers.<String>anyVararg())).thenReturn(false);
when(mRxPermissions.isGranted(ArgumentMatchers.anyString())).thenReturn(false);
int[] result = new int[]{PackageManager.PERMISSION_GRANTED, PackageManager.PERMISSION_GRANTED};

trigger().compose(mRxPermissions.ensureEach(permissions)).subscribe(sub);
Expand All @@ -305,7 +306,7 @@ public void eachSubscription_severalPermissions_granted() {
public void eachSubscriptionCombined_severalPermissions_granted() {
TestObserver<Permission> sub = new TestObserver<>();
String[] permissions = new String[]{Manifest.permission.READ_PHONE_STATE, Manifest.permission.CAMERA};
when(mRxPermissions.isGranted(Matchers.<String>anyVararg())).thenReturn(false);
when(mRxPermissions.isGranted(ArgumentMatchers.anyString())).thenReturn(false);
int[] result = new int[]{PackageManager.PERMISSION_GRANTED, PackageManager.PERMISSION_GRANTED};

trigger().compose(mRxPermissions.ensureEachCombined(permissions)).subscribe(sub);
Expand All @@ -321,7 +322,7 @@ public void eachSubscriptionCombined_severalPermissions_granted() {
public void subscription_severalPermissions_oneDenied() {
TestObserver<Boolean> sub = new TestObserver<>();
String[] permissions = new String[]{Manifest.permission.READ_PHONE_STATE, Manifest.permission.CAMERA};
when(mRxPermissions.isGranted(Matchers.<String>anyVararg())).thenReturn(false);
when(mRxPermissions.isGranted(ArgumentMatchers.anyString())).thenReturn(false);
int[] result = new int[]{PackageManager.PERMISSION_GRANTED, PackageManager.PERMISSION_DENIED};

trigger().compose(mRxPermissions.ensure(permissions)).subscribe(sub);
Expand All @@ -337,7 +338,7 @@ public void subscription_severalPermissions_oneDenied() {
public void subscription_severalPermissions_oneRevoked() {
TestObserver<Boolean> sub = new TestObserver<>();
String[] permissions = new String[]{Manifest.permission.READ_PHONE_STATE, Manifest.permission.CAMERA};
when(mRxPermissions.isGranted(Matchers.<String>anyVararg())).thenReturn(false);
when(mRxPermissions.isGranted(ArgumentMatchers.anyString())).thenReturn(false);
when(mRxPermissions.isRevoked(Manifest.permission.CAMERA)).thenReturn(true);

trigger().compose(mRxPermissions.ensure(permissions)).subscribe(sub);
Expand All @@ -355,7 +356,7 @@ public void subscription_severalPermissions_oneRevoked() {
public void eachSubscription_severalPermissions_oneAlreadyGranted() {
TestObserver<Permission> sub = new TestObserver<>();
String[] permissions = new String[]{Manifest.permission.READ_PHONE_STATE, Manifest.permission.CAMERA};
when(mRxPermissions.isGranted(Matchers.<String>anyVararg())).thenReturn(false);
when(mRxPermissions.isGranted(ArgumentMatchers.anyString())).thenReturn(false);
when(mRxPermissions.isGranted(Manifest.permission.CAMERA)).thenReturn(true);

trigger().compose(mRxPermissions.ensureEach(permissions)).subscribe(sub);
Expand All @@ -377,7 +378,7 @@ public void eachSubscription_severalPermissions_oneAlreadyGranted() {
public void eachSubscriptionCombined_severalPermissions_oneAlreadyGranted() {
TestObserver<Permission> sub = new TestObserver<>();
String[] permissions = new String[]{Manifest.permission.READ_PHONE_STATE, Manifest.permission.CAMERA};
when(mRxPermissions.isGranted(Matchers.<String>anyVararg())).thenReturn(false);
when(mRxPermissions.isGranted(ArgumentMatchers.anyString())).thenReturn(false);
when(mRxPermissions.isGranted(Manifest.permission.CAMERA)).thenReturn(true);

trigger().compose(mRxPermissions.ensureEachCombined(permissions)).subscribe(sub);
Expand All @@ -399,7 +400,7 @@ public void eachSubscriptionCombined_severalPermissions_oneAlreadyGranted() {
public void eachSubscription_severalPermissions_oneDenied() {
TestObserver<Permission> sub = new TestObserver<>();
String[] permissions = new String[]{Manifest.permission.READ_PHONE_STATE, Manifest.permission.CAMERA};
when(mRxPermissions.isGranted(Matchers.<String>anyVararg())).thenReturn(false);
when(mRxPermissions.isGranted(ArgumentMatchers.anyString())).thenReturn(false);
int[] result = new int[]{PackageManager.PERMISSION_GRANTED, PackageManager.PERMISSION_DENIED};

trigger().compose(mRxPermissions.ensureEach(permissions)).subscribe(sub);
Expand All @@ -415,7 +416,7 @@ public void eachSubscription_severalPermissions_oneDenied() {
public void eachSubscriptionCombined_severalPermissions_oneDenied() {
TestObserver<Permission> sub = new TestObserver<>();
String[] permissions = new String[]{Manifest.permission.READ_PHONE_STATE, Manifest.permission.CAMERA};
when(mRxPermissions.isGranted(Matchers.<String>anyVararg())).thenReturn(false);
when(mRxPermissions.isGranted(ArgumentMatchers.anyString())).thenReturn(false);
int[] result = new int[]{PackageManager.PERMISSION_GRANTED, PackageManager.PERMISSION_DENIED};

trigger().compose(mRxPermissions.ensureEachCombined(permissions)).subscribe(sub);
Expand All @@ -431,7 +432,7 @@ public void eachSubscriptionCombined_severalPermissions_oneDenied() {
public void eachSubscription_severalPermissions_oneRevoked() {
TestObserver<Permission> sub = new TestObserver<>();
String[] permissions = new String[]{Manifest.permission.READ_PHONE_STATE, Manifest.permission.CAMERA};
when(mRxPermissions.isGranted(Matchers.<String>anyVararg())).thenReturn(false);
when(mRxPermissions.isGranted(ArgumentMatchers.anyString())).thenReturn(false);
when(mRxPermissions.isRevoked(Manifest.permission.CAMERA)).thenReturn(true);

trigger().compose(mRxPermissions.ensureEach(permissions)).subscribe(sub);
Expand All @@ -449,7 +450,7 @@ public void eachSubscription_severalPermissions_oneRevoked() {
public void eachSubscriptionCombined_severalPermissions_oneRevoked() {
TestObserver<Permission> sub = new TestObserver<>();
String[] permissions = new String[]{Manifest.permission.READ_PHONE_STATE, Manifest.permission.CAMERA};
when(mRxPermissions.isGranted(Matchers.<String>anyVararg())).thenReturn(false);
when(mRxPermissions.isGranted(ArgumentMatchers.anyString())).thenReturn(false);
when(mRxPermissions.isRevoked(Manifest.permission.CAMERA)).thenReturn(true);

trigger().compose(mRxPermissions.ensureEachCombined(permissions)).subscribe(sub);
Expand Down
6 changes: 3 additions & 3 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ android {
dependencies {
implementation project(':rxpermissions')

implementation rootProject.ext.appCompat
implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.1'
implementation 'com.jakewharton.rxbinding2:rxbinding:2.2.0'
implementation rootProject.ext.androidXAppcompat

testImplementation rootProject.ext.junit
testImplementation 'junit:junit:4.13'
testImplementation rootProject.ext.mockito
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import android.Manifest.permission;
import android.hardware.Camera;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.SurfaceView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.jakewharton.rxbinding2.view.RxView;
import com.tbruyelle.rxpermissions2.Permission;
import com.tbruyelle.rxpermissions2.RxPermissions;
Expand Down