2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-21 17:37:39 +00:00

Fix linter warnings

This commit is contained in:
Albert Vaca Cintora 2025-04-05 00:01:33 +02:00
parent 28070954a6
commit fd51ec7c14
No known key found for this signature in database
52 changed files with 146 additions and 177 deletions

View File

@ -24,13 +24,16 @@ import java.io.Reader
import java.util.UUID
import kotlin.text.Charsets.UTF_8
class BluetoothLink(context: Context?, connection: ConnectionMultiplexer, input: InputStream, output: OutputStream, remoteAddress: BluetoothDevice, deviceInfo: DeviceInfo, linkProvider: BluetoothLinkProvider) : BaseLink(context!!, linkProvider) {
private val connection: ConnectionMultiplexer?
private val input: InputStream
private val output: OutputStream
private val remoteAddress: BluetoothDevice
private val linkProvider: BluetoothLinkProvider
private val deviceInfo: DeviceInfo
class BluetoothLink(
context: Context?,
connection: ConnectionMultiplexer,
val input: InputStream,
val output: OutputStream,
val remoteAddress: BluetoothDevice,
val theDeviceInfo: DeviceInfo,
val linkProvider: BluetoothLinkProvider
) : BaseLink(context!!, linkProvider) {
private val connection: ConnectionMultiplexer? = connection
private var continueAccepting = true
private val receivingThread = Thread(object : Runnable {
override fun run() {
@ -64,8 +67,7 @@ class BluetoothLink(context: Context?, connection: ConnectionMultiplexer, input:
}
private fun processMessage(message: String) {
val np: NetworkPacket
np = try {
val np = try {
NetworkPacket.unserialize(message)
} catch (e: JSONException) {
Log.e("BluetoothLink/receiving", "Unable to parse message.", e)
@ -84,15 +86,6 @@ class BluetoothLink(context: Context?, connection: ConnectionMultiplexer, input:
}
})
init {
this.connection = connection
this.input = input
this.output = output
this.deviceInfo = deviceInfo
this.remoteAddress = remoteAddress
this.linkProvider = linkProvider
}
fun startListening() {
receivingThread.start()
}
@ -102,7 +95,7 @@ class BluetoothLink(context: Context?, connection: ConnectionMultiplexer, input:
}
override fun getDeviceInfo(): DeviceInfo {
return deviceInfo
return theDeviceInfo
}
override fun disconnect() {

View File

@ -35,6 +35,7 @@ import java.io.Reader
import java.security.cert.CertificateException
import java.util.UUID
import kotlin.text.Charsets.UTF_8
import androidx.core.content.edit
class BluetoothLinkProvider(private val context: Context) : BaseLinkProvider() {
private val visibleDevices: MutableMap<String, BluetoothLink> = HashMap()
@ -138,9 +139,9 @@ class BluetoothLinkProvider(private val context: Context) : BaseLinkProvider() {
} catch (e: SecurityException) {
Log.e("KDEConnect", "Security Exception for CONNECT", e)
val prefenceEditor = PreferenceManager.getDefaultSharedPreferences(context).edit()
prefenceEditor.putBoolean(SettingsFragment.KEY_BLUETOOTH_ENABLED, false)
prefenceEditor.apply()
PreferenceManager.getDefaultSharedPreferences(context).edit {
putBoolean(SettingsFragment.KEY_BLUETOOTH_ENABLED, false)
}
return
}

View File

@ -21,7 +21,7 @@ import java.util.concurrent.locks.ReentrantLock
import kotlin.concurrent.withLock
class ConnectionMultiplexer(socket: BluetoothSocket) : Closeable {
private class ChannelInputStream constructor(val channel: Channel) : InputStream(), Closeable {
private class ChannelInputStream(val channel: Channel) : InputStream(), Closeable {
override fun available(): Int {
return channel.available()
}
@ -49,7 +49,7 @@ class ConnectionMultiplexer(socket: BluetoothSocket) : Closeable {
}
}
private class ChannelOutputStream constructor(val channel: Channel) : OutputStream(), Closeable {
private class ChannelOutputStream(val channel: Channel) : OutputStream(), Closeable {
@Throws(IOException::class)
override fun close() {
channel.close()
@ -78,7 +78,7 @@ class ConnectionMultiplexer(socket: BluetoothSocket) : Closeable {
}
}
private class Channel constructor(val multiplexer: ConnectionMultiplexer, val id: UUID) : Closeable {
private class Channel(val multiplexer: ConnectionMultiplexer, val id: UUID) : Closeable {
val readBuffer: ByteBuffer = ByteBuffer.allocate(BUFFER_SIZE)
val lock = ReentrantLock()
var lockCondition: Condition = lock.newCondition()
@ -371,14 +371,9 @@ class ConnectionMultiplexer(socket: BluetoothSocket) : Closeable {
}
}
private inner class ListenRunnable constructor(socket: BluetoothSocket) : Runnable {
var input: InputStream
var output: OutputStream
init {
input = socket.inputStream
output = socket.outputStream
}
private inner class ListenRunnable(socket: BluetoothSocket) : Runnable {
var input: InputStream = socket.inputStream
var output: OutputStream = socket.outputStream
@Throws(IOException::class)
private fun readBuffer(buffer: ByteArray, len: Int) {

View File

@ -41,7 +41,7 @@ public class MdnsDiscovery {
this.lanLinkProvider = lanLinkProvider;
this.mNsdManager = (NsdManager) context.getSystemService(Context.NSD_SERVICE);
this.mNsdResolveQueue = new NsdResolveQueue(this.mNsdManager);
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
multicastLock = wifiManager.createMulticastLock("kdeConnectMdnsMulticastLock");
}
@ -132,7 +132,7 @@ public class MdnsDiscovery {
// Also, on Android Lollipop those fields aren't resolved.
String deviceName = DeviceHelper.getDeviceName(context);
String deviceType = DeviceHelper.getDeviceType().toString();
String protocolVersion = Integer.toString(DeviceHelper.ProtocolVersion);
String protocolVersion = Integer.toString(DeviceHelper.PROTOCOL_VERSION);
serviceInfo.setAttribute("id", deviceId);
serviceInfo.setAttribute("name", deviceName);
serviceInfo.setAttribute("type", deviceType);

View File

@ -32,7 +32,6 @@ import org.kde.kdeconnect.Backends.BaseLinkProvider
import org.kde.kdeconnect.Backends.BaseLinkProvider.ConnectionReceiver
import org.kde.kdeconnect.Backends.BluetoothBackend.BluetoothLinkProvider
import org.kde.kdeconnect.Backends.LanBackend.LanLinkProvider
import org.kde.kdeconnect.Backends.LoopbackBackend.LoopbackLinkProvider
import org.kde.kdeconnect.Helpers.NotificationHelper
import org.kde.kdeconnect.Plugins.ClibpoardPlugin.ClipboardFloatingActivity
import org.kde.kdeconnect.Plugins.RunCommandPlugin.RunCommandActivity

View File

@ -33,7 +33,6 @@ import org.kde.kdeconnect.DeviceStats.countReceived
import org.kde.kdeconnect.DeviceStats.countSent
import org.kde.kdeconnect.Helpers.DeviceHelper
import org.kde.kdeconnect.Helpers.NotificationHelper
import org.kde.kdeconnect.Helpers.SecurityHelpers.SslHelper
import org.kde.kdeconnect.PairingHandler.PairingCallback
import org.kde.kdeconnect.Plugins.Plugin
import org.kde.kdeconnect.Plugins.Plugin.Companion.getPluginKey
@ -46,6 +45,7 @@ import java.util.Vector
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentMap
import java.util.concurrent.CopyOnWriteArrayList
import androidx.core.content.edit
class Device : PacketReceiver {
@ -164,7 +164,7 @@ class Device : PacketReceiver {
// Returns 0 if the version matches, < 0 if it is older or > 0 if it is newer
fun compareProtocolVersion(): Int =
deviceInfo.protocolVersion - DeviceHelper.ProtocolVersion
deviceInfo.protocolVersion - DeviceHelper.PROTOCOL_VERSION
val isPaired: Boolean
get() = pairingHandler.state == PairingHandler.PairState.Paired
@ -209,7 +209,7 @@ class Device : PacketReceiver {
// Store as trusted device
val preferences = context.getSharedPreferences("trusted_devices", Context.MODE_PRIVATE)
preferences.edit().putBoolean(deviceInfo.id, true).apply()
preferences.edit { putBoolean(deviceInfo.id, true) }
try {
reloadPluginsFromSettings()
@ -228,10 +228,10 @@ class Device : PacketReceiver {
override fun unpaired() {
Log.i("Device", "unpaired, removing from trusted devices list")
val preferences = context.getSharedPreferences("trusted_devices", Context.MODE_PRIVATE)
preferences.edit().remove(deviceInfo.id).apply()
preferences.edit { remove(deviceInfo.id) }
val devicePreferences = context.getSharedPreferences(deviceInfo.id, Context.MODE_PRIVATE)
devicePreferences.edit().clear().apply()
devicePreferences.edit { clear() }
pairingCallbacks.forEach(PairingCallback::unpaired)
@ -596,7 +596,7 @@ class Device : PacketReceiver {
}
fun setPluginEnabled(pluginKey: String, value: Boolean) {
settings.edit().putBoolean(pluginKey, value).apply()
settings.edit { putBoolean(pluginKey, value) }
reloadPluginsFromSettings()
}

View File

@ -59,12 +59,12 @@ class DeviceInfo(
*/
fun toIdentityPacket(): NetworkPacket =
NetworkPacket(NetworkPacket.PACKET_TYPE_IDENTITY).also { np ->
np.set("deviceId", id)
np.set("deviceName", name)
np.set("protocolVersion", protocolVersion)
np.set("deviceType", type.toString())
np.set("incomingCapabilities", incomingCapabilities!!)
np.set("outgoingCapabilities", outgoingCapabilities!!)
np["deviceId"] = id
np["deviceName"] = name
np["protocolVersion"] = protocolVersion
np["deviceType"] = type.toString()
np["incomingCapabilities"] = incomingCapabilities!!
np["outgoingCapabilities"] = outgoingCapabilities!!
}
companion object {
@ -107,10 +107,10 @@ class DeviceInfo(
fun isValidIdentityPacket(identityPacket: NetworkPacket): Boolean = with(identityPacket) {
type == NetworkPacket.PACKET_TYPE_IDENTITY &&
DeviceHelper.filterName(getString("deviceName", "")).isNotBlank() &&
isValidDeviceId(getString("deviceId", ""));
isValidDeviceId(getString("deviceId", ""))
}
private val DEVICE_ID_REGEX = "^[a-zA-Z0-9_-]{32,38}\$".toRegex()
private val DEVICE_ID_REGEX = "^[a-zA-Z0-9_-]{32,38}$".toRegex()
@JvmStatic
fun isValidDeviceId(deviceId: String): Boolean = deviceId.matches(DEVICE_ID_REGEX)

View File

@ -115,7 +115,7 @@ object DeviceStats {
val entry = iterator.next()
val events = entry.value
var index = Collections.binarySearch(events, cutoutTimestamp)
var index = events.binarySearch(cutoutTimestamp)
if (index < 0) {
index = -(index + 1) // Convert the negative index to insertion point
}

View File

@ -91,7 +91,7 @@ public final class CollectionsBackport {
}
static boolean eq(Object o1, Object o2) {
return o1 == null ? o2 == null : o1.equals(o2);
return Objects.equals(o1, o2);
}
static class UnmodifiableNavigableSetBackport<E>

View File

@ -214,7 +214,7 @@ public class ContactsHelper {
Map<uID, Map<String, String>> databaseValue = accessContactsDatabase(context, projection, selection, selectionArgs, null);
if (databaseValue.size() == 0) {
if (databaseValue.isEmpty()) {
throw new ContactNotFoundException("Querying for contact with id " + contactID + " returned no results.");
}

View File

@ -28,7 +28,7 @@ import java.util.UUID
import androidx.core.content.edit
object DeviceHelper {
const val ProtocolVersion = 8
const val PROTOCOL_VERSION = 8
const val KEY_DEVICE_NAME_PREFERENCE = "device_name_preference"
private const val KEY_DEVICE_NAME_FETCHED_FROM_THE_INTERNET = "device_name_downloaded_preference"
@ -85,7 +85,7 @@ object DeviceHelper {
// If we get here we managed to download the file. Mark that as done so we don't try again even if we don't end up finding a name.
val preferences = PreferenceManager.getDefaultSharedPreferences(context)
preferences.edit().putBoolean(KEY_DEVICE_NAME_FETCHED_FROM_THE_INTERNET, true).apply()
preferences.edit { putBoolean(KEY_DEVICE_NAME_FETCHED_FROM_THE_INTERNET, true) }
BufferedReader(
InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_16)
@ -124,7 +124,7 @@ object DeviceHelper {
fun setDeviceName(context: Context, name: String) {
val filteredName = filterName(name)
val preferences = PreferenceManager.getDefaultSharedPreferences(context)
preferences.edit().putString(KEY_DEVICE_NAME_PREFERENCE, filteredName).apply()
preferences.edit { putString(KEY_DEVICE_NAME_PREFERENCE, filteredName) }
}
fun initializeDeviceId(context: Context) {
@ -133,7 +133,6 @@ object DeviceHelper {
if (DeviceInfo.isValidDeviceId(deviceId)) {
return // We already have an ID
}
@SuppressLint("HardwareIds")
val deviceName = UUID.randomUUID().toString().replace("-", "")
preferences.edit { putString(KEY_DEVICE_ID_PREFERENCE, deviceName) }
}
@ -151,7 +150,7 @@ object DeviceHelper {
SslHelper.certificate,
getDeviceName(context),
deviceType,
ProtocolVersion,
PROTOCOL_VERSION,
PluginFactory.incomingCapabilities,
PluginFactory.outgoingCapabilities
)

View File

@ -97,7 +97,7 @@ object FilesHelper {
fun contentResolverExtract(): Triple<String?, Long, Long?> {
// Since we used Intent.CATEGORY_OPENABLE, these two columns are the only ones we are guaranteed to have: https://developer.android.com/reference/android/provider/OpenableColumns
val proj = arrayOf(OpenableColumns.SIZE, OpenableColumns.DISPLAY_NAME,)
val proj = arrayOf(OpenableColumns.SIZE, OpenableColumns.DISPLAY_NAME)
try {
contentResolver.query(uri, proj, null, null, null).use { cursor ->

View File

@ -11,7 +11,6 @@ import android.content.ContentUris
import android.content.Context
import android.database.ContentObserver
import android.database.sqlite.SQLiteException
import android.graphics.Bitmap
import android.media.MediaMetadataRetriever
import android.media.ThumbnailUtils
import android.net.Uri
@ -23,6 +22,8 @@ import android.telephony.TelephonyManager
import android.util.Log
import android.util.Pair
import androidx.annotation.RequiresApi
import androidx.core.graphics.scale
import androidx.core.net.toUri
import com.google.android.mms.pdu_alt.MultimediaMessagePdu
import com.google.android.mms.pdu_alt.PduPersister
import com.google.android.mms.util_alt.PduCache
@ -37,13 +38,11 @@ import org.kde.kdeconnect.Helpers.TelephonyHelper.LocalPhoneNumber
import org.kde.kdeconnect.Plugins.SMSPlugin.MimeType
import org.kde.kdeconnect.Plugins.SMSPlugin.SmsMmsUtils
import java.io.IOException
import java.util.Arrays
import java.util.Objects
import java.util.SortedMap
import java.util.TreeMap
import java.util.concurrent.locks.Lock
import java.util.concurrent.locks.ReentrantLock
import java.util.stream.Collectors
import kotlin.text.Charsets.UTF_8
@SuppressLint("InlinedApi")
@ -52,7 +51,7 @@ object SMSHelper {
private const val THUMBNAIL_WIDTH = 100
// The constant Telephony.Mms.Part.CONTENT_URI was added in API 29
val mMSPartUri : Uri = Uri.parse("content://mms/part/")
val mMSPartUri : Uri = "content://mms/part/".toUri()
/**
* Get the base address for all message conversations
@ -67,14 +66,14 @@ object SMSHelper {
if ("Samsung".equals(Build.MANUFACTURER, ignoreCase = true)) {
Log.i("SMSHelper", "This appears to be a Samsung device. This may cause some features to not work properly.")
}
return Uri.parse("content://mms-sms/conversations?simple=true")
return "content://mms-sms/conversations?simple=true".toUri()
}
private fun getCompleteConversationsUri(): Uri {
// This glorious - but completely undocumented - content URI gives us all messages, both MMS and SMS,
// in all conversations
// See https://stackoverflow.com/a/36439630/3723163
return Uri.parse("content://mms-sms/complete-conversations")
return "content://mms-sms/complete-conversations".toUri()
}
/**
@ -651,12 +650,7 @@ object SMSHelper {
)
val videoThumbnail = retriever.frameAtTime
val encodedThumbnail = SmsMmsUtils.bitMapToBase64(
Bitmap.createScaledBitmap(
videoThumbnail!!,
THUMBNAIL_WIDTH,
THUMBNAIL_HEIGHT,
true
)
videoThumbnail!!.scale(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT)
)
attachments.add(
Attachment(

View File

@ -24,7 +24,6 @@ import org.bouncycastle.cert.X509v3CertificateBuilder;
import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder;
import org.bouncycastle.operator.ContentSigner;
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
import org.bouncycastle.util.Arrays;
import org.kde.kdeconnect.Helpers.DeviceHelper;
import org.kde.kdeconnect.Helpers.RandomHelper;
import org.kde.kdeconnect.KdeConnect;

View File

@ -6,7 +6,6 @@
package org.kde.kdeconnect.Helpers
import android.net.Uri
import android.provider.DocumentsContract
object StorageHelper {
fun getDisplayName(treeUri: Uri): String {

View File

@ -13,6 +13,7 @@ import android.net.wifi.WifiManager
import android.preference.PreferenceManager
import android.util.Log
import androidx.core.content.ContextCompat
import androidx.core.content.edit
class TrustedNetworkHelper(private val context: Context) {
@ -22,19 +23,19 @@ class TrustedNetworkHelper(private val context: Context) {
return serializedNetworks.split(NETWORK_SSID_DELIMITER, "#_#" /* TODO remove old delimiter in 2025 */).filter { it.isNotEmpty() }
}
set(value) {
PreferenceManager.getDefaultSharedPreferences(context)
.edit()
.putString(KEY_CUSTOM_TRUSTED_NETWORKS, value.joinToString(NETWORK_SSID_DELIMITER))
.apply()
PreferenceManager.getDefaultSharedPreferences(context).edit {
putString(
KEY_CUSTOM_TRUSTED_NETWORKS,
value.joinToString(NETWORK_SSID_DELIMITER)
)
}
}
var allNetworksAllowed: Boolean
get() = !hasPermissions || PreferenceManager.getDefaultSharedPreferences(context).getBoolean(KEY_CUSTOM_TRUST_ALL_NETWORKS, true)
set(value) = PreferenceManager
.getDefaultSharedPreferences(context)
.edit()
.putBoolean(KEY_CUSTOM_TRUST_ALL_NETWORKS, value)
.apply()
set(value) = PreferenceManager.getDefaultSharedPreferences(context).edit {
putBoolean(KEY_CUSTOM_TRUST_ALL_NETWORKS, value)
}
val hasPermissions: Boolean
get() = ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED

View File

@ -25,6 +25,7 @@ import java.security.cert.CertificateException
import java.security.cert.X509Certificate
import java.util.Date
import java.util.concurrent.ConcurrentHashMap
import androidx.core.content.edit
/*
* This class holds all the active devices and makes them accessible from every other class.
@ -116,7 +117,7 @@ class KdeConnect : Application() {
"KdeConnect",
"Couldn't load the certificate for a remembered device. Removing from trusted list.", e
)
preferences.edit().remove(it).apply()
preferences.edit { remove(it) }
}
}
}
@ -127,7 +128,7 @@ class KdeConnect : Application() {
trustedDevices.filter { preferences.getBoolean(it, false) }
.forEach {
Log.d("KdeConnect", "Removing devices: $it")
preferences.edit().remove(it).apply()
preferences.edit { remove(it) }
}
}

View File

@ -11,9 +11,7 @@ import org.json.JSONObject
import java.io.ByteArrayInputStream
import java.io.IOException
import java.io.InputStream
import java.lang.RuntimeException
import java.net.Socket
import kotlin.concurrent.Volatile
class NetworkPacket private constructor(
val type: String,

View File

@ -25,8 +25,6 @@ import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
import java.util.Objects;
@PluginFactory.LoadablePlugin
public class BigscreenPlugin extends Plugin {

View File

@ -25,8 +25,6 @@ import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
import java.util.Objects;
@PluginFactory.LoadablePlugin
public class ClipboardPlugin extends Plugin {

View File

@ -37,7 +37,6 @@ import org.kde.kdeconnect.UserInterface.PluginSettingsFragment;
import org.kde.kdeconnect_tp.R;
import java.io.IOException;
import java.util.Objects;
@PluginFactory.LoadablePlugin
public class FindMyPhonePlugin extends Plugin {

View File

@ -19,8 +19,6 @@ import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect.UserInterface.PluginSettingsFragment;
import org.kde.kdeconnect_tp.R;
import java.util.Objects;
@PluginFactory.LoadablePlugin
public class MousePadPlugin extends Plugin {

View File

@ -157,9 +157,6 @@ public class PointerAccelerationProfileFactory {
public static PointerAccelerationProfile getProfileWithName(String name) {
switch (name) {
case "noacceleration":
default:
return new DefaultProfile();
case "weaker":
return new PolynomialProfile(0.25f);
case "weak":
@ -170,6 +167,9 @@ public class PointerAccelerationProfileFactory {
return new PolynomialProfile(1.5f);
case "stronger":
return new PolynomialProfile(2.0f);
case "noacceleration":
default:
return new DefaultProfile();
}
}
}

View File

@ -29,6 +29,7 @@ import java.net.URL
import java.net.URLDecoder
import java.security.MessageDigest
import java.util.concurrent.CopyOnWriteArrayList
import androidx.core.net.toUri
/**
* Handles the cache for album art
@ -130,7 +131,7 @@ internal object AlbumArtCache {
if (albumUrl.isNullOrEmpty()) {
return null
}
val url = Uri.parse(albumUrl)
val url = albumUrl.toUri()
//We currently only support http(s), file, and kdeconnect urls
if (url.scheme !in ALLOWED_SCHEMES) {
@ -221,7 +222,7 @@ internal object AlbumArtCache {
* Does the actual fetching and makes sure only not too many fetches are running at the same time
*/
private fun initiateFetch() {
var url : Uri;
var url : Uri
synchronized(fetchUrlList) {
if (numFetching >= 2 || fetchUrlList.isEmpty()) return
//Fetch the last-requested url first, it will probably be needed first
@ -283,7 +284,7 @@ internal object AlbumArtCache {
payload.close()
return
}
val url = Uri.parse(albumUrl)
val url = albumUrl.toUri()
if (url.scheme !in REMOTE_FETCH_SCHEMES) {
//Shouldn't happen (checked on receival of the url), but just to be sure
Log.e("KDE/Mpris/AlbumArtCache", "Got invalid art url with payload: $albumUrl")

View File

@ -34,6 +34,7 @@ import org.kde.kdeconnect_tp.databinding.MprisNowPlayingBinding
import java.net.MalformedURLException
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
import androidx.core.net.toUri
private typealias MprisPlayerCallback = (MprisPlayer) -> Unit
@ -370,7 +371,7 @@ class MprisNowPlayingFragment : Fragment(), VolumeKeyListener {
if (targetPlayer != null && item.itemId == MENU_OPEN_URL) {
try {
val url = VideoUrlsHelper.formatUriWithSeek(targetPlayer.url, targetPlayer.position).toString()
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
val browserIntent = Intent(Intent.ACTION_VIEW, url.toUri())
startActivity(browserIntent)
targetPlayer.sendPause()
return true

View File

@ -33,6 +33,7 @@ import org.kde.kdeconnect.UserInterface.PluginSettingsFragment
import org.kde.kdeconnect_tp.R
import java.net.MalformedURLException
import java.util.concurrent.ConcurrentHashMap
import androidx.core.net.toUri
@LoadablePlugin
class MprisPlugin : Plugin() {
@ -273,7 +274,7 @@ class MprisPlugin : Plugin() {
playerStatus.isGoPreviousAllowed = np.getBoolean("canGoPrevious", playerStatus.isGoPreviousAllowed)
playerStatus.seekAllowed = np.getBoolean("canSeek", playerStatus.seekAllowed)
val newAlbumArtUrlString = np.getString("albumArtUrl", playerStatus.albumArtUrl)
val newAlbumArtUrl = Uri.parse(newAlbumArtUrlString)
val newAlbumArtUrl = newAlbumArtUrlString.toUri()
if (newAlbumArtUrl.scheme in AlbumArtCache.ALLOWED_SCHEMES) {
playerStatus.albumArtUrl = newAlbumArtUrl.toString()
} else {
@ -334,7 +335,7 @@ class MprisPlugin : Plugin() {
) {
try {
val url = VideoUrlsHelper.formatUriWithSeek(playerStatus.url, playerStatus.position).toString()
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
val browserIntent = Intent(Intent.ACTION_VIEW, url.toUri())
val pendingIntent = PendingIntent.getActivity(context, 0, browserIntent, PendingIntent.FLAG_IMMUTABLE)
val notificationManager = ContextCompat.getSystemService(context, NotificationManager::class.java)
@ -350,7 +351,7 @@ class MprisPlugin : Plugin() {
builder.build()
)
} catch (e: MalformedURLException) {
e.printStackTrace();
e.printStackTrace()
}
}
}

View File

@ -19,7 +19,6 @@ import android.util.Log
import android.widget.Toast
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import androidx.core.content.ContextCompat.getSystemService
import androidx.core.content.getSystemService
import org.kde.kdeconnect.Helpers.NotificationHelper
import org.kde.kdeconnect.NetworkPacket

View File

@ -24,8 +24,6 @@ import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
import java.util.Objects;
@PluginFactory.LoadablePlugin
public class PresenterPlugin extends Plugin {

View File

@ -29,7 +29,6 @@ import org.kde.kdeconnect.UserInterface.MainActivity;
import org.kde.kdeconnect_tp.R;
import java.io.InputStream;
import java.util.Objects;
@PluginFactory.LoadablePlugin
public class ReceiveNotificationsPlugin extends Plugin {

View File

@ -67,7 +67,7 @@ public class RemoteKeyboardPlugin extends Plugin implements SharedPreferences.On
}
public static boolean isConnected() {
return instances.size() > 0;
return !instances.isEmpty();
}
private static final SparseIntArray specialKeyMap = new SparseIntArray();
@ -135,7 +135,7 @@ public class RemoteKeyboardPlugin extends Plugin implements SharedPreferences.On
try {
if (instances.contains(this)) {
instances.remove(this);
if (instances.size() < 1 && RemoteKeyboardService.instance != null)
if (instances.isEmpty() && RemoteKeyboardService.instance != null)
RemoteKeyboardService.instance.handler.post(() -> RemoteKeyboardService.instance.updateInputView());
}
} finally {
@ -348,7 +348,7 @@ public class RemoteKeyboardPlugin extends Plugin implements SharedPreferences.On
public enum MousePadPacketType {
Keyboard,
Mouse,
};
}
public static MousePadPacketType getMousePadPacketType(NetworkPacket np) {
if (np.has("key") || np.has("specialKey")) {

View File

@ -165,7 +165,7 @@ public class RemoteKeyboardService
intent.putExtra(MainActivity.FLAG_FORCE_OVERVIEW, true);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
if (instances.size() < 1)
if (instances.isEmpty())
Toast.makeText(this, R.string.remotekeyboard_not_connected, Toast.LENGTH_SHORT).show();
else // instances.size() > 1
Toast.makeText(this, R.string.remotekeyboard_multiple_connections, Toast.LENGTH_SHORT).show();

View File

@ -130,7 +130,7 @@ public class RunCommandActivity extends BaseActivity<ActivityRunCommandBinding>
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
if (item.getItemId() == R.id.copy_url_to_clipboard) {
CommandEntry entry = (CommandEntry) commandItems.get(info.position);
CommandEntry entry = commandItems.get(info.position);
String url = "kdeconnect://runcommand/" + deviceId + "/" + entry.getKey();
ClipboardManager cm = ContextCompat.getSystemService(this, ClipboardManager.class);
cm.setText(url);

View File

@ -34,7 +34,6 @@ import org.kde.kdeconnect_tp.R;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Objects;
@PluginFactory.LoadablePlugin
public class RunCommandPlugin extends Plugin {

View File

@ -18,12 +18,12 @@ import android.widget.ArrayAdapter
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.edit
import org.kde.kdeconnect.Device
import org.kde.kdeconnect.KdeConnect
import org.kde.kdeconnect_tp.R
import org.kde.kdeconnect_tp.databinding.WidgetRemoteCommandPluginDialogBinding
import java.util.stream.Collectors
import kotlin.streams.toList
class RunCommandWidgetConfigActivity : AppCompatActivity() {
@ -45,7 +45,7 @@ class RunCommandWidgetConfigActivity : AppCompatActivity() {
val binding = WidgetRemoteCommandPluginDialogBinding.inflate(layoutInflater)
setContentView(binding.root)
val pairedDevices = KdeConnect.getInstance().devices.values.stream().filter(Device::isPaired).collect(Collectors.toList());
val pairedDevices = KdeConnect.getInstance().devices.values.stream().filter(Device::isPaired).collect(Collectors.toList())
binding.runCommandsDeviceList.adapter = object : ArrayAdapter<Device>(this, 0, pairedDevices) {
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
@ -76,9 +76,9 @@ private const val PREFS_NAME = "org.kde.kdeconnect_tp.WidgetProvider"
private const val PREF_PREFIX_KEY = "appwidget_"
internal fun saveWidgetDeviceIdPref(context: Context, appWidgetId: Int, deviceName: String) {
val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE).edit()
prefs.putString(PREF_PREFIX_KEY + appWidgetId, deviceName)
prefs.apply()
context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE).edit {
putString(PREF_PREFIX_KEY + appWidgetId, deviceName)
}
}
internal fun loadWidgetDeviceIdPref(context: Context, appWidgetId: Int): String? {
@ -87,7 +87,7 @@ internal fun loadWidgetDeviceIdPref(context: Context, appWidgetId: Int): String?
}
internal fun deleteWidgetDeviceIdPref(context: Context, appWidgetId: Int) {
val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE).edit()
prefs.remove(PREF_PREFIX_KEY + appWidgetId)
prefs.apply()
context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE).edit {
remove(PREF_PREFIX_KEY + appWidgetId)
}
}

View File

@ -20,6 +20,7 @@ import org.kde.kdeconnect.Device
import org.kde.kdeconnect.KdeConnect
import org.kde.kdeconnect_tp.BuildConfig
import org.kde.kdeconnect_tp.R
import androidx.core.net.toUri
const val RUN_COMMAND_ACTION = "RUN_COMMAND_ACTION"
const val TARGET_COMMAND = "TARGET_COMMAND"
@ -65,10 +66,10 @@ class RunCommandWidgetProvider : AppWidgetProvider() {
Log.e("RunCommandWidget", "Error running command", ex)
}
} else {
Log.w("RunCommandWidget", "Device not available or runcommand plugin disabled");
Log.w("RunCommandWidget", "Device not available or runcommand plugin disabled")
}
} else {
super.onReceive(context, intent);
super.onReceive(context, intent)
}
}
}
@ -114,7 +115,7 @@ internal fun updateAppWidget(
val views = RemoteViews(BuildConfig.APPLICATION_ID, R.layout.widget_remotecommandplugin)
assignTitleIntent(context, appWidgetId, views)
Log.d("WidgetProvider", "updateAppWidget device: " + if (device == null) "null" else device.name)
Log.d("WidgetProvider", "updateAppWidget device: " + (device?.name ?: "null"))
// Android should automatically toggle between the command list and the error text
views.setEmptyView(R.id.widget_command_list, R.id.widget_error_text)
@ -174,7 +175,7 @@ private fun assignTitleIntent(context: Context, appWidgetId: Int, views: RemoteV
private fun assignListAdapter(context: Context, appWidgetId: Int, views: RemoteViews) {
val dataProviderIntent = Intent(context, CommandsRemoteViewsService::class.java)
dataProviderIntent.putExtra(EXTRA_APPWIDGET_ID, appWidgetId)
dataProviderIntent.data = Uri.parse(dataProviderIntent.toUri(Intent.URI_INTENT_SCHEME))
dataProviderIntent.data = dataProviderIntent.toUri(Intent.URI_INTENT_SCHEME).toUri()
views.setRemoteAdapter(R.id.widget_command_list, dataProviderIntent)
}

View File

@ -181,7 +181,7 @@ class SMSPlugin : Plugin() {
@Deprecated("")
private fun smsBroadcastReceivedDeprecated(messages: MutableList<SmsMessage>) {
if (BuildConfig.DEBUG) {
if (messages.size <= 0) {
if (messages.isEmpty()) {
throw AssertionError("This method requires at least one message")
}
}
@ -224,11 +224,11 @@ class SMSPlugin : Plugin() {
get() = R.string.telepathy_permission_explanation
override fun onCreate(): Boolean {
val filter: IntentFilter = IntentFilter(Telephony.Sms.Intents.SMS_RECEIVED_ACTION)
val filter = IntentFilter(Telephony.Sms.Intents.SMS_RECEIVED_ACTION)
filter.priority = 500
context.registerReceiver(receiver, filter)
val refreshFilter: IntentFilter = IntentFilter(Transaction.REFRESH)
val refreshFilter = IntentFilter(Transaction.REFRESH)
refreshFilter.priority = 500
context.registerReceiver(messagesUpdateReceiver, refreshFilter, ContextCompat.RECEIVER_EXPORTED)
@ -269,13 +269,11 @@ class SMSPlugin : Plugin() {
val subID = np.getLong("subID", -1)
val jsonAddressList = np.getJSONArray("addresses")
val addressList: List<SMSHelper.Address>
if (jsonAddressList == null) {
val addressList = if (jsonAddressList == null) {
// If jsonAddressList is null, then the SMS_REQUEST packet is most probably from the older version of the desktop app.
addressList = listOf(SMSHelper.Address(context, np.getString("phoneNumber")))
}
else {
addressList = jsonArrayToAddressList(context, jsonAddressList)
listOf(SMSHelper.Address(context, np.getString("phoneNumber")))
} else {
jsonArrayToAddressList(context, jsonAddressList)
}
val attachedFiles: List<SMSHelper.Attachment> = jsonArrayToAttachmentsList(np.getJSONArray("attachments"))
@ -350,11 +348,10 @@ class SMSPlugin : Plugin() {
numberToGet = null
}
val conversation: List<SMSHelper.Message>
if (rangeStartTimestamp < 0) {
conversation = getMessagesInThread(this.context, threadID, numberToGet)
val conversation = if (rangeStartTimestamp < 0) {
getMessagesInThread(this.context, threadID, numberToGet)
} else {
conversation = getMessagesInRange(this.context, threadID, rangeStartTimestamp, numberToGet, true)
getMessagesInRange(this.context, threadID, rangeStartTimestamp, numberToGet, true)
}
val reply: NetworkPacket = constructBulkMessagePacket(conversation)

View File

@ -11,10 +11,10 @@ import android.content.ContentResolver
import android.content.SharedPreferences
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.os.storage.StorageManager
import android.provider.Settings
import androidx.core.net.toUri
import org.json.JSONException
import org.json.JSONObject
import org.kde.kdeconnect.Helpers.NetworkHelper.localIpAddress
@ -44,7 +44,7 @@ class SftpPlugin : Plugin(), OnSharedPreferenceChangeListener {
return if (SimpleSftpServer.SUPPORTS_NATIVEFS) {
Environment.isExternalStorageManager()
} else {
SftpSettingsFragment.getStorageInfoList(context, this).size != 0
SftpSettingsFragment.getStorageInfoList(context, this).isNotEmpty()
}
}
@ -101,7 +101,7 @@ class SftpPlugin : Plugin(), OnSharedPreferenceChangeListener {
} else {
val storageInfoList = SftpSettingsFragment.getStorageInfoList(context, this)
storageInfoList.sortBy { it.uri }
if (storageInfoList.size <= 0) {
if (storageInfoList.isEmpty()) {
device.sendPacket(NetworkPacket(PACKET_TYPE_SFTP).apply {
this["errorMessage"] = context.getString(R.string.sftp_no_storage_locations_configured)
})
@ -127,7 +127,7 @@ class SftpPlugin : Plugin(), OnSharedPreferenceChangeListener {
this["password"] = server.regeneratePassword()
// Kept for compatibility, in case "multiPaths" is not possible or the other end does not support it
this["path"] = if (paths.size == 1) paths[0] else "/"
if (paths.size > 0) {
if (paths.isNotEmpty()) {
this["multiPaths"] = paths
this["pathNames"] = pathNames
}
@ -240,7 +240,7 @@ class SftpPlugin : Plugin(), OnSharedPreferenceChangeListener {
@Throws(JSONException::class)
fun fromJSON(jsonObject: JSONObject): StorageInfo { // TODO: Use Result after migrate callee to Kotlin
val displayName = jsonObject.getString(KEY_DISPLAY_NAME)
val uri = Uri.parse(jsonObject.getString(KEY_URI))
val uri = jsonObject.getString(KEY_URI).toUri()
return StorageInfo(displayName, uri)
}

View File

@ -48,6 +48,7 @@ import java.security.KeyPair
import java.security.MessageDigest
import java.security.NoSuchAlgorithmException
import java.security.PublicKey
import androidx.core.net.toUri
internal class SimpleSftpServer {
private lateinit var sshd: SshServer
@ -110,7 +111,7 @@ internal class SimpleSftpServer {
withFileSystemAccessor(object : SftpFileSystemAccessor {
fun notifyMediaStore(path: Path) {
kotlin.runCatching {
val uri = Uri.parse(path.toUri().toString())
val uri = path.toUri().toString().toUri()
MediaStoreHelper.indexFile(context, uri)
uri
}.fold(

View File

@ -5,14 +5,12 @@
*/
package org.kde.kdeconnect.Plugins.SftpPlugin.saf
import android.content.ContentValues
import android.content.Context
import android.net.Uri
import android.os.Build
import android.os.ParcelFileDescriptor
import android.provider.DocumentsContract
import android.util.Log
import org.kde.kdeconnect.Helpers.MediaStoreHelper
import java.io.FileNotFoundException
import java.io.IOException
import java.lang.reflect.Method

View File

@ -17,7 +17,6 @@ import android.webkit.URLUtil;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.PreferenceManager;
import org.kde.kdeconnect.BackgroundService;

View File

@ -20,7 +20,6 @@ import org.kde.kdeconnect_tp.R;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
@PluginFactory.LoadablePlugin

View File

@ -34,7 +34,6 @@ import org.kde.kdeconnect.UserInterface.PluginSettingsFragment;
import org.kde.kdeconnect_tp.R;
import java.util.Map;
import java.util.Objects;
import java.util.Timer;
import java.util.TimerTask;

View File

@ -21,6 +21,7 @@ import org.kde.kdeconnect.UserInterface.MainActivity
import org.kde.kdeconnect.extensions.setupBottomPadding
import org.kde.kdeconnect_tp.R
import org.kde.kdeconnect_tp.databinding.FragmentAboutBinding
import androidx.core.net.toUri
class AboutFragment : Fragment() {
private var _binding: FragmentAboutBinding? = null
@ -113,7 +114,7 @@ class AboutFragment : Fragment() {
button.visibility = View.GONE
} else {
button.setOnClickListener {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
startActivity(Intent(Intent.ACTION_VIEW, url.toUri()))
}
}
}

View File

@ -15,6 +15,7 @@ import androidx.appcompat.widget.TooltipCompat
import org.kde.kdeconnect.UserInterface.List.ListAdapter
import org.kde.kdeconnect_tp.R
import org.kde.kdeconnect_tp.databinding.AboutPersonListItemEntryBinding
import androidx.core.net.toUri
class AboutPersonEntryItem(val person: AboutPerson) : ListAdapter.Item {
override fun inflateView(layoutInflater: LayoutInflater): View {
@ -31,7 +32,8 @@ class AboutPersonEntryItem(val person: AboutPerson) : ListAdapter.Item {
binding.aboutPersonListItemEntryVisitHomepageButton.visibility = View.VISIBLE
TooltipCompat.setTooltipText(binding.aboutPersonListItemEntryVisitHomepageButton, layoutInflater.context.resources.getString(R.string.visit_contributors_homepage, person.webAddress))
binding.aboutPersonListItemEntryVisitHomepageButton.setOnClickListener {
layoutInflater.context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(person.webAddress)))
layoutInflater.context.startActivity(Intent(Intent.ACTION_VIEW,
person.webAddress.toUri()))
}
}

View File

@ -194,7 +194,7 @@ public class CustomDevicesActivity extends BaseActivity<ActivityCustomDevicesBin
saveList();
showEmptyListMessageIfRequired();
})
.addCallback(new BaseTransientBottomBar.BaseCallback<Snackbar>() {
.addCallback(new BaseTransientBottomBar.BaseCallback<>() {
@Override
public void onDismissed(Snackbar transientBottomBar, int event) {
switch (event) {
@ -272,8 +272,8 @@ public class CustomDevicesActivity extends BaseActivity<ActivityCustomDevicesBin
}
private static class DeletedCustomDevice {
@NonNull DeviceHost hostnameOrIP;
int position;
@NonNull final DeviceHost hostnameOrIP;
final int position;
DeletedCustomDevice(@NonNull DeviceHost hostnameOrIP, int position) {
this.hostnameOrIP = hostnameOrIP;

View File

@ -39,7 +39,9 @@ import org.kde.kdeconnect.UserInterface.About.AboutFragment
import org.kde.kdeconnect.UserInterface.About.getApplicationAboutData
import org.kde.kdeconnect_tp.R
import org.kde.kdeconnect_tp.databinding.ActivityMainBinding
import java.util.LinkedList
import androidx.core.content.edit
import androidx.core.view.size
import androidx.core.view.get
private const val MENU_ENTRY_ADD_DEVICE = 1 //0 means no-selection
private const val MENU_ENTRY_SETTINGS = 2
@ -59,7 +61,7 @@ class MainActivity : AppCompatActivity(), OnSharedPreferenceChangeListener {
private var mCurrentDevice: String? = null
private var mCurrentMenuEntry = 0
private set(value) {
set(value) {
field = value
//Enabling "go to default fragment on back" callback when user in settings or "about" fragment
mainFragmentCallback.isEnabled = value == MENU_ENTRY_SETTINGS || value == MENU_ENTRY_ABOUT
@ -87,7 +89,7 @@ class MainActivity : AppCompatActivity(), OnSharedPreferenceChangeListener {
val root = binding.root
setContentView(root)
mDrawerLayout = if (root is DrawerLayout) root else null
mDrawerLayout = root as? DrawerLayout
val mDrawerHeader = mNavigationView.getHeaderView(0)
mNavViewDeviceName = mDrawerHeader.findViewById(R.id.device_name)
@ -115,17 +117,17 @@ class MainActivity : AppCompatActivity(), OnSharedPreferenceChangeListener {
when (mCurrentMenuEntry) {
MENU_ENTRY_ADD_DEVICE -> {
mCurrentDevice = null
preferences.edit().putString(STATE_SELECTED_DEVICE, null).apply()
preferences.edit { putString(STATE_SELECTED_DEVICE, null) }
setContentFragment(PairingFragment())
}
MENU_ENTRY_SETTINGS -> {
preferences.edit().putString(STATE_SELECTED_DEVICE, null).apply()
preferences.edit { putString(STATE_SELECTED_DEVICE, null) }
setContentFragment(SettingsFragment())
}
MENU_ENTRY_ABOUT -> {
preferences.edit().putString(STATE_SELECTED_DEVICE, null).apply()
preferences.edit { putString(STATE_SELECTED_DEVICE, null) }
setContentFragment(AboutFragment.newInstance(getApplicationAboutData(this)))
}
@ -207,7 +209,7 @@ class MainActivity : AppCompatActivity(), OnSharedPreferenceChangeListener {
}
}
if(missingPermissions.size > 0){
if(missingPermissions.isNotEmpty()){
ActivityCompat.requestPermissions(this, missingPermissions.toTypedArray(), RESULT_NOTIFICATIONS_ENABLED)
}
}
@ -303,7 +305,7 @@ class MainActivity : AppCompatActivity(), OnSharedPreferenceChangeListener {
@JvmOverloads
fun onDeviceSelected(deviceId: String?, fromDeviceList: Boolean = false) {
mCurrentDevice = deviceId
preferences.edit().putString(STATE_SELECTED_DEVICE, deviceId).apply()
preferences.edit { putString(STATE_SELECTED_DEVICE, deviceId) }
if (mCurrentDevice != null) {
mCurrentMenuEntry = deviceIdToMenuEntryId(deviceId)
if (mCurrentMenuEntry == MENU_ENTRY_DEVICE_UNKNOWN) {
@ -364,9 +366,9 @@ class MainActivity : AppCompatActivity(), OnSharedPreferenceChangeListener {
if (isPermissionGranted(permissions, grantResults, Manifest.permission.BLUETOOTH_CONNECT) &&
isPermissionGranted(permissions, grantResults, Manifest.permission.BLUETOOTH_SCAN)) {
val preferenceEditor = PreferenceManager.getDefaultSharedPreferences(this).edit()
preferenceEditor.putBoolean(SettingsFragment.KEY_BLUETOOTH_ENABLED, true)
preferenceEditor.apply()
PreferenceManager.getDefaultSharedPreferences(this).edit {
putBoolean(SettingsFragment.KEY_BLUETOOTH_ENABLED, true)
}
setContentFragment(SettingsFragment())
}
@ -390,9 +392,9 @@ class MainActivity : AppCompatActivity(), OnSharedPreferenceChangeListener {
}
private fun uncheckAllMenuItems(menu: Menu) {
val size = menu.size()
val size = menu.size
for (i in 0 until size) {
val item = menu.getItem(i)
val item = menu[i]
item.subMenu?.let { uncheckAllMenuItems(it) } ?: item.setChecked(false)
}
}

View File

@ -6,7 +6,6 @@
package org.kde.kdeconnect.UserInterface
import android.Manifest
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager

View File

@ -6,9 +6,8 @@
package org.kde.kdeconnect.UserInterface
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import org.apache.commons.lang3.StringUtils
import androidx.core.net.toUri
class StartActivityAlertDialogFragment : AlertDialogFragment() {
private var intentAction: String? = null
@ -36,8 +35,9 @@ class StartActivityAlertDialogFragment : AlertDialogFragment() {
setCallback(object : Callback() {
override fun onPositiveButtonClicked() {
val intentUrl = intentUrl
val intent = if (!intentUrl.isNullOrEmpty()) {
Intent(intentAction, Uri.parse(intentUrl))
Intent(intentAction, intentUrl.toUri())
} else {
Intent(intentAction)
}

View File

@ -9,8 +9,11 @@ package org.kde.kdeconnect.UserInterface.compose
import androidx.compose.foundation.layout.RowScope
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.*
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource

View File

@ -6,7 +6,6 @@
package org.kde.kdeconnect.async
import java.util.concurrent.atomic.AtomicLong
import kotlin.concurrent.Volatile
abstract class BackgroundJob<I, R> : Runnable {
private val callback: Callback<R>

View File

@ -129,7 +129,7 @@ class DeviceTest {
val deviceId = "testDevice"
val settings = context.getSharedPreferences(deviceId, Context.MODE_PRIVATE)
val deviceInfo = loadFromSettings(context, deviceId, settings)
deviceInfo.protocolVersion = DeviceHelper.ProtocolVersion
deviceInfo.protocolVersion = DeviceHelper.PROTOCOL_VERSION
deviceInfo.incomingCapabilities = hashSetOf("kdeconnect.plugin1State", "kdeconnect.plugin2State")
deviceInfo.outgoingCapabilities = hashSetOf("kdeconnect.plugin1State.request", "kdeconnect.plugin2State.request")
@ -208,7 +208,7 @@ class DeviceTest {
val deviceId = "unpairedTestDevice"
fakeNetworkPacket["deviceId"] = deviceId
fakeNetworkPacket["deviceName"] = "Unpaired Test Device"
fakeNetworkPacket["protocolVersion"] = DeviceHelper.ProtocolVersion
fakeNetworkPacket["protocolVersion"] = DeviceHelper.PROTOCOL_VERSION
fakeNetworkPacket["deviceType"] = DeviceType.PHONE.toString()
val certificateString =
"""

View File

@ -12,7 +12,6 @@ import org.junit.Before
import org.junit.Test
import org.kde.kdeconnect.Helpers.SecurityHelpers.SslHelper
import org.kde.kdeconnect.MockSharedPreference
import org.kde.kdeconnect.PairingHandler
import org.mockito.ArgumentMatchers
import org.mockito.MockedStatic
import org.mockito.Mockito