From 9d6ff65fc4645a4ae97d02b23c3d6a2e66835a32 Mon Sep 17 00:00:00 2001 From: mahomedalid Date: Wed, 2 Oct 2013 09:28:11 -0500 Subject: [PATCH 1/3] Update WebIntent.java Allowing launch and app with package name --- src/android/WebIntent.java | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/android/WebIntent.java b/src/android/WebIntent.java index c1b2d87..e4512fe 100644 --- a/src/android/WebIntent.java +++ b/src/android/WebIntent.java @@ -51,22 +51,31 @@ public PluginResult execute(String action, JSONArray args, String callbackId) { // Parse the arguments JSONObject obj = args.getJSONObject(0); - String type = obj.has("type") ? obj.getString("type") : null; - Uri uri = obj.has("url") ? Uri.parse(obj.getString("url")) : null; - JSONObject extras = obj.has("extras") ? obj.getJSONObject("extras") : null; - Map extrasMap = new HashMap(); + + if(obj.has("package") { + String package = obj.has("package") ? obj.getString("package"); + Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("package"); + startActivity(LaunchIntent); - // Populate the extras if any exist - if (extras != null) { - JSONArray extraNames = extras.names(); - for (int i = 0; i < extraNames.length(); i++) { - String key = extraNames.getString(i); - String value = extras.getString(key); - extrasMap.put(key, value); + } else { + String type = obj.has("type") ? obj.getString("type") : null; + Uri uri = obj.has("url") ? Uri.parse(obj.getString("url")) : null; + JSONObject extras = obj.has("extras") ? obj.getJSONObject("extras") : null; + Map extrasMap = new HashMap(); + + // Populate the extras if any exist + if (extras != null) { + JSONArray extraNames = extras.names(); + for (int i = 0; i < extraNames.length(); i++) { + String key = extraNames.getString(i); + String value = extras.getString(key); + extrasMap.put(key, value); + } } + + startActivity(obj.getString("action"), uri, type, extrasMap); } - - startActivity(obj.getString("action"), uri, type, extrasMap); + return new PluginResult(PluginResult.Status.OK); } else if (action.equals("hasExtra")) { From 7b9c31bee5709d79f9d8dfd59159a7677895262c Mon Sep 17 00:00:00 2001 From: mahomedalid Date: Wed, 2 Oct 2013 14:42:48 -0500 Subject: [PATCH 2/3] Update WebIntent.java --- src/android/WebIntent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/android/WebIntent.java b/src/android/WebIntent.java index e4512fe..a8ec7d1 100644 --- a/src/android/WebIntent.java +++ b/src/android/WebIntent.java @@ -55,7 +55,7 @@ public PluginResult execute(String action, JSONArray args, String callbackId) { if(obj.has("package") { String package = obj.has("package") ? obj.getString("package"); Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("package"); - startActivity(LaunchIntent); + ((DroidGap)this.cordova.getActivity()).startActivity(LaunchIntent); } else { String type = obj.has("type") ? obj.getString("type") : null; From 43852b64a768ada33ac46b31bbf198c29f47c33c Mon Sep 17 00:00:00 2001 From: Mahomedalid Pacheco Date: Wed, 2 Oct 2013 18:20:46 -0500 Subject: [PATCH 3/3] webintent reloaded --- README.md | 6 +++--- plugin.xml | 6 +++--- src/android/WebIntent.java | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f01d5e0..c057b70 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # WebIntents plugin for Phonegap # -By Boris Smus +By Mahomedalid Pacheco (fork of Boris Smus) ## Adding the Plugin to your project ## 1. To install the plugin, move webintent.js to your project's www folder and include a reference to it in your html files. -2. Create the path "com/borismus/webintent" within your project's src/ folder and move the java file into it. +2. Create the path "com/lizardsc/webintent" within your project's src/ folder and move the java file into it. 3. Add the plugin to your `res/xml/config.xml` file: -`` +`` ## Using the plugin ## The plugin creates the object `window.plugins.webintent` with five methods: diff --git a/plugin.xml b/plugin.xml index a126a27..f1a24ed 100644 --- a/plugin.xml +++ b/plugin.xml @@ -3,7 +3,7 @@ WebIntent Web Intent Plugin @@ -18,11 +18,11 @@ - + - + diff --git a/src/android/WebIntent.java b/src/android/WebIntent.java index a8ec7d1..3b84383 100644 --- a/src/android/WebIntent.java +++ b/src/android/WebIntent.java @@ -1,4 +1,4 @@ -package com.borismus.webintent; +package com.lizardsc.webintent; import java.util.HashMap; import java.util.Map; @@ -24,7 +24,7 @@ * (after setting up correct intent filters for PhoneGap applications), Android * intents can be handled by PhoneGap web applications. * - * @author boris@borismus.com + * @author boris@lizardsc.com * */ public class WebIntent extends Plugin {