Introduce Stocks.apk

This CL renames SkyShell.apk to SkyDemo.apk and adds a Stocks.apk which
defaults to the stocks demo app. Sky Shell is now a library that can be
packaged by different APKs.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/965493002
diff --git a/sky/BUILD.gn b/sky/BUILD.gn
index 8ec5827..780daf9 100644
--- a/sky/BUILD.gn
+++ b/sky/BUILD.gn
@@ -20,7 +20,10 @@
   ]
 
   if (is_android) {
-    deps += [ "//sky/shell" ]
+    deps += [
+      "//sky/apk/demo",
+      "//sky/apk/stocks",
+    ]
   }
 
   if (!is_android) {
diff --git a/sky/shell/apk/AndroidManifest.xml b/sky/apk/demo/AndroidManifest.xml
similarity index 86%
rename from sky/shell/apk/AndroidManifest.xml
rename to sky/apk/demo/AndroidManifest.xml
index 1d9b12d..6eccbb0 100644
--- a/sky/shell/apk/AndroidManifest.xml
+++ b/sky/apk/demo/AndroidManifest.xml
@@ -4,13 +4,13 @@
      found in the LICENSE file.
  -->
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="org.domokit.sky.shell">
+    package="org.domokit.sky.demo">
 
     <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
     <uses-permission android:name="android.permission.INTERNET"/>
 
-    <application android:name="SkyShellApplication" android:label="Sky">
-        <activity android:name="SkyShellActivity"
+    <application android:name="org.domokit.sky.shell.SkyApplication" android:label="Sky">
+        <activity android:name="SkyDemoActivity"
                   android:launchMode="singleTask"
                   android:theme="@android:style/Theme.Holo.Light.NoActionBar"
                   android:configChanges="orientation|keyboardHidden|keyboard|screenSize"
diff --git a/sky/apk/demo/BUILD.gn b/sky/apk/demo/BUILD.gn
new file mode 100644
index 0000000..afd5006
--- /dev/null
+++ b/sky/apk/demo/BUILD.gn
@@ -0,0 +1,25 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+assert(is_android)
+
+import("//build/config/android/config.gni")
+import("//build/config/android/rules.gni")
+import("//sky/apk/rules.gni")
+
+android_library("java") {
+  java_files = [ "org/domokit/sky/demo/SkyDemoActivity.java" ]
+
+  deps = [
+    "//sky/shell:java",
+  ]
+}
+
+sky_apk("demo") {
+  apk_name = "SkyDemo"
+  android_manifest = "AndroidManifest.xml"
+  deps = [
+    ":java",
+  ]
+}
diff --git a/sky/shell/apk/src/org/domokit/sky/shell/SkyShellActivity.java b/sky/apk/demo/org/domokit/sky/demo/SkyDemoActivity.java
similarity index 71%
rename from sky/shell/apk/src/org/domokit/sky/shell/SkyShellActivity.java
rename to sky/apk/demo/org/domokit/sky/demo/SkyDemoActivity.java
index e15982a..7d9021c 100644
--- a/sky/shell/apk/src/org/domokit/sky/shell/SkyShellActivity.java
+++ b/sky/apk/demo/org/domokit/sky/demo/SkyDemoActivity.java
@@ -2,17 +2,18 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-package org.domokit.sky.shell;
+package org.domokit.sky.demo;
 
-import android.app.Activity;
 import android.content.Intent;
 import android.net.Uri;
 import android.os.Bundle;
 
+import org.domokit.sky.shell.SkyActivity;
+
 /**
- * Main activity for SkyShell.
+ * Main activity for SkyDemo.
  */
-public class SkyShellActivity extends Activity {
+public class SkyDemoActivity extends SkyActivity {
     /**
      * @see android.app.Activity#onCreate(android.os.Bundle)
      */
@@ -28,9 +29,6 @@
             url = httpsUri.toString();
         }
 
-        SkyMain.ensureInitialized(getApplicationContext());
-        PlatformView view = new PlatformView(this);
-        setContentView(view);
-        view.loadUrl(url);
+        loadUrl(url);
     }
 }
