Fix various linter and compiler warnings

This commit is contained in:
Niels van Velzen
2025-05-27 15:12:22 +02:00
committed by Niels van Velzen
parent 0d36d61626
commit bb473ce9e3
13 changed files with 18 additions and 19 deletions

View File

@@ -85,7 +85,6 @@ android {
}
}
@Suppress("UnstableApiUsage")
buildFeatures {
buildConfig = true
viewBinding = true

View File

@@ -45,7 +45,7 @@ import org.jellyfin.sdk.api.client.ApiClient
import org.jellyfin.sdk.api.client.util.AuthorizationHeaderBuilder
import org.koin.android.ext.koin.androidApplication
import org.koin.androidx.fragment.dsl.fragment
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.core.module.dsl.viewModel
import org.koin.core.qualifier.named
import org.koin.dsl.module
import java.io.File

View File

@@ -4,11 +4,11 @@ import android.app.Activity
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.webkit.JavascriptInterface
import android.widget.Toast
import androidx.activity.result.ActivityResultRegistry
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.net.toUri
import androidx.core.text.isDigitsOnly
import androidx.lifecycle.LifecycleOwner
import kotlinx.coroutines.MainScope
@@ -137,7 +137,7 @@ class ExternalPlayer(
if (context.packageManager.isPackageInstalled(appPreferences.externalPlayerApp)) {
component = getComponent(appPreferences.externalPlayerApp)
}
setDataAndType(Uri.parse(url), "video/*")
setDataAndType(url.toUri(), "video/*")
putExtra("title", source.name)
putExtra("position", source.startTimeMs.toInt())
putExtra("return_result", true)
@@ -155,12 +155,12 @@ class ExternalPlayer(
// MX Player API / MPV
val subtitleUris = externalSubs.map { stream ->
Uri.parse(apiClient.createUrl(stream.deliveryUrl))
apiClient.createUrl(stream.deliveryUrl).toUri()
}
putExtra("subs", subtitleUris.toTypedArray())
putExtra("subs.name", externalSubs.map(ExternalSubtitleStream::displayTitle).toTypedArray())
putExtra("subs.filename", externalSubs.map(ExternalSubtitleStream::language).toTypedArray())
putExtra("subs.enable", enabledSubUrl?.let { url -> arrayOf(Uri.parse(url)) } ?: emptyArray())
putExtra("subs.enable", enabledSubUrl?.let { url -> arrayOf(url.toUri()) } ?: emptyArray())
// VLC
if (enabledSubUrl != null) putExtra("subtitles_location", enabledSubUrl)

View File

@@ -4,9 +4,9 @@ import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.media.session.PlaybackState
import android.net.Uri
import android.webkit.JavascriptInterface
import androidx.core.content.ContextCompat
import androidx.core.net.toUri
import org.jellyfin.mobile.events.ActivityEvent
import org.jellyfin.mobile.events.ActivityEventHandler
import org.jellyfin.mobile.utils.Constants
@@ -134,7 +134,7 @@ class NativeInterface(private val context: Context) : KoinComponent {
val filename: String = file.getString("filename")
val url: String = file.getString("url")
emitEvent(ActivityEvent.DownloadFile(Uri.parse(url), title, filename))
emitEvent(ActivityEvent.DownloadFile(url.toUri(), title, filename))
}
} catch (e: JSONException) {
Timber.e("Download failed: %s", e.message)

View File

@@ -9,7 +9,6 @@ import androidx.room.Index
import androidx.room.PrimaryKey
import androidx.room.TypeConverter
import androidx.room.TypeConverters
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.Json.Default.decodeFromString
import org.jellyfin.mobile.data.entity.DownloadEntity.Key.ITEM_ID

View File

@@ -135,7 +135,7 @@ class DownloadUtils(
)
}
private fun isNetworkMetered(): Boolean = connectivityManager?.isActiveNetworkMetered ?: false
private fun isNetworkMetered(): Boolean = connectivityManager?.isActiveNetworkMetered == true
private fun isNetworkRoamingCompat(): Boolean = connectivityManager?.activeNetworkInfo?.isRoaming ?: throw AndroidException()

View File

@@ -3,8 +3,8 @@ package org.jellyfin.mobile.events
import android.content.ActivityNotFoundException
import android.content.Intent
import android.content.pm.ActivityInfo
import android.net.Uri
import android.os.Bundle
import androidx.core.net.toUri
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
@@ -68,7 +68,7 @@ class ActivityEventHandler(
}
is ActivityEvent.OpenUrl -> {
try {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(event.uri))
val intent = Intent(Intent.ACTION_VIEW, event.uri.toUri())
startActivity(intent)
} catch (e: ActivityNotFoundException) {
Timber.e("openIntent: %s", e.message)

View File

@@ -325,7 +325,7 @@ class QueueManager(
): Array<MediaSource> {
val factory = get<SingleSampleMediaSource.Factory>()
return source.externalSubtitleStreams.map { stream ->
val uri = Uri.parse(apiClient.createUrl(stream.deliveryUrl))
val uri = apiClient.createUrl(stream.deliveryUrl).toUri()
val mediaItem = MediaItem.SubtitleConfiguration.Builder(uri).apply {
setId("${ExternalSubtitleStream.ID_PREFIX}${stream.index}")
setLabel(stream.displayTitle)
@@ -353,7 +353,7 @@ class QueueManager(
source: JellyfinMediaSource,
fileUri: String,
): Array<MediaSource> {
val downloadDir: String = File(fileUri).parent
val downloadDir = File(fileUri).parent
val factory = get<SingleSampleMediaSource.Factory>()
return source.externalSubtitleStreams.map { stream ->
val uri: Uri = File(downloadDir, "${stream.index}.subrip").toUri()

View File

@@ -1,5 +1,6 @@
package org.jellyfin.mobile.player.source
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerializationException
import kotlinx.serialization.descriptors.SerialDescriptor
@@ -15,6 +16,7 @@ import org.jellyfin.sdk.model.api.MediaSourceInfo
import org.jellyfin.sdk.model.serializer.toUUID
import java.util.UUID
@OptIn(ExperimentalSerializationApi::class)
class JellyfinMediaSourceSerializer : KSerializer<LocalJellyfinMediaSource> {
override val descriptor: SerialDescriptor = buildClassSerialDescriptor("JellyfinMediaSource") {
element<String>("itemId")

View File

@@ -68,7 +68,7 @@ class ImageProvider : ContentProvider(), KoinComponent {
selectionArgs: Array<out String?>?,
sortOrder: String?,
): Cursor = MatrixCursor(arrayOf("_id", MediaMetadata.METADATA_KEY_ART_URI)).apply {
addRow(arrayOf(0, uri.toString()))
addRow(arrayOf<Any?>(0, uri.toString()))
}
override fun openTypedAssetFile(uri: Uri, mimeTypeFilter: String, opts: Bundle?): AssetFileDescriptor {

View File

@@ -27,7 +27,7 @@ import androidx.compose.material.MaterialTheme
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.ArrowBack
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
@@ -278,7 +278,7 @@ private fun ServerDiscoveryList(
verticalAlignment = Alignment.CenterVertically,
) {
IconButton(onClick = onGoBack) {
Icon(imageVector = Icons.Outlined.ArrowBack, contentDescription = null)
Icon(imageVector = Icons.AutoMirrored.Outlined.ArrowBack, contentDescription = null)
}
Text(
modifier = Modifier

View File

@@ -17,6 +17,6 @@ allprojects {
}
}
tasks.create<Delete>("clean") {
tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}

View File

@@ -1,5 +1,4 @@
import org.gradle.api.Project
import java.util.*
/**
* Get the version name from the current environment or use the fallback.