Commit 78b38b5a authored by Albert Vaca Cintora's avatar Albert Vaca Cintora

Use ClassIndex to create a list of plugins in compile time

Instead of manually initializing a map statically.
parent 33c9f70c
......@@ -83,6 +83,9 @@ dependencies {
implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
implementation 'org.atteo.classindex:classindex:3.6'
annotationProcessor 'org.atteo.classindex:classindex:3.6'
// Testing
androidTestImplementation 'org.mockito:mockito-core:1.10.19'
androidTestImplementation 'com.google.dexmaker:dexmaker-mockito:1.1'// Because mockito has some problems with dex environment
......
......@@ -43,3 +43,4 @@
-dontwarn sun.reflect.**
-dontwarn android.test.**
-dontwarn java.lang.management.**
-dontwarn javax.**
......@@ -42,6 +42,7 @@ import org.kde.kdeconnect.Helpers.NotificationHelper;
import org.kde.kdeconnect.Helpers.SecurityHelpers.RsaHelper;
import org.kde.kdeconnect.Helpers.SecurityHelpers.SslHelper;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect.UserInterface.MainActivity;
import org.kde.kdeconnect_tp.R;
......@@ -284,6 +285,7 @@ public class BackgroundService extends Service {
Log.i("KDE/BackgroundService", "Service not started yet, initializing...");
PluginFactory.initPluginInfo(getBaseContext());
initializeSecurityParameters();
NotificationHelper.initializeChannels(this);
loadRememberedDevicesFromSettings();
......
......@@ -513,7 +513,7 @@ public class Device implements BaseLink.PacketReceiver {
Set<String> outgoingCapabilities = identityPacket.getStringSet("outgoingCapabilities", null);
Set<String> incomingCapabilities = identityPacket.getStringSet("incomingCapabilities", null);
if (incomingCapabilities != null && outgoingCapabilities != null) {
m_supportedPlugins = new Vector<>(PluginFactory.pluginsForCapabilities(context, incomingCapabilities, outgoingCapabilities));
m_supportedPlugins = new Vector<>(PluginFactory.pluginsForCapabilities(incomingCapabilities, outgoingCapabilities));
} else {
m_supportedPlugins = new Vector<>(PluginFactory.getAvailablePlugins());
}
......@@ -808,7 +808,7 @@ public class Device implements BaseLink.PacketReceiver {
}
public boolean isPluginEnabled(String pluginKey) {
boolean enabledByDefault = PluginFactory.getPluginInfo(context, pluginKey).isEnabledByDefault();
boolean enabledByDefault = PluginFactory.getPluginInfo(pluginKey).isEnabledByDefault();
return settings.getBoolean(pluginKey, enabledByDefault);
}
......@@ -820,7 +820,7 @@ public class Device implements BaseLink.PacketReceiver {
for (String pluginKey : m_supportedPlugins) {
PluginFactory.PluginInfo pluginInfo = PluginFactory.getPluginInfo(context, pluginKey);
PluginFactory.PluginInfo pluginInfo = PluginFactory.getPluginInfo(pluginKey);
boolean pluginEnabled = false;
boolean listenToUnpaired = pluginInfo.listenToUnpaired();
......
......@@ -276,8 +276,8 @@ public class NetworkPacket {
np.mBody.put("deviceName", DeviceHelper.getDeviceName(context));
np.mBody.put("protocolVersion", NetworkPacket.ProtocolVersion);
np.mBody.put("deviceType", DeviceHelper.getDeviceType(context).toString());
np.mBody.put("incomingCapabilities", new JSONArray(PluginFactory.getIncomingCapabilities(context)));
np.mBody.put("outgoingCapabilities", new JSONArray(PluginFactory.getOutgoingCapabilities(context)));
np.mBody.put("incomingCapabilities", new JSONArray(PluginFactory.getIncomingCapabilities()));
np.mBody.put("outgoingCapabilities", new JSONArray(PluginFactory.getOutgoingCapabilities()));
} catch (Exception e) {
e.printStackTrace();
Log.e("NetworkPacakge", "Exception on createIdentityPacket");
......
......@@ -28,9 +28,10 @@ import android.os.BatteryManager;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
@PluginFactory.LoadablePlugin
public class BatteryPlugin extends Plugin {
private final static String PACKET_TYPE_BATTERY = "kdeconnect.battery";
......
......@@ -22,8 +22,10 @@ package org.kde.kdeconnect.Plugins.ClibpoardPlugin;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
@PluginFactory.LoadablePlugin
public class ClipboardPlugin extends Plugin {
private final static String PACKET_TYPE_CLIPBOARD = "kdeconnect.clipboard";
......
......@@ -34,6 +34,7 @@ import org.kde.kdeconnect.Helpers.ContactsHelper.VCardBuilder;
import org.kde.kdeconnect.Helpers.ContactsHelper.uID;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
import java.util.ArrayList;
......@@ -43,6 +44,7 @@ import java.util.Map;
import java.util.Set;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@PluginFactory.LoadablePlugin
public class ContactsPlugin extends Plugin {
/**
......
......@@ -25,9 +25,11 @@ import android.content.Intent;
import org.kde.kdeconnect.Helpers.DeviceHelper;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect.UserInterface.PluginSettingsFragment;
import org.kde.kdeconnect_tp.R;
@PluginFactory.LoadablePlugin
public class FindMyPhonePlugin extends Plugin {
public final static String PACKET_TYPE_FINDMYPHONE_REQUEST = "kdeconnect.findmyphone.request";
......
......@@ -25,9 +25,10 @@ import android.app.Activity;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.FindMyPhonePlugin.FindMyPhonePlugin;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
@PluginFactory.LoadablePlugin
public class FindRemoteDevicePlugin extends Plugin {
@Override
......
......@@ -26,10 +26,12 @@ import android.graphics.drawable.Drawable;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
import androidx.core.content.ContextCompat;
@PluginFactory.LoadablePlugin
public class MousePadPlugin extends Plugin {
//public final static String PACKET_TYPE_MOUSEPAD = "kdeconnect.mousepad";
......
......@@ -30,6 +30,7 @@ import android.util.Log;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
import java.net.MalformedURLException;
......@@ -42,6 +43,7 @@ import java.util.List;
import androidx.core.content.ContextCompat;
@PluginFactory.LoadablePlugin
public class MprisPlugin extends Plugin {
public class MprisPlayer {
private String player = "";
......
......@@ -46,6 +46,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
//@PluginFactory.LoadablePlugin
public class MprisReceiverPlugin extends Plugin implements MediaSessionManager.OnActiveSessionsChangedListener {
private final static String PACKET_TYPE_MPRIS = "kdeconnect.mpris";
......
......@@ -42,6 +42,7 @@ import android.util.Log;
import org.kde.kdeconnect.Helpers.AppsHelper;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect.UserInterface.AlertDialogFragment;
import org.kde.kdeconnect.UserInterface.MainActivity;
import org.kde.kdeconnect.UserInterface.PluginSettingsFragment;
......@@ -61,6 +62,7 @@ import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@PluginFactory.LoadablePlugin
public class NotificationsPlugin extends Plugin implements NotificationReceiver.NotificationListener {
private final static String PACKET_TYPE_NOTIFICATION = "kdeconnect.notification";
......
......@@ -31,12 +31,13 @@ import android.util.Log;
import org.kde.kdeconnect.Helpers.NotificationHelper;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect.UserInterface.MainActivity;
import org.kde.kdeconnect_tp.R;
import androidx.core.app.NotificationCompat;
@PluginFactory.LoadablePlugin
public class PingPlugin extends Plugin {
private final static String PACKET_TYPE_PING = "kdeconnect.ping";
......
......@@ -24,25 +24,9 @@ import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.Log;
import org.atteo.classindex.ClassIndex;
import org.atteo.classindex.IndexAnnotated;
import org.kde.kdeconnect.Device;
import org.kde.kdeconnect.Plugins.BatteryPlugin.BatteryPlugin;
import org.kde.kdeconnect.Plugins.ClibpoardPlugin.ClipboardPlugin;
import org.kde.kdeconnect.Plugins.ContactsPlugin.ContactsPlugin;
import org.kde.kdeconnect.Plugins.FindMyPhonePlugin.FindMyPhonePlugin;
import org.kde.kdeconnect.Plugins.FindRemoteDevicePlugin.FindRemoteDevicePlugin;
import org.kde.kdeconnect.Plugins.MousePadPlugin.MousePadPlugin;
import org.kde.kdeconnect.Plugins.MprisPlugin.MprisPlugin;
import org.kde.kdeconnect.Plugins.NotificationsPlugin.NotificationsPlugin;
import org.kde.kdeconnect.Plugins.PingPlugin.PingPlugin;
import org.kde.kdeconnect.Plugins.PresenterPlugin.PresenterPlugin;
import org.kde.kdeconnect.Plugins.ReceiveNotificationsPlugin.ReceiveNotificationsPlugin;
import org.kde.kdeconnect.Plugins.RemoteKeyboardPlugin.RemoteKeyboardPlugin;
import org.kde.kdeconnect.Plugins.RunCommandPlugin.RunCommandPlugin;
import org.kde.kdeconnect.Plugins.SftpPlugin.SftpPlugin;
import org.kde.kdeconnect.Plugins.SharePlugin.SharePlugin;
import org.kde.kdeconnect.Plugins.SystemvolumePlugin.SystemvolumePlugin;
import org.kde.kdeconnect.Plugins.SMSPlugin.SMSPlugin;
import org.kde.kdeconnect.Plugins.TelephonyPlugin.TelephonyPlugin;
import java.util.Collections;
import java.util.HashSet;
......@@ -52,11 +36,15 @@ import java.util.concurrent.ConcurrentHashMap;
public class PluginFactory {
@IndexAnnotated
public @interface LoadablePlugin { } //Annotate plugins with this so PluginFactory finds them
public static class PluginInfo {
PluginInfo(String displayName, String description, Drawable icon,
boolean enabledByDefault, boolean hasSettings, boolean listenToUnpaired,
String[] supportedPacketTypes, String[] outgoingPacketTypes) {
String[] supportedPacketTypes, String[] outgoingPacketTypes,
Class<? extends Plugin> instantiableClass) {
this.displayName = displayName;
this.description = description;
this.icon = icon;
......@@ -69,6 +57,7 @@ public class PluginFactory {
HashSet<String> outgoing = new HashSet<>();
if (outgoingPacketTypes != null) Collections.addAll(outgoing, outgoingPacketTypes);
this.outgoingPacketTypes = Collections.unmodifiableSet(outgoing);
this.instantiableClass = instantiableClass;
}
public String getDisplayName() {
......@@ -103,6 +92,10 @@ public class PluginFactory {
return supportedPacketTypes;
}
Class<? extends Plugin> getInstantiableClass() {
return instantiableClass;
}
private final String displayName;
private final String description;
private final Drawable icon;
......@@ -111,70 +104,40 @@ public class PluginFactory {
private final boolean listenToUnpaired;
private final Set<String> supportedPacketTypes;
private final Set<String> outgoingPacketTypes;
private final Class<? extends Plugin> instantiableClass;
}
private static final Map<String, Class> availablePlugins = new ConcurrentHashMap<>();
private static final Map<String, PluginInfo> pluginInfoCache = new ConcurrentHashMap<>();
static {
PluginFactory.registerPlugin(TelephonyPlugin.class);
PluginFactory.registerPlugin(PingPlugin.class);
PluginFactory.registerPlugin(MprisPlugin.class);
PluginFactory.registerPlugin(ClipboardPlugin.class);
PluginFactory.registerPlugin(BatteryPlugin.class);
PluginFactory.registerPlugin(SftpPlugin.class);
PluginFactory.registerPlugin(NotificationsPlugin.class);
PluginFactory.registerPlugin(ReceiveNotificationsPlugin.class);
PluginFactory.registerPlugin(MousePadPlugin.class);
PluginFactory.registerPlugin(PresenterPlugin.class);
PluginFactory.registerPlugin(SharePlugin.class);
PluginFactory.registerPlugin(SMSPlugin.class);
PluginFactory.registerPlugin(FindMyPhonePlugin.class);
PluginFactory.registerPlugin(RunCommandPlugin.class);
PluginFactory.registerPlugin(ContactsPlugin.class);
PluginFactory.registerPlugin(RemoteKeyboardPlugin.class);
PluginFactory.registerPlugin(SystemvolumePlugin.class);
//PluginFactory.registerPlugin(MprisReceiverPlugin.class);
PluginFactory.registerPlugin(FindRemoteDevicePlugin.class);
}
public static PluginInfo getPluginInfo(Context context, String pluginKey) {
private static final Map<String, PluginInfo> pluginInfo = new ConcurrentHashMap<>();
PluginInfo info = pluginInfoCache.get(pluginKey); //Is it cached?
if (info != null) {
return info;
}
public static PluginInfo getPluginInfo(String pluginKey) {
return pluginInfo.get(pluginKey);
}
public static void initPluginInfo(Context context) {
try {
Plugin p = ((Plugin) availablePlugins.get(pluginKey).newInstance());
p.setContext(context, null);
info = new PluginInfo(p.getDisplayName(), p.getDescription(), p.getIcon(),
p.isEnabledByDefault(), p.hasSettings(), p.listensToUnpairedDevices(),
p.getSupportedPacketTypes(), p.getOutgoingPacketTypes());
pluginInfoCache.put(pluginKey, info); //Cache it
return info;
for (Class<?> pluginClass : ClassIndex.getAnnotated(LoadablePlugin.class)) {
Plugin p = ((Plugin) pluginClass.newInstance());
p.setContext(context, null);
PluginInfo info = new PluginInfo(p.getDisplayName(), p.getDescription(), p.getIcon(),
p.isEnabledByDefault(), p.hasSettings(), p.listensToUnpairedDevices(),
p.getSupportedPacketTypes(), p.getOutgoingPacketTypes(), p.getClass());
pluginInfo.put(p.getPluginKey(), info);
}
} catch (Exception e) {
Log.e("PluginFactory", "getPluginInfo exception");
e.printStackTrace();
throw new RuntimeException(e);
}
Log.i("PluginFactory","Loaded "+pluginInfo.size()+" plugins");
}
public static Set<String> getAvailablePlugins() {
return availablePlugins.keySet();
return pluginInfo.keySet();
}
public static Plugin instantiatePluginForDevice(Context context, String pluginKey, Device device) {
Class c = availablePlugins.get(pluginKey);
if (c == null) {
Log.e("PluginFactory", "Plugin not found: " + pluginKey);
return null;
}
PluginInfo info = pluginInfo.get(pluginKey);
try {
Plugin plugin = (Plugin) c.newInstance();
Plugin plugin = info.getInstantiableClass().newInstance();
plugin.setContext(context, device);
return plugin;
} catch (Exception e) {
......@@ -182,46 +145,32 @@ public class PluginFactory {
e.printStackTrace();
return null;
}
}
private static void registerPlugin(Class<? extends Plugin> pluginClass) {
try {
String pluginKey = Plugin.getPluginKey(pluginClass);
availablePlugins.put(pluginKey, pluginClass);
} catch (Exception e) {
Log.e("PluginFactory", "addPlugin exception");
e.printStackTrace();
}
}
public static Set<String> getIncomingCapabilities(Context context) {
public static Set<String> getIncomingCapabilities() {
HashSet<String> capabilities = new HashSet<>();
for (String pluginId : availablePlugins.keySet()) {
PluginInfo plugin = getPluginInfo(context, pluginId);
for (PluginInfo plugin : pluginInfo.values()) {
capabilities.addAll(plugin.getSupportedPacketTypes());
}
return capabilities;
}
public static Set<String> getOutgoingCapabilities(Context context) {
public static Set<String> getOutgoingCapabilities() {
HashSet<String> capabilities = new HashSet<>();
for (String pluginId : availablePlugins.keySet()) {
PluginInfo plugin = getPluginInfo(context, pluginId);
for (PluginInfo plugin : pluginInfo.values()) {
capabilities.addAll(plugin.getOutgoingPacketTypes());
}
return capabilities;
}
public static Set<String> pluginsForCapabilities(Context context, Set<String> incoming, Set<String> outgoing) {
public static Set<String> pluginsForCapabilities(Set<String> incoming, Set<String> outgoing) {
HashSet<String> plugins = new HashSet<>();
for (String pluginId : availablePlugins.keySet()) {
PluginInfo plugin = getPluginInfo(context, pluginId);
for (Map.Entry<String, PluginInfo> entry : pluginInfo.entrySet()) {
String pluginId = entry.getKey();
PluginInfo info = entry.getValue();
//Check incoming against outgoing
if (Collections.disjoint(outgoing, plugin.getSupportedPacketTypes())
&& Collections.disjoint(incoming, plugin.getOutgoingPacketTypes())) {
if (Collections.disjoint(outgoing, info.getSupportedPacketTypes())
&& Collections.disjoint(incoming, info.getOutgoingPacketTypes())) {
Log.i("PluginFactory", "Won't load " + pluginId + " because of unmatched capabilities");
continue; //No capabilities in common, do not load this plugin
}
......
......@@ -28,12 +28,14 @@ import android.view.KeyEvent;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
import androidx.core.content.ContextCompat;
import static org.kde.kdeconnect.Plugins.MousePadPlugin.KeyListenerView.SpecialKeysMap;
@PluginFactory.LoadablePlugin
public class PresenterPlugin extends Plugin {
private final static String PACKET_TYPE_MOUSEPAD_REQUEST = "kdeconnect.mousepad.request";
......
......@@ -32,6 +32,7 @@ import android.util.Log;
import org.kde.kdeconnect.Helpers.NotificationHelper;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect.UserInterface.MainActivity;
import org.kde.kdeconnect_tp.R;
......@@ -39,6 +40,7 @@ import java.io.InputStream;
import androidx.core.app.NotificationCompat;
@PluginFactory.LoadablePlugin
public class ReceiveNotificationsPlugin extends Plugin {
private final static String PACKET_TYPE_NOTIFICATION = "kdeconnect.notification";
......
......@@ -33,6 +33,7 @@ import android.view.inputmethod.InputConnection;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
import java.util.ArrayList;
......@@ -41,6 +42,7 @@ import java.util.concurrent.locks.ReentrantLock;
import androidx.core.content.ContextCompat;
import androidx.core.util.Pair;
@PluginFactory.LoadablePlugin
public class RemoteKeyboardPlugin extends Plugin {
private final static String PACKET_TYPE_MOUSEPAD_REQUEST = "kdeconnect.mousepad.request";
......
......@@ -29,6 +29,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
import java.util.ArrayList;
......@@ -37,6 +38,7 @@ import java.util.Iterator;
import androidx.core.content.ContextCompat;
@PluginFactory.LoadablePlugin
public class RunCommandPlugin extends Plugin {
private final static String PACKET_TYPE_RUNCOMMAND = "kdeconnect.runcommand";
......
......@@ -44,6 +44,7 @@ import org.kde.kdeconnect.Helpers.ContactsHelper;
import org.kde.kdeconnect.Helpers.SMSHelper;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect.Plugins.TelephonyPlugin.TelephonyPlugin;
import org.kde.kdeconnect_tp.BuildConfig;
import org.kde.kdeconnect_tp.R;
......@@ -59,6 +60,7 @@ import androidx.core.content.ContextCompat;
import static org.kde.kdeconnect.Plugins.TelephonyPlugin.TelephonyPlugin.PACKET_TYPE_TELEPHONY;
@PluginFactory.LoadablePlugin
public class SMSPlugin extends Plugin {
/**
......
......@@ -27,12 +27,14 @@ import android.os.Environment;
import org.kde.kdeconnect.Helpers.StorageHelper;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@PluginFactory.LoadablePlugin
public class SftpPlugin extends Plugin {
private final static String PACKET_TYPE_SFTP = "kdeconnect.sftp";
......
......@@ -43,6 +43,7 @@ import android.widget.Toast;
import org.kde.kdeconnect.Helpers.NotificationHelper;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect.UserInterface.PluginSettingsFragment;
import org.kde.kdeconnect_tp.R;
......@@ -57,6 +58,7 @@ import androidx.annotation.WorkerThread;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
@PluginFactory.LoadablePlugin
public class SharePlugin extends Plugin {
private final static String PACKET_TYPE_SHARE_REQUEST = "kdeconnect.share.request";
final static String PACKET_TYPE_SHARE_REQUEST_UPDATE = "kdeconnect.share.request.update";
......
......@@ -25,13 +25,14 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@PluginFactory.LoadablePlugin
public class SystemvolumePlugin extends Plugin {
private final static String PACKET_TYPE_SYSTEMVOLUME = "kdeconnect.systemvolume";
......
......@@ -37,6 +37,7 @@ import android.util.Log;
import org.kde.kdeconnect.Helpers.ContactsHelper;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
import java.util.Map;
......@@ -45,6 +46,7 @@ import java.util.TimerTask;
import androidx.core.content.ContextCompat;
@PluginFactory.LoadablePlugin
public class TelephonyPlugin extends Plugin {
......
......@@ -26,7 +26,7 @@ class PluginPreference extends CheckBoxPreference {
this.device = device;
this.pluginKey = pluginKey;
PluginFactory.PluginInfo info = PluginFactory.getPluginInfo(context, pluginKey);
PluginFactory.PluginInfo info = PluginFactory.getPluginInfo(pluginKey);
setTitle(info.getDisplayName());
setSummary(info.getDescription());
setIcon(android.R.color.transparent);
......
......@@ -75,7 +75,7 @@ public class PluginSettingsFragment extends PreferenceFragmentCompat {
public void onResume() {
super.onResume();
PluginFactory.PluginInfo info = PluginFactory.getPluginInfo(requireContext(), pluginKey);
PluginFactory.PluginInfo info = PluginFactory.getPluginInfo(pluginKey);
requireActivity().setTitle(getString(R.string.plugin_settings_with_name, info.getDisplayName()));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment