From f99198f99a4a4487e72f478264f798dcf8c54002 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 23 Oct 2023 17:55:09 +0200 Subject: [PATCH] style: run ktlint --- .../com/github/libretube/api/obj/Streams.kt | 2 +- .../java/com/github/libretube/db/Converters.kt | 4 ++-- .../com/github/libretube/extensions/Player.kt | 4 ++-- .../libretube/services/OnlinePlayerService.kt | 7 ++++++- .../ui/activities/OfflinePlayerActivity.kt | 3 +-- .../ui/dialogs/VoteForSegmentDialog.kt | 12 ++++++++---- .../libretube/ui/fragments/PlayerFragment.kt | 9 ++++++--- .../libretube/ui/sheets/CommentsSheet.kt | 1 - .../libretube/ui/views/CustomExoPlayerView.kt | 4 +++- .../libretube/ui/views/DescriptionLayout.kt | 18 +++++++++++------- 10 files changed, 40 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/com/github/libretube/api/obj/Streams.kt b/app/src/main/java/com/github/libretube/api/obj/Streams.kt index 1607cc204..28009bedb 100644 --- a/app/src/main/java/com/github/libretube/api/obj/Streams.kt +++ b/app/src/main/java/com/github/libretube/api/obj/Streams.kt @@ -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( diff --git a/app/src/main/java/com/github/libretube/db/Converters.kt b/app/src/main/java/com/github/libretube/db/Converters.kt index 71bfb289a..c4e38ee43 100644 --- a/app/src/main/java/com/github/libretube/db/Converters.kt +++ b/app/src/main/java/com/github/libretube/db/Converters.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/extensions/Player.kt b/app/src/main/java/com/github/libretube/extensions/Player.kt index cb168fb89..4294297aa 100644 --- a/app/src/main/java/com/github/libretube/extensions/Player.kt +++ b/app/src/main/java/com/github/libretube/extensions/Player.kt @@ -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() diff --git a/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt b/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt index 47daf74dd..3919055fc 100644 --- a/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt +++ b/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt @@ -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) } diff --git a/app/src/main/java/com/github/libretube/ui/activities/OfflinePlayerActivity.kt b/app/src/main/java/com/github/libretube/ui/activities/OfflinePlayerActivity.kt index 04e522821..f16806153 100644 --- a/app/src/main/java/com/github/libretube/ui/activities/OfflinePlayerActivity.kt +++ b/app/src/main/java/com/github/libretube/ui/activities/OfflinePlayerActivity.kt @@ -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() { diff --git a/app/src/main/java/com/github/libretube/ui/dialogs/VoteForSegmentDialog.kt b/app/src/main/java/com/github/libretube/ui/dialogs/VoteForSegmentDialog.kt index f040eb7db..17d0b0e1a 100644 --- a/app/src/main/java/com/github/libretube/ui/dialogs/VoteForSegmentDialog.kt +++ b/app/src/main/java/com/github/libretube/ui/dialogs/VoteForSegmentDialog.kt @@ -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) { @@ -104,4 +108,4 @@ class VoteForSegmentDialog : DialogFragment() { super.onDestroyView() _binding = null } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index 78109d89f..cf3d5323d 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/ui/sheets/CommentsSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/CommentsSheet.kt index 43f992e96..27392b49c 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/CommentsSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/CommentsSheet.kt @@ -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 diff --git a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt index 27c5fec2d..353e18f31 100644 --- a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt +++ b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt @@ -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) diff --git a/app/src/main/java/com/github/libretube/ui/views/DescriptionLayout.kt b/app/src/main/java/com/github/libretube/ui/views/DescriptionLayout.kt index 627df76f3..1749e2f60 100644 --- a/app/src/main/java/com/github/libretube/ui/views/DescriptionLayout.kt +++ b/app/src/main/java/com/github/libretube/ui/views/DescriptionLayout.kt @@ -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 = {} @@ -73,8 +73,8 @@ class DescriptionLayout( }.orEmpty() additionalVideoInfo.text = "${context?.getString(R.string.category)}: ${streams.category}\n" + - "${context?.getString(R.string.license)}: ${streams.license}\n" + - "${context?.getString(R.string.visibility)}: $visibility" + "${context?.getString(R.string.license)}: ${streams.license}\n" + + "${context?.getString(R.string.visibility)}: $visibility" if (streams.tags.isNotEmpty()) { binding.tagsRecycler.layoutManager = @@ -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 @@ -143,4 +147,4 @@ class DescriptionLayout( companion object { private const val ANIMATION_DURATION = 250L } -} \ No newline at end of file +}