Search in sources :

Example 11 with NetworkPacket

use of org.kde.kdeconnect.NetworkPacket in project kdeconnect-android by KDE.

the class LoopbackLinkProvider method onNetworkChange.

@Override
public void onNetworkChange() {
    NetworkPacket np = NetworkPacket.createIdentityPacket(context);
    connectionAccepted(np, new LoopbackLink(context, this));
}
Also used : NetworkPacket(org.kde.kdeconnect.NetworkPacket)

Example 12 with NetworkPacket

use of org.kde.kdeconnect.NetworkPacket in project kdeconnect-android by KDE.

the class KeyListenerView method onKeyUp.

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        // We don't want to swallow the back button press
        return false;
    }
    // NOTE: Most keyboards, and specifically the Android default keyboard when
    // entering non-ascii characters, will not trigger KeyEvent events as documented
    // here: http://developer.android.com/reference/android/view/KeyEvent.html
    // Log.e("KeyDown", "------------");
    // Log.e("KeyDown", "keyChar:" + (int) event.getDisplayLabel());
    // Log.e("KeyDown", "utfChar:" + (char)event.getUnicodeChar());
    // Log.e("KeyDown", "intUtfChar:" + event.getUnicodeChar());
    final NetworkPacket np = new NetworkPacket(MousePadPlugin.PACKET_TYPE_MOUSEPAD_REQUEST);
    boolean modifier = false;
    if (event.isAltPressed()) {
        np.set("alt", true);
        modifier = true;
    }
    if (event.isCtrlPressed()) {
        np.set("ctrl", true);
        modifier = true;
    }
    if (event.isShiftPressed()) {
        np.set("shift", true);
    }
    if (event.isMetaPressed()) {
        np.set("super", true);
        modifier = true;
    }
    int specialKey = SpecialKeysMap.get(keyCode, -1);
    if (specialKey != -1) {
        np.set("specialKey", specialKey);
    } else if (event.getDisplayLabel() != 0 && modifier) {
        // Alt will change the utf symbol to non-ascii characters, we want the plain original letter
        // Since getDisplayLabel will always have a value, we have to check for special keys before
        char keyCharacter = event.getDisplayLabel();
        np.set("key", new String(new char[] { keyCharacter }).toLowerCase());
    } else {
        // A normal key, but still not handled by the KeyInputConnection (happens with numbers)
        np.set("key", new String(new char[] { (char) event.getUnicodeChar() }));
    }
    sendKeyPressPacket(np);
    return true;
}
Also used : NetworkPacket(org.kde.kdeconnect.NetworkPacket)

Example 13 with NetworkPacket

use of org.kde.kdeconnect.NetworkPacket in project kdeconnect-android by KDE.

the class MousePadPlugin method sendLeftClick.

public void sendLeftClick() {
    NetworkPacket np = new NetworkPacket(PACKET_TYPE_MOUSEPAD_REQUEST);
    np.set("singleclick", true);
    device.sendPacket(np);
}
Also used : NetworkPacket(org.kde.kdeconnect.NetworkPacket)

Example 14 with NetworkPacket

use of org.kde.kdeconnect.NetworkPacket in project kdeconnect-android by KDE.

the class MousePadPlugin method sendSingleHold.

public void sendSingleHold() {
    NetworkPacket np = new NetworkPacket(PACKET_TYPE_MOUSEPAD_REQUEST);
    np.set("singlehold", true);
    device.sendPacket(np);
}
Also used : NetworkPacket(org.kde.kdeconnect.NetworkPacket)

Example 15 with NetworkPacket

use of org.kde.kdeconnect.NetworkPacket in project kdeconnect-android by KDE.

the class MousePadPlugin method sendMiddleClick.

public void sendMiddleClick() {
    NetworkPacket np = new NetworkPacket(PACKET_TYPE_MOUSEPAD_REQUEST);
    np.set("middleclick", true);
    device.sendPacket(np);
}
Also used : NetworkPacket(org.kde.kdeconnect.NetworkPacket)

Aggregations

NetworkPacket (org.kde.kdeconnect.NetworkPacket)77 IOException (java.io.IOException)6 SSLSocket (javax.net.ssl.SSLSocket)4 SMSHelper (org.kde.kdeconnect.Helpers.SMSHelper)4 BufferedReader (java.io.BufferedReader)3 InputStreamReader (java.io.InputStreamReader)3 ServerSocket (java.net.ServerSocket)3 Socket (java.net.Socket)3 SocketException (java.net.SocketException)3 ArrayList (java.util.ArrayList)3 Timer (java.util.Timer)3 SuppressLint (android.annotation.SuppressLint)2 Uri (android.net.Uri)2 SmsMessage (android.telephony.SmsMessage)2 SpannableString (android.text.SpannableString)2 InputStream (java.io.InputStream)2 OutputStream (java.io.OutputStream)2 DatagramSocket (java.net.DatagramSocket)2 InetAddress (java.net.InetAddress)2 InetSocketAddress (java.net.InetSocketAddress)2