Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
Conflicts:
	Android/SpeechRecognizer/README.md
	Android/SpeechRecognizer/SpeechRecognizer.java
  • Loading branch information
poiuytrez committed Mar 20, 2012
2 parents 543cfb9 + 8bfb79c commit 8507e98
Show file tree
Hide file tree
Showing 418 changed files with 46,422 additions and 647 deletions.
42 changes: 42 additions & 0 deletions Android/AccountList/AccountList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.seltzlab.mobile;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.accounts.Account;
import android.accounts.AccountManager;

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

public class AccountList extends Plugin {

@Override
public PluginResult execute(String action, JSONArray args, String callbackId) {

try {
JSONObject obj = args.getJSONObject(0);

AccountManager am = AccountManager.get(this.ctx);

Account[] accounts;
if (obj.has("type"))
accounts = am.getAccountsByType(obj.getString("type"));
else
accounts = am.getAccounts();

JSONArray res = new JSONArray();
for (int i = 0; i < accounts.length; i++) {
Account a = accounts[i];
res.put(a.name);
}

return new PluginResult(PluginResult.Status.OK, res);

} catch (JSONException e) {
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
}
}

}
34 changes: 34 additions & 0 deletions Android/AccountList/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
AccountList Phonegap Plugin for Android
=======================================
This plugin allows you to obtain an array containing all the accounts configured on the device

Adding the Plugin to your project
=================================

To install the plugin, copy accountlist.js to your project's www folder and include a reference to it in your html files.

<script type="text/javascript" src="accountlist.js"></script>

Create a folder called 'com/seltzlab/mobile' within your project's src folder and copy AccountList.java file into that new folder.

Add a plugin line to res/xml/plugins.xml
<plugin name="AccountList" value="com.seltzlab.mobile.AccountList" />

Add a permission line to the AndroidManifest.xml
<uses-permission android:name="android.permission.GET_ACCOUNTS" />

Using the plugin
================
window.plugins.AccountList.get(
{
type: 'account type' // if not specified get all accounts
},
function (result) {
console.log(result.length);
for (i in res)
console.log(result[i]);
},
function (error) {
console.log(error);
}
);
13 changes: 13 additions & 0 deletions Android/AccountList/accountlist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var AccountList = function() {};

AccountList.prototype.get = function(params, success, fail) {
return PhoneGap.exec( function(args) {
success(args);
}, function(args) {
fail(args);
}, 'AccountList', '', [params]);
};

PhoneGap.addConstructor(function() {
PhoneGap.addPlugin('AccountList', new AccountList());
});
4 changes: 4 additions & 0 deletions Android/Analytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Using this plugin requires [Android PhoneGap](http://github.com/phonegap/phonega

4. Copy "lib/libGoogleAnalytics.jar" into the libs directory within your project. You will also need to right click on this file in eclipse and add the jar to the build path.

5. In your res/xml/plugins.xml file add the following line:

<plugin name="GoogleAnalyticsTracker" value="com.phonegap.plugins.analytics.GoogleAnalyticsTracker" />

## Using the plugin ##

The plugin creates the object `window.plugins.analytics`. To use, call one of the following, available methods:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
public class GoogleAnalyticsTracker extends Plugin {
public static final String START = "start";
public static final String TRACK_PAGE_VIEW = "trackPageView";
public static final String TRACK_EVENT = "trackEvent";
public static final String TRACK_EVENT = "trackEvent";
public static final String SET_CUSTOM_VARIABLE = "setCustomVariable";

public static final int DISPATCH_INTERVAL = 20;
private com.google.android.apps.analytics.GoogleAnalyticsTracker tracker;
Expand Down Expand Up @@ -52,6 +53,12 @@ public PluginResult execute(String action, JSONArray data, String callbackId) {
} catch (JSONException e) {
result = new PluginResult(Status.JSON_EXCEPTION);
}
} else if (SET_CUSTOM_VARIABLE.equals(action)){
try {
setCustomVar(data.getInt(0), data.getString(1), data.getString(2), data.getInt(3));
} catch (JSONException e) {
result = new PluginResult(Status.JSON_EXCEPTION);
}
} else {
result = new PluginResult(Status.INVALID_ACTION);
}
Expand All @@ -69,4 +76,8 @@ private void trackPageView(String key) {
private void trackEvent(String category, String action, String label, int value){
tracker.trackEvent(category, action, label, value);
}

private void setCustomVar(int index, String label, String value, int scope) {
tracker.setCustomVar(index, label, value, scope);
}
}
21 changes: 19 additions & 2 deletions Android/Analytics/www/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,29 @@ Analytics.prototype.trackEvent = function(category, action, label, value, succes
typeof label === "undefined" ? "" : label,
(isNaN(parseInt(value,10))) ? 0 : parseInt(value, 10)
]);
}
};

Analytics.prototype.setCustomVar = function(index, label, value, scope, successCallback, failureCallback){
return PhoneGap.exec(
successCallback,
failureCallback,
'GoogleAnalyticsTracker',
'setCustomVariable',
[
(isNaN(parseInt(index,10))) ? 0 : parseInt(index, 10),
label,
value,
(isNaN(parseInt(scope,10))) ? 0 : parseInt(scope, 10)
]);
};

