2013-09-05 01:37:59 +02:00
|
|
|
package org.kde.kdeconnect.Plugins;
|
2013-08-16 10:31:01 +02:00
|
|
|
|
2013-08-19 19:57:29 +02:00
|
|
|
import android.app.Activity;
|
|
|
|
import android.app.AlertDialog;
|
2013-08-16 10:31:01 +02:00
|
|
|
import android.content.Context;
|
2013-08-19 19:57:29 +02:00
|
|
|
import android.graphics.drawable.Drawable;
|
2013-09-03 17:58:59 +02:00
|
|
|
import android.widget.Button;
|
2013-08-16 10:31:01 +02:00
|
|
|
|
2013-09-05 01:37:59 +02:00
|
|
|
import org.kde.kdeconnect.Device;
|
|
|
|
import org.kde.kdeconnect.NetworkPackage;
|
2013-08-16 10:31:01 +02:00
|
|
|
|
|
|
|
public abstract class Plugin {
|
|
|
|
|
|
|
|
protected Device device;
|
|
|
|
protected Context context;
|
|
|
|
|
|
|
|
public void setContext(Context context, Device device) {
|
|
|
|
this.device = device;
|
|
|
|
this.context = context;
|
|
|
|
}
|
|
|
|
|
2013-08-19 19:57:29 +02:00
|
|
|
/**
|
|
|
|
* Return the internal plugin name, that will be used as a
|
|
|
|
* unique key to distinguish it. This function can not access
|
|
|
|
* this.context nor this.device.
|
|
|
|
*/
|
|
|
|
public abstract String getPluginName();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the human-readable plugin name. This function can
|
|
|
|
* access this.context to provide translated text.
|
|
|
|
*/
|
|
|
|
public abstract String getDisplayName();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the human-readable description of this plugin. This
|
|
|
|
* function can access this.context to provide translated text.
|
|
|
|
*/
|
|
|
|
public abstract String getDescription();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an icon associated to this plugin. This function can
|
|
|
|
* access this.context to load the image from resources.
|
|
|
|
*/
|
|
|
|
public abstract Drawable getIcon();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if this plugin should be enabled on new devices.
|
|
|
|
* This function can access this.context and perform compatibility
|
|
|
|
* checks with the Android version, but can not access this.device.
|
|
|
|
*/
|
|
|
|
public abstract boolean isEnabledByDefault();
|
|
|
|
|
2014-09-16 15:45:31 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if this plugin needs an specific UI settings.
|
|
|
|
*/
|
|
|
|
public abstract boolean hasSettings();
|
|
|
|
|
2013-08-19 19:57:29 +02:00
|
|
|
/**
|
|
|
|
* Initialize the listeners and structures in your plugin.
|
|
|
|
* Should return true if initialization was successful.
|
|
|
|
*/
|
2013-08-16 10:31:01 +02:00
|
|
|
public abstract boolean onCreate();
|
2013-08-19 19:57:29 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Finish any ongoing operations, remove listeners... so
|
2013-09-03 17:58:59 +02:00
|
|
|
* this object could be garbage collected.
|
2013-08-19 19:57:29 +02:00
|
|
|
*/
|
2013-08-16 10:31:01 +02:00
|
|
|
public abstract void onDestroy();
|
2013-08-19 19:57:29 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If onCreate returns false, should create a dialog explaining
|
2013-09-03 17:58:59 +02:00
|
|
|
* the problem (and how to fix it, if possible) to the user.
|
2013-08-19 19:57:29 +02:00
|
|
|
*/
|
2013-08-16 10:31:01 +02:00
|
|
|
public abstract boolean onPackageReceived(NetworkPackage np);
|
|
|
|
|
2013-08-19 19:57:29 +02:00
|
|
|
/**
|
|
|
|
* If onCreate returns false, should create a dialog explaining
|
2013-09-03 17:58:59 +02:00
|
|
|
* the problem (and how to fix it, if possible) to the user.
|
2013-08-19 19:57:29 +02:00
|
|
|
*/
|
2014-09-20 10:52:03 +02:00
|
|
|
public abstract AlertDialog getErrorDialog(Activity deviceActivity);
|
2013-08-19 19:57:29 +02:00
|
|
|
|
2013-09-03 17:58:59 +02:00
|
|
|
/**
|
|
|
|
* Creates a button that will be displayed in the user interface
|
|
|
|
* It can open an activity or perform any other action that the
|
|
|
|
* plugin would wants to expose to the user. Return null if no
|
|
|
|
* button should be displayed.
|
|
|
|
*/
|
|
|
|
public abstract Button getInterfaceButton(Activity activity);
|
|
|
|
|
2013-08-21 21:30:25 +02:00
|
|
|
|
2013-08-16 10:31:01 +02:00
|
|
|
}
|