mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-30 21:55:10 +00:00
Use capabilities to enable presenter pointer
This commit is contained in:
@@ -49,6 +49,7 @@ import java.security.spec.PKCS8EncodedKeySpec;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -86,6 +87,11 @@ public class Device implements BaseLink.PacketReceiver {
|
|||||||
private final SharedPreferences settings;
|
private final SharedPreferences settings;
|
||||||
|
|
||||||
private final CopyOnWriteArrayList<PluginsChangedListener> pluginsChangedListeners = new CopyOnWriteArrayList<>();
|
private final CopyOnWriteArrayList<PluginsChangedListener> pluginsChangedListeners = new CopyOnWriteArrayList<>();
|
||||||
|
private Set<String> incomingCapabilities = new HashSet<>();
|
||||||
|
|
||||||
|
public boolean supportsPacketType(String type) {
|
||||||
|
return incomingCapabilities.contains(type);
|
||||||
|
}
|
||||||
|
|
||||||
public interface PluginsChangedListener {
|
public interface PluginsChangedListener {
|
||||||
void onPluginsChanged(Device device);
|
void onPluginsChanged(Device device);
|
||||||
@@ -492,12 +498,14 @@ public class Device implements BaseLink.PacketReceiver {
|
|||||||
|
|
||||||
Set<String> outgoingCapabilities = identityPacket.getStringSet("outgoingCapabilities", null);
|
Set<String> outgoingCapabilities = identityPacket.getStringSet("outgoingCapabilities", null);
|
||||||
Set<String> incomingCapabilities = identityPacket.getStringSet("incomingCapabilities", null);
|
Set<String> incomingCapabilities = identityPacket.getStringSet("incomingCapabilities", null);
|
||||||
|
|
||||||
|
|
||||||
if (incomingCapabilities != null && outgoingCapabilities != null) {
|
if (incomingCapabilities != null && outgoingCapabilities != null) {
|
||||||
supportedPlugins = new Vector<>(PluginFactory.pluginsForCapabilities(incomingCapabilities, outgoingCapabilities));
|
supportedPlugins = new Vector<>(PluginFactory.pluginsForCapabilities(incomingCapabilities, outgoingCapabilities));
|
||||||
} else {
|
} else {
|
||||||
supportedPlugins = new Vector<>(PluginFactory.getAvailablePlugins());
|
supportedPlugins = new Vector<>(PluginFactory.getAvailablePlugins());
|
||||||
}
|
}
|
||||||
|
this.incomingCapabilities = incomingCapabilities;
|
||||||
|
|
||||||
reloadPluginsFromSettings();
|
reloadPluginsFromSettings();
|
||||||
|
|
||||||
|
@@ -44,7 +44,7 @@ public class PresenterPlugin extends Plugin {
|
|||||||
private final static String PACKET_TYPE_MOUSEPAD_REQUEST = "kdeconnect.mousepad.request";
|
private final static String PACKET_TYPE_MOUSEPAD_REQUEST = "kdeconnect.mousepad.request";
|
||||||
|
|
||||||
public boolean isPointerSupported() {
|
public boolean isPointerSupported() {
|
||||||
return true; //TODO: Check capabilities
|
return device.supportsPacketType(PACKET_TYPE_PRESENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user