Changeset View
Changeset View
Standalone View
Standalone View
src/org/kde/kdeconnect/Plugins/MousePadPlugin/MousePadActivity.java
Show First 20 Lines • Show All 129 Lines • ▼ Show 20 Line(s) | 128 | case "fastest": | |||
---|---|---|---|---|---|
130 | break; | 130 | break; | ||
131 | default: | 131 | default: | ||
132 | mCurrentSensitivity = 1.0f; | 132 | mCurrentSensitivity = 1.0f; | ||
133 | return; | 133 | return; | ||
134 | } | 134 | } | ||
135 | 135 | | |||
136 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { | 136 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { | ||
137 | final View decorView = getWindow().getDecorView(); | 137 | final View decorView = getWindow().getDecorView(); | ||
138 | decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { | 138 | decorView.setOnSystemUiVisibilityChangeListener(visibility -> { | ||
139 | @Override | | |||
140 | public void onSystemUiVisibilityChange(int visibility) { | | |||
141 | if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) { | 139 | if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) { | ||
142 | 140 | | |||
143 | int fullscreenType = 0; | 141 | int fullscreenType = 0; | ||
144 | 142 | | |||
145 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { | 143 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { | ||
146 | fullscreenType |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; | 144 | fullscreenType |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; | ||
147 | } | 145 | } | ||
148 | 146 | | |||
149 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { | 147 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { | ||
150 | fullscreenType |= View.SYSTEM_UI_FLAG_FULLSCREEN; | 148 | fullscreenType |= View.SYSTEM_UI_FLAG_FULLSCREEN; | ||
151 | } | 149 | } | ||
152 | 150 | | |||
153 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { | 151 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { | ||
154 | fullscreenType |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; | 152 | fullscreenType |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; | ||
155 | } | 153 | } | ||
156 | 154 | | |||
157 | getWindow().getDecorView().setSystemUiVisibility(fullscreenType); | 155 | getWindow().getDecorView().setSystemUiVisibility(fullscreenType); | ||
158 | } | 156 | } | ||
159 | } | | |||
160 | }); | 157 | }); | ||
161 | } | 158 | } | ||
162 | 159 | | |||
163 | } | 160 | } | ||
164 | 161 | | |||
165 | @Override | 162 | @Override | ||
166 | public boolean onCreateOptionsMenu(Menu menu) { | 163 | public boolean onCreateOptionsMenu(Menu menu) { | ||
167 | MenuInflater inflater = getMenuInflater(); | 164 | MenuInflater inflater = getMenuInflater(); | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 187 | public boolean onTouchEvent(MotionEvent event) { | |||
209 | switch (actionType) { | 206 | switch (actionType) { | ||
210 | case MotionEvent.ACTION_DOWN: | 207 | case MotionEvent.ACTION_DOWN: | ||
211 | mPrevX = event.getX(); | 208 | mPrevX = event.getX(); | ||
212 | mPrevY = event.getY(); | 209 | mPrevY = event.getY(); | ||
213 | break; | 210 | break; | ||
214 | case MotionEvent.ACTION_MOVE: | 211 | case MotionEvent.ACTION_MOVE: | ||
215 | mCurrentX = event.getX(); | 212 | mCurrentX = event.getX(); | ||
216 | mCurrentY = event.getY(); | 213 | mCurrentY = event.getY(); | ||
217 | BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback() { | 214 | BackgroundService.RunCommand(this, service -> { | ||
218 | @Override | | |||
219 | public void onServiceStart(BackgroundService service) { | | |||
220 | Device device = service.getDevice(deviceId); | 215 | Device device = service.getDevice(deviceId); | ||
221 | MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class); | 216 | MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class); | ||
222 | if (mousePadPlugin == null) return; | 217 | if (mousePadPlugin == null) return; | ||
223 | mousePadPlugin.sendMouseDelta(mCurrentX - mPrevX, mCurrentY - mPrevY, mCurrentSensitivity); | 218 | mousePadPlugin.sendMouseDelta(mCurrentX - mPrevX, mCurrentY - mPrevY, mCurrentSensitivity); | ||
224 | mPrevX = mCurrentX; | 219 | mPrevX = mCurrentX; | ||
225 | mPrevY = mCurrentY; | 220 | mPrevY = mCurrentY; | ||
226 | } | | |||
227 | }); | 221 | }); | ||
228 | break; | 222 | break; | ||
229 | } | 223 | } | ||
230 | return true; | 224 | return true; | ||
231 | } | 225 | } | ||
232 | 226 | | |||
233 | @Override | 227 | @Override | ||
234 | public boolean onDown(MotionEvent e) { | 228 | public boolean onDown(MotionEvent e) { | ||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 261 | public boolean onScroll(MotionEvent e1, MotionEvent e2, final float distanceX, final float distanceY) { | |||
282 | return true; | 276 | return true; | ||
283 | } | 277 | } | ||
284 | 278 | | |||
285 | @Override | 279 | @Override | ||
286 | public void onLongPress(MotionEvent e) { | 280 | public void onLongPress(MotionEvent e) { | ||
287 | 281 | | |||
288 | getWindow().getDecorView().performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); | 282 | getWindow().getDecorView().performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); | ||
289 | 283 | | |||
290 | BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback() { | 284 | BackgroundService.RunCommand(this, service -> { | ||
291 | @Override | | |||
292 | public void onServiceStart(BackgroundService service) { | | |||
293 | Device device = service.getDevice(deviceId); | 285 | Device device = service.getDevice(deviceId); | ||
294 | MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class); | 286 | MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class); | ||
295 | if (mousePadPlugin == null) return; | 287 | if (mousePadPlugin == null) return; | ||
296 | mousePadPlugin.sendSingleHold(); | 288 | mousePadPlugin.sendSingleHold(); | ||
297 | } | | |||
298 | }); | 289 | }); | ||
299 | } | 290 | } | ||
300 | 291 | | |||
301 | @Override | 292 | @Override | ||
302 | public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { | 293 | public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { | ||
303 | return false; | 294 | return false; | ||
304 | } | 295 | } | ||
305 | 296 | | |||
306 | @Override | 297 | @Override | ||
307 | public boolean onSingleTapConfirmed(MotionEvent e) { | 298 | public boolean onSingleTapConfirmed(MotionEvent e) { | ||
308 | BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback() { | 299 | BackgroundService.RunCommand(this, service -> { | ||
309 | @Override | | |||
310 | public void onServiceStart(BackgroundService service) { | | |||
311 | Device device = service.getDevice(deviceId); | 300 | Device device = service.getDevice(deviceId); | ||
312 | MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class); | 301 | MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class); | ||
313 | if (mousePadPlugin == null) return; | 302 | if (mousePadPlugin == null) return; | ||
314 | mousePadPlugin.sendSingleClick(); | 303 | mousePadPlugin.sendSingleClick(); | ||
315 | } | | |||
316 | }); | 304 | }); | ||
317 | return true; | 305 | return true; | ||
318 | } | 306 | } | ||
319 | 307 | | |||
320 | @Override | 308 | @Override | ||
321 | public boolean onDoubleTap(MotionEvent e) { | 309 | public boolean onDoubleTap(MotionEvent e) { | ||
322 | BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback() { | 310 | BackgroundService.RunCommand(this, service -> { | ||
323 | @Override | | |||
324 | public void onServiceStart(BackgroundService service) { | | |||
325 | Device device = service.getDevice(deviceId); | 311 | Device device = service.getDevice(deviceId); | ||
326 | MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class); | 312 | MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class); | ||
327 | if (mousePadPlugin == null) return; | 313 | if (mousePadPlugin == null) return; | ||
328 | mousePadPlugin.sendDoubleClick(); | 314 | mousePadPlugin.sendDoubleClick(); | ||
329 | } | | |||
330 | }); | 315 | }); | ||
331 | return true; | 316 | return true; | ||
332 | } | 317 | } | ||
333 | 318 | | |||
334 | @Override | 319 | @Override | ||
335 | public boolean onDoubleTapEvent(MotionEvent e) { | 320 | public boolean onDoubleTapEvent(MotionEvent e) { | ||
336 | return false; | 321 | return false; | ||
337 | } | 322 | } | ||
Show All 23 Lines | 344 | case MIDDLE: | |||
361 | break; | 346 | break; | ||
362 | default: | 347 | default: | ||
363 | } | 348 | } | ||
364 | return true; | 349 | return true; | ||
365 | } | 350 | } | ||
366 | 351 | | |||
367 | 352 | | |||
368 | private void sendMiddleClick() { | 353 | private void sendMiddleClick() { | ||
369 | BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback() { | 354 | BackgroundService.RunCommand(this, service -> { | ||
370 | @Override | | |||
371 | public void onServiceStart(BackgroundService service) { | | |||
372 | Device device = service.getDevice(deviceId); | 355 | Device device = service.getDevice(deviceId); | ||
373 | MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class); | 356 | MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class); | ||
374 | if (mousePadPlugin == null) return; | 357 | if (mousePadPlugin == null) return; | ||
375 | mousePadPlugin.sendMiddleClick(); | 358 | mousePadPlugin.sendMiddleClick(); | ||
376 | } | | |||
377 | }); | 359 | }); | ||
378 | } | 360 | } | ||
379 | 361 | | |||
380 | private void sendRightClick() { | 362 | private void sendRightClick() { | ||
381 | BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback() { | 363 | BackgroundService.RunCommand(this, service -> { | ||
382 | @Override | | |||
383 | public void onServiceStart(BackgroundService service) { | | |||
384 | Device device = service.getDevice(deviceId); | 364 | Device device = service.getDevice(deviceId); | ||
385 | MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class); | 365 | MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class); | ||
386 | if (mousePadPlugin == null) return; | 366 | if (mousePadPlugin == null) return; | ||
387 | mousePadPlugin.sendRightClick(); | 367 | mousePadPlugin.sendRightClick(); | ||
388 | } | | |||
389 | }); | 368 | }); | ||
390 | } | 369 | } | ||
391 | 370 | | |||
392 | private void sendSingleHold() { | 371 | private void sendSingleHold() { | ||
393 | BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback() { | 372 | BackgroundService.RunCommand(this, service -> { | ||
394 | @Override | | |||
395 | public void onServiceStart(BackgroundService service) { | | |||
396 | Device device = service.getDevice(deviceId); | 373 | Device device = service.getDevice(deviceId); | ||
397 | MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class); | 374 | MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class); | ||
398 | if (mousePadPlugin == null) return; | 375 | if (mousePadPlugin == null) return; | ||
399 | mousePadPlugin.sendSingleHold(); | 376 | mousePadPlugin.sendSingleHold(); | ||
400 | } | | |||
401 | }); | 377 | }); | ||
402 | } | 378 | } | ||
403 | 379 | | |||
404 | private void sendScroll(final float y) { | 380 | private void sendScroll(final float y) { | ||
405 | BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback() { | 381 | BackgroundService.RunCommand(this, service -> { | ||
406 | @Override | | |||
407 | public void onServiceStart(BackgroundService service) { | | |||
408 | Device device = service.getDevice(deviceId); | 382 | Device device = service.getDevice(deviceId); | ||
409 | MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class); | 383 | MousePadPlugin mousePadPlugin = device.getPlugin(MousePadPlugin.class); | ||
410 | if (mousePadPlugin == null) return; | 384 | if (mousePadPlugin == null) return; | ||
411 | mousePadPlugin.sendScroll(0, y); | 385 | mousePadPlugin.sendScroll(0, y); | ||
412 | } | | |||
413 | }); | 386 | }); | ||
414 | } | 387 | } | ||
415 | 388 | | |||
416 | private void showKeyboard() { | 389 | private void showKeyboard() { | ||
417 | InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); | 390 | InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); | ||
418 | imm.toggleSoftInputFromWindow(keyListenerView.getWindowToken(), 0, 0); | 391 | imm.toggleSoftInputFromWindow(keyListenerView.getWindowToken(), 0, 0); | ||
419 | } | 392 | } | ||
420 | 393 | | |||
Show All 14 Lines |