style: run ktlint

This commit is contained in:
Bnyro 2023-10-23 17:55:09 +02:00
parent fc9e3e6501
commit f99198f99a
10 changed files with 40 additions and 24 deletions

View File

@ -5,12 +5,12 @@ import com.github.libretube.enums.FileType
import com.github.libretube.helpers.ProxyHelper
import com.github.libretube.json.SafeInstantSerializer
import com.github.libretube.parcelable.DownloadData
import kotlin.io.path.Path
import kotlinx.datetime.Instant
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlin.io.path.Path
@Serializable
data class Streams(

View File

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

View File

@ -4,8 +4,8 @@ import androidx.media3.common.Player
import com.github.libretube.helpers.PlayerHelper
fun Player.togglePlayPauseState() {
val minBufferingReached = totalBufferedDuration >= PlayerHelper.MINIMUM_BUFFER_DURATION
|| currentPosition + PlayerHelper.MINIMUM_BUFFER_DURATION >= duration
val minBufferingReached = totalBufferedDuration >= PlayerHelper.MINIMUM_BUFFER_DURATION ||
currentPosition + PlayerHelper.MINIMUM_BUFFER_DURATION >= duration
when {
playerError != null -> {
prepare()

View File

@ -172,7 +172,12 @@ class OnlinePlayerService : LifecycleService() {
if (!keepQueue) PlayingQueue.clear()
if (PlayingQueue.isEmpty()) {
PlayingQueue.updateQueue(streams!!.toStreamItem(videoId), playlistId, channelId, streams!!.relatedStreams)
PlayingQueue.updateQueue(
streams!!.toStreamItem(videoId),
playlistId,
channelId,
streams!!.relatedStreams
)
} else if (PlayingQueue.isLast() && playlistId == null && channelId == null) {
PlayingQueue.insertRelatedStreams(streams!!.relatedStreams)
}

View File

@ -37,11 +37,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() {

View File

@ -54,9 +54,13 @@ class VoteForSegmentDialog : DialogFragment() {
?.uuid ?: return@setOnClickListener
// see https://wiki.sponsor.ajay.app/w/API_Docs#POST_/api/voteOnSponsorTime
val score = if (binding.upvote.isChecked) 1
else if (binding.downvote.isChecked) 0
else 20
val score = if (binding.upvote.isChecked) {
1
} else if (binding.downvote.isChecked) {
0
} else {
20
}
dialog?.hide()
lifecycleScope.launch(Dispatchers.IO) {

View File

@ -20,7 +20,6 @@ import android.view.View
import android.view.ViewGroup
import android.view.ViewGroup.LayoutParams
import android.widget.Toast
import android.window.OnBackInvokedDispatcher
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.constraintlayout.motion.widget.TransitionAdapter
import androidx.core.content.getSystemService
@ -200,7 +199,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
private var playerLayoutOrientation = Int.MIN_VALUE
private val fullscreenDialog by lazy {
object: Dialog(requireContext(), android.R.style.Theme_Black_NoTitleBar_Fullscreen) {
object : Dialog(requireContext(), android.R.style.Theme_Black_NoTitleBar_Fullscreen) {
override fun onBackPressed() {
super.onBackPressed()
unsetFullscreen()
@ -1595,7 +1594,11 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
* If true, the activity will be automatically restarted
*/
private fun checkForNecessaryOrientationRestart() {
val lockedOrientations = listOf(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
val lockedOrientations =
listOf(
ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT,
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
)
if (mainActivity.screenOrientationPref in lockedOrientations) return
val orientation = resources.configuration.orientation

View File

@ -5,7 +5,6 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
import androidx.core.view.isVisible
import androidx.fragment.app.activityViewModels
import androidx.fragment.app.commit

View File

@ -536,7 +536,9 @@ open class CustomExoPlayerView(
override fun onRepeatModeClicked() {
// repeat mode options dialog
BaseBottomSheet()
.setSimpleItems(PlayerHelper.repeatModes.map { context.getString(it.second) }) { index ->
.setSimpleItems(
PlayerHelper.repeatModes.map { context.getString(it.second) }
) { index ->
PlayingQueue.repeatMode = PlayerHelper.repeatModes[index].first
}
.show(supportFragmentManager)

View File

@ -19,14 +19,14 @@ import com.github.libretube.ui.activities.VideoTagsAdapter
import com.github.libretube.util.HtmlParser
import com.github.libretube.util.LinkHandler
import com.github.libretube.util.TextUtils
import java.util.Locale
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime
import java.util.Locale
class DescriptionLayout(
context: Context,
attributeSet: AttributeSet?
): LinearLayout(context, attributeSet) {
) : LinearLayout(context, attributeSet) {
val binding = DescriptionLayoutBinding.inflate(LayoutInflater.from(context), this, true)
private var streams: Streams? = null
var handleLink: (link: String) -> Unit = {}
@ -117,14 +117,18 @@ class DescriptionLayout(
val viewInfo = context.getString(R.string.normal_views, views, localizeDate(streams))
if (binding.descLinLayout.isVisible) {
// hide the description and chapters
binding.playerDescriptionArrow.animate().rotation(0F).setDuration(ANIMATION_DURATION).start()
binding.playerDescriptionArrow.animate().rotation(
0F
).setDuration(ANIMATION_DURATION).start()
binding.descLinLayout.isGone = true
// limit the title height to two lines
binding.playerTitle.maxLines = 2
} else {
// show the description and chapters
binding.playerDescriptionArrow.animate().rotation(180F).setDuration(ANIMATION_DURATION).start()
binding.playerDescriptionArrow.animate().rotation(
180F
).setDuration(ANIMATION_DURATION).start()
binding.descLinLayout.isVisible = true
// show the whole title