diff --git a/sky/apk/rules.gni b/sky/apk/rules.gni
new file mode 100644
index 0000000..43eb5b2
--- /dev/null
+++ b/sky/apk/rules.gni
@@ -0,0 +1,23 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/android/config.gni")
+import("//build/config/android/rules.gni")
+
+template("sky_apk") {
+  android_apk(target_name) {
+    apk_name = invoker.apk_name
+    android_manifest = invoker.android_manifest
+
+    native_libs = [ "libsky_shell.so" ]
+    asset_location = "$root_build_dir/sky_shell/assets"
+
+    deps = [
+             "//base:base_java",
+             "//sky/shell:assets",
+             "//sky/shell:java",
+             "//sky/shell:sky_shell",
+           ] + invoker.deps
+  }
+}
diff --git a/sky/shell/apk/AndroidManifest.xml b/sky/apk/stocks/AndroidManifest.xml
similarity index 69%
copy from sky/shell/apk/AndroidManifest.xml
copy to sky/apk/stocks/AndroidManifest.xml
index 1d9b12d..52b3ccd 100644
--- a/sky/shell/apk/AndroidManifest.xml
+++ b/sky/apk/stocks/AndroidManifest.xml
@@ -4,13 +4,13 @@
      found in the LICENSE file.
  -->
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="org.domokit.sky.shell">
+    package="org.domokit.stocks">
 
     <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
     <uses-permission android:name="android.permission.INTERNET"/>
 
-    <application android:name="SkyShellApplication" android:label="Sky">
-        <activity android:name="SkyShellActivity"
+    <application android:name="org.domokit.sky.shell.SkyApplication" android:label="Stocks">
+        <activity android:name="StocksActivity"
                   android:launchMode="singleTask"
                   android:theme="@android:style/Theme.Holo.Light.NoActionBar"
                   android:configChanges="orientation|keyboardHidden|keyboard|screenSize"
@@ -19,11 +19,6 @@
                 <action android:name="android.intent.action.MAIN"/>
                 <category android:name="android.intent.category.LAUNCHER"/>
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.VIEW"/>
-                <category android:name="android.intent.category.DEFAULT" />
-                <data android:scheme="sky" />
-            </intent-filter>
         </activity>
     </application>
  </manifest>
diff --git a/sky/apk/stocks/BUILD.gn b/sky/apk/stocks/BUILD.gn
new file mode 100644
index 0000000..1f5fd25
--- /dev/null
+++ b/sky/apk/stocks/BUILD.gn
@@ -0,0 +1,25 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+assert(is_android)
+
+import("//build/config/android/config.gni")
+import("//build/config/android/rules.gni")
+import("//sky/apk/rules.gni")
+
+android_library("java") {
+  java_files = [ "org/domokit/stocks/StocksActivity.java" ]
+
+  deps = [
+    "//sky/shell:java",
+  ]
+}
+
+sky_apk("stocks") {
+  apk_name = "Stocks"
+  android_manifest = "AndroidManifest.xml"
+  deps = [
+    ":java",
+  ]
+}
diff --git a/sky/apk/stocks/org/domokit/stocks/StocksActivity.java b/sky/apk/stocks/org/domokit/stocks/StocksActivity.java
new file mode 100644
index 0000000..d167394
--- /dev/null
+++ b/sky/apk/stocks/org/domokit/stocks/StocksActivity.java
@@ -0,0 +1,23 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.domokit.stocks;
+
+import android.os.Bundle;
+
+import org.domokit.sky.shell.SkyActivity;
+
+/**
+ * Main activity for Stocks.
+ */
+public class StocksActivity extends SkyActivity {
+    /**
+     * @see android.app.Activity#onCreate(android.os.Bundle)
+     */
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        loadUrl("https://domokit.github.io/sky/examples/stocks/index.sky");
+    }
+}
diff --git a/sky/shell/BUILD.gn b/sky/shell/BUILD.gn
index ed252e4..cb52c78 100644
--- a/sky/shell/BUILD.gn
+++ b/sky/shell/BUILD.gn
@@ -7,17 +7,11 @@
 import("//build/config/android/config.gni")
 import("//build/config/android/rules.gni")
 
-group("shell") {
-  deps = [
-    ":sky_shell_apk",
-  ]
-}
-
 generate_jni("jni_headers") {
   sources = [
-    "apk/src/org/domokit/sky/shell/JavaServiceProvider.java",
-    "apk/src/org/domokit/sky/shell/SkyMain.java",
-    "apk/src/org/domokit/sky/shell/PlatformView.java",
+    "org/domokit/sky/shell/JavaServiceProvider.java",
+    "org/domokit/sky/shell/SkyMain.java",
+    "org/domokit/sky/shell/PlatformView.java",
   ]
   jni_package = "sky/shell"
 }
@@ -74,11 +68,11 @@
 
 android_library("java") {
   java_files = [
-    "apk/src/org/domokit/sky/shell/JavaServiceProvider.java",
-    "apk/src/org/domokit/sky/shell/PlatformView.java",
-    "apk/src/org/domokit/sky/shell/SkyMain.java",
-    "apk/src/org/domokit/sky/shell/SkyShellActivity.java",
-    "apk/src/org/domokit/sky/shell/SkyShellApplication.java",
+    "org/domokit/sky/shell/JavaServiceProvider.java",
+    "org/domokit/sky/shell/PlatformView.java",
+    "org/domokit/sky/shell/SkyMain.java",
+    "org/domokit/sky/shell/SkyActivity.java",
+    "org/domokit/sky/shell/SkyApplication.java",
   ]
 
   deps = [
@@ -93,16 +87,9 @@
   ]
 }
 
