Skip to content

Commit

Permalink
Android 10+ Support (npomfret#6)
Browse files Browse the repository at this point in the history
* Fix Android 10+ support

* Clean up

* Update build.gradle

* Update package.json
  • Loading branch information
brunobar79 authored Oct 5, 2020
1 parent f80180e commit cc7436a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ allprojects {
}

dependencies {
provided 'com.google.android.gms:play-services-drive:+'
implementation ('com.google.android.gms:play-services-auth:18.1.0') {
provided 'com.google.android.gms:play-services-drive:17.0.0'
implementation ('com.google.android.gms:play-services-auth:17.0.0') {
force = true;
}
implementation 'com.google.http-client:google-http-client-gson:1.26.0'
Expand Down
15 changes: 12 additions & 3 deletions android/src/main/java/org/rncloudfs/RNCloudFsModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.android.gms.tasks.Tasks;
import com.google.api.client.extensions.android.http.AndroidHttp;
import com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential;
import com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.drive.Drive;
import com.google.api.services.drive.DriveScopes;
Expand All @@ -49,6 +50,7 @@ public class RNCloudFsModule extends ReactContextBaseJavaModule implements Googl
public static final String TAG = "RNCloudFs";
private static final int REQUEST_CODE_SIGN_IN = 1;
private static final int REQUEST_CODE_OPEN_DOCUMENT = 2;
private static final int REQUEST_AUTHORIZATION = 11;
private DriveServiceHelper mDriveServiceHelper;

private Promise signInPromise;
Expand All @@ -59,7 +61,6 @@ public RNCloudFsModule(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;


reactContext.addLifecycleEventListener(this);
reactContext.addActivityEventListener(this);
}
Expand Down Expand Up @@ -144,7 +145,15 @@ public void listFiles(ReadableMap options, final Promise promise) {
result.putArray("files", files);
promise.resolve(result);
})
.addOnFailureListener(exception -> Log.e(TAG, "Unable to query files.", exception));
.addOnFailureListener(exception -> {
Log.e(TAG, "Unable to query files: " + exception.getCause().getMessage());
try{
UserRecoverableAuthIOException e = (UserRecoverableAuthIOException)exception;
this.reactContext.startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION, null);
} catch(Exception e){
throw e;
}
});
}
}

Expand Down Expand Up @@ -292,7 +301,7 @@ public void logout(Promise promise) {

/**
* Handles the {@code result} of a completed sign-in activity initiated from {@link
* #requestSignIn()}.
* #requestSignIn()} ()}.
*/
private void handleSignInResult(Intent result) {
GoogleSignIn.getSignedInAccountFromIntent(result)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-cloud-fs",
"version": "2.0.0",
"version": "2.1.0",
"description": "",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit cc7436a

Please sign in to comment.