/**
* Load Analytics
*/
PhoneGap.addConstructor(function() {
PhoneGap.addPlugin('analytics', new Analytics());
PluginManager.addService("GoogleAnalyticsTracker", "com.phonegap.plugins.analytics.GoogleAnalyticsTracker");

// @deprecated: No longer needed in PhoneGap 1.0. Uncomment the addService code for earlier
// PhoneGap releases.
// PluginManager.addService("GoogleAnalyticsTracker", "com.phonegap.plugins.analytics.GoogleAnalyticsTracker");
});
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public void onCreate(Bundle icicle) {
inactivityTimer = new InactivityTimer(this);
beepManager = new BeepManager(this);

showHelpOnFirstLaunch();
// showHelpOnFirstLaunch();
}

@Override
Expand Down
11 changes: 2 additions & 9 deletions Android/ChildBrowser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,11 @@ Using this plugin requires [Android PhoneGap](http://github.com/phonegap/phonega
&lt;script type="text/javascript" charset="utf-8" src="phonegap.js"&gt;&lt;/script&gt;<br/>
&lt;script type="text/javascript" charset="utf-8" src="childbrowser.js"&gt;&lt;/script&gt;

2. Copy the image files folder www/childbrowser to your project'w www folder. Note you need the entire folder not just the images.
2. Copy the image files folder www/childbrowser to your project's www folder. Note you need the entire folder not just the images.

3. Create a directory within your project called "src/com/phonegap/plugins/childBrowser" and move ChildBrowser.java into it.

4. Add the following activity to your AndroidManifest.xml file. It should be added inside the &lt;application&gt; tag.

&lt;activity android:name="com.phonegap.plugins.childBrowser.ChildBrowser" android:label="@string/app_name"&gt;<br/>
&lt;intent-filter&gt;<br/>
&lt;/intent-filter&gt;<br/>
&lt;/activity&gt;

5. In your res/xml/plugins.xml file add the following line:
4. In your res/xml/plugins.xml file add the following line:

&lt;plugin name="ChildBrowser" value="com.phonegap.plugins.childBrowser.ChildBrowser"/&gt;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.IOException;
import java.io.InputStream;

import org.apache.cordova.api.CordovaInterface;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
Expand Down Expand Up @@ -119,7 +120,7 @@ public String openExternal(String url, boolean usePhoneGap) {
try {
Intent intent = null;
if (usePhoneGap) {
intent = new Intent().setClass(this.ctx, com.phonegap.DroidGap.class);
intent = new Intent().setClass((Context) this.ctx, org.apache.cordova.DroidGap.class);
intent.setData(Uri.parse(url)); // This line will be removed in future.
intent.putExtra("url", url);

Expand Down Expand Up @@ -147,6 +148,7 @@ public String openExternal(String url, boolean usePhoneGap) {
*/
private void closeDialog() {
if (dialog != null) {
this.webview.stopLoading();
dialog.dismiss();
}
}
Expand Down Expand Up @@ -210,7 +212,7 @@ public String showWebPage(final String url, JSONObject options) {
// Create dialog in new thread
Runnable runnable = new Runnable() {
public void run() {
dialog = new Dialog(ctx);
dialog = new Dialog((Context) ctx);

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(true);
Expand All @@ -233,13 +235,13 @@ public void onDismiss(DialogInterface dialog) {
LinearLayout.LayoutParams closeParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
LinearLayout.LayoutParams wvParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);

LinearLayout main = new LinearLayout(ctx);
LinearLayout main = new LinearLayout((Context) ctx);
main.setOrientation(LinearLayout.VERTICAL);

LinearLayout toolbar = new LinearLayout(ctx);
LinearLayout toolbar = new LinearLayout((Context) ctx);
toolbar.setOrientation(LinearLayout.HORIZONTAL);

ImageButton back = new ImageButton(ctx);
ImageButton back = new ImageButton((Context) ctx);
back.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goBack();
Expand All @@ -253,7 +255,7 @@ public void onClick(View v) {
}
back.setLayoutParams(backParams);

ImageButton forward = new ImageButton(ctx);
ImageButton forward = new ImageButton((Context) ctx);
forward.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goForward();
Expand All @@ -267,7 +269,7 @@ public void onClick(View v) {
}
forward.setLayoutParams(forwardParams);

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

ImageButton close = new ImageButton(ctx);
ImageButton close = new ImageButton((Context) ctx);
close.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
closeDialog();
Expand All @@ -297,7 +299,7 @@ public void onClick(View v) {
}
close.setLayoutParams(closeParams);

webview = new WebView(ctx);
webview = new WebView((Context) ctx);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
WebViewClient client = new ChildBrowserClient(ctx, edittext);
Expand Down Expand Up @@ -356,7 +358,7 @@ private void sendUpdate(JSONObject obj, boolean keepCallback) {
* The webview client receives notifications about appView
*/
public class ChildBrowserClient extends WebViewClient {
PhonegapActivity ctx;
CordovaInterface ctx;
EditText edittext;

/**
Expand All @@ -365,7 +367,7 @@ public class ChildBrowserClient extends WebViewClient {
* @param mContext
* @param edittext
*/
public ChildBrowserClient(PhonegapActivity mContext, EditText mEditText) {
public ChildBrowserClient(CordovaInterface mContext, EditText mEditText) {
this.ctx = mContext;
this.edittext = mEditText;
}
Expand Down
Loading

0 comments on commit 8507e98

Please sign in to comment.