mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-22 18:07:55 +00:00
Tweaks
This commit is contained in:
parent
c3e51d13fe
commit
568a8e623b
@ -137,6 +137,8 @@ SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted
|
|||||||
<item>stronger</item>
|
<item>stronger</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string name="virtualmonitor_rdp_client_not_installed">No app can handle RDP. Please install aFreeRDP or another client.</string>
|
||||||
|
|
||||||
<string name="sendkeystrokes_send_to">Send keystrokes to</string>
|
<string name="sendkeystrokes_send_to">Send keystrokes to</string>
|
||||||
<string name="sendkeystrokes_textbox_hint">Send keystrokes to host</string>
|
<string name="sendkeystrokes_textbox_hint">Send keystrokes to host</string>
|
||||||
<string name="sendkeystrokes_disabled_toast">Sending keystrokes is disabled - enable it in the settings</string>
|
<string name="sendkeystrokes_disabled_toast">Sending keystrokes is disabled - enable it in the settings</string>
|
||||||
|
@ -45,7 +45,7 @@ public abstract class BaseLink {
|
|||||||
return getDeviceInfo().id;
|
return getDeviceInfo().id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InetAddress getDeviceIp() { return null; }
|
public abstract InetAddress getDeviceIp();
|
||||||
|
|
||||||
public BaseLinkProvider getLinkProvider() {
|
public BaseLinkProvider getLinkProvider() {
|
||||||
return linkProvider;
|
return linkProvider;
|
||||||
|
@ -650,12 +650,7 @@ class Device : PacketReceiver {
|
|||||||
fun removePluginsChangedListener(listener: PluginsChangedListener) = pluginsChangedListeners.remove(listener)
|
fun removePluginsChangedListener(listener: PluginsChangedListener) = pluginsChangedListeners.remove(listener)
|
||||||
|
|
||||||
fun ipAddress(): InetAddress? {
|
fun ipAddress(): InetAddress? {
|
||||||
for (link in links) {
|
return links.firstNotNullOf { it.deviceIp }
|
||||||
if (link.deviceIp != null) {
|
|
||||||
return link.deviceIp
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun disconnect() {
|
fun disconnect() {
|
||||||
|
@ -6,14 +6,9 @@
|
|||||||
package org.kde.kdeconnect.Plugins.VirtualMonitorPlugin
|
package org.kde.kdeconnect.Plugins.VirtualMonitorPlugin
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Rect
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.WindowManager
|
import android.widget.Toast
|
||||||
import android.view.WindowMetrics
|
|
||||||
import androidx.annotation.RequiresApi
|
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
@ -67,7 +62,8 @@ class VirtualMonitorPlugin : Plugin() {
|
|||||||
Log.i("KDE/VirtualMonitor", "Received request, try connecting to $url")
|
Log.i("KDE/VirtualMonitor", "Received request, try connecting to $url")
|
||||||
|
|
||||||
if (!openUrlExternally(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 {
|
val failure = NetworkPacket(PACKET_TYPE_VIRTUALMONITOR).apply {
|
||||||
this["failed"] = 0
|
this["failed"] = 0
|
||||||
}
|
}
|
||||||
@ -77,23 +73,21 @@ class VirtualMonitorPlugin : Plugin() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
|
|
||||||
override fun onCreate() : Boolean
|
override fun onCreate() : Boolean
|
||||||
{
|
{
|
||||||
val windowManager = ContextCompat.getSystemService(context, WindowManager::class.java)
|
|
||||||
assert(windowManager != null);
|
|
||||||
val windowMetrics: WindowMetrics = windowManager!!.currentWindowMetrics
|
|
||||||
if (device.ipAddress() == null) {
|
if (device.ipAddress() == null) {
|
||||||
Log.e("KDE/VirtualMonitor", "No IP address for device, pass.")
|
Log.e("KDE/VirtualMonitor", "No IP address for device, pass.")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
val bounds: Rect = windowMetrics.bounds
|
val metrics = context.resources.displayMetrics
|
||||||
val np = NetworkPacket(PACKET_TYPE_VIRTUALMONITOR).apply {
|
val np = NetworkPacket(PACKET_TYPE_VIRTUALMONITOR).apply {
|
||||||
this["resolutions"] = JSONArray().apply { put(JSONObject().apply {
|
this["resolutions"] = JSONArray().apply {
|
||||||
put("resolution", bounds.width().toString() + 'x' + bounds.height())
|
put(JSONObject().apply {
|
||||||
put("scale", windowMetrics.density)
|
put("resolution", "${metrics.widthPixels}x${metrics.heightPixels}")
|
||||||
}) }
|
put("scale", metrics.density)
|
||||||
|
})
|
||||||
|
}
|
||||||
this["supports_rdp"] = true
|
this["supports_rdp"] = true
|
||||||
this["supports_virt_mon"] = false
|
this["supports_virt_mon"] = false
|
||||||
}
|
}
|
||||||
@ -102,10 +96,6 @@ class VirtualMonitorPlugin : Plugin() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUnpairedDevicePacketReceived(np: NetworkPacket): Boolean {
|
|
||||||
return super.onUnpairedDevicePacketReceived(np)
|
|
||||||
}
|
|
||||||
|
|
||||||
override val supportedPacketTypes: Array<String>
|
override val supportedPacketTypes: Array<String>
|
||||||
get() = arrayOf(PACKET_TYPE_VIRTUALMONITOR, PACKET_TYPE_VIRTUALMONITOR_REQUEST)
|
get() = arrayOf(PACKET_TYPE_VIRTUALMONITOR, PACKET_TYPE_VIRTUALMONITOR_REQUEST)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user