Changeset View
Changeset View
Standalone View
Standalone View
src/org/kde/kdeconnect/Plugins/MousePadPlugin/KeyListenerView.java
Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Line(s) | 36 | public class KeyListenerView extends View { | |||
---|---|---|---|---|---|
104 | 104 | | |||
105 | public void sendChars(CharSequence chars) { | 105 | public void sendChars(CharSequence chars) { | ||
106 | final NetworkPacket np = new NetworkPacket(MousePadPlugin.PACKET_TYPE_MOUSEPAD_REQUEST); | 106 | final NetworkPacket np = new NetworkPacket(MousePadPlugin.PACKET_TYPE_MOUSEPAD_REQUEST); | ||
107 | np.set("key", chars.toString()); | 107 | np.set("key", chars.toString()); | ||
108 | sendKeyPressPacket(np); | 108 | sendKeyPressPacket(np); | ||
109 | } | 109 | } | ||
110 | 110 | | |||
111 | private void sendKeyPressPacket(final NetworkPacket np) { | 111 | private void sendKeyPressPacket(final NetworkPacket np) { | ||
112 | BackgroundService.RunCommand(getContext(), new BackgroundService.InstanceCallback() { | 112 | BackgroundService.RunCommand(getContext(), service -> { | ||
113 | @Override | | |||
114 | public void onServiceStart(BackgroundService service) { | | |||
115 | Device device = service.getDevice(deviceId); | 113 | Device device = service.getDevice(deviceId); | ||
116 | MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class); | 114 | MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class); | ||
117 | if (mousePadPlugin == null) return; | 115 | if (mousePadPlugin == null) return; | ||
118 | mousePadPlugin.sendKeyboardPacket(np); | 116 | mousePadPlugin.sendKeyboardPacket(np); | ||
119 | } | | |||
120 | }); | 117 | }); | ||
121 | } | 118 | } | ||
122 | 119 | | |||
123 | @Override | 120 | @Override | ||
124 | public boolean onKeyUp(int keyCode, KeyEvent event) { | 121 | public boolean onKeyUp(int keyCode, KeyEvent event) { | ||
125 | 122 | | |||
126 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 123 | if (keyCode == KeyEvent.KEYCODE_BACK) { | ||
127 | //We don't want to swallow the back button press | 124 | //We don't want to swallow the back button press | ||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |