Initial commit for Google Services plugin

A developer service is a collection of code, resources, and
dependencies. When installed, it will copy all relevant values into
a user's project, making it easy for users to start developing with
those APIs.

This plugin will house Google-specific developer services, such as
analytics, ads, maps, etc. For now, this CL includes basic core
classes which all future services will build upon.

Change-Id: I45072d6657faf187ec02b8d4496d9f98737835ee
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3acb573
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+out/
+.DS_Store
diff --git a/google-services.iml b/google-services.iml
new file mode 100644
index 0000000..5b7575c
--- /dev/null
+++ b/google-services.iml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$APPLICATION_HOME_DIR$/lib/annotations.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="library" name="Guava" level="project" />
+    <orderEntry type="module" module-name="android" />
+    <orderEntry type="module" module-name="google-login" />
+    <orderEntry type="module" module-name="extensions" />
+    <orderEntry type="module" module-name="core-api" />
+    <orderEntry type="module" module-name="annotations" />
+    <orderEntry type="library" scope="TEST" name="JUnit4" level="project" />
+    <orderEntry type="library" scope="TEST" name="fest" level="project" />
+  </component>
+</module>
\ No newline at end of file
diff --git a/src/META-INF/plugin.xml b/src/META-INF/plugin.xml
new file mode 100644
index 0000000..1a31613
--- /dev/null
+++ b/src/META-INF/plugin.xml
@@ -0,0 +1,56 @@
+<!--
+  ~ Copyright (C) 2015 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<idea-plugin version="2">
+  <id>com.gooogle.services</id>
+  <name>Google Services</name>
+  <version>0.1</version>
+  <vendor>Google</vendor>
+
+  <description>
+    A collection of Google services which can be integrated into your Android app.
+  </description>
+
+  <change-notes>
+      Initial submission, containing Ads, Analytics, and Maps.
+  </change-notes>
+
+  <!-- please see https://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description -->
+  <idea-version since-build="107.105"/>
+
+  <depends>org.jetbrains.android</depends>
+  <depends>com.google.gct.login</depends>
+
+  <extensions defaultExtensionNs="com.android.tools.idea.structure.services">
+    <developerServiceCreators implementation="com.google.services.GoogleServiceCreators"/>
+  </extensions>
+
+  <extensions defaultExtensionNs="com.google.gct.login">
+    <googleLoginListener implementation="com.google.services.GoogleServiceLoginListener"/>
+  </extensions>
+
+  <application-components>
+    <!-- Add your application components here -->
+  </application-components>
+
+  <project-components>
+    <!-- Add your project components here -->
+  </project-components>
+
+  <actions>
+    <!-- Add your actions here -->
+  </actions>
+
+</idea-plugin>
\ No newline at end of file
diff --git a/src/com/google/services/GoogleServiceCreators.java b/src/com/google/services/GoogleServiceCreators.java
new file mode 100644
index 0000000..864b80d
--- /dev/null
+++ b/src/com/google/services/GoogleServiceCreators.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.services;
+
+import com.android.tools.idea.structure.services.DeveloperServiceCreator;
+import com.android.tools.idea.structure.services.DeveloperServiceCreators;
+import com.google.common.collect.ImmutableSet;
+
+import java.util.Collection;
+
+/**
+ * Extension for Android Studio which provides helpers that initialize Google developer services.
+ */
+public final class GoogleServiceCreators implements DeveloperServiceCreators {
+  @Override
+  public Collection<? extends DeveloperServiceCreator> getCreators() {
+    return ImmutableSet.of();
+  }
+}
diff --git a/src/com/google/services/GoogleServiceLoginListener.java b/src/com/google/services/GoogleServiceLoginListener.java
new file mode 100644
index 0000000..f2e4d9c
--- /dev/null
+++ b/src/com/google/services/GoogleServiceLoginListener.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.services;
+
+import com.android.tools.idea.ui.properties.core.BoolValueProperty;
+import com.google.gct.login.GoogleLogin;
+import com.google.gct.login.GoogleLoginListener;
+import com.intellij.openapi.extensions.Extensions;
+
+/**
+ * Listener which is notified when the user logs in or out of Google, exposed to classes in this
+ * plugin through the {@link #isLoggedIn()} property.
+ */
+public final class GoogleServiceLoginListener implements GoogleLoginListener {
+  public static GoogleServiceLoginListener getInstance() {
+    return Extensions.findExtension(GoogleLoginListener.EP_NAME, GoogleServiceLoginListener.class);
+  }
+
+  private final BoolValueProperty isLoggedIn = new BoolValueProperty();
+
+  public BoolValueProperty isLoggedIn() {
+    return isLoggedIn;
+  }
+
+  @Override
+  public void statusChanged() {
+    isLoggedIn.set(GoogleLogin.getInstance().isLoggedIn());
+  }
+}