diff --git a/plugin.xml b/plugin.xml index 371d609..be1b68a 100644 --- a/plugin.xml +++ b/plugin.xml @@ -42,4 +42,23 @@ + + + + + + + + + + + + + diff --git a/src/android/ChildBrowser.java b/src/android/ChildBrowser.java index 60ef634..1c5d85c 100644 --- a/src/android/ChildBrowser.java +++ b/src/android/ChildBrowser.java @@ -121,7 +121,7 @@ public String openExternal(String url, boolean usePhoneGap) { try { Intent intent = null; if (usePhoneGap) { - intent = new Intent().setClass((Context) this.ctx, org.apache.cordova.DroidGap.class); + intent = new Intent().setClass((Context) this.ctx.getActivity(), org.apache.cordova.DroidGap.class); intent.setData(Uri.parse(url)); // This line will be removed in future. intent.putExtra("url", url); @@ -135,7 +135,7 @@ public String openExternal(String url, boolean usePhoneGap) { intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); } - this.ctx.startActivity(intent); + this.ctx.getActivity().startActivity(intent); return ""; } catch (android.content.ActivityNotFoundException e) { Log.d(LOG_TAG, "ChildBrowser: Error loading url " + url + ":" + e.toString()); @@ -177,7 +177,7 @@ private void goForward() { * @param url to load */ private void navigate(String url) { - InputMethodManager imm = (InputMethodManager) this.ctx.getSystemService(Context.INPUT_METHOD_SERVICE); + InputMethodManager imm = (InputMethodManager) this.ctx.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0); if (!url.startsWith("http")) { @@ -213,7 +213,7 @@ public String showWebPage(final String url, JSONObject options) { // Create dialog in new thread Runnable runnable = new Runnable() { public void run() { - dialog = new Dialog((Context) ctx); + dialog = new Dialog((Context) ctx.getActivity()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); @@ -242,13 +242,13 @@ public void onDismiss(DialogInterface dialog) { closeParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1.0f); } - LinearLayout main = new LinearLayout((Context) ctx); + LinearLayout main = new LinearLayout((Context) ctx.getActivity()); main.setOrientation(LinearLayout.VERTICAL); - LinearLayout toolbar = new LinearLayout((Context) ctx); + LinearLayout toolbar = new LinearLayout((Context) ctx.getActivity()); toolbar.setOrientation(LinearLayout.HORIZONTAL); - ImageButton back = new ImageButton((Context) ctx); + ImageButton back = new ImageButton((Context) ctx.getActivity()); back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); @@ -262,7 +262,7 @@ public void onClick(View v) { } back.setLayoutParams(backParams); - ImageButton forward = new ImageButton((Context) ctx); + ImageButton forward = new ImageButton((Context) ctx.getActivity()); forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); @@ -276,7 +276,7 @@ public void onClick(View v) { } forward.setLayoutParams(forwardParams); - edittext = new EditText((Context) ctx); + edittext = new EditText((Context) ctx.getActivity()); edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button @@ -292,7 +292,7 @@ public boolean onKey(View v, int keyCode, KeyEvent event) { edittext.setText(url); edittext.setLayoutParams(editParams); - ImageButton close = new ImageButton((Context) ctx); + ImageButton close = new ImageButton((Context) ctx.getActivity()); close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); @@ -306,7 +306,7 @@ public void onClick(View v) { } close.setLayoutParams(closeParams); - webview = new WebView((Context) ctx); + webview = new WebView((Context) ctx.getActivity()); webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setBuiltInZoomControls(true); WebViewClient client = new ChildBrowserClient(ctx, edittext); @@ -349,11 +349,11 @@ public void onClick(View v) { } private Bitmap loadDrawable(String filename) throws java.io.IOException { - InputStream input = ctx.getAssets().open(filename); + InputStream input = ctx.getActivity().getAssets().open(filename); return BitmapFactory.decodeStream(input); } }; - this.ctx.runOnUiThread(runnable); + this.ctx.getActivity().runOnUiThread(runnable); return ""; } diff --git a/src/blackberry/ChildBrowser.java b/src/blackberry/ChildBrowser.java index da2acd7..6c48db8 100644 --- a/src/blackberry/ChildBrowser.java +++ b/src/blackberry/ChildBrowser.java @@ -11,12 +11,12 @@ import net.rim.blackberry.api.browser.BrowserSession; import net.rim.device.api.ui.UiApplication; -import com.phonegap.api.Plugin; -import com.phonegap.api.PluginResult; -import com.phonegap.json4j.JSONArray; -import com.phonegap.json4j.JSONException; -import com.phonegap.json4j.JSONObject; -import com.phonegap.util.Logger; +import org.apache.cordova.api.Plugin; +import org.apache.cordova.api.PluginResult; +import org.apache.cordova.json4j.JSONArray; +import org.apache.cordova.json4j.JSONException; +import org.apache.cordova.json4j.JSONObject; +import org.apache.cordova.util.Logger; /** * The ChildBrowser plug-in. This class provides the ability to load external diff --git a/src/blackberry/CustomBrowser.java b/src/blackberry/CustomBrowser.java index 8ab74b9..9515563 100644 --- a/src/blackberry/CustomBrowser.java +++ b/src/blackberry/CustomBrowser.java @@ -20,11 +20,11 @@ import org.w3c.dom.Document; -import com.phonegap.PhoneGapExtension; -import com.phonegap.api.PluginResult; -import com.phonegap.json4j.JSONException; -import com.phonegap.json4j.JSONObject; -import com.phonegap.util.Logger; +import org.apache.cordova.CordovaExtension; +import org.apache.cordova.api.PluginResult; +import org.apache.cordova.json4j.JSONException; +import org.apache.cordova.json4j.JSONObject; +import org.apache.cordova.util.Logger; /** * A custom browser screen. Contains an optional navigation bar at the top of @@ -268,7 +268,7 @@ private void sendUpdate(JSONObject obj, boolean keepCallback) { if (callbackId != null) { PluginResult result = new PluginResult(PluginResult.Status.OK, obj); result.setKeepCallback(keepCallback); - PhoneGapExtension.invokeSuccessCallback(callbackId, result); + CordovaExtension.invokeSuccessCallback(callbackId, result); } } } diff --git a/src/blackberry/NavigationBar.java b/src/blackberry/NavigationBar.java index feaadcf..afa6417 100644 --- a/src/blackberry/NavigationBar.java +++ b/src/blackberry/NavigationBar.java @@ -24,7 +24,8 @@ import net.rim.device.api.ui.container.VerticalFieldManager; import net.rim.device.api.ui.decor.BackgroundFactory; -import com.phonegap.util.Logger; +import org.apache.cordova.util.Logger; + /** * Implements a navigation bar for the custom browser. Provides UI elements to diff --git a/www/blackberry/childbrowser.js b/www/blackberry/childbrowser.js deleted file mode 100644 index fb82f8f..0000000 --- a/www/blackberry/childbrowser.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * PhoneGap is available under *either* the terms of the modified BSD license *or* the - * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text. - * - * Copyright (c) 2005-2010, Nitobi Software Inc. - * Copyright (c) 2011, IBM Corporation - */ - -/** - * window.plugins.childBrowser - * - * Provides - */ -var ChildBrowser = ChildBrowser || (function() { - - /** - * Constructor - */ - function ChildBrowser() { - }; - - ChildBrowser.CLOSE_EVENT = 0; - ChildBrowser.LOCATION_CHANGED_EVENT = 1; - - /** - * Display a new browser with the specified URL. This method loads up a new - * custom browser field. - * - * @param url - * The url to load - * @param options - * An object that specifies additional options - */ - ChildBrowser.prototype.showWebPage = function(url, options) { - if (options === null || options === "undefined") { - var options = new Object(); - options.showLocationBar = true; - } - PhoneGap.exec(this._onEvent, this._onError, "ChildBrowser", - "showWebPage", [url, options ]); - }; - - /** - * Close the browser opened by showWebPage. - */ - ChildBrowser.prototype.close = function() { - PhoneGap.exec(null, this._onError, "ChildBrowser", "close", []); - }; - - /** - * Display a new browser with the specified URL. This method starts a new - * web browser activity. - * - * @param url - * The url to load - * @param usePhoneGap - * Load url in PhoneGap webview [ignored] - */ - ChildBrowser.prototype.openExternal = function(url, usePhoneGap) { - // if (usePhoneGap === true) { - // navigator.app.loadUrl(url); - // } else { - PhoneGap.exec(null, null, "ChildBrowser", "openExternal", [ url, - usePhoneGap ]); - // } - }; - - /** - * Method called when the child browser is closed. - */ - ChildBrowser.prototype._onEvent = function(data) { - if (data.type == ChildBrowser.CLOSE_EVENT - && typeof window.plugins.childBrowser.onClose === "function") { - window.plugins.childBrowser.onClose(); - } - if (data.type == ChildBrowser.LOCATION_CHANGED_EVENT - && typeof window.plugins.childBrowser.onLocationChange === "function") { - window.plugins.childBrowser.onLocationChange(data.location); - } - }; - - /** - * Method called when the child browser has an error. - */ - ChildBrowser.prototype._onError = function(data) { - if (typeof window.plugins.childBrowser.onError === "function") { - window.plugins.childBrowser.onError(data); - } - }; - - /** - * Maintain API consistency with iOS - */ - ChildBrowser.prototype.install = function() { - }; - - /** - * Load ChildBrowser - */ - PhoneGap.addConstructor(function() { - PhoneGap.addPlugin("childBrowser", new ChildBrowser()); - }); -})(); diff --git a/www/blackberry/childbrowser/icon_arrow_left.png b/www/blackberry/childbrowser/icon_arrow_left.png deleted file mode 100644 index f557c40..0000000 Binary files a/www/blackberry/childbrowser/icon_arrow_left.png and /dev/null differ diff --git a/www/blackberry/childbrowser/icon_arrow_right.png b/www/blackberry/childbrowser/icon_arrow_right.png deleted file mode 100644 index 6e5a0f7..0000000 Binary files a/www/blackberry/childbrowser/icon_arrow_right.png and /dev/null differ diff --git a/www/blackberry/childbrowser/icon_refresh.png b/www/childbrowser/icon_refresh.png similarity index 100% rename from www/blackberry/childbrowser/icon_refresh.png rename to www/childbrowser/icon_refresh.png diff --git a/www/blackberry/childbrowser/icon_stop.png b/www/childbrowser/icon_stop.png similarity index 100% rename from www/blackberry/childbrowser/icon_stop.png rename to www/childbrowser/icon_stop.png