From 23463afc3397c9ffa433e6d343685e3c4ee9416d Mon Sep 17 00:00:00 2001 From: "Ahmed I. Khalil" Date: Sun, 29 Jun 2014 18:36:23 +0200 Subject: [PATCH] Added Right and Middle Clicks as Menu Items. I've made them as "never" to be shown on the ActionBar, until hopefully we could get icons for them. REVIEW: 119016 --- .../MousePadPlugin/MousePadActivity.java | 39 +++++++++++++++++++ src/main/res/values/strings.xml | 2 + 2 files changed, 41 insertions(+) diff --git a/src/main/java/org/kde/kdeconnect/Plugins/MousePadPlugin/MousePadActivity.java b/src/main/java/org/kde/kdeconnect/Plugins/MousePadPlugin/MousePadActivity.java index dea959ed..6cab94bd 100644 --- a/src/main/java/org/kde/kdeconnect/Plugins/MousePadPlugin/MousePadActivity.java +++ b/src/main/java/org/kde/kdeconnect/Plugins/MousePadPlugin/MousePadActivity.java @@ -3,6 +3,9 @@ package org.kde.kdeconnect.Plugins.MousePadPlugin; import android.app.Activity; import android.os.Bundle; import android.view.GestureDetector; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.MotionEvent; import org.kde.kdeconnect.BackgroundService; @@ -35,6 +38,42 @@ public class MousePadActivity extends Activity implements GestureDetector.OnGest mDetector.setOnDoubleTapListener(this); } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.menu_mousepad, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_right_click: + BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback() { + @Override + public void onServiceStart(BackgroundService service) { + Device device = service.getDevice(deviceId); + MousePadPlugin mousePadPlugin = (MousePadPlugin)device.getPlugin("plugin_mousepad"); + if (mousePadPlugin == null) return; + mousePadPlugin.sendRightClick(); + } + }); + break; + case R.id.menu_middle_click: + BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback() { + @Override + public void onServiceStart(BackgroundService service) { + Device device = service.getDevice(deviceId); + MousePadPlugin mousePadPlugin = (MousePadPlugin)device.getPlugin("plugin_mousepad"); + if (mousePadPlugin == null) return; + mousePadPlugin.sendMiddleClick(); + } + }); + break; + } + return true; + } + @Override public boolean onTouchEvent(MotionEvent event) { if ( mDetector.onTouchEvent(event) ) { diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 81e2e36a..4ca395b8 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -55,6 +55,8 @@ Tap to open \'%1s\' Tap to answer Reconnect + Send Right Click + Send Middle Click Device not paired Request pairing Accept