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

fix in soundPlug and update in torch #60

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d7514e6
Added an open in external application link for when linking to doc fi…
Sep 29, 2011
58ca387
Recommit of lost code from destroyed fork.
Oct 5, 2011
c216d57
Video Player Plugin
macdonst Oct 3, 2011
cc12250
Fix for Issue #139: New Child Browser: can't get keyboard when show l…
macdonst Oct 4, 2011
9c9bdb6
Fix for Issue #179: Android ChildBrowser openExternal DroidGap option…
macdonst Oct 12, 2011
3b57f44
Since GetFunctionName was removed in https://github.com/shazron/phone…
niik Oct 3, 2011
ca39b2c
Add step for line in plugins.xml and some format clenaup
wader Oct 4, 2011
006689c
PhoneGap wrapper around Shopify4J to make authenticated API calls
jiblits Oct 8, 2011
b97551f
Phonegap plugin for Android to enable Torch functionality
Oct 18, 2011
f3fdae6
Fixing zoom issue in child browser
macdonst Oct 19, 2011
b63ba97
Facebook Android SDK plugin start
Nov 4, 2010
f056925
ChildBrowser plugin for WindowsPhone Mango
purplecabbage Oct 20, 2011
49ed1db
adding DateTimePicker plugin for Android
Oct 29, 2011
578dbfe
Social Sharing plugin
purplecabbage Nov 4, 2011
024aa73
Readme
purplecabbage Nov 4, 2011
d4709e3
formatting ...
purplecabbage Nov 4, 2011
94cb547
formatting ...
purplecabbage Nov 4, 2011
be81bb7
formatting ...
purplecabbage Nov 4, 2011
a2e51c6
formatting ...
purplecabbage Nov 4, 2011
543048f
formatting ...
purplecabbage Nov 4, 2011
8af2559
dismiss modal view controller ios 5
Nov 5, 2011
c558609
WP7 Map launcher for searching nearby and getting directions
purplecabbage Nov 19, 2011
6e51111
updated childbrowser plugin
Dec 1, 2011
1a28397
facebook plugin
Dec 1, 2011
69d0d52
Merge pull request #46 from sgrebnov/master
Dec 7, 2011
71f613d
Merge pull request #39 from ng4e/master
Dec 7, 2011
c164c4c
Merge pull request #34 from ebzlo/master
Dec 7, 2011
29135b1
Merge pull request #32 from dsowsy/master
Dec 7, 2011
e75e098
Adding an onError method to the ChildBrowser
macdonst Nov 21, 2011
84758e8
make readme markdown for better readability on github.com
max-mapper Nov 26, 2011
03be5dc
update top level readme
max-mapper Nov 26, 2011
229b25e
The reference to GetFunctionName was causing this to fail for me. Is…
Oct 20, 2011
b0ba342
Since GetFunctionName was removed in https://github.com/shazron/phone…
funkjedi Nov 28, 2011
a2a67c9
Clean up logic errors causing issue #183 and others
devgeeks Nov 28, 2011
5c68989
Added Sergey's LiveTile plugin for updating the Metro homescreen tile
purplecabbage Dec 12, 2011
654d719
check for light on devices with no flashsupport
Jan 11, 2012
7b6e8c4
import PhoneGap/Plugin.h fixed in SoundPlug.h
Jan 11, 2012
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
21 changes: 12 additions & 9 deletions Android/BarcodeScanner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ By Matt Kane
This plugin requires the end user to install [the ZXing Barcode Scanner app](http://code.google.com/p/zxing/)
If the user doesn't have the app install they will be promped to install it the first time the plugin is used.

1. To install the plugin, move barcodescanner.js to your project's www folder and include a reference to it
1. To install the plugin, move `barcodescanner.js` to your project's www folder and include a reference to it
in your html files.
2. Create a folder called 'src/com/beetight/barcodescanner' within your project's src/com/ folder.
3. And copy the java file into that new folder.

`mkdir <your_project>/src/com/beetight/barcodescanner`
mkdir -p <your_project>/src/com/beetight/barcodescanner
cp ./BarcodeScanner.java <your_project>/src/com/beetight/barcodescanner

4. Add a plugin line to `res/xml/plugins.xml`

`cp ./BarcodeScanner.java <your_project>/src/com/beetight/barcodescanner`
`<plugin name="BarcodeScanner" value="com.beetight.barcodescanner.BarcodeScanner"/>`

## Using the plugin ##
The plugin creates the object `window.plugins.barcodeScanner` with one method `scan(types, success, fail, options)`
Expand Down Expand Up @@ -67,12 +70,12 @@ Supported encoding types:

A full example could be:

window.plugins.barcodeScanner.encode(BarcodeScanner.Encode.TEXT_TYPE, "http://www.nytimes.com", function(success) {
alert("encode success: " + success);
}, function(fail) {
alert("encoding failed: " + fail);
}, {yesString: "Install"}
);
window.plugins.barcodeScanner.encode(BarcodeScanner.Encode.TEXT_TYPE, "http://www.nytimes.com", function(success) {
alert("encode success: " + success);
}, function(fail) {
alert("encoding failed: " + fail);
}, {yesString: "Install"}
);


## BUGS AND CONTRIBUTIONS ##
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.json.JSONObject;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
Expand All @@ -26,6 +27,7 @@
import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.view.inputmethod.InputMethodManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.EditText;
Expand All @@ -46,6 +48,7 @@ public class ChildBrowser extends Plugin {

private Dialog dialog;
private WebView webview;
private EditText edittext;
private boolean showLocationBar = true;

/**
Expand All @@ -64,6 +67,11 @@ public PluginResult execute(String action, JSONArray args, String callbackId) {
if (action.equals("showWebPage")) {
this.browserCallbackId = callbackId;

// If the ChildBrowser is already open then throw an error
if (dialog != null && dialog.isShowing()) {
return new PluginResult(PluginResult.Status.ERROR, "ChildBrowser is already open");
}

result = this.showWebPage(args.getString(0), args.optJSONObject(1));

if (result.length() > 0) {
Expand Down Expand Up @@ -129,7 +137,7 @@ public String openExternal(String url, boolean usePhoneGap) {
this.ctx.startActivity(intent);
return "";
} catch (android.content.ActivityNotFoundException e) {
System.out.println("ChildBrowser: Error loading url "+url+":"+ e.toString());
Log.d(LOG_TAG, "ChildBrowser: Error loading url "+url+":"+ e.toString());
return e.toString();
}
}
Expand Down Expand Up @@ -166,11 +174,15 @@ private void goForward() {
*
* @param url to load
*/
private void navigate(String url) {
private void navigate(String url) {
InputMethodManager imm = (InputMethodManager)this.ctx.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);

if (!url.startsWith("http")) {
this.webview.loadUrl("http://" + url);
}
this.webview.loadUrl(url);
this.webview.requestFocus();
}


Expand Down Expand Up @@ -255,7 +267,7 @@ public void onClick(View v) {
}
forward.setLayoutParams(forwardParams);

final EditText edittext = new EditText(ctx);
edittext = new EditText(ctx);
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 @@ -270,7 +282,7 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
edittext.setSingleLine(true);
edittext.setText(url);
edittext.setLayoutParams(editParams);

ImageButton close = new ImageButton(ctx);
close.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Expand All @@ -287,11 +299,16 @@ public void onClick(View v) {

webview = new WebView(ctx);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
WebViewClient client = new ChildBrowserClient(ctx, edittext);
webview.setWebViewClient(client);
webview.loadUrl(url);
webview.setId(5);
webview.setInitialScale(0);
webview.setLayoutParams(wvParams);
webview.requestFocus();
webview.requestFocusFromTouch();


toolbar.addView(back);
toolbar.addView(forward);
Expand Down Expand Up @@ -363,7 +380,7 @@ public ChildBrowserClient(PhonegapActivity mContext, EditText mEditText) {
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
String newloc;
if (url.startsWith("http")) {
if (url.startsWith("http:")) {
newloc = url;
} else {
newloc = "http://" + url;
Expand Down
24 changes: 17 additions & 7 deletions Android/ChildBrowser/www/childbrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ChildBrowser.prototype.showWebPage = function(url, options) {
var options = new Object();
options.showLocationBar = true;
}
PhoneGap.exec(this._onEvent, null, "ChildBrowser", "showWebPage", [url, options]);
PhoneGap.exec(this._onEvent, this._onError, "ChildBrowser", "showWebPage", [url, options]);
};

/**
Expand All @@ -45,25 +45,35 @@ ChildBrowser.prototype.close = function() {
* @param usePhoneGap Load url in PhoneGap webview [optional]
*/
ChildBrowser.prototype.openExternal = function(url, usePhoneGap) {
PhoneGap.exec(null, null, "ChildBrowser", "openExternal", [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.
* Method called when the child browser has an event.
*/
ChildBrowser.prototype._onEvent = function(data) {
console.log("In _onEvent");
console.log("data type = " + data.type);
if (data.type == ChildBrowser.CLOSE_EVENT && typeof window.plugins.childBrowser.onClose === "function") {
console.log("Calling onClose");
window.plugins.childBrowser.onClose();
}
if (data.type == ChildBrowser.LOCATION_CHANGED_EVENT && typeof window.plugins.childBrowser.onLocationChange === "function") {
console.log("Calling onLocChange");
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
*/
Expand Down
152 changes: 152 additions & 0 deletions Android/DateTimePicker/DatePickerPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/**
*
*/
package com.ngapplication.plugin;

import java.util.Calendar;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.app.TimePickerDialog;
import android.app.TimePickerDialog.OnTimeSetListener;
import android.util.Log;
import android.widget.DatePicker;
import android.widget.TimePicker;

import com.phonegap.api.PhonegapActivity;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
import com.phonegap.api.PluginResult.Status;

/**
* @author ng4e
*
*/
public class DatePickerPlugin extends Plugin {

private static final String ACTION_DATE = "date";
private static final String ACTION_TIME = "time";

/*
* (non-Javadoc)
*
* @see com.phonegap.api.Plugin#execute(java.lang.String,
* org.json.JSONArray, java.lang.String)
*/
@Override
public PluginResult execute(final String action, final JSONArray data,
final String callBackId) {
Log.d("DatePickerPlugin", "Plugin Called");
PluginResult result = null;

if (ACTION_DATE.equalsIgnoreCase(action)) {
Log.d("DatePickerPluginListener execute", ACTION_DATE);
this.showDatePicker(callBackId);
final PluginResult r = new PluginResult(
PluginResult.Status.NO_RESULT);
r.setKeepCallback(true);
return r;

} else if (ACTION_TIME.equalsIgnoreCase(action)) {
Log.d("DatePickerPluginListener execute", ACTION_TIME);
this.showTimePicker(callBackId);
final PluginResult r = new PluginResult(
PluginResult.Status.NO_RESULT);
r.setKeepCallback(true);
return r;

} else {
result = new PluginResult(Status.INVALID_ACTION);
Log.d("DatePickerPlugin", "Invalid action : " + action + " passed");
}

return result;
}

public synchronized void showTimePicker(final String callBackId) {
final DatePickerPlugin datePickerPlugin = this;
final PhonegapActivity currentCtx = ctx;

final Runnable runnable = new Runnable() {

public void run() {
final TimePickerDialog tpd = new TimePickerDialog(currentCtx,
new OnTimeSetListener() {

public void onTimeSet(final TimePicker view,
final int hourOfDay, final int minute) {
final JSONObject userChoice = new JSONObject();
try {
userChoice.put("hour", hourOfDay);
userChoice.put("min", minute);
} catch (final JSONException jsonEx) {
Log.e("showDatePicker",
"Got JSON Exception "
+ jsonEx.getMessage());
datePickerPlugin.error(new PluginResult(
Status.JSON_EXCEPTION), callBackId);
}
datePickerPlugin.success(new PluginResult(
PluginResult.Status.OK, userChoice),
callBackId);

}
}, 1, 1, true);

tpd.show();
}
};
ctx.runOnUiThread(runnable);

}

public synchronized void showDatePicker(final String callBackId) {

final DatePickerPlugin datePickerPlugin = this;
final PhonegapActivity currentCtx = ctx;
final Calendar c = Calendar.getInstance();
final int mYear = c.get(Calendar.YEAR);
final int mMonth = c.get(Calendar.MONTH);
final int mDay = c.get(Calendar.DAY_OF_MONTH);

final Runnable runnable = new Runnable() {

public void run() {
final DatePickerDialog dpd = new DatePickerDialog(currentCtx,
new OnDateSetListener() {

public void onDateSet(final DatePicker view,
final int year, final int monthOfYear,
final int dayOfMonth) {

final JSONObject userChoice = new JSONObject();

try {
userChoice.put("year", year);
userChoice.put("month", monthOfYear);
userChoice.put("day", dayOfMonth);
} catch (final JSONException jsonEx) {
Log.e("showDatePicker",
"Got JSON Exception "
+ jsonEx.getMessage());
datePickerPlugin.error(new PluginResult(
Status.JSON_EXCEPTION), callBackId);
}

datePickerPlugin.success(new PluginResult(
PluginResult.Status.OK, userChoice),
callBackId);

}
}, mYear, mMonth, mDay);

dpd.show();
}
};
ctx.runOnUiThread(runnable);
}

}
Loading