mirror of
https://github.com/jellyfin/jellyfin-android.git
synced 2025-12-23 23:37:53 -05:00
Update detekt to v1.23.7 (#1094)
* Update detekt to v1.23.7 * Fix detekt config deprecation * Update ForbiddenComment detekt rule configuration * Fix new detekt warnings --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Maxr1998 <max.rumpf1998@gmail.com>
This commit is contained in:
@@ -17,7 +17,9 @@ trim_trailing_whitespace = true
|
||||
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
|
||||
ij_kotlin_allow_trailing_comma = true
|
||||
ij_kotlin_allow_trailing_comma_on_call_site = true
|
||||
ij_kotlin_blank_lines_around_block_when_branches = 0
|
||||
ij_kotlin_line_break_after_multiline_when_entry = false
|
||||
ij_kotlin_indent_before_arrow_on_new_line = false
|
||||
ij_kotlin_name_count_to_use_star_import = 999
|
||||
ij_kotlin_name_count_to_use_star_import_for_members = 999
|
||||
ij_kotlin_packages_to_use_import_on_demand =
|
||||
|
||||
@@ -15,7 +15,7 @@ plugins {
|
||||
detekt {
|
||||
buildUponDefaultConfig = true
|
||||
allRules = false
|
||||
config = files("${rootProject.projectDir}/detekt.yml")
|
||||
config.setFrom("${rootProject.projectDir}/detekt.yml")
|
||||
autoCorrect = true
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,11 @@ class TrackSelectionHelper(
|
||||
* @see selectPlayerAudioTrack
|
||||
*/
|
||||
@Suppress("ReturnCount")
|
||||
private fun selectPlayerAudioTrack(mediaSource: JellyfinMediaSource, audioStream: MediaStream, initial: Boolean): Boolean {
|
||||
private fun selectPlayerAudioTrack(
|
||||
mediaSource: JellyfinMediaSource,
|
||||
audioStream: MediaStream,
|
||||
initial: Boolean,
|
||||
): Boolean {
|
||||
if (mediaSource.playMethod == PlayMethod.TRANSCODE) {
|
||||
// Transcoding does not require explicit audio selection
|
||||
return true
|
||||
@@ -113,7 +117,11 @@ class TrackSelectionHelper(
|
||||
* @see selectSubtitleTrack
|
||||
*/
|
||||
@Suppress("ReturnCount")
|
||||
private fun selectSubtitleTrack(mediaSource: JellyfinMediaSource, subtitleStream: MediaStream?, initial: Boolean): Boolean {
|
||||
private fun selectSubtitleTrack(
|
||||
mediaSource: JellyfinMediaSource,
|
||||
subtitleStream: MediaStream?,
|
||||
initial: Boolean,
|
||||
): Boolean {
|
||||
when {
|
||||
// Fast-pass: Skip execution on subsequent calls with the same selection
|
||||
!initial && subtitleStream === mediaSource.selectedSubtitleStream -> return true
|
||||
|
||||
@@ -102,7 +102,8 @@ class MediaService : MediaBrowserServiceCompat() {
|
||||
apiClientController.loadSavedServerUser()
|
||||
}
|
||||
|
||||
val sessionActivityPendingIntent = packageManager?.getLaunchIntentForPackage(packageName)?.let { sessionIntent ->
|
||||
val packageLaunchIntent = packageManager?.getLaunchIntentForPackage(packageName)
|
||||
val sessionActivityPendingIntent = packageLaunchIntent?.let { sessionIntent ->
|
||||
PendingIntent.getActivity(this, 0, sessionIntent, Constants.PENDING_INTENT_FLAGS)
|
||||
}
|
||||
|
||||
|
||||
@@ -277,7 +277,9 @@ class DeviceProfileBuilder(
|
||||
private val EXO_EMBEDDED_SUBTITLES = arrayOf("dvbsub", "pgssub", "srt", "subrip", "ttml")
|
||||
private val EXO_EXTERNAL_SUBTITLES = arrayOf("srt", "subrip", "ttml", "vtt", "webvtt")
|
||||
private val SUBTITLES_SSA = arrayOf("ssa", "ass")
|
||||
private val EXTERNAL_PLAYER_SUBTITLES = arrayOf("ass", "dvbsub", "pgssub", "srt", "srt", "ssa", "subrip", "subrip", "ttml", "ttml", "vtt", "webvtt")
|
||||
private val EXTERNAL_PLAYER_SUBTITLES = arrayOf(
|
||||
"ass", "dvbsub", "pgssub", "srt", "srt", "ssa", "subrip", "subrip", "ttml", "ttml", "vtt", "webvtt",
|
||||
)
|
||||
|
||||
/**
|
||||
* Taken from Jellyfin Web:
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.jellyfin.mobile.setup
|
||||
import android.content.Context
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.firstOrNull
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
import org.jellyfin.mobile.R
|
||||
import org.jellyfin.mobile.ui.state.CheckUrlState
|
||||
@@ -18,6 +17,7 @@ class ConnectionHelper(
|
||||
private val context: Context,
|
||||
private val jellyfin: Jellyfin,
|
||||
) {
|
||||
@Suppress("LongMethod")
|
||||
suspend fun checkServerUrl(enteredUrl: String): CheckUrlState {
|
||||
Timber.i("checkServerUrlAndConnection $enteredUrl")
|
||||
|
||||
@@ -62,13 +62,16 @@ class ConnectionHelper(
|
||||
val count = badServers.size
|
||||
val (unreachableServers, incompatibleServers) = badServers.partition { result -> result.systemInfo.getOrNull() == null }
|
||||
|
||||
StringBuilder(context.resources.getQuantityString(R.plurals.connection_error_prefix, count, count)).apply {
|
||||
StringBuilder().apply {
|
||||
append(context.resources.getQuantityString(R.plurals.connection_error_prefix, count, count))
|
||||
if (unreachableServers.isNotEmpty()) {
|
||||
append("\n\n")
|
||||
append(context.getString(R.string.connection_error_unable_to_reach_sever))
|
||||
append(":\n")
|
||||
append(
|
||||
unreachableServers.joinToString(separator = "\n") { result -> "\u00b7 ${result.address}" },
|
||||
unreachableServers.joinToString(separator = "\n") { result ->
|
||||
"\u00b7 ${result.address}"
|
||||
},
|
||||
)
|
||||
}
|
||||
if (incompatibleServers.isNotEmpty()) {
|
||||
@@ -76,7 +79,9 @@ class ConnectionHelper(
|
||||
append(context.getString(R.string.connection_error_unsupported_version_or_product))
|
||||
append(":\n")
|
||||
append(
|
||||
incompatibleServers.joinToString(separator = "\n") { result -> "\u00b7 ${result.address}" },
|
||||
incompatibleServers.joinToString(separator = "\n") { result ->
|
||||
"\u00b7 ${result.address}"
|
||||
},
|
||||
)
|
||||
}
|
||||
}.toString()
|
||||
|
||||
@@ -33,6 +33,7 @@ import timber.log.Timber
|
||||
import java.io.File
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.coroutines.suspendCoroutine
|
||||
import kotlin.time.Duration.Companion.minutes
|
||||
|
||||
fun WebViewFragment.requestNoBatteryOptimizations(rootView: CoordinatorLayout) {
|
||||
if (AndroidVersion.isAtLeastM) {
|
||||
@@ -64,8 +65,7 @@ suspend fun MainActivity.requestDownload(uri: Uri, title: String, filename: Stri
|
||||
|
||||
// Storage permission for downloads isn't necessary from Android 10 onwards
|
||||
if (!AndroidVersion.isAtLeastQ) {
|
||||
@Suppress("MagicNumber")
|
||||
val granted = withTimeout(2 * 60 * 1000 /* 2 minutes */) {
|
||||
val granted = withTimeout(2.minutes.inWholeMilliseconds) {
|
||||
suspendCoroutine { continuation ->
|
||||
requestPermission(WRITE_EXTERNAL_STORAGE) { requestPermissionsResult ->
|
||||
continuation.resume(requestPermissionsResult[WRITE_EXTERNAL_STORAGE] == PERMISSION_GRANTED)
|
||||
|
||||
@@ -52,7 +52,9 @@ abstract class JellyfinWebViewClient(
|
||||
path.endsWith(Constants.SESSION_CAPABILITIES_PATH) -> {
|
||||
coroutineScope.launch {
|
||||
val credentials = suspendCoroutine { continuation ->
|
||||
webView.evaluateJavascript("JSON.parse(window.localStorage.getItem('jellyfin_credentials'))") { result ->
|
||||
webView.evaluateJavascript(
|
||||
"JSON.parse(window.localStorage.getItem('jellyfin_credentials'))",
|
||||
) { result ->
|
||||
try {
|
||||
continuation.resume(JSONObject(result))
|
||||
} catch (e: JSONException) {
|
||||
@@ -90,8 +92,14 @@ abstract class JellyfinWebViewClient(
|
||||
request: WebResourceRequest,
|
||||
error: WebResourceErrorCompat,
|
||||
) {
|
||||
val description = if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_RESOURCE_ERROR_GET_DESCRIPTION)) error.description else null
|
||||
val errorCode = if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_RESOURCE_ERROR_GET_CODE)) error.errorCode else ERROR_UNKNOWN
|
||||
val description = when {
|
||||
WebViewFeature.isFeatureSupported(WebViewFeature.WEB_RESOURCE_ERROR_GET_DESCRIPTION) -> error.description
|
||||
else -> null
|
||||
}
|
||||
val errorCode = when {
|
||||
WebViewFeature.isFeatureSupported(WebViewFeature.WEB_RESOURCE_ERROR_GET_CODE) -> error.errorCode
|
||||
else -> ERROR_UNKNOWN
|
||||
}
|
||||
Timber.e("Received WebView error %d at %s: %s", errorCode, request.url.toString(), description)
|
||||
|
||||
// Abort on some specific error codes or when the request url matches the server url
|
||||
|
||||
@@ -64,6 +64,7 @@ import org.jellyfin.mobile.utils.createMediaNotificationChannel
|
||||
import org.jellyfin.mobile.utils.setPlaybackState
|
||||
import org.koin.android.ext.android.inject
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.time.Duration.Companion.hours
|
||||
|
||||
class RemotePlayerService : Service(), CoroutineScope {
|
||||
|
||||
@@ -157,8 +158,7 @@ class RemotePlayerService : Service(), CoroutineScope {
|
||||
|
||||
private fun startWakelock() {
|
||||
if (!wakeLock.isHeld) {
|
||||
@Suppress("MagicNumber")
|
||||
wakeLock.acquire(4 * 60 * 60 * 1000L /* 4 hours */)
|
||||
wakeLock.acquire(4.hours.inWholeMilliseconds)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,8 +277,10 @@ class RemotePlayerService : Service(), CoroutineScope {
|
||||
}
|
||||
}
|
||||
setStyle(style)
|
||||
setVisibility(Notification.VISIBILITY_PUBLIC) // Privacy value for lock screen
|
||||
setOngoing(!isPaused && !appPreferences.musicNotificationAlwaysDismissible) // Swipe to dismiss if paused
|
||||
// Privacy value for lock screen
|
||||
setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
// Swipe to dismiss if paused
|
||||
setOngoing(!isPaused && !appPreferences.musicNotificationAlwaysDismissible)
|
||||
setDeleteIntent(createDeleteIntent())
|
||||
setContentIntent(createContentIntent())
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ performance:
|
||||
style:
|
||||
ForbiddenComment:
|
||||
# Allow TODOs
|
||||
values: [ 'FIXME:', 'STOPSHIP:' ]
|
||||
comments: [ 'FIXME:', 'STOPSHIP:' ]
|
||||
LoopWithTooManyJumpStatements:
|
||||
maxJumpCount: 2
|
||||
MaxLineLength:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
android-plugin = "8.8.0"
|
||||
kotlin = "2.1.0"
|
||||
kotlin-ksp = "2.1.0-1.0.29"
|
||||
detekt = "1.22.0"
|
||||
detekt = "1.23.7"
|
||||
android-junit5 = "1.11.3.0"
|
||||
|
||||
# KotlinX
|
||||
|
||||
Reference in New Issue
Block a user