mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 15:12:51 +08:00
Merge branch 'master' of git://github.com/phonegap/phonegap-android
This commit is contained in:
commit
ebd92a4b12
@ -49,7 +49,7 @@ import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.phonegap.api.PhonegapActivity;
|
||||
import com.phonegap.api.Plugin;
|
||||
import com.phonegap.api.IPlugin;
|
||||
import com.phonegap.api.PluginManager;
|
||||
|
||||
/**
|
||||
@ -140,7 +140,7 @@ public class DroidGap extends PhonegapActivity {
|
||||
private String baseUrl = null;
|
||||
|
||||
// Plugin to call when activity result is received
|
||||
protected Plugin activityResultCallback = null;
|
||||
protected IPlugin activityResultCallback = null;
|
||||
protected boolean activityResultKeepRunning;
|
||||
|
||||
// Flag indicates that a loadUrl timeout occurred
|
||||
@ -1288,7 +1288,7 @@ public class DroidGap extends PhonegapActivity {
|
||||
* @param intent The intent to start
|
||||
* @param requestCode The request code that is passed to callback to identify the activity
|
||||
*/
|
||||
public void startActivityForResult(Plugin command, Intent intent, int requestCode) {
|
||||
public void startActivityForResult(IPlugin command, Intent intent, int requestCode) {
|
||||
this.activityResultCallback = command;
|
||||
this.activityResultKeepRunning = this.keepRunning;
|
||||
|
||||
@ -1313,14 +1313,14 @@ public class DroidGap extends PhonegapActivity {
|
||||
*/
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
Plugin callback = this.activityResultCallback;
|
||||
IPlugin callback = this.activityResultCallback;
|
||||
if (callback != null) {
|
||||
callback.onActivityResult(requestCode, resultCode, intent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActivityResultCallback(Plugin plugin) {
|
||||
public void setActivityResultCallback(IPlugin plugin) {
|
||||
this.activityResultCallback = plugin;
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,11 @@ public interface IPlugin {
|
||||
*/
|
||||
void onResume(boolean multitasking);
|
||||
|
||||
/**
|
||||
* Called when the activity receives a new intent.
|
||||
*/
|
||||
void onNewIntent(Intent intent);
|
||||
|
||||
/**
|
||||
* The final call you receive before your activity is destroyed.
|
||||
*/
|
||||
|
@ -39,12 +39,12 @@ public abstract class PhonegapActivity extends Activity {
|
||||
* @param intent The intent to start
|
||||
* @param requestCode The request code that is passed to callback to identify the activity
|
||||
*/
|
||||
abstract public void startActivityForResult(Plugin command, Intent intent, int requestCode);
|
||||
abstract public void startActivityForResult(IPlugin command, Intent intent, int requestCode);
|
||||
|
||||
/**
|
||||
* Set the plugin to be called when a sub-activity exits.
|
||||
*
|
||||
* @param plugin The plugin on which onActivityResult is to be called
|
||||
*/
|
||||
abstract public void setActivityResultCallback(Plugin plugin);
|
||||
abstract public void setActivityResultCallback(IPlugin plugin);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import android.webkit.WebView;
|
||||
*/
|
||||
public final class PluginManager {
|
||||
|
||||
private HashMap<String, Plugin> plugins = new HashMap<String,Plugin>();
|
||||
private HashMap<String, IPlugin> plugins = new HashMap<String,IPlugin>();
|
||||
private HashMap<String, String> services = new HashMap<String,String>();
|
||||
|
||||
private final PhonegapActivity ctx;
|
||||
@ -105,7 +105,7 @@ public final class PluginManager {
|
||||
c = getClassByName(clazz);
|
||||
}
|
||||
if (isPhoneGapPlugin(c)) {
|
||||
final Plugin plugin = this.addPlugin(clazz, c);
|
||||
final IPlugin plugin = this.addPlugin(clazz, c);
|
||||
final PhonegapActivity ctx = this.ctx;
|
||||
runAsync = async && !plugin.isSynch(action);
|
||||
if (runAsync) {
|
||||
@ -201,12 +201,12 @@ public final class PluginManager {
|
||||
* @return The plugin
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private Plugin addPlugin(String className, Class clazz) {
|
||||
private IPlugin addPlugin(String className, Class clazz) {
|
||||
if (this.plugins.containsKey(className)) {
|
||||
return this.getPlugin(className);
|
||||
}
|
||||
try {
|
||||
Plugin plugin = (Plugin)clazz.newInstance();
|
||||
IPlugin plugin = (IPlugin)clazz.newInstance();
|
||||
this.plugins.put(className, plugin);
|
||||
plugin.setContext(this.ctx);
|
||||
plugin.setView(this.app);
|
||||
@ -225,8 +225,8 @@ public final class PluginManager {
|
||||
* @param className The class of the loaded plugin.
|
||||
* @return
|
||||
*/
|
||||
private Plugin getPlugin(String className) {
|
||||
Plugin plugin = this.plugins.get(className);
|
||||
private IPlugin getPlugin(String className) {
|
||||
IPlugin plugin = this.plugins.get(className);
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@ -247,11 +247,11 @@ public final class PluginManager {
|
||||
* @param multitasking Flag indicating if multitasking is turned on for app
|
||||
*/
|
||||
public void onPause(boolean multitasking) {
|
||||
java.util.Set<Entry<String,Plugin>> s = this.plugins.entrySet();
|
||||
java.util.Iterator<Entry<String,Plugin>> it = s.iterator();
|
||||
java.util.Set<Entry<String,IPlugin>> s = this.plugins.entrySet();
|
||||
java.util.Iterator<Entry<String,IPlugin>> it = s.iterator();
|
||||
while(it.hasNext()) {
|
||||
Entry<String,Plugin> entry = it.next();
|
||||
Plugin plugin = entry.getValue();
|
||||
Entry<String,IPlugin> entry = it.next();
|
||||
IPlugin plugin = entry.getValue();
|
||||
plugin.onPause(multitasking);
|
||||
}
|
||||
}
|
||||
@ -262,11 +262,11 @@ public final class PluginManager {
|
||||
* @param multitasking Flag indicating if multitasking is turned on for app
|
||||
*/
|
||||
public void onResume(boolean multitasking) {
|
||||
java.util.Set<Entry<String,Plugin>> s = this.plugins.entrySet();
|
||||
java.util.Iterator<Entry<String,Plugin>> it = s.iterator();
|
||||
java.util.Set<Entry<String,IPlugin>> s = this.plugins.entrySet();
|
||||
java.util.Iterator<Entry<String,IPlugin>> it = s.iterator();
|
||||
while(it.hasNext()) {
|
||||
Entry<String,Plugin> entry = it.next();
|
||||
Plugin plugin = entry.getValue();
|
||||
Entry<String,IPlugin> entry = it.next();
|
||||
IPlugin plugin = entry.getValue();
|
||||
plugin.onResume(multitasking);
|
||||
}
|
||||
}
|
||||
@ -275,11 +275,11 @@ public final class PluginManager {
|
||||
* The final call you receive before your activity is destroyed.
|
||||
*/
|
||||
public void onDestroy() {
|
||||
java.util.Set<Entry<String,Plugin>> s = this.plugins.entrySet();
|
||||
java.util.Iterator<Entry<String,Plugin>> it = s.iterator();
|
||||
java.util.Set<Entry<String,IPlugin>> s = this.plugins.entrySet();
|
||||
java.util.Iterator<Entry<String,IPlugin>> it = s.iterator();
|
||||
while(it.hasNext()) {
|
||||
Entry<String,Plugin> entry = it.next();
|
||||
Plugin plugin = entry.getValue();
|
||||
Entry<String,IPlugin> entry = it.next();
|
||||
IPlugin plugin = entry.getValue();
|
||||
plugin.onDestroy();
|
||||
}
|
||||
}
|
||||
@ -288,11 +288,11 @@ public final class PluginManager {
|
||||
* Called when the activity receives a new intent.
|
||||
*/
|
||||
public void onNewIntent(Intent intent) {
|
||||
java.util.Set<Entry<String,Plugin>> s = this.plugins.entrySet();
|
||||
java.util.Iterator<Entry<String,Plugin>> it = s.iterator();
|
||||
java.util.Set<Entry<String,IPlugin>> s = this.plugins.entrySet();
|
||||
java.util.Iterator<Entry<String,IPlugin>> it = s.iterator();
|
||||
while(it.hasNext()) {
|
||||
Entry<String,Plugin> entry = it.next();
|
||||
Plugin plugin = entry.getValue();
|
||||
Entry<String,IPlugin> entry = it.next();
|
||||
IPlugin plugin = entry.getValue();
|
||||
plugin.onNewIntent(intent);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user