forked from phonegap/phonegap-plugins
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
Conflicts: Android/SpeechRecognizer/README.md Android/SpeechRecognizer/SpeechRecognizer.java
- Loading branch information
Showing
418 changed files
with
46,422 additions
and
647 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.