Delete IPlugin interface.

This commit is contained in:
Andrew Grieve 2012-10-01 14:54:24 -04:00
parent 5289d569b0
commit ec3c5b2ca2
8 changed files with 20 additions and 146 deletions

View File

@ -6464,4 +6464,4 @@ window.cordova = require('cordova');
}(window));
})();
})();

View File

@ -22,7 +22,7 @@ import java.util.HashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.cordova.api.IPlugin;
import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.LOG;
import org.apache.cordova.api.CordovaInterface;
import org.json.JSONException;
@ -162,7 +162,7 @@ public class DroidGap extends Activity implements CordovaInterface {
String baseUrl = null;
// Plugin to call when activity result is received
protected IPlugin activityResultCallback = null;
protected Plugin activityResultCallback = null;
protected boolean activityResultKeepRunning;
// Default background color for activity
@ -773,7 +773,7 @@ public class DroidGap extends Activity implements CordovaInterface {
* @param intent The intent to start
* @param requestCode The request code that is passed to callback to identify the activity
*/
public void startActivityForResult(IPlugin command, Intent intent, int requestCode) {
public void startActivityForResult(Plugin command, Intent intent, int requestCode) {
this.activityResultCallback = command;
this.activityResultKeepRunning = this.keepRunning;
@ -798,13 +798,13 @@ public class DroidGap extends Activity implements CordovaInterface {
*/
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
IPlugin callback = this.activityResultCallback;
Plugin callback = this.activityResultCallback;
if (callback != null) {
callback.onActivityResult(requestCode, resultCode, intent);
}
}
public void setActivityResultCallback(IPlugin plugin) {
public void setActivityResultCallback(Plugin plugin) {
this.activityResultCallback = plugin;
}

View File

@ -38,14 +38,14 @@ public interface CordovaInterface {
* @param intent The intent to start
* @param requestCode The request code that is passed to callback to identify the activity
*/
abstract public void startActivityForResult(IPlugin command, Intent intent, int requestCode);
abstract public void startActivityForResult(Plugin 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(IPlugin plugin);
abstract public void setActivityResultCallback(Plugin plugin);
/**

View File

@ -1,126 +0,0 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.api;
import org.apache.cordova.CordovaWebView;
import org.json.JSONArray;
//import android.content.Context;
import android.content.Intent;
/**
* Plugin interface must be implemented by any plugin classes.
*
* The execute method is called by the PluginManager.
*/
public interface IPlugin {
/**
* Executes the request and returns PluginResult.
*
* @param action The action to execute.
* @param args JSONArry of arguments for the plugin.
* @param callbackId The callback id used when calling back into JavaScript.
* @return A PluginResult object with a status and message.
*/
PluginResult execute(String action, JSONArray args, String callbackId);
/**
* Identifies if action to be executed returns a value and should be run synchronously.
*
* @param action The action to execute
* @return T=returns value
*/
public boolean isSynch(String action);
/**
* Sets the context of the Plugin. This can then be used to do things like
* get file paths associated with the Activity.
*
* @param ctx The context of the main Activity.
*/
void setContext(CordovaInterface ctx);
/**
* Sets the main View of the application, this is the WebView within which
* a Cordova app runs.
*
* @param webView The Cordova WebView
*/
void setView(CordovaWebView webView);
/**
* Called when the system is about to start resuming a previous activity.
*
* @param multitasking Flag indicating if multitasking is turned on for app
*/
void onPause(boolean multitasking);
/**
* Called when the activity will start interacting with the user.
*
* @param multitasking Flag indicating if multitasking is turned on for app
*/
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.
*/
void onDestroy();
/**
* Called when a message is sent to plugin.
*
* @param id The message id
* @param data The message data
* @return Object to stop propagation or null
*/
public Object onMessage(String id, Object data);
/**
* Called when an activity you launched exits, giving you the requestCode you started it with,
* the resultCode it returned, and any additional data from it.
*
* @param requestCode The request code originally supplied to startActivityForResult(),
* allowing you to identify who this result came from.
* @param resultCode The integer result code returned by the child activity through its setResult().
* @param data An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
*/
void onActivityResult(int requestCode, int resultCode, Intent intent);
/**
* By specifying a <url-filter> in plugins.xml you can map a URL (using startsWith atm) to this method.
*
* @param url The URL that is trying to be loaded in the Cordova webview.
* @return Return true to prevent the URL from loading. Default is false.
*/
boolean onOverrideUrlLoading(String url);
/**
* Called when the WebView does a top-level navigation or refreshes.
*
* Plugins should stop any long-running processes and clean up internal state.
*/
void onReset();
}

View File

@ -65,13 +65,13 @@ public class LegacyContext implements CordovaInterface {
}
@Deprecated
public void setActivityResultCallback(IPlugin arg0) {
public void setActivityResultCallback(Plugin arg0) {
Log.i(LOG_TAG, "Replace ctx.setActivityResultCallback() with cordova.setActivityResultCallback()");
this.cordova.setActivityResultCallback(arg0);
}
@Deprecated
public void startActivityForResult(IPlugin arg0, Intent arg1, int arg2) {
public void startActivityForResult(Plugin arg0, Intent arg1, int arg2) {
Log.i(LOG_TAG, "Replace ctx.startActivityForResult() with cordova.startActivityForResult()");
this.cordova.startActivityForResult(arg0, arg1, arg2);
}

View File

@ -30,7 +30,7 @@ import android.util.Log;
*
* The execute method is called by the PluginManager.
*/
public abstract class Plugin implements IPlugin {
public abstract class Plugin {
public String id;
public CordovaWebView webView; // WebView object

View File

@ -43,7 +43,7 @@ public class PluginEntry {
* Plugin objects are only created when they are called from JavaScript. (see PluginManager.exec)
* The exception is if the onload flag is set, then they are created when PluginManager is initialized.
*/
public IPlugin plugin = null;
public Plugin plugin = null;
/**
* Flag that indicates the plugin object should be created when PluginManager is initialized.
@ -69,7 +69,7 @@ public class PluginEntry {
*
* @return The plugin object
*/
public IPlugin createPlugin(CordovaWebView webView, CordovaInterface ctx) {
public Plugin createPlugin(CordovaWebView webView, CordovaInterface ctx) {
if (this.plugin != null) {
return this.plugin;
}
@ -77,7 +77,7 @@ public class PluginEntry {
@SuppressWarnings("rawtypes")
Class c = getClassByName(this.pluginClass);
if (isCordovaPlugin(c)) {
this.plugin = (IPlugin) c.newInstance();
this.plugin = (Plugin) c.newInstance();
this.plugin.setContext(ctx);
this.plugin.setView(webView);
return plugin;
@ -115,7 +115,7 @@ public class PluginEntry {
@SuppressWarnings("rawtypes")
private boolean isCordovaPlugin(Class c) {
if (c != null) {
return org.apache.cordova.api.Plugin.class.isAssignableFrom(c) || org.apache.cordova.api.IPlugin.class.isAssignableFrom(c);
return org.apache.cordova.api.Plugin.class.isAssignableFrom(c) || org.apache.cordova.api.Plugin.class.isAssignableFrom(c);
}
return false;
}

View File

@ -213,7 +213,7 @@ public class PluginManager {
*/
public boolean exec(final String service, final String action, final String callbackId, final String jsonArgs) {
PluginResult cr = null;
final IPlugin plugin = this.getPlugin(service);
final Plugin plugin = this.getPlugin(service);
boolean runAsync = !plugin.isSynch(action);
try {
final JSONArray args = new JSONArray(jsonArgs);
@ -273,14 +273,14 @@ public class PluginManager {
* If the service doesn't exist, then return null.
*
* @param service The name of the service.
* @return IPlugin or null
* @return Plugin or null
*/
private IPlugin getPlugin(String service) {
private Plugin getPlugin(String service) {
PluginEntry entry = this.entries.get(service);
if (entry == null) {
return null;
}
IPlugin plugin = entry.plugin;
Plugin plugin = entry.plugin;
if (plugin == null) {
plugin = entry.createPlugin(this.app, this.ctx);
}
@ -403,7 +403,7 @@ public class PluginManager {
public void onReset() {
Iterator<PluginEntry> it = this.entries.values().iterator();
while (it.hasNext()) {
IPlugin plugin = it.next().plugin;
Plugin plugin = it.next().plugin;
if (plugin != null) {
plugin.onReset();
}