style: run ktlint

This commit is contained in:
FineFindus 2023-10-11 18:13:32 +02:00
parent 9e8216acb0
commit b1c16cc622
No known key found for this signature in database
GPG Key ID: 64873EE210FF8E6B
24 changed files with 78 additions and 134 deletions

View File

@ -47,9 +47,7 @@ interface PipedApi {
): SegmentData ): SegmentData
@GET("dearrow") @GET("dearrow")
suspend fun getDeArrowContent( suspend fun getDeArrowContent(@Query("videoIds") videoIds: String): JsonObject
@Query("videoIds") videoIds: String
): JsonObject
@GET("nextpage/comments/{videoId}") @GET("nextpage/comments/{videoId}")
suspend fun getCommentsNextPage( suspend fun getCommentsNextPage(
@ -116,14 +114,10 @@ interface PipedApi {
suspend fun getFeed(@Query("authToken") token: String?): List<StreamItem> suspend fun getFeed(@Query("authToken") token: String?): List<StreamItem>
@GET("feed/unauthenticated") @GET("feed/unauthenticated")
suspend fun getUnauthenticatedFeed( suspend fun getUnauthenticatedFeed(@Query("channels") channels: String): List<StreamItem>
@Query("channels") channels: String
): List<StreamItem>
@POST("feed/unauthenticated") @POST("feed/unauthenticated")
suspend fun getUnauthenticatedFeed( suspend fun getUnauthenticatedFeed(@Body channels: List<String>): List<StreamItem>
@Body channels: List<String>
): List<StreamItem>
@GET("subscribed") @GET("subscribed")
suspend fun isSubscribed( suspend fun isSubscribed(
@ -140,9 +134,7 @@ interface PipedApi {
): List<Subscription> ): List<Subscription>
@POST("subscriptions/unauthenticated") @POST("subscriptions/unauthenticated")
suspend fun unauthenticatedSubscriptions( suspend fun unauthenticatedSubscriptions(@Body channels: List<String>): List<Subscription>
@Body channels: List<String>
): List<Subscription>
@POST("subscribe") @POST("subscribe")
suspend fun subscribe( suspend fun subscribe(

View File

@ -19,5 +19,5 @@ data class Comment(
val thumbnail: String, val thumbnail: String,
val verified: Boolean, val verified: Boolean,
val replyCount: Long, val replyCount: Long,
val creatorReplied: Boolean = false, val creatorReplied: Boolean = false
) : Parcelable ) : Parcelable

View File

@ -6,8 +6,8 @@ import com.github.libretube.extensions.toLocalDateSafe
import com.github.libretube.extensions.toMillis import com.github.libretube.extensions.toMillis
import com.github.libretube.helpers.ProxyHelper import com.github.libretube.helpers.ProxyHelper
import com.github.libretube.parcelable.DownloadData import com.github.libretube.parcelable.DownloadData
import kotlinx.serialization.Serializable
import kotlin.io.path.Path import kotlin.io.path.Path
import kotlinx.serialization.Serializable
@Serializable @Serializable
data class Streams( data class Streams(

View File

@ -3,10 +3,10 @@ package com.github.libretube.db
import androidx.room.TypeConverter import androidx.room.TypeConverter
import com.github.libretube.api.JsonHelper import com.github.libretube.api.JsonHelper
import com.github.libretube.extensions.toLocalDateSafe import com.github.libretube.extensions.toLocalDateSafe
import kotlinx.datetime.LocalDate
import kotlinx.serialization.encodeToString
import java.nio.file.Path import java.nio.file.Path
import kotlin.io.path.Path import kotlin.io.path.Path
import kotlinx.datetime.LocalDate
import kotlinx.serialization.encodeToString
object Converters { object Converters {
@TypeConverter @TypeConverter

View File

@ -21,10 +21,8 @@ object DatabaseHelper {
videoId, videoId,
streams.toStreamItem(videoId) streams.toStreamItem(videoId)
) )
suspend fun addToWatchHistory( suspend fun addToWatchHistory(videoId: String, stream: StreamItem) =
videoId: String, withContext(Dispatchers.IO) {
stream: StreamItem
) = withContext(Dispatchers.IO) {
val watchHistoryItem = WatchHistoryItem( val watchHistoryItem = WatchHistoryItem(
videoId, videoId,
stream.title, stream.title,
@ -37,7 +35,10 @@ object DatabaseHelper {
stream.duration stream.duration
) )
Database.watchHistoryDao().insert(watchHistoryItem) Database.watchHistoryDao().insert(watchHistoryItem)
val maxHistorySize = PreferenceHelper.getString(PreferenceKeys.WATCH_HISTORY_SIZE, "100") val maxHistorySize = PreferenceHelper.getString(
PreferenceKeys.WATCH_HISTORY_SIZE,
"100"
)
if (maxHistorySize == "unlimited") { if (maxHistorySize == "unlimited") {
return@withContext return@withContext
} }

View File

@ -25,11 +25,7 @@ object DashHelper {
val audioLocale: String? = null val audioLocale: String? = null
) )
fun createManifest( fun createManifest(streams: Streams, supportsHdr: Boolean, rewriteUrls: Boolean): String {
streams: Streams,
supportsHdr: Boolean,
rewriteUrls: Boolean
): String {
val builder = builderFactory.newDocumentBuilder() val builder = builderFactory.newDocumentBuilder()
val doc = builder.newDocument() val doc = builder.newDocument()
@ -173,10 +169,7 @@ object DashHelper {
return representation return representation
} }
private fun createSegmentBaseElement( private fun createSegmentBaseElement(document: Document, stream: PipedStream): Element {
document: Document,
stream: PipedStream
): Element {
val segmentBase = document.createElement("SegmentBase") val segmentBase = document.createElement("SegmentBase")
segmentBase.setAttribute("indexRange", "${stream.indexStart}-${stream.indexEnd}") segmentBase.setAttribute("indexRange", "${stream.indexStart}-${stream.indexEnd}")

View File

@ -25,10 +25,7 @@ import com.github.libretube.ui.views.SingleViewTouchableMotionLayout
object NavigationHelper { object NavigationHelper {
private val handler = Handler(Looper.getMainLooper()) private val handler = Handler(Looper.getMainLooper())
fun navigateChannel( fun navigateChannel(context: Context, channelId: String?) {
context: Context,
channelId: String?
) {
if (channelId == null) return if (channelId == null) return
val activity = ContextHelper.unwrapActivity(context) val activity = ContextHelper.unwrapActivity(context)
@ -85,11 +82,7 @@ object NavigationHelper {
} }
} }
fun navigatePlaylist( fun navigatePlaylist(context: Context, playlistId: String?, playlistType: PlaylistType) {
context: Context,
playlistId: String?,
playlistType: PlaylistType
) {
if (playlistId == null) return if (playlistId == null) return
val activity = ContextHelper.unwrapActivity(context) val activity = ContextHelper.unwrapActivity(context)

View File

@ -16,10 +16,7 @@ object NotificationHelper {
/** /**
* Enqueue the work manager task * Enqueue the work manager task
*/ */
fun enqueueWork( fun enqueueWork(context: Context, existingPeriodicWorkPolicy: ExistingPeriodicWorkPolicy) {
context: Context,
existingPeriodicWorkPolicy: ExistingPeriodicWorkPolicy
) {
// get the notification preferences // get the notification preferences
PreferenceHelper.initialize(context) PreferenceHelper.initialize(context)
val notificationsEnabled = PreferenceHelper.getBoolean( val notificationsEnabled = PreferenceHelper.getBoolean(

View File

@ -40,11 +40,11 @@ import com.github.libretube.enums.SbSkipOptions
import com.github.libretube.extensions.updateParameters import com.github.libretube.extensions.updateParameters
import com.github.libretube.obj.VideoStats import com.github.libretube.obj.VideoStats
import com.github.libretube.util.TextUtils import com.github.libretube.util.TextUtils
import kotlinx.coroutines.runBlocking
import java.util.Locale import java.util.Locale
import java.util.concurrent.Executors import java.util.concurrent.Executors
import kotlin.math.absoluteValue import kotlin.math.absoluteValue
import kotlin.math.roundToInt import kotlin.math.roundToInt
import kotlinx.coroutines.runBlocking
object PlayerHelper { object PlayerHelper {
private const val ACTION_MEDIA_CONTROL = "media_control" private const val ACTION_MEDIA_CONTROL = "media_control"
@ -65,11 +65,7 @@ object PlayerHelper {
/** /**
* Create a base64 encoded DASH stream manifest * Create a base64 encoded DASH stream manifest
*/ */
fun createDashSource( fun createDashSource(streams: Streams, context: Context, disableProxy: Boolean): Uri {
streams: Streams,
context: Context,
disableProxy: Boolean
): Uri {
val manifest = DashHelper.createManifest( val manifest = DashHelper.createManifest(
streams, streams,
DisplayHelper.supportsHdr(context), DisplayHelper.supportsHdr(context),
@ -330,10 +326,12 @@ object PlayerHelper {
) )
fun shouldPlayNextVideo(isPlaylist: Boolean = false): Boolean { fun shouldPlayNextVideo(isPlaylist: Boolean = false): Boolean {
return autoPlayEnabled || (isPlaylist && PreferenceHelper.getBoolean( return autoPlayEnabled || (
isPlaylist && PreferenceHelper.getBoolean(
PreferenceKeys.AUTOPLAY_PLAYLISTS, PreferenceKeys.AUTOPLAY_PLAYLISTS,
false false
)) )
)
} }
private val handleAudioFocus private val handleAudioFocus

View File

@ -33,9 +33,7 @@ object ThemeHelper {
/** /**
* Update the accent color of the app and apply dynamic colors if needed * Update the accent color of the app and apply dynamic colors if needed
*/ */
private fun updateAccentColor( private fun updateAccentColor(activity: AppCompatActivity) {
activity: AppCompatActivity
) {
var accentColor = PreferenceHelper.getString(PreferenceKeys.ACCENT_COLOR, "") var accentColor = PreferenceHelper.getString(PreferenceKeys.ACCENT_COLOR, "")
// automatically choose an accent color on the first app startup // automatically choose an accent color on the first app startup
@ -117,10 +115,8 @@ object ThemeHelper {
/** /**
* Get a color by a color resource attr * Get a color by a color resource attr
*/ */
fun getThemeColor( fun getThemeColor(context: Context, colorCode: Int) =
context: Context, MaterialColors.getColor(context, colorCode, Color.TRANSPARENT)
colorCode: Int
) = MaterialColors.getColor(context, colorCode, Color.TRANSPARENT)
/** /**
* Get the styled app name * Get the styled app name

View File

@ -19,7 +19,6 @@ import com.github.libretube.enums.FileType
import com.github.libretube.extensions.toAndroidUri import com.github.libretube.extensions.toAndroidUri
import com.github.libretube.extensions.updateParameters import com.github.libretube.extensions.updateParameters
import com.github.libretube.helpers.PlayerHelper import com.github.libretube.helpers.PlayerHelper
import com.github.libretube.helpers.PlayerHelper.loadPlaybackParams
import com.github.libretube.obj.PlayerNotificationData import com.github.libretube.obj.PlayerNotificationData
import com.github.libretube.util.NowPlayingNotification import com.github.libretube.util.NowPlayingNotification
import com.github.libretube.util.NowPlayingNotification.Companion.PLAYER_NOTIFICATION_ID import com.github.libretube.util.NowPlayingNotification.Companion.PLAYER_NOTIFICATION_ID

View File

@ -35,7 +35,6 @@ import com.github.libretube.extensions.toID
import com.github.libretube.extensions.updateParameters import com.github.libretube.extensions.updateParameters
import com.github.libretube.helpers.PlayerHelper import com.github.libretube.helpers.PlayerHelper
import com.github.libretube.helpers.PlayerHelper.checkForSegments import com.github.libretube.helpers.PlayerHelper.checkForSegments
import com.github.libretube.helpers.PlayerHelper.loadPlaybackParams
import com.github.libretube.helpers.ProxyHelper import com.github.libretube.helpers.ProxyHelper
import com.github.libretube.obj.PlayerNotificationData import com.github.libretube.obj.PlayerNotificationData
import com.github.libretube.parcelable.PlayerData import com.github.libretube.parcelable.PlayerData

View File

@ -36,10 +36,10 @@ import com.github.libretube.ui.interfaces.TimeFrameReceiver
import com.github.libretube.ui.listeners.SeekbarPreviewListener import com.github.libretube.ui.listeners.SeekbarPreviewListener
import com.github.libretube.ui.models.PlayerViewModel import com.github.libretube.ui.models.PlayerViewModel
import com.github.libretube.util.OfflineTimeFrameReceiver import com.github.libretube.util.OfflineTimeFrameReceiver
import kotlin.io.path.exists
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import kotlin.io.path.exists
@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class) @androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
class OfflinePlayerActivity : BaseActivity() { class OfflinePlayerActivity : BaseActivity() {

View File

@ -39,19 +39,10 @@ class ColorPickerDialog : DialogFragment(), SeekBar.OnSeekBarChangeListener {
// Add listener to text input // Add listener to text input
binding.colorHexInput.addTextChangedListener(object : TextWatcher { binding.colorHexInput.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged( override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) =
s: CharSequence?, Unit
start: Int,
count: Int,
after: Int
) = Unit
override fun onTextChanged( override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) = Unit
s: CharSequence?,
start: Int,
before: Int,
count: Int
) = Unit
var isValid = true var isValid = true
var oldHex = "" var oldHex = ""

View File

@ -61,8 +61,8 @@ class ShareDialog : DialogFragment() {
var url = when { var url = when {
shareObjectType == ShareObjectType.VIDEO && host == YOUTUBE_SHORT_URL -> "$YOUTUBE_SHORT_URL/$id" shareObjectType == ShareObjectType.VIDEO && host == YOUTUBE_SHORT_URL -> "$YOUTUBE_SHORT_URL/$id"
shareObjectType == ShareObjectType.VIDEO -> "$host/watch?v=$id" shareObjectType == ShareObjectType.VIDEO -> "$host/watch?v=$id"
shareObjectType == ShareObjectType.PLAYLIST -> "${host}/playlist?list=$id" shareObjectType == ShareObjectType.PLAYLIST -> "$host/playlist?list=$id"
else -> "${host}/channel/$id" else -> "$host/channel/$id"
} }
if (shareObjectType == ShareObjectType.VIDEO && binding.timeCodeSwitch.isChecked) { if (shareObjectType == ShareObjectType.VIDEO && binding.timeCodeSwitch.isChecked) {

View File

@ -15,7 +15,6 @@ import android.os.Looper
import android.os.PowerManager import android.os.PowerManager
import android.text.format.DateUtils import android.text.format.DateUtils
import android.text.util.Linkify import android.text.util.Linkify
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -1112,10 +1111,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
/** /**
* Set up the description text with video links and timestamps * Set up the description text with video links and timestamps
*/ */
private fun setupDescription( private fun setupDescription(descTextView: TextView, description: String) {
descTextView: TextView,
description: String
) {
// detect whether the description is html formatted // detect whether the description is html formatted
if (description.contains("<") && description.contains(">")) { if (description.contains("<") && description.contains(">")) {
descTextView.movementMethod = LinkMovementMethodCompat.getInstance() descTextView.movementMethod = LinkMovementMethodCompat.getInstance()

View File

@ -356,10 +356,7 @@ class PlaylistFragment : Fragment() {
return false return false
} }
override fun onSwiped( override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
viewHolder: RecyclerView.ViewHolder,
direction: Int
) {
playlistAdapter!!.removeFromPlaylist( playlistAdapter!!.removeFromPlaylist(
requireContext(), requireContext(),
viewHolder.absoluteAdapterPosition viewHolder.absoluteAdapterPosition

View File

@ -127,10 +127,7 @@ class WatchHistoryFragment : Fragment() {
return false return false
} }
override fun onSwiped( override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
viewHolder: RecyclerView.ViewHolder,
direction: Int
) {
val position = viewHolder.absoluteAdapterPosition val position = viewHolder.absoluteAdapterPosition
watchHistoryAdapter.removeFromWatchHistory(position) watchHistoryAdapter.removeFromWatchHistory(position)
} }

View File

@ -53,7 +53,8 @@ class ChaptersBottomSheet : UndimmedBottomSheet() {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
binding.optionsRecycler.layoutManager = LinearLayoutManager(context) binding.optionsRecycler.layoutManager = LinearLayoutManager(context)
val adapter = ChaptersAdapter(playerViewModel.chapters, playerViewModel.player?.duration ?: 0) { val adapter =
ChaptersAdapter(playerViewModel.chapters, playerViewModel.player?.duration ?: 0) {
playerViewModel.player?.seekTo(it) playerViewModel.player?.seekTo(it)
} }
binding.optionsRecycler.adapter = adapter binding.optionsRecycler.adapter = adapter

View File

@ -43,7 +43,7 @@ class VideoOptionsBottomSheet : BaseBottomSheet() {
val videoId = streamItem.url?.toID() ?: return val videoId = streamItem.url?.toID() ?: return
// List that stores the different menu options. In the future could be add more options here. // List that stores the different menu options. In the future could be add more options here.
val optionsList = mutableListOf( val optionsList = mutableListOf(
getString(R.string.playOnBackground), getString(R.string.playOnBackground)
) )
// Check whether the player is running and add queue options // Check whether the player is running and add queue options

View File

@ -315,10 +315,7 @@ class NowPlayingNotification(
/** /**
* Updates or creates the [notificationBuilder] * Updates or creates the [notificationBuilder]
*/ */
fun updatePlayerNotification( fun updatePlayerNotification(videoId: String, data: PlayerNotificationData) {
videoId: String,
data: PlayerNotificationData
) {
this.videoId = videoId this.videoId = videoId
this.notificationData = data this.notificationData = data
// reset the thumbnail bitmap in order to become reloaded for the new video // reset the thumbnail bitmap in order to become reloaded for the new video

View File

@ -213,10 +213,7 @@ class YoutubeHlsPlaylistParser : ParsingLoadable.Parser<HlsPlaylist> {
* @param acontValue the value of the `acont` property * @param acontValue the value of the `acont` property
* @return the full audio role flags of the audio track like described above * @return the full audio role flags of the audio track like described above
*/ */
private fun getFullAudioRoleFlags( private fun getFullAudioRoleFlags(roleFlags: Int, acontValue: String): Int {
roleFlags: Int,
acontValue: String
): Int {
val acontRoleFlags = when (acontValue.lowercase()) { val acontRoleFlags = when (acontValue.lowercase()) {
"dubbed" -> C.ROLE_FLAG_DUB "dubbed" -> C.ROLE_FLAG_DUB
"descriptive" -> C.ROLE_FLAG_DESCRIBES_VIDEO "descriptive" -> C.ROLE_FLAG_DESCRIBES_VIDEO