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.helpers.ProxyHelper
import com.github.libretube.json.SafeInstantSerializer import com.github.libretube.json.SafeInstantSerializer
import com.github.libretube.parcelable.DownloadData import com.github.libretube.parcelable.DownloadData
import kotlin.io.path.Path
import kotlinx.datetime.Instant import kotlinx.datetime.Instant
import kotlinx.datetime.TimeZone import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime import kotlinx.datetime.toLocalDateTime
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlin.io.path.Path
@Serializable @Serializable
data class Streams( data class Streams(

View File

@ -2,11 +2,11 @@ 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 java.nio.file.Path
import kotlin.io.path.Path
import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDate
import kotlinx.datetime.toLocalDate import kotlinx.datetime.toLocalDate
import kotlinx.serialization.encodeToString import kotlinx.serialization.encodeToString
import java.nio.file.Path
import kotlin.io.path.Path
object Converters { object Converters {
@TypeConverter @TypeConverter

View File

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

View File

@ -172,7 +172,12 @@ class OnlinePlayerService : LifecycleService() {
if (!keepQueue) PlayingQueue.clear() if (!keepQueue) PlayingQueue.clear()
if (PlayingQueue.isEmpty()) { 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) { } else if (PlayingQueue.isLast() && playlistId == null && channelId == null) {
PlayingQueue.insertRelatedStreams(streams!!.relatedStreams) 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.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

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

View File

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

View File

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

View File

@ -536,7 +536,9 @@ open class CustomExoPlayerView(
override fun onRepeatModeClicked() { override fun onRepeatModeClicked() {
// repeat mode options dialog // repeat mode options dialog
BaseBottomSheet() 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 PlayingQueue.repeatMode = PlayerHelper.repeatModes[index].first
} }
.show(supportFragmentManager) .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.HtmlParser
import com.github.libretube.util.LinkHandler import com.github.libretube.util.LinkHandler
import com.github.libretube.util.TextUtils import com.github.libretube.util.TextUtils
import java.util.Locale
import kotlinx.datetime.TimeZone import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime import kotlinx.datetime.toLocalDateTime
import java.util.Locale
class DescriptionLayout( class DescriptionLayout(
context: Context, context: Context,
attributeSet: AttributeSet? attributeSet: AttributeSet?
): LinearLayout(context, attributeSet) { ) : LinearLayout(context, attributeSet) {
val binding = DescriptionLayoutBinding.inflate(LayoutInflater.from(context), this, true) val binding = DescriptionLayoutBinding.inflate(LayoutInflater.from(context), this, true)
private var streams: Streams? = null private var streams: Streams? = null
var handleLink: (link: String) -> Unit = {} var handleLink: (link: String) -> Unit = {}
@ -117,14 +117,18 @@ class DescriptionLayout(
val viewInfo = context.getString(R.string.normal_views, views, localizeDate(streams)) val viewInfo = context.getString(R.string.normal_views, views, localizeDate(streams))
if (binding.descLinLayout.isVisible) { if (binding.descLinLayout.isVisible) {
// hide the description and chapters // 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 binding.descLinLayout.isGone = true
// limit the title height to two lines // limit the title height to two lines
binding.playerTitle.maxLines = 2 binding.playerTitle.maxLines = 2
} else { } else {
// show the description and chapters // 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 binding.descLinLayout.isVisible = true
// show the whole title // show the whole title