-sky_shell_assets_dir = "$root_build_dir/sky_shell/assets"
-
-android_resources("resources") {
-  resource_dirs = [ "apk/res" ]
-  custom_package = "org.domokit.sky.shell"
-}
-
 copy_ex("assets") {
   clear_dir = true
-  dest = sky_shell_assets_dir
+  dest = "$root_build_dir/sky_shell/assets"
   sources = [
     "$root_build_dir/icudtl.dat",
   ]
@@ -110,20 +97,3 @@
     "//third_party/icu",
   ]
 }
-
-android_apk("sky_shell_apk") {
-  apk_name = "SkyShell"
-
-  android_manifest = "apk/AndroidManifest.xml"
-  native_libs = [ "libsky_shell.so" ]
-
-  asset_location = sky_shell_assets_dir
-
-  deps = [
-    "//base:base_java",
-    ":assets",
-    ":java",
-    ":resources",
-    ":sky_shell",
-  ]
-}
diff --git a/sky/shell/apk/res/values/strings.xml b/sky/shell/apk/res/values/strings.xml
deleted file mode 100644
index ff69533..0000000
--- a/sky/shell/apk/res/values/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright 2015 The Chromium Authors. All rights reserved.
-     Use of this source code is governed by a BSD-style license that can be
-     found in the LICENSE file.
- -->
-<resources>
-</resources>
diff --git a/sky/shell/apk/src/org/domokit/sky/shell/JavaServiceProvider.java b/sky/shell/org/domokit/sky/shell/JavaServiceProvider.java
similarity index 100%
rename from sky/shell/apk/src/org/domokit/sky/shell/JavaServiceProvider.java
rename to sky/shell/org/domokit/sky/shell/JavaServiceProvider.java
diff --git a/sky/shell/apk/src/org/domokit/sky/shell/PlatformView.java b/sky/shell/org/domokit/sky/shell/PlatformView.java
similarity index 100%
rename from sky/shell/apk/src/org/domokit/sky/shell/PlatformView.java
rename to sky/shell/org/domokit/sky/shell/PlatformView.java
diff --git a/sky/shell/org/domokit/sky/shell/SkyActivity.java b/sky/shell/org/domokit/sky/shell/SkyActivity.java
new file mode 100644
index 0000000..b0eb9c0
--- /dev/null
+++ b/sky/shell/org/domokit/sky/shell/SkyActivity.java
@@ -0,0 +1,30 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.domokit.sky.shell;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+/**
+ * Base class for activities that use Sky.
+ */
+public class SkyActivity extends Activity {
+    private PlatformView mView;
+
+    /**
+     * @see android.app.Activity#onCreate(android.os.Bundle)
+     */
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        SkyMain.ensureInitialized(getApplicationContext());
+        mView = new PlatformView(this);
+        setContentView(mView);
+    }
+
+    public void loadUrl(String url) {
+        mView.loadUrl(url);
+    }
+}
diff --git a/sky/shell/apk/src/org/domokit/sky/shell/SkyShellApplication.java b/sky/shell/org/domokit/sky/shell/SkyApplication.java
similarity index 95%
rename from sky/shell/apk/src/org/domokit/sky/shell/SkyShellApplication.java
rename to sky/shell/org/domokit/sky/shell/SkyApplication.java
index d60ce5f..ba53c6d 100644
--- a/sky/shell/apk/src/org/domokit/sky/shell/SkyShellApplication.java
+++ b/sky/shell/org/domokit/sky/shell/SkyApplication.java
@@ -17,7 +17,7 @@
  * MojoShell implementation of {@link android.app.Application}, managing application-level global
  * state and initializations.
  */
-public class SkyShellApplication extends BaseChromiumApplication {
+public class SkyApplication extends BaseChromiumApplication {
     private static final String TAG = "SkyShellApplication";
     private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "sky_shell";
     private static final String[] SKY_MANDATORY_PAKS = {
diff --git a/sky/shell/apk/src/org/domokit/sky/shell/SkyMain.java b/sky/shell/org/domokit/sky/shell/SkyMain.java
similarity index 100%
rename from sky/shell/apk/src/org/domokit/sky/shell/SkyMain.java
rename to sky/shell/org/domokit/sky/shell/SkyMain.java