API key substitution

pull/25/head
Alex Baker 11 years ago
parent 8084a4b372
commit b3a6fdb3c3

@ -46,6 +46,17 @@ android {
}
}
android.applicationVariants.all { variant ->
variant.mergeResources.doLast {
if (project.hasProperty('gapiKey')) {
File values = file("${buildDir}/res/all/${variant.dirName}/values/values.xml")
values.write(
values.getText('UTF-8').replaceAll(/<string name="gapi_key">.*<\/string>/, "<string name=\"gapi_key\">${project.property('gapiKey')}</string>"),
'UTF-8')
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile project(":android-aac-enc")

@ -1,7 +1,5 @@
package com.todoroo.astrid.gtasks.api;
import java.io.IOException;
import android.content.Context;
import com.google.api.client.extensions.android2.AndroidHttp;
@ -17,13 +15,16 @@ import com.google.api.services.tasks.Tasks.TasksOperations.Move;
import com.google.api.services.tasks.model.Task;
import com.google.api.services.tasks.model.TaskList;
import com.google.api.services.tasks.model.TaskLists;
import org.tasks.R;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.astrid.gtasks.auth.GtasksTokenValidator;
import org.tasks.R;
import java.io.IOException;
/**
* Wrapper around the official Google Tasks API to simplify common operations. In the case
* of an exception, each request is tried twice in case of a timeout.
@ -38,8 +39,6 @@ public class GtasksInvoker {
@Autowired ExceptionService exceptionService;
private static final String API_KEY = "AIzaSyBXGYNWNQcfse4JS5gI9teTSKMzinWzL2M"; // non-production API key
public static final String AUTH_TOKEN_TYPE = "Manage your tasks"; //"oauth2:https://www.googleapis.com/auth/tasks";
public GtasksInvoker(String authToken) {
@ -52,9 +51,11 @@ public class GtasksInvoker {
accessProtectedResource = new GoogleAccessProtectedResource(authToken);
jsonFactory = new GsonFactory();
Context context = ContextManager.getContext();
String key = context.getString(R.string.gapi_key);
service = new Tasks(AndroidHttp.newCompatibleTransport(), accessProtectedResource, jsonFactory);
service.setKey(API_KEY);
service.setApplicationName("Astrid");
service.setKey(key);
service.setApplicationName("Tasks");
}
//If we get a 401 or 403, try revalidating the auth token before bailing

@ -4,9 +4,9 @@
These should not be translated
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="fb_app_id">183862944961271</string>
<string name="gapi_key">AIzaSyBXGYNWNQcfse4JS5gI9teTSKMzinWzL2M</string>
<!-- ======================================================== REMINDERS == -->
<!-- whether reminders should appear at all -->

Loading…
Cancel
Save