Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

483/Remove PlusClient dependencies #589

Merged
merged 13 commits into from
Mar 18, 2016
Merged
4 changes: 0 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ android {
buildConfigField "String", "IP_SIMPLE_API_ACCESS_KEY", "\"$local_properties.ip_simple_api_access_key_debug\""
buildConfigField "String", "ANDROID_SIMPLE_API_ACCESS_KEY", "\"$local_properties.android_simple_api_access_key_debug\""
resValue "string", "android_simple_api_access_key", local_properties.android_simple_api_access_key_debug ?: ""

multiDexEnabled true
}
}

Expand Down Expand Up @@ -136,7 +134,6 @@ dependencies {
compile "com.android.support:design:$rootProject.supportLibraryVersion"
compile "com.android.support:customtabs:$rootProject.supportLibraryVersion"
compile "com.android.support.test.espresso:espresso-idling-resource:$rootProject.espressoVersion"
debugCompile 'com.android.support:multidex:1.0.1'

//Play Services
compile "com.google.android.gms:play-services-games:$rootProject.playServicesVersion"
Expand All @@ -148,7 +145,6 @@ dependencies {

//Google
compile 'com.google.http-client:google-http-client-gson:1.21.0'
compile 'com.google.apis:google-api-services-plus:v1-rev126-1.18.0-rc'
compile 'com.google.android.apps.dashclock:dashclock-api:2.0.0'
compile 'com.google.zxing:android-integration:3.2.1'
compile 'com.google.zxing:core:3.2.1'
Expand Down
12 changes: 2 additions & 10 deletions app/src/debug/java/org/gdg/frisbee/android/app/BaseApp.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
package org.gdg.frisbee.android.app;

import android.content.Context;
import android.support.multidex.MultiDex;
import android.support.multidex.MultiDexApplication;
import android.app.Application;

public class BaseApp extends MultiDexApplication {

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
public class BaseApp extends Application {

protected void onAppUpdate(int oldVersion, int newVersion) {
}
Expand Down
101 changes: 0 additions & 101 deletions app/src/main/java/org/gdg/frisbee/android/api/GapiOkHttpRequest.java

This file was deleted.

118 changes: 0 additions & 118 deletions app/src/main/java/org/gdg/frisbee/android/api/GapiOkResponse.java

This file was deleted.

75 changes: 0 additions & 75 deletions app/src/main/java/org/gdg/frisbee/android/api/GapiOkTransport.java

This file was deleted.

17 changes: 16 additions & 1 deletion app/src/main/java/org/gdg/frisbee/android/api/PlusApi.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package org.gdg.frisbee.android.api;

import android.support.annotation.Nullable;

import org.gdg.frisbee.android.BuildConfig;
import org.gdg.frisbee.android.api.model.ImageInfo;
import org.gdg.frisbee.android.api.model.plus.Activities;
import org.gdg.frisbee.android.api.model.plus.ImageInfo;
import org.gdg.frisbee.android.api.model.plus.Person;

import retrofit2.Call;
import retrofit2.http.GET;
Expand All @@ -10,4 +14,15 @@
public interface PlusApi {
@GET("people/{gplusId}?fields=image&key=" + BuildConfig.IP_SIMPLE_API_ACCESS_KEY)
Call<ImageInfo> getImageInfo(@Path("gplusId") String gplusId);

@GET("people/{gplusId}?fields=image,aboutMe,tagline,urls,url,cover,displayName&key="
+ BuildConfig.IP_SIMPLE_API_ACCESS_KEY)
@Nullable Person getPerson(@Path("gplusId") String gplusId);

@GET("people/{gplusId}/activities/public?fields="
+ "nextPageToken,"
+ "items(id,published,url,object/content,verb,"
+ "object/attachments,annotation,object(plusoners,replies,resharers))"
+ "&key=" + BuildConfig.IP_SIMPLE_API_ACCESS_KEY)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using key here (instead of in an interceptor) makes it more explicit where the authentication takes place. I prefer this solution of a

public class ApiKeyAdder implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        Request original = chain.request();

        HttpUrl newUrl = original.url().newBuilder()
            .addQueryParameter("key", BuildConfig.IP_SIMPLE_API_ACCESS_KEY).build();
        Request.Builder requestBuilder = original.newBuilder().url(newUrl);

        Request request = requestBuilder.build();
        return chain.proceed(request);
    }
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this interceptor. API keys and Auth related things usually done in interceptor anyways. That's what Square does

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is added now.

@Nullable Activities getActivities(@Path("gplusId") String gplusId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ private static Retrofit provideRestAdapter() {
return new Retrofit.Builder()
.baseUrl(API_URL)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(SynchronousCallAdapterFactory.create())
.client(OkClientFactory.okHttpClientWithIdlingResources(App.getInstance().getOkHttpClient()))
.build();
}
Expand Down
Loading