Fixes deprecated URI parse function warnings

This commit is contained in:
Vitor Pamplona
2025-04-24 16:52:25 -04:00
parent d04f6c977e
commit 30c4e3c646
8 changed files with 19 additions and 16 deletions
@@ -20,11 +20,13 @@
*/
package com.vitorpamplona.amethyst.service
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.net.Uri
import androidx.core.net.toUri
object PackageUtils {
@SuppressLint("QueryPermissionsNeeded")
private fun isPackageInstalled(
context: Context,
target: String,
@@ -39,7 +41,7 @@ object PackageUtils {
val intent =
Intent().apply {
action = Intent.ACTION_VIEW
data = Uri.parse("nostrsigner:")
data = "nostrsigner:".toUri()
}
val infos = context.packageManager.queryIntentActivities(intent, 0)
return infos.size > 0
@@ -26,9 +26,9 @@ import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.graphics.drawable.BitmapDrawable
import android.net.Uri
import android.service.notification.StatusBarNotification
import androidx.core.app.NotificationCompat
import androidx.core.net.toUri
import coil3.ImageLoader
import coil3.asDrawable
import coil3.executeBlocking
@@ -201,7 +201,7 @@ object NotificationUtils {
}
val contentIntent =
Intent(applicationContext, MainActivity::class.java).apply { data = Uri.parse(uri) }
Intent(applicationContext, MainActivity::class.java).apply { data = uri.toUri() }
val contentPendingIntent =
PendingIntent.getActivity(
@@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.service.playback.websocket
import android.net.Uri
import androidx.annotation.OptIn
import androidx.core.net.toUri
import androidx.media3.common.util.UnstableApi
import androidx.media3.datasource.BaseDataSource
import androidx.media3.datasource.DataSource
@@ -64,7 +65,7 @@ class WssStreamDataSource(
override fun getUri(): Uri? {
webSocketClient?.request()?.url?.let {
return Uri.parse(it.toString())
return it.toString().toUri()
}
return null
@@ -31,7 +31,6 @@ import com.vitorpamplona.quartz.nip01Core.core.Event
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.flow.sample
@@ -42,7 +42,7 @@ class ImageDownloader {
var imageData: Blob? = null
var tentatives = 0
// Servers are usually not ready.. so tries to download it for 15 times/seconds.
// Servers are usually not ready, so tries to download it for 15 times/seconds.
while (imageData == null && tentatives < 15) {
imageData =
try {
@@ -22,7 +22,6 @@ package com.vitorpamplona.amethyst.ui.components
import android.content.Context
import android.content.Intent
import android.net.Uri
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
@@ -53,6 +52,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.core.content.ContextCompat.startActivity
import androidx.core.net.toUri
import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.commons.hashtags.Cashu
import com.vitorpamplona.amethyst.commons.hashtags.CustomHashTagIcons
@@ -209,7 +209,7 @@ fun CashuPreviewNew(
FilledTonalButton(
onClick = {
try {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("cashu://${token.token}"))
val intent = Intent(Intent.ACTION_VIEW, "cashu://${token.token}".toUri())
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(context, intent, null)
@@ -22,7 +22,6 @@ package com.vitorpamplona.amethyst.ui.note
import android.content.Context
import android.content.Intent
import android.net.Uri
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@@ -58,6 +57,7 @@ import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import androidx.core.content.ContextCompat
import androidx.core.net.toUri
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewmodel.compose.viewModel
import com.vitorpamplona.amethyst.R
@@ -388,7 +388,7 @@ fun payViaIntent(
onError: (String) -> Unit,
) {
try {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("lightning:$invoice"))
val intent = Intent(Intent.ACTION_VIEW, "lightning:$invoice".toUri())
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
ContextCompat.startActivity(context, intent, null)
@@ -22,14 +22,15 @@ package com.vitorpamplona.quartz.nip55AndroidSigner
import android.content.ContentResolver
import android.content.Intent
import android.net.Uri
import android.util.Log
import android.util.LruCache
import androidx.core.net.toUri
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.deser.std.StdDeserializer
import com.fasterxml.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
@@ -63,7 +64,7 @@ class Result(
@JsonProperty("id") val id: String?,
) {
companion object {
val mapper =
val mapper: ObjectMapper =
jacksonObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.registerModule(
@@ -210,7 +211,7 @@ class ExternalSignerLauncher(
id: String,
onReady: (String) -> Unit,
) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$data"))
val intent = Intent(Intent.ACTION_VIEW, "nostrsigner:$data".toUri())
val signerType =
when (type) {
SignerType.SIGN_EVENT -> "sign_event"
@@ -287,7 +288,7 @@ class ExternalSignerLauncher(
contentResolver
?.let { it() }
?.query(
Uri.parse("content://$signerPackageName.$signerType"),
"content://$signerPackageName.$signerType".toUri(),
localData,
"1",
null,
@@ -313,7 +314,7 @@ class ExternalSignerLauncher(
}
}
} catch (e: Exception) {
Log.e("ExternalSignerLauncher", "Failed to query the Signer app in the background")
Log.e("ExternalSignerLauncher", "Failed to query the Signer app in the background", e)
return kotlin.Result.success(null)
}