Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI builds by migrating the code to ktlint 0.49.0 #3741

Merged
merged 1 commit into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions app/src/main/java/com/github/libretube/LibreTubeApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class LibreTubeApp : Application() {
*/
NotificationHelper.enqueueWork(
context = this,
existingPeriodicWorkPolicy = ExistingPeriodicWorkPolicy.KEEP
existingPeriodicWorkPolicy = ExistingPeriodicWorkPolicy.KEEP,
)

/**
Expand All @@ -76,21 +76,21 @@ class LibreTubeApp : Application() {
private fun initializeNotificationChannels() {
val downloadChannel = NotificationChannelCompat.Builder(
DOWNLOAD_CHANNEL_ID,
NotificationManagerCompat.IMPORTANCE_LOW
NotificationManagerCompat.IMPORTANCE_LOW,
)
.setName(getString(R.string.download_channel_name))
.setDescription(getString(R.string.download_channel_description))
.build()
val backgroundChannel = NotificationChannelCompat.Builder(
BACKGROUND_CHANNEL_ID,
NotificationManagerCompat.IMPORTANCE_LOW
NotificationManagerCompat.IMPORTANCE_LOW,
)
.setName(getString(R.string.background_channel_name))
.setDescription(getString(R.string.background_channel_description))
.build()
val pushChannel = NotificationChannelCompat.Builder(
PUSH_CHANNEL_ID,
NotificationManagerCompat.IMPORTANCE_DEFAULT
NotificationManagerCompat.IMPORTANCE_DEFAULT,
)
.setName(getString(R.string.push_channel_name))
.setDescription(getString(R.string.push_channel_description))
Expand All @@ -101,8 +101,8 @@ class LibreTubeApp : Application() {
listOf(
downloadChannel,
backgroundChannel,
pushChannel
)
pushChannel,
),
)
}

Expand Down
44 changes: 22 additions & 22 deletions app/src/main/java/com/github/libretube/api/PipedApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,26 @@ interface PipedApi {
@GET("sponsors/{videoId}")
suspend fun getSegments(
@Path("videoId") videoId: String,
@Query("category") category: String
@Query("category") category: String,
): SegmentData

@GET("nextpage/comments/{videoId}")
suspend fun getCommentsNextPage(
@Path("videoId") videoId: String,
@Query("nextpage") nextPage: String
@Query("nextpage") nextPage: String,
): CommentsPage

@GET("search")
suspend fun getSearchResults(
@Query("q") searchQuery: String,
@Query("filter") filter: String
@Query("filter") filter: String,
): SearchResult

@GET("nextpage/search")
suspend fun getSearchResultsNextPage(
@Query("q") searchQuery: String,
@Query("filter") filter: String,
@Query("nextpage") nextPage: String
@Query("nextpage") nextPage: String,
): SearchResult

@GET("suggestions")
Expand All @@ -72,7 +72,7 @@ interface PipedApi {
@GET("channels/tabs")
suspend fun getChannelTab(
@Query("data") data: String,
@Query("nextpage") nextPage: String? = null
@Query("nextpage") nextPage: String? = null,
): ChannelTabResponse

@GET("user/{name}")
Expand All @@ -81,7 +81,7 @@ interface PipedApi {
@GET("nextpage/channel/{channelId}")
suspend fun getChannelNextPage(
@Path("channelId") channelId: String,
@Query("nextpage") nextPage: String
@Query("nextpage") nextPage: String,
): Channel

@GET("playlists/{playlistId}")
Expand All @@ -90,7 +90,7 @@ interface PipedApi {
@GET("nextpage/playlists/{playlistId}")
suspend fun getPlaylistNextPage(
@Path("playlistId") playlistId: String,
@Query("nextpage") nextPage: String
@Query("nextpage") nextPage: String,
): Playlist

@POST("login")
Expand All @@ -102,64 +102,64 @@ interface PipedApi {
@POST("user/delete")
suspend fun deleteAccount(
@Header("Authorization") token: String,
@Body password: DeleteUserRequest
@Body password: DeleteUserRequest,
)

@GET("feed")
suspend fun getFeed(@Query("authToken") token: String?): List<StreamItem>

@GET("feed/unauthenticated")
suspend fun getUnauthenticatedFeed(
@Query("channels") channels: String
@Query("channels") channels: String,
): List<StreamItem>

@POST("feed/unauthenticated")
suspend fun getUnauthenticatedFeed(
@Body channels: List<String>
@Body channels: List<String>,
): List<StreamItem>

@GET("subscribed")
suspend fun isSubscribed(
@Query("channelId") channelId: String,
@Header("Authorization") token: String
@Header("Authorization") token: String,
): Subscribed

@GET("subscriptions")
suspend fun subscriptions(@Header("Authorization") token: String): List<Subscription>

@GET("subscriptions/unauthenticated")
suspend fun unauthenticatedSubscriptions(
@Query("channels") channels: String
@Query("channels") channels: String,
): List<Subscription>

@POST("subscriptions/unauthenticated")
suspend fun unauthenticatedSubscriptions(
@Body channels: List<String>
@Body channels: List<String>,
): List<Subscription>

@POST("subscribe")
suspend fun subscribe(
@Header("Authorization") token: String,
@Body subscribe: Subscribe
@Body subscribe: Subscribe,
): Message

@POST("unsubscribe")
suspend fun unsubscribe(
@Header("Authorization") token: String,
@Body subscribe: Subscribe
@Body subscribe: Subscribe,
): Message

@POST("import")
suspend fun importSubscriptions(
@Query("override") override: Boolean,
@Header("Authorization") token: String,
@Body channels: List<String>
@Body channels: List<String>,
): Message

@POST("import/playlist")
suspend fun clonePlaylist(
@Header("Authorization") token: String,
@Body playlistId: PlaylistId
@Body playlistId: PlaylistId,
): PlaylistId

@GET("user/playlists")
Expand All @@ -168,30 +168,30 @@ interface PipedApi {
@POST("user/playlists/rename")
suspend fun renamePlaylist(
@Header("Authorization") token: String,
@Body playlistId: PlaylistId
@Body playlistId: PlaylistId,
): Message

@POST("user/playlists/delete")
suspend fun deletePlaylist(
@Header("Authorization") token: String,
@Body playlistId: PlaylistId
@Body playlistId: PlaylistId,
): Message

@POST("user/playlists/create")
suspend fun createPlaylist(
@Header("Authorization") token: String,
@Body name: Playlists
@Body name: Playlists,
): PlaylistId

@POST("user/playlists/add")
suspend fun addToPlaylist(
@Header("Authorization") token: String,
@Body playlistId: PlaylistId
@Body playlistId: PlaylistId,
): Message

@POST("user/playlists/remove")
suspend fun removeFromPlaylist(
@Header("Authorization") token: String,
@Body playlistId: PlaylistId
@Body playlistId: PlaylistId,
): Message
}
14 changes: 7 additions & 7 deletions app/src/main/java/com/github/libretube/api/PlaylistsHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object PlaylistsHelper {
id = it.playlist.id.toString(),
name = it.playlist.name,
thumbnail = ProxyHelper.rewriteUrl(it.playlist.thumbnailUrl),
videos = it.videos.size.toLong()
videos = it.videos.size.toLong(),
)
}
}
Expand All @@ -54,7 +54,7 @@ object PlaylistsHelper {
name = relation.playlist.name,
thumbnailUrl = ProxyHelper.rewriteUrl(relation.playlist.thumbnailUrl),
videos = relation.videos.size,
relatedStreams = relation.videos.map { it.toStreamItem() }
relatedStreams = relation.videos.map { it.toStreamItem() },
)
}
}
Expand Down Expand Up @@ -117,7 +117,7 @@ object PlaylistsHelper {
val transaction = DatabaseHolder.Database.localPlaylistsDao().getAll()
.first { it.playlist.id.toString() == playlistId }
DatabaseHolder.Database.localPlaylistsDao().removePlaylistVideo(
transaction.videos[index]
transaction.videos[index],
)
// set a new playlist thumbnail if the first video got removed
if (index == 0) {
Expand All @@ -128,7 +128,7 @@ object PlaylistsHelper {
} else {
RetrofitInstance.authApi.removeFromPlaylist(
PreferenceHelper.getToken(),
PlaylistId(playlistId = playlistId, index = index)
PlaylistId(playlistId = playlistId, index = index),
).message == "ok"
}
}
Expand All @@ -144,7 +144,7 @@ object PlaylistsHelper {
playlistId,
*playlist.videos.map {
StreamItem(url = it)
}.toTypedArray()
}.toTypedArray(),
)
} else {
// if not logged in, all video information needs to become fetched manually
Expand All @@ -155,7 +155,7 @@ object PlaylistsHelper {
async {
runCatching {
val stream = RetrofitInstance.api.getStreams(it.first).toStreamItem(
it.first
it.first,
)
addToPlaylist(playlistId, stream)
}
Expand Down Expand Up @@ -210,7 +210,7 @@ object PlaylistsHelper {
return runCatching {
RetrofitInstance.authApi.deletePlaylist(
PreferenceHelper.getToken(),
PlaylistId(playlistId)
PlaylistId(playlistId),
).message == "ok"
}.getOrDefault(false)
}
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/github/libretube/api/ResettableLazy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class ResettableLazy<PROPTYPE>(val manager: ResettableLazyManager, val init: ()
}
}

fun <PROPTYPE> resettableLazy(manager: ResettableLazyManager, init: () -> PROPTYPE):
ResettableLazy<PROPTYPE> {
fun <PROPTYPE> resettableLazy(manager: ResettableLazyManager, init: () -> PROPTYPE): ResettableLazy<PROPTYPE> {
return ResettableLazy(manager, init)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ object RetrofitInstance {
if (
PreferenceHelper.getBoolean(
PreferenceKeys.AUTH_INSTANCE_TOGGLE,
false
false,
)
) {
PreferenceHelper.getString(
PreferenceKeys.AUTH_INSTANCE,
PIPED_API_URL
PIPED_API_URL,
)
} else {
url
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/github/libretube/api/SubscriptionHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object SubscriptionHelper {
context: Context,
channelId: String,
channelName: String?,
onUnsubscribe: () -> Unit
onUnsubscribe: () -> Unit,
) {
if (!PreferenceHelper.getBoolean(PreferenceKeys.CONFIRM_UNSUBSCRIBE, false)) {
runBlocking {
Expand Down Expand Up @@ -112,10 +112,10 @@ object SubscriptionHelper {
val subscriptions = Database.localSubscriptionDao().getAll().map { it.channelId }
when {
subscriptions.size > GET_SUBSCRIPTIONS_LIMIT -> RetrofitInstance.authApi.unauthenticatedSubscriptions(
subscriptions
subscriptions,
)
else -> RetrofitInstance.authApi.unauthenticatedSubscriptions(
subscriptions.joinToString(",")
subscriptions.joinToString(","),
)
}
}
Expand All @@ -129,10 +129,10 @@ object SubscriptionHelper {
val subscriptions = Database.localSubscriptionDao().getAll().map { it.channelId }
when {
subscriptions.size > GET_SUBSCRIPTIONS_LIMIT -> RetrofitInstance.authApi.getUnauthenticatedFeed(
subscriptions
subscriptions,
)
else -> RetrofitInstance.authApi.getUnauthenticatedFeed(
subscriptions.joinToString(",")
subscriptions.joinToString(","),
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/github/libretube/api/obj/Channel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ data class Channel(
val subscriberCount: Long = 0,
val verified: Boolean = false,
val relatedStreams: List<StreamItem> = emptyList(),
val tabs: List<ChannelTab> = emptyList()
val tabs: List<ChannelTab> = emptyList(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import kotlinx.serialization.Serializable
@Serializable
data class ChannelTab(
val name: String,
val data: String
val data: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import kotlinx.serialization.Serializable
@Serializable
data class ChannelTabResponse(
val content: List<ContentItem> = emptyList(),
val nextpage: String? = null
val nextpage: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import kotlinx.serialization.Serializable
data class ChapterSegment(
val title: String,
val image: String,
val start: Long
val start: Long,
)
2 changes: 1 addition & 1 deletion app/src/main/java/com/github/libretube/api/obj/Comment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ data class Comment(
val pinned: Boolean,
val thumbnail: String,
val verified: Boolean,
val replyCount: Long
val replyCount: Long,
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import kotlinx.serialization.Serializable
data class CommentsPage(
var comments: List<Comment> = emptyList(),
val disabled: Boolean = false,
val nextpage: String? = null
val nextpage: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ data class ContentItem(
val description: String? = null,
val subscribers: Long = -1,
val videos: Long = -1,
val verified: Boolean? = null
val verified: Boolean? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ data class Instances(
@SerialName("up_to_date") val upToDate: Boolean = true,
val cdn: Boolean = false,
val registered: Long = 0,
@SerialName("last_checked") val lastChecked: Long = 0
@SerialName("last_checked") val lastChecked: Long = 0,
)
2 changes: 1 addition & 1 deletion app/src/main/java/com/github/libretube/api/obj/Login.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import kotlinx.serialization.Serializable
@Serializable
data class Login(
val username: String,
val password: String
val password: String,
)
Loading