Skip to content

Commit 37194cb

Browse files
author
Caitlin Hurley
committed
Update Drive sample app
-Use new Auth APIs -Update library version numbers -Switch to maven {} instead of mavenLocal() Change-Id: I65f97bd9215b9b4c0859fbf42d4375ff11bafc78
1 parent c9bdb8f commit 37194cb

File tree

4 files changed

+14
-23
lines changed

4 files changed

+14
-23
lines changed

app/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
22

33
android {
44
compileSdkVersion 26
5-
buildToolsVersion "26.0.1"
5+
buildToolsVersion "26.0.2"
66

77
defaultConfig {
88
applicationId "com.google.android.gms.drive.sample.conflict"
@@ -20,7 +20,7 @@ android {
2020
}
2121

2222
dependencies {
23-
compile 'com.android.support:support-v4:26.0.2'
24-
compile 'com.google.android.gms:play-services-auth:11.8.0-SNAPSHOT'
25-
compile 'com.google.android.gms:play-services-drive:11.8.0-SNAPSHOT'
23+
compile 'com.android.support:support-v4:26.1.0'
24+
compile 'com.google.android.gms:play-services-auth:11.6.0'
25+
compile 'com.google.android.gms:play-services-drive:11.6.0'
2626
}

app/src/main/java/com/google/android/gms/drive/sample/conflict/BaseDemoActivity.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ protected void onStart() {
6060
* Handles resolution callbacks.
6161
*/
6262
@Override
63-
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
63+
public void onActivityResult(int requestCode, int resultCode, Intent data) {
6464
super.onActivityResult(requestCode, resultCode, data);
6565
if (requestCode == REQUEST_CODE_SIGN_IN) {
6666
if (resultCode != RESULT_OK) {
@@ -71,14 +71,8 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
7171
return;
7272
}
7373

74-
Task<GoogleSignInAccount> getAccountTask =
75-
GoogleSignInClient.getGoogleSignInAccountFromIntent(data);
76-
if (getAccountTask.isSuccessful()) {
77-
initializeDriveClient(getAccountTask.getResult());
78-
} else {
79-
Log.e(TAG, "Sign-in failed.");
80-
finish();
81-
}
74+
// We can use last signed in account here because we know the account has Drive scopes
75+
initializeDriveClient(GoogleSignIn.getLastSignedInAccount(this));
8276
}
8377
}
8478

@@ -92,12 +86,7 @@ protected void signIn() {
9286
.requestScopes(Drive.SCOPE_APPFOLDER)
9387
.build();
9488
GoogleSignInClient googleSignInClient = GoogleSignIn.getClient(this, signInOptions);
95-
GoogleSignInAccount signInAccount = googleSignInClient.getLastSignedInAccount();
96-
if (signInAccount != null) {
97-
initializeDriveClient(signInAccount);
98-
} else {
99-
startActivityForResult(googleSignInClient.getSignInIntent(), REQUEST_CODE_SIGN_IN);
100-
}
89+
startActivityForResult(googleSignInClient.getSignInIntent(), REQUEST_CODE_SIGN_IN);
10190
}
10291

10392
/**

build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
buildscript {
44
repositories {
55
jcenter()
6+
maven {
7+
url "https://maven.google.com"
8+
}
69
}
710
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.3.3'
11+
classpath 'com.android.tools.build:gradle:3.0.0'
912

1013
// NOTE: Do not place your application dependencies here; they belong
1114
// in the individual module build.gradle files
@@ -18,6 +21,5 @@ allprojects {
1821
maven {
1922
url "https://maven.google.com"
2023
}
21-
mavenLocal()
2224
}
2325
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon Aug 21 15:48:43 MDT 2017
1+
#Tue Oct 31 12:50:02 MDT 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

0 commit comments

Comments
 (0)