2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-31 14:15:14 +00:00

Hide keyboard display action if remote keyboard input is not supported

This commit is contained in:
Nicolas Fella
2019-06-13 19:28:45 +00:00
parent 71b034a025
commit 6e053a7e95
2 changed files with 25 additions and 3 deletions

View File

@@ -173,6 +173,13 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_mousepad, menu);
BackgroundService.RunWithPlugin(this, deviceId, MousePadPlugin.class, plugin -> {
if (!plugin.isKeyboardEnabled()) {
menu.removeItem(R.id.menu_show_keyboard);
}
});
return true;
}

View File

@@ -15,8 +15,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.kde.kdeconnect.Plugins.MousePadPlugin;
@@ -36,6 +36,17 @@ public class MousePadPlugin extends Plugin {
//public final static String PACKET_TYPE_MOUSEPAD = "kdeconnect.mousepad";
public final static String PACKET_TYPE_MOUSEPAD_REQUEST = "kdeconnect.mousepad.request";
private final static String PACKET_TYPE_MOUSEPAD_KEYBOARDSTATE = "kdeconnect.mousepad.keyboardstate";
private boolean keyboardEnabled = true;
@Override
public boolean onPacketReceived(NetworkPacket np) {
keyboardEnabled = np.getBoolean("state", true);
return true;
}
@Override
public String getDisplayName() {
@@ -71,7 +82,7 @@ public class MousePadPlugin extends Plugin {
@Override
public String[] getSupportedPacketTypes() {
return new String[0];
return new String[]{PACKET_TYPE_MOUSEPAD_KEYBOARDSTATE};
}
@Override
@@ -135,4 +146,8 @@ public class MousePadPlugin extends Plugin {
device.sendPacket(np);
}
boolean isKeyboardEnabled() {
return keyboardEnabled;
}
}