Adds SHA1 key to Maps template, templateMergeStrategy attribute

Uses this to overwrite the instructions in the Google Maps template.
Subsequent runs of the template always update the instructions with
the user's current keystore credentials.

Also changed the Maps instructions to deep link into a Google
developer console flow, which allows for easier key generation.

Change-Id: I770465b3d628ffce2ef09456ae78afd694b73683
diff --git a/templates/activities/GoogleMapsActivity/recipe.xml.ftl b/templates/activities/GoogleMapsActivity/recipe.xml.ftl
index 2f84073..f1694a6 100644
--- a/templates/activities/GoogleMapsActivity/recipe.xml.ftl
+++ b/templates/activities/GoogleMapsActivity/recipe.xml.ftl
@@ -15,10 +15,10 @@
     <instantiate from="src/app_package/MapActivity.java.ftl"
                    to="${escapeXmlAttribute(srcOut)}/${activityClass}.java" />
 
-    <merge from="res/values/google_maps_api.xml.ftl"
+    <merge from="debugRes/values/google_maps_api.xml.ftl"
              to="${escapeXmlAttribute(debugResOut)}/values/google_maps_api.xml" />
 
-    <merge from="res/values/google_maps_api.xml.ftl"
+    <merge from="releaseRes/values/google_maps_api.xml.ftl"
              to="${escapeXmlAttribute(releaseResOut)}/values/google_maps_api.xml" />
 
     <open file="${escapeXmlAttribute(srcOut)}/${activityClass}.java" />
diff --git a/templates/activities/GoogleMapsActivity/root/debugRes/values/google_maps_api.xml.ftl b/templates/activities/GoogleMapsActivity/root/debugRes/values/google_maps_api.xml.ftl
new file mode 100644
index 0000000..0c8c501
--- /dev/null
+++ b/templates/activities/GoogleMapsActivity/root/debugRes/values/google_maps_api.xml.ftl
@@ -0,0 +1,22 @@
+<resources>
+    <#--
+    NOTE: the merger does not merge comments (only NodeType == ELEMENT_NODE).
+    Wrap it in an element as a workaround. -->
+    <string name="google_maps_key_instructions" templateMergeStrategy="replace"><!--
+
+    TODO: Before you run your application, you need a Google Maps API key.
+
+    To get one, follow this link, follow the directions and press "Create" at the end:
+
+https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=${debugKeystoreSha1}%3B${packageName}
+
+    You can also add your credentials to an existing key, using this line:
+    ${debugKeystoreSha1};${packageName}
+
+    Once you have your key (it starts with "AIza"), replace the "google_maps_key"
+    string in this file.
+    --></string>
+
+    <#-- Always preserve the existing key. -->
+    <string name="google_maps_key" templateMergeStrategy="preserve">YOUR_KEY_HERE</string>
+</resources>
diff --git a/templates/activities/GoogleMapsActivity/root/releaseRes/values/google_maps_api.xml.ftl b/templates/activities/GoogleMapsActivity/root/releaseRes/values/google_maps_api.xml.ftl
new file mode 100644
index 0000000..206463b
--- /dev/null
+++ b/templates/activities/GoogleMapsActivity/root/releaseRes/values/google_maps_api.xml.ftl
@@ -0,0 +1,22 @@
+<resources>
+    <#--
+    NOTE: the merger does not merge comments (only NodeType == ELEMENT_NODE).
+    Wrap it in an element as a workaround. -->
+    <string name="google_maps_key_instructions" templateMergeStrategy="replace"><!--
+
+    TODO: Before you release your application, you need a Google Maps API key.
+
+    To do this, you can either add your release key credentials to your existing
+    key, or create a new key.
+
+    Follow the directions here:
+
+https://developers.google.com/maps/documentation/android/start#get_an_android_certificate_and_the_google_maps_api_key
+
+    Once you have your key (it starts with "AIza"), replace the "google_maps_key"
+    string in this file.
+    --></string>
+
+    <#-- Always preserve the existing key. -->
+    <string name="google_maps_key" templateMergeStrategy="preserve">YOUR_KEY_HERE</string>
+</resources>
diff --git a/templates/activities/GoogleMapsActivity/root/res/values/google_maps_api.xml.ftl b/templates/activities/GoogleMapsActivity/root/res/values/google_maps_api.xml.ftl
deleted file mode 100644
index f403b49..0000000
--- a/templates/activities/GoogleMapsActivity/root/res/values/google_maps_api.xml.ftl
+++ /dev/null
@@ -1,18 +0,0 @@
-<resources>
-    <#--
-    NOTE: the resource file merger does not merge comments.
-    Wrap it in an element as a workaround. -->
-    <string name="google_maps_key_instructions"><!--
-
-    TODO: Before you run your application, you need a Google Maps API key.
-
-    Follow the steps in the documentation.
-    https://developers.google.com/maps/documentation/android/start
-
-    A key looks something like "AIzaSyAhpLN7hAwBfFGjKcSe75MMjYWU7rvLwNw".
-
-    Once you have your key, replace the "google_maps_key" string in this file.
-    --></string>
-    <string name="google_maps_key">YOUR_KEY_HERE</string>
-</resources>
-