diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0890af28..11e62992 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -137,6 +137,8 @@ SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted
- stronger
+ No app can handle RDP. Please install aFreeRDP or another client.
+
Send keystrokes to
Send keystrokes to host
Sending keystrokes is disabled - enable it in the settings
diff --git a/src/org/kde/kdeconnect/Backends/BaseLink.java b/src/org/kde/kdeconnect/Backends/BaseLink.java
index f2aa634c..5b5ba7f2 100644
--- a/src/org/kde/kdeconnect/Backends/BaseLink.java
+++ b/src/org/kde/kdeconnect/Backends/BaseLink.java
@@ -45,7 +45,7 @@ public abstract class BaseLink {
return getDeviceInfo().id;
}
- public InetAddress getDeviceIp() { return null; }
+ public abstract InetAddress getDeviceIp();
public BaseLinkProvider getLinkProvider() {
return linkProvider;
diff --git a/src/org/kde/kdeconnect/Device.kt b/src/org/kde/kdeconnect/Device.kt
index e5e7fbe6..b5c2a55b 100644
--- a/src/org/kde/kdeconnect/Device.kt
+++ b/src/org/kde/kdeconnect/Device.kt
@@ -650,12 +650,7 @@ class Device : PacketReceiver {
fun removePluginsChangedListener(listener: PluginsChangedListener) = pluginsChangedListeners.remove(listener)
fun ipAddress(): InetAddress? {
- for (link in links) {
- if (link.deviceIp != null) {
- return link.deviceIp
- }
- }
- return null
+ return links.firstNotNullOf { it.deviceIp }
}
fun disconnect() {
diff --git a/src/org/kde/kdeconnect/Plugins/VirtualMonitorPlugin/VirtualMonitorPlugin.kt b/src/org/kde/kdeconnect/Plugins/VirtualMonitorPlugin/VirtualMonitorPlugin.kt
index b976498e..ccb1dbdb 100644
--- a/src/org/kde/kdeconnect/Plugins/VirtualMonitorPlugin/VirtualMonitorPlugin.kt
+++ b/src/org/kde/kdeconnect/Plugins/VirtualMonitorPlugin/VirtualMonitorPlugin.kt
@@ -6,14 +6,9 @@
package org.kde.kdeconnect.Plugins.VirtualMonitorPlugin
import android.content.Intent
-import android.graphics.Rect
import android.net.Uri
-import android.os.Build
import android.util.Log
-import android.view.WindowManager
-import android.view.WindowMetrics
-import androidx.annotation.RequiresApi
-import androidx.core.content.ContextCompat
+import android.widget.Toast
import androidx.core.net.toUri
import org.json.JSONArray
import org.json.JSONObject
@@ -67,7 +62,8 @@ class VirtualMonitorPlugin : Plugin() {
Log.i("KDE/VirtualMonitor", "Received request, try connecting to $url")
if (!openUrlExternally(url)) {
- Log.e("KDE/VirtualMonitor", "Failed to open $url")
+ Toast.makeText(context, R.string.virtualmonitor_rdp_client_not_installed, Toast.LENGTH_LONG).show()
+ openUrlExternally("https://f-droid.org/en/packages/com.freerdp.afreerdp/".toUri())
val failure = NetworkPacket(PACKET_TYPE_VIRTUALMONITOR).apply {
this["failed"] = 0
}
@@ -77,23 +73,21 @@ class VirtualMonitorPlugin : Plugin() {
return true
}
- @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
override fun onCreate() : Boolean
{
- val windowManager = ContextCompat.getSystemService(context, WindowManager::class.java)
- assert(windowManager != null);
- val windowMetrics: WindowMetrics = windowManager!!.currentWindowMetrics
if (device.ipAddress() == null) {
Log.e("KDE/VirtualMonitor", "No IP address for device, pass.")
return false
}
- val bounds: Rect = windowMetrics.bounds
+ val metrics = context.resources.displayMetrics
val np = NetworkPacket(PACKET_TYPE_VIRTUALMONITOR).apply {
- this["resolutions"] = JSONArray().apply { put(JSONObject().apply {
- put("resolution", bounds.width().toString() + 'x' + bounds.height())
- put("scale", windowMetrics.density)
- }) }
+ this["resolutions"] = JSONArray().apply {
+ put(JSONObject().apply {
+ put("resolution", "${metrics.widthPixels}x${metrics.heightPixels}")
+ put("scale", metrics.density)
+ })
+ }
this["supports_rdp"] = true
this["supports_virt_mon"] = false
}
@@ -102,10 +96,6 @@ class VirtualMonitorPlugin : Plugin() {
return true
}
- override fun onUnpairedDevicePacketReceived(np: NetworkPacket): Boolean {
- return super.onUnpairedDevicePacketReceived(np)
- }
-
override val supportedPacketTypes: Array
get() = arrayOf(PACKET_TYPE_VIRTUALMONITOR, PACKET_TYPE_VIRTUALMONITOR_REQUEST)