mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
style: run ktlint
This commit is contained in:
parent
9e8216acb0
commit
b1c16cc622
@ -47,9 +47,7 @@ interface PipedApi {
|
||||
): SegmentData
|
||||
|
||||
@GET("dearrow")
|
||||
suspend fun getDeArrowContent(
|
||||
@Query("videoIds") videoIds: String
|
||||
): JsonObject
|
||||
suspend fun getDeArrowContent(@Query("videoIds") videoIds: String): JsonObject
|
||||
|
||||
@GET("nextpage/comments/{videoId}")
|
||||
suspend fun getCommentsNextPage(
|
||||
@ -116,14 +114,10 @@ interface PipedApi {
|
||||
suspend fun getFeed(@Query("authToken") token: String?): List<StreamItem>
|
||||
|
||||
@GET("feed/unauthenticated")
|
||||
suspend fun getUnauthenticatedFeed(
|
||||
@Query("channels") channels: String
|
||||
): List<StreamItem>
|
||||
suspend fun getUnauthenticatedFeed(@Query("channels") channels: String): List<StreamItem>
|
||||
|
||||
@POST("feed/unauthenticated")
|
||||
suspend fun getUnauthenticatedFeed(
|
||||
@Body channels: List<String>
|
||||
): List<StreamItem>
|
||||
suspend fun getUnauthenticatedFeed(@Body channels: List<String>): List<StreamItem>
|
||||
|
||||
@GET("subscribed")
|
||||
suspend fun isSubscribed(
|
||||
@ -140,9 +134,7 @@ interface PipedApi {
|
||||
): List<Subscription>
|
||||
|
||||
@POST("subscriptions/unauthenticated")
|
||||
suspend fun unauthenticatedSubscriptions(
|
||||
@Body channels: List<String>
|
||||
): List<Subscription>
|
||||
suspend fun unauthenticatedSubscriptions(@Body channels: List<String>): List<Subscription>
|
||||
|
||||
@POST("subscribe")
|
||||
suspend fun subscribe(
|
||||
|
@ -19,5 +19,5 @@ data class Comment(
|
||||
val thumbnail: String,
|
||||
val verified: Boolean,
|
||||
val replyCount: Long,
|
||||
val creatorReplied: Boolean = false,
|
||||
val creatorReplied: Boolean = false
|
||||
) : Parcelable
|
||||
|
@ -6,8 +6,8 @@ import com.github.libretube.extensions.toLocalDateSafe
|
||||
import com.github.libretube.extensions.toMillis
|
||||
import com.github.libretube.helpers.ProxyHelper
|
||||
import com.github.libretube.parcelable.DownloadData
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.io.path.Path
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Streams(
|
||||
|
@ -3,10 +3,10 @@ package com.github.libretube.db
|
||||
import androidx.room.TypeConverter
|
||||
import com.github.libretube.api.JsonHelper
|
||||
import com.github.libretube.extensions.toLocalDateSafe
|
||||
import kotlinx.datetime.LocalDate
|
||||
import kotlinx.serialization.encodeToString
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.Path
|
||||
import kotlinx.datetime.LocalDate
|
||||
import kotlinx.serialization.encodeToString
|
||||
|
||||
object Converters {
|
||||
@TypeConverter
|
||||
|
@ -21,33 +21,34 @@ object DatabaseHelper {
|
||||
videoId,
|
||||
streams.toStreamItem(videoId)
|
||||
)
|
||||
suspend fun addToWatchHistory(
|
||||
videoId: String,
|
||||
stream: StreamItem
|
||||
) = withContext(Dispatchers.IO) {
|
||||
val watchHistoryItem = WatchHistoryItem(
|
||||
videoId,
|
||||
stream.title,
|
||||
Instant.fromEpochMilliseconds(stream.uploaded)
|
||||
.toLocalDateTime(TimeZone.currentSystemDefault()).date,
|
||||
stream.uploaderName,
|
||||
stream.uploaderUrl?.toID(),
|
||||
stream.uploaderAvatar,
|
||||
stream.thumbnail,
|
||||
stream.duration
|
||||
)
|
||||
Database.watchHistoryDao().insert(watchHistoryItem)
|
||||
val maxHistorySize = PreferenceHelper.getString(PreferenceKeys.WATCH_HISTORY_SIZE, "100")
|
||||
if (maxHistorySize == "unlimited") {
|
||||
return@withContext
|
||||
}
|
||||
suspend fun addToWatchHistory(videoId: String, stream: StreamItem) =
|
||||
withContext(Dispatchers.IO) {
|
||||
val watchHistoryItem = WatchHistoryItem(
|
||||
videoId,
|
||||
stream.title,
|
||||
Instant.fromEpochMilliseconds(stream.uploaded)
|
||||
.toLocalDateTime(TimeZone.currentSystemDefault()).date,
|
||||
stream.uploaderName,
|
||||
stream.uploaderUrl?.toID(),
|
||||
stream.uploaderAvatar,
|
||||
stream.thumbnail,
|
||||
stream.duration
|
||||
)
|
||||
Database.watchHistoryDao().insert(watchHistoryItem)
|
||||
val maxHistorySize = PreferenceHelper.getString(
|
||||
PreferenceKeys.WATCH_HISTORY_SIZE,
|
||||
"100"
|
||||
)
|
||||
if (maxHistorySize == "unlimited") {
|
||||
return@withContext
|
||||
}
|
||||
|
||||
// delete the first watch history entry if the limit is reached
|
||||
val watchHistory = Database.watchHistoryDao().getAll()
|
||||
if (watchHistory.size > maxHistorySize.toInt()) {
|
||||
Database.watchHistoryDao().delete(watchHistory.first())
|
||||
// delete the first watch history entry if the limit is reached
|
||||
val watchHistory = Database.watchHistoryDao().getAll()
|
||||
if (watchHistory.size > maxHistorySize.toInt()) {
|
||||
Database.watchHistoryDao().delete(watchHistory.first())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun addToSearchHistory(searchHistoryItem: SearchHistoryItem) {
|
||||
Database.searchHistoryDao().insert(searchHistoryItem)
|
||||
|
@ -7,4 +7,4 @@ import kotlinx.datetime.toLocalDate
|
||||
|
||||
fun LocalDate.toMillis() = this.atStartOfDayIn(TimeZone.UTC).toEpochMilliseconds()
|
||||
|
||||
fun String.toLocalDateSafe() = this.substring(0, 10).toLocalDate()
|
||||
fun String.toLocalDateSafe() = this.substring(0, 10).toLocalDate()
|
||||
|
@ -25,11 +25,7 @@ object DashHelper {
|
||||
val audioLocale: String? = null
|
||||
)
|
||||
|
||||
fun createManifest(
|
||||
streams: Streams,
|
||||
supportsHdr: Boolean,
|
||||
rewriteUrls: Boolean
|
||||
): String {
|
||||
fun createManifest(streams: Streams, supportsHdr: Boolean, rewriteUrls: Boolean): String {
|
||||
val builder = builderFactory.newDocumentBuilder()
|
||||
|
||||
val doc = builder.newDocument()
|
||||
@ -173,10 +169,7 @@ object DashHelper {
|
||||
return representation
|
||||
}
|
||||
|
||||
private fun createSegmentBaseElement(
|
||||
document: Document,
|
||||
stream: PipedStream
|
||||
): Element {
|
||||
private fun createSegmentBaseElement(document: Document, stream: PipedStream): Element {
|
||||
val segmentBase = document.createElement("SegmentBase")
|
||||
segmentBase.setAttribute("indexRange", "${stream.indexStart}-${stream.indexEnd}")
|
||||
|
||||
|
@ -25,10 +25,7 @@ import com.github.libretube.ui.views.SingleViewTouchableMotionLayout
|
||||
object NavigationHelper {
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
|
||||
fun navigateChannel(
|
||||
context: Context,
|
||||
channelId: String?
|
||||
) {
|
||||
fun navigateChannel(context: Context, channelId: String?) {
|
||||
if (channelId == null) return
|
||||
|
||||
val activity = ContextHelper.unwrapActivity(context)
|
||||
@ -85,11 +82,7 @@ object NavigationHelper {
|
||||
}
|
||||
}
|
||||
|
||||
fun navigatePlaylist(
|
||||
context: Context,
|
||||
playlistId: String?,
|
||||
playlistType: PlaylistType
|
||||
) {
|
||||
fun navigatePlaylist(context: Context, playlistId: String?, playlistType: PlaylistType) {
|
||||
if (playlistId == null) return
|
||||
|
||||
val activity = ContextHelper.unwrapActivity(context)
|
||||
|
@ -16,10 +16,7 @@ object NotificationHelper {
|
||||
/**
|
||||
* Enqueue the work manager task
|
||||
*/
|
||||
fun enqueueWork(
|
||||
context: Context,
|
||||
existingPeriodicWorkPolicy: ExistingPeriodicWorkPolicy
|
||||
) {
|
||||
fun enqueueWork(context: Context, existingPeriodicWorkPolicy: ExistingPeriodicWorkPolicy) {
|
||||
// get the notification preferences
|
||||
PreferenceHelper.initialize(context)
|
||||
val notificationsEnabled = PreferenceHelper.getBoolean(
|
||||
|
@ -40,11 +40,11 @@ import com.github.libretube.enums.SbSkipOptions
|
||||
import com.github.libretube.extensions.updateParameters
|
||||
import com.github.libretube.obj.VideoStats
|
||||
import com.github.libretube.util.TextUtils
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.math.absoluteValue
|
||||
import kotlin.math.roundToInt
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
object PlayerHelper {
|
||||
private const val ACTION_MEDIA_CONTROL = "media_control"
|
||||
@ -65,11 +65,7 @@ object PlayerHelper {
|
||||
/**
|
||||
* Create a base64 encoded DASH stream manifest
|
||||
*/
|
||||
fun createDashSource(
|
||||
streams: Streams,
|
||||
context: Context,
|
||||
disableProxy: Boolean
|
||||
): Uri {
|
||||
fun createDashSource(streams: Streams, context: Context, disableProxy: Boolean): Uri {
|
||||
val manifest = DashHelper.createManifest(
|
||||
streams,
|
||||
DisplayHelper.supportsHdr(context),
|
||||
@ -330,10 +326,12 @@ object PlayerHelper {
|
||||
)
|
||||
|
||||
fun shouldPlayNextVideo(isPlaylist: Boolean = false): Boolean {
|
||||
return autoPlayEnabled || (isPlaylist && PreferenceHelper.getBoolean(
|
||||
PreferenceKeys.AUTOPLAY_PLAYLISTS,
|
||||
false
|
||||
))
|
||||
return autoPlayEnabled || (
|
||||
isPlaylist && PreferenceHelper.getBoolean(
|
||||
PreferenceKeys.AUTOPLAY_PLAYLISTS,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private val handleAudioFocus
|
||||
@ -547,9 +545,9 @@ object PlayerHelper {
|
||||
if (currentPosition in segmentStart until segmentEnd) {
|
||||
if (sponsorBlockConfig[segment.category] == SbSkipOptions.AUTOMATIC ||
|
||||
(
|
||||
sponsorBlockConfig[segment.category] == SbSkipOptions.AUTOMATIC_ONCE &&
|
||||
!segment.skipped
|
||||
)
|
||||
sponsorBlockConfig[segment.category] == SbSkipOptions.AUTOMATIC_ONCE &&
|
||||
!segment.skipped
|
||||
)
|
||||
) {
|
||||
if (sponsorBlockNotifications) {
|
||||
runCatching {
|
||||
@ -561,9 +559,9 @@ object PlayerHelper {
|
||||
segment.skipped = true
|
||||
} else if (sponsorBlockConfig[segment.category] == SbSkipOptions.MANUAL ||
|
||||
(
|
||||
sponsorBlockConfig[segment.category] == SbSkipOptions.AUTOMATIC_ONCE &&
|
||||
segment.skipped
|
||||
)
|
||||
sponsorBlockConfig[segment.category] == SbSkipOptions.AUTOMATIC_ONCE &&
|
||||
segment.skipped
|
||||
)
|
||||
) {
|
||||
return segment
|
||||
}
|
||||
@ -747,9 +745,9 @@ object PlayerHelper {
|
||||
*/
|
||||
fun haveAudioTrackRoleFlagSet(@C.RoleFlags roleFlags: Int): Boolean {
|
||||
return isFlagSet(roleFlags, C.ROLE_FLAG_DESCRIBES_VIDEO) ||
|
||||
isFlagSet(roleFlags, C.ROLE_FLAG_DUB) ||
|
||||
isFlagSet(roleFlags, C.ROLE_FLAG_MAIN) ||
|
||||
isFlagSet(roleFlags, C.ROLE_FLAG_ALTERNATE)
|
||||
isFlagSet(roleFlags, C.ROLE_FLAG_DUB) ||
|
||||
isFlagSet(roleFlags, C.ROLE_FLAG_MAIN) ||
|
||||
isFlagSet(roleFlags, C.ROLE_FLAG_ALTERNATE)
|
||||
}
|
||||
|
||||
@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
|
||||
|
@ -33,9 +33,7 @@ object ThemeHelper {
|
||||
/**
|
||||
* Update the accent color of the app and apply dynamic colors if needed
|
||||
*/
|
||||
private fun updateAccentColor(
|
||||
activity: AppCompatActivity
|
||||
) {
|
||||
private fun updateAccentColor(activity: AppCompatActivity) {
|
||||
var accentColor = PreferenceHelper.getString(PreferenceKeys.ACCENT_COLOR, "")
|
||||
|
||||
// automatically choose an accent color on the first app startup
|
||||
@ -117,10 +115,8 @@ object ThemeHelper {
|
||||
/**
|
||||
* Get a color by a color resource attr
|
||||
*/
|
||||
fun getThemeColor(
|
||||
context: Context,
|
||||
colorCode: Int
|
||||
) = MaterialColors.getColor(context, colorCode, Color.TRANSPARENT)
|
||||
fun getThemeColor(context: Context, colorCode: Int) =
|
||||
MaterialColors.getColor(context, colorCode, Color.TRANSPARENT)
|
||||
|
||||
/**
|
||||
* Get the styled app name
|
||||
|
@ -19,7 +19,6 @@ import com.github.libretube.enums.FileType
|
||||
import com.github.libretube.extensions.toAndroidUri
|
||||
import com.github.libretube.extensions.updateParameters
|
||||
import com.github.libretube.helpers.PlayerHelper
|
||||
import com.github.libretube.helpers.PlayerHelper.loadPlaybackParams
|
||||
import com.github.libretube.obj.PlayerNotificationData
|
||||
import com.github.libretube.util.NowPlayingNotification
|
||||
import com.github.libretube.util.NowPlayingNotification.Companion.PLAYER_NOTIFICATION_ID
|
||||
|
@ -35,7 +35,6 @@ import com.github.libretube.extensions.toID
|
||||
import com.github.libretube.extensions.updateParameters
|
||||
import com.github.libretube.helpers.PlayerHelper
|
||||
import com.github.libretube.helpers.PlayerHelper.checkForSegments
|
||||
import com.github.libretube.helpers.PlayerHelper.loadPlaybackParams
|
||||
import com.github.libretube.helpers.ProxyHelper
|
||||
import com.github.libretube.obj.PlayerNotificationData
|
||||
import com.github.libretube.parcelable.PlayerData
|
||||
|
@ -36,10 +36,10 @@ import com.github.libretube.ui.interfaces.TimeFrameReceiver
|
||||
import com.github.libretube.ui.listeners.SeekbarPreviewListener
|
||||
import com.github.libretube.ui.models.PlayerViewModel
|
||||
import com.github.libretube.util.OfflineTimeFrameReceiver
|
||||
import kotlin.io.path.exists
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlin.io.path.exists
|
||||
|
||||
@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
|
||||
class OfflinePlayerActivity : BaseActivity() {
|
||||
|
@ -113,9 +113,9 @@ class VideosAdapter(
|
||||
}
|
||||
|
||||
val context = (
|
||||
holder.videoRowBinding ?: holder.trendingRowBinding
|
||||
holder.videoRowBinding ?: holder.trendingRowBinding
|
||||
?: holder.allCaughtUpBinding
|
||||
)!!.root.context
|
||||
)!!.root.context
|
||||
val activity = (context as BaseActivity)
|
||||
val fragmentManager = activity.supportFragmentManager
|
||||
|
||||
|
@ -39,19 +39,10 @@ class ColorPickerDialog : DialogFragment(), SeekBar.OnSeekBarChangeListener {
|
||||
|
||||
// Add listener to text input
|
||||
binding.colorHexInput.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(
|
||||
s: CharSequence?,
|
||||
start: Int,
|
||||
count: Int,
|
||||
after: Int
|
||||
) = Unit
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) =
|
||||
Unit
|
||||
|
||||
override fun onTextChanged(
|
||||
s: CharSequence?,
|
||||
start: Int,
|
||||
before: Int,
|
||||
count: Int
|
||||
) = Unit
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) = Unit
|
||||
|
||||
var isValid = true
|
||||
var oldHex = ""
|
||||
|
@ -61,8 +61,8 @@ class ShareDialog : DialogFragment() {
|
||||
var url = when {
|
||||
shareObjectType == ShareObjectType.VIDEO && host == YOUTUBE_SHORT_URL -> "$YOUTUBE_SHORT_URL/$id"
|
||||
shareObjectType == ShareObjectType.VIDEO -> "$host/watch?v=$id"
|
||||
shareObjectType == ShareObjectType.PLAYLIST -> "${host}/playlist?list=$id"
|
||||
else -> "${host}/channel/$id"
|
||||
shareObjectType == ShareObjectType.PLAYLIST -> "$host/playlist?list=$id"
|
||||
else -> "$host/channel/$id"
|
||||
}
|
||||
|
||||
if (shareObjectType == ShareObjectType.VIDEO && binding.timeCodeSwitch.isChecked) {
|
||||
|
@ -15,7 +15,6 @@ import android.os.Looper
|
||||
import android.os.PowerManager
|
||||
import android.text.format.DateUtils
|
||||
import android.text.util.Linkify
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -1112,10 +1111,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
/**
|
||||
* Set up the description text with video links and timestamps
|
||||
*/
|
||||
private fun setupDescription(
|
||||
descTextView: TextView,
|
||||
description: String
|
||||
) {
|
||||
private fun setupDescription(descTextView: TextView, description: String) {
|
||||
// detect whether the description is html formatted
|
||||
if (description.contains("<") && description.contains(">")) {
|
||||
descTextView.movementMethod = LinkMovementMethodCompat.getInstance()
|
||||
|
@ -356,10 +356,7 @@ class PlaylistFragment : Fragment() {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onSwiped(
|
||||
viewHolder: RecyclerView.ViewHolder,
|
||||
direction: Int
|
||||
) {
|
||||
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
|
||||
playlistAdapter!!.removeFromPlaylist(
|
||||
requireContext(),
|
||||
viewHolder.absoluteAdapterPosition
|
||||
|
@ -127,10 +127,7 @@ class WatchHistoryFragment : Fragment() {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onSwiped(
|
||||
viewHolder: RecyclerView.ViewHolder,
|
||||
direction: Int
|
||||
) {
|
||||
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
|
||||
val position = viewHolder.absoluteAdapterPosition
|
||||
watchHistoryAdapter.removeFromWatchHistory(position)
|
||||
}
|
||||
|
@ -53,9 +53,10 @@ class ChaptersBottomSheet : UndimmedBottomSheet() {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
binding.optionsRecycler.layoutManager = LinearLayoutManager(context)
|
||||
val adapter = ChaptersAdapter(playerViewModel.chapters, playerViewModel.player?.duration ?: 0) {
|
||||
playerViewModel.player?.seekTo(it)
|
||||
}
|
||||
val adapter =
|
||||
ChaptersAdapter(playerViewModel.chapters, playerViewModel.player?.duration ?: 0) {
|
||||
playerViewModel.player?.seekTo(it)
|
||||
}
|
||||
binding.optionsRecycler.adapter = adapter
|
||||
|
||||
binding.bottomSheetTitle.text = context?.getString(R.string.chapters)
|
||||
|
@ -43,7 +43,7 @@ class VideoOptionsBottomSheet : BaseBottomSheet() {
|
||||
val videoId = streamItem.url?.toID() ?: return
|
||||
// List that stores the different menu options. In the future could be add more options here.
|
||||
val optionsList = mutableListOf(
|
||||
getString(R.string.playOnBackground),
|
||||
getString(R.string.playOnBackground)
|
||||
)
|
||||
|
||||
// Check whether the player is running and add queue options
|
||||
|
@ -315,10 +315,7 @@ class NowPlayingNotification(
|
||||
/**
|
||||
* Updates or creates the [notificationBuilder]
|
||||
*/
|
||||
fun updatePlayerNotification(
|
||||
videoId: String,
|
||||
data: PlayerNotificationData
|
||||
) {
|
||||
fun updatePlayerNotification(videoId: String, data: PlayerNotificationData) {
|
||||
this.videoId = videoId
|
||||
this.notificationData = data
|
||||
// reset the thumbnail bitmap in order to become reloaded for the new video
|
||||
|
@ -213,10 +213,7 @@ class YoutubeHlsPlaylistParser : ParsingLoadable.Parser<HlsPlaylist> {
|
||||
* @param acontValue the value of the `acont` property
|
||||
* @return the full audio role flags of the audio track like described above
|
||||
*/
|
||||
private fun getFullAudioRoleFlags(
|
||||
roleFlags: Int,
|
||||
acontValue: String
|
||||
): Int {
|
||||
private fun getFullAudioRoleFlags(roleFlags: Int, acontValue: String): Int {
|
||||
val acontRoleFlags = when (acontValue.lowercase()) {
|
||||
"dubbed" -> C.ROLE_FLAG_DUB
|
||||
"descriptive" -> C.ROLE_FLAG_DESCRIBES_VIDEO
|
||||
|
Loading…
x
Reference in New Issue
Block a user