Skip to content

Commit

Permalink
Merge pull request phonegap#1000 from aetchegoyen/master
Browse files Browse the repository at this point in the history
Compatibility with phonegap 2.0 (js and java) (Cordova) and previuos versions (in JS file)
  • Loading branch information
devgeeks committed Jan 28, 2013
2 parents 3fb6bb5 + 9aa3a44 commit 968d1e3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Android/AccountList/AccountList.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.accounts.Account;
import android.accounts.AccountManager;

import org.apache.cordova.DroidGap;
import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;

Expand All @@ -18,7 +19,7 @@ public PluginResult execute(String action, JSONArray args, String callbackId) {
try {
JSONObject obj = args.getJSONObject(0);

AccountManager am = AccountManager.get(this.ctx.getContext());
AccountManager am = AccountManager.get(cordova.getActivity());

Account[] accounts;
if (obj.has("type"))
Expand Down
34 changes: 22 additions & 12 deletions Android/AccountList/accountlist.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
var AccountList = function() {};

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

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

gap.addConstructor(function () {
if (gap.addPlugin) {
gap.addPlugin("AccountList", new AccountList());
} else {
if (!window.plugins) {
window.plugins = {};
}

window.plugins.ccountList = new AccountList();
}
});

})(window.cordova || window.Cordova || window.PhoneGap);

0 comments on commit 968d1e3

Please sign in to comment.