mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-03 15:45:10 +00:00
Hide keyboard display action if remote keyboard input is not supported
This commit is contained in:
@@ -173,6 +173,13 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
|
|||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = getMenuInflater();
|
||||||
inflater.inflate(R.menu.menu_mousepad, menu);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,8 +15,8 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* 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;
|
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 = "kdeconnect.mousepad";
|
||||||
public final static String PACKET_TYPE_MOUSEPAD_REQUEST = "kdeconnect.mousepad.request";
|
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
|
@Override
|
||||||
public String getDisplayName() {
|
public String getDisplayName() {
|
||||||
@@ -71,7 +82,7 @@ public class MousePadPlugin extends Plugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getSupportedPacketTypes() {
|
public String[] getSupportedPacketTypes() {
|
||||||
return new String[0];
|
return new String[]{PACKET_TYPE_MOUSEPAD_KEYBOARDSTATE};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -135,4 +146,8 @@ public class MousePadPlugin extends Plugin {
|
|||||||
device.sendPacket(np);
|
device.sendPacket(np);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isKeyboardEnabled() {
|
||||||
|
return keyboardEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user