[
  {
    "path": ".classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"src\" path=\"gen\"/>\n\t<classpathentry kind=\"con\" path=\"com.android.ide.eclipse.adt.ANDROID_FRAMEWORK\"/>\n\t<classpathentry kind=\"con\" path=\"com.android.ide.eclipse.adt.LIBRARIES\"/>\n\t<classpathentry kind=\"output\" path=\"bin/classes\"/>\n</classpath>\n"
  },
  {
    "path": ".gitignore",
    "content": "_site\nMANIFEST.MF\n./*.jar\nbuild.num\nbuild\nlocal.properties\nbin/\ngen/\n_layouts\n.DS_Store\ngh-pages\nres/\n\n.gradle\n/local.properties\n/.idea/workspace.xml\n/.idea/libraries\n.DS_Store\n/build"
  },
  {
    "path": ".idea/.name",
    "content": "Routable"
  },
  {
    "path": ".idea/compiler.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"CompilerConfiguration\">\n    <resourceExtensions />\n    <wildcardResourcePatterns>\n      <entry name=\"!?*.java\" />\n      <entry name=\"!?*.form\" />\n      <entry name=\"!?*.class\" />\n      <entry name=\"!?*.groovy\" />\n      <entry name=\"!?*.scala\" />\n      <entry name=\"!?*.flex\" />\n      <entry name=\"!?*.kt\" />\n      <entry name=\"!?*.clj\" />\n      <entry name=\"!?*.aj\" />\n    </wildcardResourcePatterns>\n    <annotationProcessing>\n      <profile default=\"true\" name=\"Default\" enabled=\"false\">\n        <processorPath useClasspath=\"true\" />\n      </profile>\n    </annotationProcessing>\n  </component>\n</project>"
  },
  {
    "path": ".idea/copyright/profiles_settings.xml",
    "content": "<component name=\"CopyrightManager\">\n  <settings default=\"\" />\n</component>"
  },
  {
    "path": ".idea/encodings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"Encoding\">\n    <file url=\"PROJECT\" charset=\"UTF-8\" />\n  </component>\n</project>"
  },
  {
    "path": ".idea/gradle.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"GradleSettings\">\n    <option name=\"linkedExternalProjectsSettings\">\n      <GradleProjectSettings>\n        <option name=\"distributionType\" value=\"DEFAULT_WRAPPED\" />\n        <option name=\"externalProjectPath\" value=\"$PROJECT_DIR$\" />\n        <option name=\"gradleJvm\" value=\"1.7\" />\n        <option name=\"modules\">\n          <set>\n            <option value=\"$PROJECT_DIR$\" />\n          </set>\n        </option>\n      </GradleProjectSettings>\n    </option>\n  </component>\n</project>"
  },
  {
    "path": ".idea/misc.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"EntryPointsManager\">\n    <entry_points version=\"2.0\" />\n  </component>\n  <component name=\"ProjectLevelVcsManager\" settingsEditedManually=\"false\">\n    <OptionsSetting value=\"true\" id=\"Add\" />\n    <OptionsSetting value=\"true\" id=\"Remove\" />\n    <OptionsSetting value=\"true\" id=\"Checkout\" />\n    <OptionsSetting value=\"true\" id=\"Update\" />\n    <OptionsSetting value=\"true\" id=\"Status\" />\n    <OptionsSetting value=\"true\" id=\"Edit\" />\n    <ConfirmationsSetting value=\"0\" id=\"Add\" />\n    <ConfirmationsSetting value=\"0\" id=\"Remove\" />\n  </component>\n  <component name=\"ProjectRootManager\" version=\"2\" languageLevel=\"JDK_1_7\" default=\"true\" assert-keyword=\"true\" jdk-15=\"true\" project-jdk-name=\"1.7\" project-jdk-type=\"JavaSDK\">\n    <output url=\"file://$PROJECT_DIR$/build/classes\" />\n  </component>\n  <component name=\"ProjectType\">\n    <option name=\"id\" value=\"Android\" />\n  </component>\n</project>"
  },
  {
    "path": ".idea/modules.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"ProjectModuleManager\">\n    <modules>\n      <module fileurl=\"file://$PROJECT_DIR$/Routable.iml\" filepath=\"$PROJECT_DIR$/Routable.iml\" />\n    </modules>\n  </component>\n</project>"
  },
  {
    "path": ".idea/vcs.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"VcsDirectoryMappings\">\n    <mapping directory=\"\" vcs=\"Git\" />\n  </component>\n</project>"
  },
  {
    "path": ".project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>Routable</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>com.android.ide.eclipse.adt.ApkBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>com.android.ide.eclipse.adt.AndroidNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n          package=\"com.usepropeller.routable\"\n          android:versionName=\"1.0.0\"\n          android:versionCode=\"1\">\n\n    <uses-sdk\n            android:minSdkVersion=\"3\" />\n\n    <application />\n\n</manifest>"
  },
  {
    "path": "LICENSE",
    "content": "Copyright (c) 2013 Turboprop, Inc. (http://usepropeller.com/)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE."
  },
  {
    "path": "README.md",
    "content": "# Routable\n\nRoutable is an in-app native URL router, for Android. Also available for [iOS](https://github.com/usepropeller/routable-ios).\n\n## Usage\n\nSet up your app's router and URLs:\n\n```java\nimport com.usepropeller.routable.Router;\n\npublic class PropellerApplication extends Application {\n    @Override\n    public void onCreate() {\n        super.onCreate();\n        \n        // Set the global context\n        Router.sharedRouter().setContext(getApplicationContext());\n        // Symbol-esque params are passed as intent extras to the activities\n        Router.sharedRouter().map(\"users/:id\", UserActivity.class);\n        Router.sharedRouter().map(\"users/new/:name/:zip\", NewUserActivity.class);\n    }\n}\n```\n\nIn your `Activity` classes, add support for the URL params:\n\n```java\nimport com.usepropeller.routable.Router;\n\npublic class UserActivity extends Activity {\n    @Override\n    public void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        Bundle intentExtras = getIntent().getExtras();\n        // Note this extra, and how it corresponds to the \":id\" above\n        String userId = intentExtras.get(\"id\");\n    }\n}\n\npublic class NewUserActivity extends Activity {\n    @Override\n    public void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        Bundle intentExtras = getIntent().getExtras();\n        // Corresponds to the \":name\" above\n        String name = intentExtras.get(\"name\");\n        // Corresponds to the \":zip\" above\n        String zip = intentExtras.get(\"zip\");\n    }\n}\n```\n\n*Anywhere* else in your app, open some URLs:\n\n```java\n// starts a new UserActivity\nRouter.sharedRouter().open(\"users/16\");\n// starts a new NewUserActivity\nRouter.sharedRouter().open(\"users/new/Clay/94303\");\n```\n\n## Installation\n\nRoutable is currently an Android library project (so no Maven).\n\nIf you're in a hurry, you can just copy-paste the [Router.java](https://github.com/usepropeller/routable-android/blob/master/src/com/usepropeller/routable/Router.java) file.\n\nOr if you're being a little more proactive, you should import the Routable project (this entire git repo) into Eclipse and [reference it](http://developer.android.com/tools/projects/projects-eclipse.html#ReferencingLibraryProject) in your own project. \n\n## Features\n\n### Routable Functions\n\nYou can call arbitrary blocks of code with Routable:\n\n```java\nRouter.sharedRouter().map(\"logout\", new Router.RouterCallback() {\n    public void run(Router.RouteContext context) {\n        User.logout();\n    }\n});\n\n// Somewhere else\nRouter.sharedRouter().open(\"logout\");\n```\n\n### Open External URLs\n\nSometimes you want to open a URL outside of your app, like a YouTube URL or open a web URL in the browser. You can use Routable to do that:\n\n```java\nRouter.sharedRouter().openExternal(\"http://www.youtube.com/watch?v=oHg5SJYRHA0\")\n```\n\n### Multiple Routers\n\nIf you need to use multiple routers, simply create new instances of `Router`:\n\n```java\nRouter adminRouter = new Router();\n\nRouter userRouter = new Router();\n```\n\n## Contact\n\nClay Allsopp ([http://clayallsopp.com](http://clayallsopp.com))\n\n- [http://twitter.com/clayallsopp](http://twitter.com/clayallsopp)\n- [clay@usepropeller.com](clay@usepropeller.com)\n\n## License\n\nRoutable for Android is available under the MIT license. See the LICENSE file for more info.\n"
  },
  {
    "path": "Routable.iml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<module external.linked.project.id=\"Routable\" external.linked.project.path=\"$MODULE_DIR$\" external.root.project.path=\"$MODULE_DIR$\" external.system.id=\"GRADLE\" external.system.module.group=\"\" external.system.module.version=\"unspecified\" type=\"JAVA_MODULE\" version=\"4\">\n  <component name=\"FacetManager\">\n    <facet type=\"android\" name=\"Android\">\n      <configuration>\n        <option name=\"SELECTED_BUILD_VARIANT\" value=\"debug\" />\n        <option name=\"SELECTED_TEST_ARTIFACT\" value=\"_android_test_\" />\n        <option name=\"ASSEMBLE_TASK_NAME\" value=\"assembleDebug\" />\n        <option name=\"COMPILE_JAVA_TASK_NAME\" value=\"compileDebugSources\" />\n        <option name=\"SOURCE_GEN_TASK_NAME\" value=\"generateDebugSources\" />\n        <option name=\"ASSEMBLE_TEST_TASK_NAME\" value=\"assembleDebugAndroidTest\" />\n        <option name=\"COMPILE_JAVA_TEST_TASK_NAME\" value=\"compileDebugAndroidTestSources\" />\n        <option name=\"TEST_SOURCE_GEN_TASK_NAME\" value=\"generateDebugAndroidTestSources\" />\n        <option name=\"ALLOW_USER_CONFIGURATION\" value=\"false\" />\n        <option name=\"RES_FOLDERS_RELATIVE_PATH\" value=\"\" />\n        <option name=\"ASSETS_FOLDER_RELATIVE_PATH\" value=\"/src/main/assets\" />\n        <option name=\"LIBRARY_PROJECT\" value=\"true\" />\n      </configuration>\n    </facet>\n    <facet type=\"android-gradle\" name=\"Android-Gradle\">\n      <configuration>\n        <option name=\"GRADLE_PROJECT_PATH\" value=\":\" />\n      </configuration>\n    </facet>\n  </component>\n  <component name=\"NewModuleRootManager\" inherit-compiler-output=\"false\">\n    <output url=\"file://$MODULE_DIR$/build/intermediates/classes/debug\" />\n    <output-test url=\"file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug\" />\n    <exclude-output />\n    <content url=\"file://$MODULE_DIR$\">\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/r/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/aidl/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/buildConfig/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/rs/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/rs/debug\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/generated/debug\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/r/androidTest/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/generated/androidTest/debug\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/res\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/resources\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/assets\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/aidl\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/java\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/jni\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/rs\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/res\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/resources\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/assets\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/aidl\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/jni\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/rs\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/res\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/resources\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/assets\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/aidl\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/java\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/RoutableTestTest/src\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/jni\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/rs\" isTestSource=\"true\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/assets\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/bundles\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/classes\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/dependency-cache\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/dex\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/dex-cache\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/incremental\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/jacoco\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/javaResources\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/libs\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/lint\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/manifests\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/ndk\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/pre-dexed\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/proguard\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/res\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/rs\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/symbols\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/outputs\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/reports\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/test-results\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/tmp\" />\n    </content>\n    <orderEntry type=\"jdk\" jdkName=\"Android API 17 Platform\" jdkType=\"Android SDK\" />\n    <orderEntry type=\"sourceFolder\" forTests=\"false\" />\n  </component>\n</module>"
  },
  {
    "path": "RoutableTestTest/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"src\" path=\"gen\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/Routable\"/>\n\t<classpathentry kind=\"con\" path=\"com.android.ide.eclipse.adt.ANDROID_FRAMEWORK\"/>\n\t<classpathentry kind=\"con\" path=\"com.android.ide.eclipse.adt.LIBRARIES\"/>\n\t<classpathentry kind=\"output\" path=\"bin/classes\"/>\n</classpath>\n"
  },
  {
    "path": "RoutableTestTest/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>RoutableTest</name>\n\t<comment></comment>\n\t<projects>\n\t\t<project>Routable</project>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>com.android.ide.eclipse.adt.ApkBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>com.android.ide.eclipse.adt.AndroidNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "RoutableTestTest/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.usepropeller.routable.test\"\n    android:versionCode=\"1\"\n    android:versionName=\"1.0\" >\n\n    <uses-sdk android:minSdkVersion=\"3\" />\n\n    <instrumentation\n        android:name=\"android.test.InstrumentationTestRunner\"\n        android:targetPackage=\"com.usepropeller.routable.test\" />\n\n    <application\n        android:icon=\"@drawable/ic_launcher\"\n        android:label=\"@string/app_name\" >\n        <uses-library android:name=\"android.test.runner\" />\n    </application>\n\n</manifest>"
  },
  {
    "path": "RoutableTestTest/proguard-project.txt",
    "content": "# To enable ProGuard in your project, edit project.properties\n# to define the proguard.config property as described in that file.\n#\n# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in ${sdk.dir}/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the ProGuard\n# include property in project.properties.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n"
  },
  {
    "path": "RoutableTestTest/project.properties",
    "content": "# This file is automatically generated by Android Tools.\n# Do not modify this file -- YOUR CHANGES WILL BE ERASED!\n#\n# This file must be checked in Version Control Systems.\n#\n# To customize properties used by the Ant build system edit\n# \"ant.properties\", and override values to adapt the script to your\n# project structure.\n#\n# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):\n#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt\n\n# Project target.\ntarget=android-7\nandroid.library.reference.1=..\n"
  },
  {
    "path": "RoutableTestTest/src/com/usepropeller/routable/test/RouterTest.java",
    "content": "package com.usepropeller.routable.test;\n\nimport java.util.Map;\n\nimport com.usepropeller.routable.Router;\n\nimport junit.framework.Assert;\n\nimport android.app.ListActivity;\nimport android.content.Intent;\nimport android.os.Bundle;\nimport android.test.AndroidTestCase;\n\npublic class RouterTest extends AndroidTestCase {\n\tprivate boolean _called;\n\n\t@Override\n\tpublic void setUp() throws Exception {\n\t\tsuper.setUp();\n\n\t\tthis._called = false;\n\t}\n\n\tpublic void test_basic() {\n\t\tRouter router = new Router();\n\t\trouter.map(\"users/:user_id\", ListActivity.class);\n\n\t\tIntent intent = router.intentFor(\"users/4\");\n\t\tAssert.assertEquals(\"4\", intent.getExtras().getString(\"user_id\"));\n\t}\n\n\tpublic void test_empty() {\n\t\tRouter router = new Router();\n\t\trouter.map(\"users\", ListActivity.class);\n\n\t\tIntent intent = router.intentFor(\"users\");\n\t\tAssert.assertNull(intent.getExtras());\n\t}\n\n\tpublic void test_invalid_route() {\n\t\tRouter router = new Router();\n\t\tboolean exceptionThrown = false;\n\n\t\ttry {\n\t\t\trouter.intentFor(\"users/4\");\n\t\t} catch (Router.RouteNotFoundException e) {\n\t\t\texceptionThrown = true;\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t\tfail(\"Incorrect exception throw: \" + e.toString());\n\t\t}\n\n\t\tAssert.assertTrue(\"Invalid route did not throw exception\", exceptionThrown);\n\t}\n\n\tpublic void test_invalid_context() {\n\t\tRouter router = new Router();\n\t\trouter.map(\"users\", ListActivity.class);\n\t\tboolean exceptionThrown = false;\n\n\t\ttry {\n\t\t\trouter.open(\"users\");\n\t\t} catch (Router.ContextNotProvided e) {\n\t\t\texceptionThrown = true;\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t\tfail(\"Incorrect exception throw: \" + e.toString());\n\t\t}\n\n\t\tAssert.assertTrue(\"Invalid context did not throw exception\", exceptionThrown);\n\t}\n\n\tpublic void test_code_callbacks() {\n\t\tRouter router = new Router(this.getContext());\n\t\trouter.map(\"callback\", new Router.RouterCallback() {\n\t\t\t@Override\n\t\t\tpublic void run(Router.RouteContext context) {\n\t\t\t\tRouterTest.this._called = true;\n\n                Assert.assertNotNull(context.getContext());\n\t\t\t}\n\t\t});\n\n\t\trouter.open(\"callback\");\n\n\t\tAssert.assertTrue(this._called);\n\t}\n\n\tpublic void test_code_callbacks_with_params() {\n\t\tRouter router = new Router(this.getContext());\n\t\trouter.map(\"callback/:id\", new Router.RouterCallback() {\n\t\t\t@Override\n\t\t\tpublic void run(Router.RouteContext context) {\n\t\t\t\tRouterTest.this._called = true;\n\t\t\t\tAssert.assertEquals(\"123\", context.getParams().get(\"id\"));\n\t\t\t}\n\t\t});\n\n\t\trouter.open(\"callback/123\");\n\n\t\tAssert.assertTrue(this._called);\n\t}\n\n\tpublic void test_code_callbacks_with_extras() {\n\t\tRouter router = new Router(this.getContext());\n\t\trouter.map(\"callback/:id\", new Router.RouterCallback() {\n            @Override\n            public void run(Router.RouteContext context) {\n                RouterTest.this._called = true;\n                Assert.assertEquals(\"value\", context.getExtras().getString(\"test\"));\n            }\n        });\n\n        Bundle extras = new Bundle();\n        extras.putString(\"test\", \"value\");\n\n\t\trouter.open(\"callback/123\", extras);\n\n\t\tAssert.assertTrue(this._called);\n\t}\n\n    public void test_url_starting_with_slash() {\n        Router router = new Router();\n        router.map(\"/users\", ListActivity.class);\n\n        Intent intent = router.intentFor(\"/users\");\n        Assert.assertNull(intent.getExtras());\n    }\n\n    public void test_url_querystring() {\n        Router router = new Router();\n        router.map(\"/users/:id\", ListActivity.class);\n\n        Intent intent = router.intentFor(\"/users/123?key1=val2\");\n        Bundle extras = intent.getExtras();\n\n        Assert.assertEquals(\"123\", extras.getString(\"id\"));\n        Assert.assertEquals(\"val2\", extras.getString(\"key1\"));\n    }\n\n    public void test_url_containing_spaces() {\n        Router router = new Router();\n        router.map(\"/path+entry/:id\", ListActivity.class);\n\n        Intent intent = router.intentFor(\"/path+entry/123\");\n        Bundle extras = intent.getExtras();\n\n        Assert.assertEquals(\"123\", extras.getString(\"id\"));\n    }\n\n    public void test_url_querystring_with_encoded_value() {\n        Router router = new Router();\n        router.map(\"/users/:id\", ListActivity.class);\n\n        Intent intent = router.intentFor(\"/users/123?key1=val+1&key2=val%202\");\n        Bundle extras = intent.getExtras();\n\n        Assert.assertEquals(\"val 1\", extras.getString(\"key1\"));\n        Assert.assertEquals(\"val 2\", extras.getString(\"key2\"));\n    }\n\n    public void test_url_querystring_without_value() {\n        Router router = new Router();\n        router.map(\"/users/:id\", ListActivity.class);\n\n        Intent intent = router.intentFor(\"/users/123?val1\");\n        Bundle extras = intent.getExtras();\n\n        Assert.assertTrue(extras.containsKey(\"val1\"));\n    }\n\n    public void test_url_starting_with_slash_with_params() {\n        Router router = new Router();\n        router.map(\"/users/:user_id\", ListActivity.class);\n\n        Intent intent = router.intentFor(\"/users/4\");\n        Assert.assertEquals(\"4\", intent.getExtras().getString(\"user_id\"));\n    }\n}\n"
  },
  {
    "path": "build.gradle",
    "content": "buildscript {\n    repositories {\n        mavenCentral()\n    }\n    dependencies {\n        classpath 'com.android.tools.build:gradle:1.2.3'\n    }\n}\napply plugin: 'android-library'\n\nrepositories {\n    mavenCentral()\n}\n\nandroid {\n    compileSdkVersion 17\n    buildToolsVersion \"19.1.0\"\n\n    defaultConfig {\n        minSdkVersion 9\n        targetSdkVersion 17\n    }\n\n    sourceSets {\n        main {\n            manifest.srcFile 'AndroidManifest.xml'\n            java.srcDirs = ['src']\n            res.srcDirs = ['res']\n        }\n\n        androidTest {\n            java.srcDir 'RoutableTestTest/src'\n        }\n    }\n}"
  },
  {
    "path": "build.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project name=\"library\" default=\"help\">\n\n    <!-- The local.properties file is created and updated by the 'android' tool.\n         It contains the path to the SDK. It should *NOT* be checked into\n         Version Control Systems. -->\n    <property file=\"local.properties\" />\n\n    <!-- The ant.properties file can be created by you. It is only edited by the\n         'android' tool to add properties to it.\n         This is the place to change some Ant specific build properties.\n         Here are some properties you may want to change/update:\n\n         source.dir\n             The name of the source directory. Default is 'src'.\n         out.dir\n             The name of the output directory. Default is 'bin'.\n\n         For other overridable properties, look at the beginning of the rules\n         files in the SDK, at tools/ant/build.xml\n\n         Properties related to the SDK location or the project target should\n         be updated using the 'android' tool with the 'update' action.\n\n         This file is an integral part of the build system for your\n         application and should be checked into Version Control Systems.\n\n         -->\n    <property file=\"ant.properties\" />\n\n    <!-- if sdk.dir was not set from one of the property file, then\n         get it from the ANDROID_HOME env var.\n         This must be done before we load project.properties since\n         the proguard config can use sdk.dir -->\n    <property environment=\"env\" />\n    <condition property=\"sdk.dir\" value=\"${env.ANDROID_HOME}\">\n        <isset property=\"env.ANDROID_HOME\" />\n    </condition>\n\n    <!-- The project.properties file is created and updated by the 'android'\n         tool, as well as ADT.\n\n         This contains project specific properties such as project target, and library\n         dependencies. Lower level build properties are stored in ant.properties\n         (or in .classpath for Eclipse projects).\n\n         This file is an integral part of the build system for your\n         application and should be checked into Version Control Systems. -->\n    <loadproperties srcFile=\"project.properties\" />\n\n    <!-- quick check on sdk.dir -->\n    <fail\n            message=\"sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable.\"\n            unless=\"sdk.dir\"\n    />\n\n    <!--\n        Import per project custom build rules if present at the root of the project.\n        This is the place to put custom intermediary targets such as:\n            -pre-build\n            -pre-compile\n            -post-compile (This is typically used for code obfuscation.\n                           Compiled code location: ${out.classes.absolute.dir}\n                           If this is not done in place, override ${out.dex.input.absolute.dir})\n            -post-package\n            -post-build\n            -pre-clean\n    -->\n    <import file=\"custom_rules.xml\" optional=\"true\" />\n\n    <!-- Import the actual build file.\n\n         To customize existing targets, there are two options:\n         - Customize only one target:\n             - copy/paste the target into this file, *before* the\n               <import> task.\n             - customize it to your needs.\n         - Customize the whole content of build.xml\n             - copy/paste the content of the rules files (minus the top node)\n               into this file, replacing the <import> task.\n             - customize to your needs.\n\n         ***********************\n         ****** IMPORTANT ******\n         ***********************\n         In all cases you must update the value of version-tag below to read 'custom' instead of an integer,\n         in order to avoid having your file be overridden by tools such as \"android update project\"\n    -->\n    <!-- version-tag: 1 -->\n    <import file=\"${sdk.dir}/tools/ant/build.xml\" />\n\n</project>\n"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "#Wed Apr 10 15:27:10 PDT 2013\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-2.2.1-all.zip\n"
  },
  {
    "path": "gradlew",
    "content": "#!/usr/bin/env bash\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS=\"\"\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn ( ) {\n    echo \"$*\"\n}\n\ndie ( ) {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\nesac\n\n# For Cygwin, ensure paths are in UNIX format before anything is touched.\nif $cygwin ; then\n    [ -n \"$JAVA_HOME\" ] && JAVA_HOME=`cygpath --unix \"$JAVA_HOME\"`\nfi\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >&-\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >&-\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=$((i+1))\n    done\n    case $i in\n        (0) set -- ;;\n        (1) set -- \"$args0\" ;;\n        (2) set -- \"$args0\" \"$args1\" ;;\n        (3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        (4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        (5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        (6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        (7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        (8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        (9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules\nfunction splitJvmOpts() {\n    JVM_OPTS=(\"$@\")\n}\neval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS\nJVM_OPTS[${#JVM_OPTS[*]}]=\"-Dorg.gradle.appname=$APP_BASE_NAME\"\n\nexec \"$JAVACMD\" \"${JVM_OPTS[@]}\" -classpath \"$CLASSPATH\" org.gradle.wrapper.GradleWrapperMain \"$@\"\n"
  },
  {
    "path": "gradlew.bat",
    "content": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem  Gradle startup script for Windows\n@rem\n@rem ##########################################################################\n\n@rem Set local scope for the variables with windows NT shell\nif \"%OS%\"==\"Windows_NT\" setlocal\n\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nset DEFAULT_JVM_OPTS=\n\nset DIRNAME=%~dp0\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\nset APP_BASE_NAME=%~n0\nset APP_HOME=%DIRNAME%\n\n@rem Find java.exe\nif defined JAVA_HOME goto findJavaFromJavaHome\n\nset JAVA_EXE=java.exe\n%JAVA_EXE% -version >NUL 2>&1\nif \"%ERRORLEVEL%\" == \"0\" goto init\n\necho.\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:findJavaFromJavaHome\nset JAVA_HOME=%JAVA_HOME:\"=%\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\n\nif exist \"%JAVA_EXE%\" goto init\n\necho.\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:init\n@rem Get command-line arguments, handling Windowz variants\n\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\nif \"%@eval[2+2]\" == \"4\" goto 4NT_args\n\n:win9xME_args\n@rem Slurp the command line arguments.\nset CMD_LINE_ARGS=\nset _SKIP=2\n\n:win9xME_args_slurp\nif \"x%~1\" == \"x\" goto execute\n\nset CMD_LINE_ARGS=%*\ngoto execute\n\n:4NT_args\n@rem Get arguments from the 4NT Shell from JP Software\nset CMD_LINE_ARGS=%$\n\n:execute\n@rem Setup the command line\n\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\n\n@rem Execute Gradle\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\n\n:end\n@rem End local scope for the variables with windows NT shell\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\n\n:fail\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\nrem the _cmd.exe /c_ return code!\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\nexit /b 1\n\n:mainEnd\nif \"%OS%\"==\"Windows_NT\" endlocal\n\n:omega\n"
  },
  {
    "path": "proguard-project.txt",
    "content": "# To enable ProGuard in your project, edit project.properties\n# to define the proguard.config property as described in that file.\n#\n# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in ${sdk.dir}/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the ProGuard\n# include property in project.properties.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n"
  },
  {
    "path": "project.properties",
    "content": "# This file is automatically generated by Android Tools.\n# Do not modify this file -- YOUR CHANGES WILL BE ERASED!\n#\n# This file must be checked in Version Control Systems.\n#\n# To customize properties used by the Ant build system edit\n# \"ant.properties\", and override values to adapt the script to your\n# project structure.\n#\n# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):\n#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt\n\n# Project target.\ntarget=android-17\nandroid.library=true\n"
  },
  {
    "path": "src/com/usepropeller/routable/Router.java",
    "content": "/*\n    Routable for Android\n    Copyright (c) 2013 Turboprop, Inc. <clay@usepropeller.com>\n    http://usepropeller.com\n\n    Licensed under the MIT License.\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\n*/\n\npackage com.usepropeller.routable;\n\nimport java.net.URI;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Map.Entry;\n\nimport android.app.Activity;\nimport android.content.Context;\nimport android.content.Intent;\nimport android.net.Uri;\nimport android.os.Bundle;\n\nimport org.apache.http.NameValuePair;\nimport org.apache.http.client.utils.URLEncodedUtils;\n\npublic class Router {\n\tprivate static final Router _router = new Router();\n\n\t/**\n     * A globally accessible Router instance that will work for\n     * most use cases.\n     */\n\tpublic static Router sharedRouter() {\n\t\treturn _router;\n\t}\n\n    /**\n     * The class used when you want to map a function (given in `run`)\n     * to a Router URL.\n     */\n\tpublic static abstract class RouterCallback {\n\t\tpublic abstract void run(RouteContext context);\n\t}\n\n    /**\n     * The class supplied to custom callbacks to describe the route route\n     */\n\tpublic class RouteContext {\n\t\tMap<String, String> _params;\n\t\tBundle _extras;\n        Context _context;\n\n        public RouteContext(Map<String, String> params, Bundle extras, Context context) {\n\t\t\t_params = params;\n            _extras = extras;\n            _context = context;\n        }\n\n        /**\n         * Returns the route parameters as specified by the configured route\n         */\n\t\tpublic Map<String, String> getParams() { return _params; }\n\n        /**\n         * Returns the extras supplied with the route\n         */\n\t\tpublic Bundle getExtras() { return _extras; }\n\n        /**\n         * Returns the Android Context that should be used to open the route\n         */\n        public Context getContext() { return _context; }\n    }\n\n\t/**\n     * The class used to determine behavior when opening a URL.\n     * If you want to extend Routable to handle things like transition\n     * animations or fragments, this class should be augmented.\n     */\n\tpublic static class RouterOptions {\n\t\tClass<? extends Activity> _klass;\n\t\tRouterCallback _callback;\n\t\tMap<String, String> _defaultParams;\n\n\t\tpublic RouterOptions() {\n\n\t\t}\n\n\t\tpublic RouterOptions(Class<? extends Activity> klass) {\n\t\t\tthis.setOpenClass(klass);\n\t\t}\n\n\t\tpublic RouterOptions(Map<String, String> defaultParams) {\n\t\t\tthis.setDefaultParams(defaultParams);\n\t\t}\n\n\t\tpublic RouterOptions(Map<String, String> defaultParams, Class<? extends Activity> klass) {\n\t\t\tthis.setDefaultParams(defaultParams);\n\t\t\tthis.setOpenClass(klass);\n\t\t}\n\n\t\tpublic void setOpenClass(Class<? extends Activity> klass) {\n\t\t\tthis._klass = klass;\n\t\t}\n\n\t\tpublic Class<? extends Activity> getOpenClass() {\n\t\t\treturn this._klass;\n\t\t}\n\n\t\tpublic RouterCallback getCallback() {\n\t\t\treturn this._callback;\n\t\t}\n\n\t\tpublic void setCallback(RouterCallback callback) {\n\t\t\tthis._callback = callback;\n\t\t}\n\n\t\tpublic void setDefaultParams(Map<String, String> defaultParams) {\n\t\t\tthis._defaultParams = defaultParams;\n\t\t}\n\n\t\tpublic Map<String, String> getDefaultParams() {\n\t\t\treturn this._defaultParams;\n\t\t}\n\t}\n\n\tprivate static class RouterParams {\n\t\tpublic RouterOptions routerOptions;\n\t\tpublic Map<String, String> openParams;\n\t}\n\n\tprivate final Map<String, RouterOptions> _routes = new HashMap<String, RouterOptions>();\n\tprivate String _rootUrl = null;\n\tprivate final Map<String, RouterParams> _cachedRoutes = new HashMap<String, RouterParams>();\n\tprivate Context _context;\n\n\t/**\n     * Creates a new Router\n     */\n\tpublic Router() {\n\n\t}\n\n\t/**\n     * Creates a new Router\n     * @param context {@link Context} that all {@link Intent}s generated by the router will use\n     */\n\tpublic Router(Context context) {\n\t\tthis.setContext(context);\n\t}\n\n\t/**\n     * @param context {@link Context} that all {@link Intent}s generated by the router will use\n     */\n\tpublic void setContext(Context context) {\n\t\tthis._context = context;\n\t}\n\n\t/**\n\t * @return The context for the router\n\t */\n\tpublic Context getContext() {\n\t\treturn this._context;\n\t}\n\n\t/**\n     * Map a URL to a callback\n     * @param format The URL being mapped; for example, \"users/:id\" or \"groups/:id/topics/:topic_id\"\n     * @param callback {@link RouterCallback} instance which contains the code to execute when the URL is opened\n     */\n\tpublic void map(String format, RouterCallback callback) {\n\t\tRouterOptions options = new RouterOptions();\n\t\toptions.setCallback(callback);\n\t\tthis.map(format, null, options);\n\t}\n\n\t/**\n     * Map a URL to open an {@link Activity}\n     * @param format The URL being mapped; for example, \"users/:id\" or \"groups/:id/topics/:topic_id\"\n     * @param klass The {@link Activity} class to be opened with the URL\n     */\n\tpublic void map(String format, Class<? extends Activity> klass) {\n\t\tthis.map(format, klass, null);\n\t}\n\n\t/**\n     * Map a URL to open an {@link Activity}\n     * @param format The URL being mapped; for example, \"users/:id\" or \"groups/:id/topics/:topic_id\"\n     * @param klass The {@link Activity} class to be opened with the URL\n     * @param options The {@link RouterOptions} to be used for more granular and customized options for when the URL is opened\n     */\n\tpublic void map(String format, Class<? extends Activity> klass, RouterOptions options) {\n\t\tif (options == null) {\n\t\t\toptions = new RouterOptions();\n\t\t}\n\t\toptions.setOpenClass(klass);\n\t\tthis._routes.put(format, options);\n\t}\n\n\t/**\n\t * Set the root url; used when opening an activity or callback via RouterActivity\n\t * @param rootUrl The URL format to use as the root\n\t */\n\tpublic void setRootUrl(String rootUrl) {\n\t\tthis._rootUrl = rootUrl;\n\t}\n\n\t/**\n\t * @return The router's root URL, or null.\n\t */\n\tpublic String getRootUrl() {\n\t\treturn this._rootUrl;\n\t}\n\n\t/**\n     * Open a URL using the operating system's configuration (such as opening a link to Chrome or a video to YouTube)\n     * @param url The URL; for example, \"http://www.youtube.com/watch?v=oHg5SJYRHA0\"\n     */\n\tpublic void openExternal(String url) {\n\t\tthis.openExternal(url, this._context);\n\t}\n\n\t/**\n     * Open a URL using the operating system's configuration (such as opening a link to Chrome or a video to YouTube)\n     * @param url The URL; for example, \"http://www.youtube.com/watch?v=oHg5SJYRHA0\"\n     * @param context The context which is used in the generated {@link Intent}\n     */\n\tpublic void openExternal(String url, Context context) {\n\t\tthis.openExternal(url, null, context);\n\t}\n\n\t/**\n     * Open a URL using the operating system's configuration (such as opening a link to Chrome or a video to YouTube)\n     * @param url The URL; for example, \"http://www.youtube.com/watch?v=oHg5SJYRHA0\"\n     * @param extras The {@link Bundle} which contains the extras to be assigned to the generated {@link Intent}\n     */\n\tpublic void openExternal(String url, Bundle extras) {\n\t\tthis.openExternal(url, extras, this._context);\n\t}\n\n\t/**\n     * Open a URL using the operating system's configuration (such as opening a link to Chrome or a video to YouTube)\n     * @param url The URL; for example, \"http://www.youtube.com/watch?v=oHg5SJYRHA0\"\n     * @param extras The {@link Bundle} which contains the extras to be assigned to the generated {@link Intent}\n     * @param context The context which is used in the generated {@link Intent}\n     */\n\tpublic void openExternal(String url, Bundle extras, Context context) {\n\t\tif (context == null) {\n\t\t\tthrow new ContextNotProvided(\n\t\t\t\t\t\"You need to supply a context for Router \"\n\t\t\t\t\t\t\t+ this.toString());\n\t\t}\n\t\tIntent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));\n\t\tthis.addFlagsToIntent(intent, context);\n\t\tif (extras != null) {\n\t\t\tintent.putExtras(extras);\n\t\t}\n\t\tcontext.startActivity(intent);\n\t}\n\n\t/**\n     * Open a map'd URL set using {@link #map(String, Class)} or {@link #map(String, RouterCallback)}\n     * @param url The URL; for example, \"users/16\" or \"groups/5/topics/20\"\n     */\n\tpublic void open(String url) {\n\t\tthis.open(url, this._context);\n\t}\n\n\t/**\n     * Open a map'd URL set using {@link #map(String, Class)} or {@link #map(String, RouterCallback)}\n     * @param url The URL; for example, \"users/16\" or \"groups/5/topics/20\"\n     * @param extras The {@link Bundle} which contains the extras to be assigned to the generated {@link Intent}\n     */\n\tpublic void open(String url, Bundle extras) {\n\t\tthis.open(url, extras, this._context);\n\t}\n\n\t/**\n     * Open a map'd URL set using {@link #map(String, Class)} or {@link #map(String, RouterCallback)}\n     * @param url The URL; for example, \"users/16\" or \"groups/5/topics/20\"\n     * @param context The context which is used in the generated {@link Intent}\n     */\n\tpublic void open(String url, Context context) {\n\t\tthis.open(url, null, context);\n\t}\n\n\t/**\n     * Open a map'd URL set using {@link #map(String, Class)} or {@link #map(String, RouterCallback)}\n     * @param url The URL; for example, \"users/16\" or \"groups/5/topics/20\"\n     * @param extras The {@link Bundle} which contains the extras to be assigned to the generated {@link Intent}\n     * @param context The context which is used in the generated {@link Intent}\n     */\n\tpublic void open(String url, Bundle extras, Context context) {\n\t\tif (context == null) {\n\t\t\tthrow new ContextNotProvided(\n\t\t\t\t\t\"You need to supply a context for Router \"\n\t\t\t\t\t\t\t+ this.toString());\n\t\t}\n\t\tRouterParams params = this.paramsForUrl(url);\n\t\tRouterOptions options = params.routerOptions;\n\t\tif (options.getCallback() != null) {\n            RouteContext routeContext = new RouteContext(params.openParams, extras, context);\n\n\t\t\toptions.getCallback().run(routeContext);\n\t\t\treturn;\n\t\t}\n\n\t\tIntent intent = this.intentFor(context, params);\n\t\tif (intent == null) {\n\t\t\t// Means the options weren't opening a new activity\n\t\t\treturn;\n\t\t}\n\t\tif (extras != null) {\n\t\t\tintent.putExtras(extras);\n\t\t}\n\t\tcontext.startActivity(intent);\n\t}\n\n\t/*\n\t * Allows Intents to be spawned regardless of what context they were opened with.\n\t */\n\tprivate void addFlagsToIntent(Intent intent, Context context) {\n\t\tif (context == this._context) {\n\t\t\tintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\n\t\t}\n\t}\n\n\t/**\n     * @param url The URL; for example, \"users/16\" or \"groups/5/topics/20\"\n\t * @return The {@link Intent} for the url\n\t */\n\tpublic Intent intentFor(String url) {\n\t\tRouterParams params = this.paramsForUrl(url);\n\n        return intentFor(params);\n\t}\n\n    private Intent intentFor(RouterParams params) {\n        RouterOptions options = params.routerOptions;\n        Intent intent = new Intent();\n        if (options.getDefaultParams() != null) {\n            for (Entry<String, String> entry : options.getDefaultParams().entrySet()) {\n                intent.putExtra(entry.getKey(), entry.getValue());\n            }\n        }\n        for (Entry<String, String> entry : params.openParams.entrySet()) {\n            intent.putExtra(entry.getKey(), entry.getValue());\n        }\n        return intent;\n    }\n\n\t/**\n\t * @param url The URL to check\n\t * @return Whether or not the URL refers to an anonymous callback function\n\t */\n\tpublic boolean isCallbackUrl(String url) {\n\t\tRouterParams params = this.paramsForUrl(url);\n\t\tRouterOptions options = params.routerOptions;\n\t\treturn options.getCallback() != null;\n\t}\n\n\t/**\n\t *\n\t * @param context The context which is spawning the intent\n     * @param url The URL; for example, \"users/16\" or \"groups/5/topics/20\"\n\t * @return The {@link Intent} for the url, with the correct {@link Activity} set, or null.\n\t */\n\tpublic Intent intentFor(Context context, String url) {\n\t\tRouterParams params = this.paramsForUrl(url);\n\n        return intentFor(context, params);\n\t}\n\n    private Intent intentFor(Context context, RouterParams params) {\n        RouterOptions options = params.routerOptions;\n        if (options.getCallback() != null) {\n            return null;\n        }\n\n        Intent intent = intentFor(params);\n        intent.setClass(context, options.getOpenClass());\n        this.addFlagsToIntent(intent, context);\n        return intent;\n    }\n\n\t/*\n\t * Takes a url (i.e. \"/users/16/hello\") and breaks it into a {@link RouterParams} instance where\n\t * each of the parameters (like \":id\") has been parsed.\n\t */\n\tprivate RouterParams paramsForUrl(String url) {\n        final String cleanedUrl = cleanUrl(url);\n\n\t\tURI parsedUri = URI.create(\"http://tempuri.org/\" + cleanedUrl);\n\n\t\tString urlPath = parsedUri.getPath().substring(1);\n\n\t\tif (this._cachedRoutes.get(cleanedUrl) != null) {\n\t\t\treturn this._cachedRoutes.get(cleanedUrl);\n\t\t}\n\n\t\tString[] givenParts = urlPath.split(\"/\");\n\n\t\tRouterParams routerParams = null;\n\t\tfor (Entry<String, RouterOptions> entry : this._routes.entrySet()) {\n\t\t\tString routerUrl = cleanUrl(entry.getKey());\n\t\t\tRouterOptions routerOptions = entry.getValue();\n\t\t\tString[] routerParts = routerUrl.split(\"/\");\n\n\t\t\tif (routerParts.length != givenParts.length) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tMap<String, String> givenParams = urlToParamsMap(givenParts, routerParts);\n\t\t\tif (givenParams == null) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\trouterParams = new RouterParams();\n\t\t\trouterParams.openParams = givenParams;\n\t\t\trouterParams.routerOptions = routerOptions;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (routerParams == null) {\n\t\t\tthrow new RouteNotFoundException(\"No route found for url \" + url);\n\t\t}\n\n\t\tList<NameValuePair> query = URLEncodedUtils.parse(parsedUri, \"utf-8\");\n\n\t\tfor (NameValuePair pair : query) {\n\t\t\trouterParams.openParams.put(pair.getName(), pair.getValue());\n\t\t}\n\n\t\tthis._cachedRoutes.put(cleanedUrl, routerParams);\n\t\treturn routerParams;\n\t}\n\n\t/**\n\t *\n\t * @param givenUrlSegments An array representing the URL path attempting to be opened (i.e. [\"users\", \"42\"])\n\t * @param routerUrlSegments An array representing a possible URL match for the router (i.e. [\"users\", \":id\"])\n\t * @return A map of URL parameters if it's a match (i.e. {\"id\" => \"42\"}) or null if there is no match\n\t */\n\tprivate Map<String, String> urlToParamsMap(String[] givenUrlSegments, String[] routerUrlSegments) {\n\t\tMap<String, String> formatParams = new HashMap<String, String>();\n\t\tfor (int index = 0; index < routerUrlSegments.length; index++) {\n\t\t\tString routerPart = routerUrlSegments[index];\n\t\t\tString givenPart = givenUrlSegments[index];\n\n\t\t\tif (routerPart.charAt(0) == ':') {\n\t\t\t\tString key = routerPart.substring(1, routerPart.length());\n\t\t\t\tformatParams.put(key, givenPart);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!routerPart.equals(givenPart)) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\treturn formatParams;\n\t}\n\n    /**\n     * Clean up url\n     * @param url\n     * @return cleaned url\n     */\n    private String cleanUrl(String url) {\n        if (url.startsWith(\"/\")) {\n            return url.substring(1, url.length());\n        }\n        return url;\n    }\n\n\t/**\n\t * Thrown if a given route is not found.\n\t */\n\tpublic static class RouteNotFoundException extends RuntimeException {\n\t\tprivate static final long serialVersionUID = -2278644339983544651L;\n\n\t\tpublic RouteNotFoundException(String message) {\n\t\t\tsuper(message);\n\t\t}\n\t}\n\n\t/**\n\t * Thrown if no context has been found.\n\t */\n\tpublic static class ContextNotProvided extends RuntimeException {\n\t\tprivate static final long serialVersionUID = -1381427067387547157L;\n\n\t\tpublic ContextNotProvided(String message) {\n\t\t\tsuper(message);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/com/usepropeller/routable/RouterActivity.java",
    "content": "package com.usepropeller.routable;\n\nimport android.app.Activity;\nimport android.content.Intent;\nimport android.net.Uri;\nimport android.os.Bundle;\n\npublic class RouterActivity extends Activity {\n\t@Override\n\tpublic void onCreate(Bundle savedInstanceState) {\n\t    super.onCreate(savedInstanceState);\n\n\t    Intent intent = getIntent();\n\t    String url;\n\n\t    Bundle extras = intent.getExtras();\n\t    if (extras.containsKey(\"url\")) {\n\t    \turl = extras.getString(\"url\");\n\t    }\n\t    else {\n\t\t    Uri data = intent.getData();\n\t\t    String protocol = data.getScheme() + \"://\";\n\t\t    url = data.toString().replaceFirst(protocol, \"\");\n\t\t    if (Router.sharedRouter().getRootUrl() != null) {\n\t\t\t    Router.sharedRouter().open(Router.sharedRouter().getRootUrl());\n\t\t    }\n\t    }\n\n\t    Router.sharedRouter().open(url);\n\n\t    setResult(RESULT_OK, null);\n\t    finish();\n\t}\n}\n"
  }
]