Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Java files support Cordova 1.9+, also BlackBerry support #11

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,23 @@
<source-file src="ChildBrowserCommand.m" />
<source-file src="ChildBrowserViewController.m" />
</platform>

<!-- blackberry -->
<platform name="blackberry">
<config-file target="www/plugins.xml" parent="/plugins">
<plugin name="ChildBrowser"
value="com.phonegap.plugins.childbrowser.ChildBrowser"/>
</config-file>

<source-file src="src/blackberry/ChildBrowser.java"
target-dir="www/ext/com/phonegap/plugins/childbrowser" />
<source-file src="src/blackberry/CustomBrowser.java"
target-dir="www/ext/com/phonegap/plugins/childbrowser" />
<source-file src="src/blackberry/NavigationBar.java"
target-dir="www/ext/com/phonegap/plugins/childbrowser" />
<source-file src="src/blackberry/URLEditField.java"
target-dir="www/ext/com/phonegap/plugins/childbrowser" />
<source-file src="src/blackberry/URLLabelField.java"
target-dir="www/ext/com/phonegap/plugins/childbrowser" />
</platform>
</plugin>
26 changes: 13 additions & 13 deletions src/android/ChildBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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());
Expand Down Expand Up @@ -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")) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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
Expand All @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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 "";
}

Expand Down
12 changes: 6 additions & 6 deletions src/blackberry/ChildBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/blackberry/CustomBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
}
3 changes: 2 additions & 1 deletion src/blackberry/NavigationBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
103 changes: 0 additions & 103 deletions www/blackberry/childbrowser.js

This file was deleted.

Binary file removed www/blackberry/childbrowser/icon_arrow_left.png
Binary file not shown.
Binary file removed www/blackberry/childbrowser/icon_arrow_right.png
Binary file not shown.