Merge pull request #5149 from Bnyro/master

style: run ktlint
This commit is contained in:
Bnyro 2023-11-14 19:07:06 +01:00 committed by GitHub
commit 014838b4a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 53 additions and 31 deletions

View File

@ -100,8 +100,9 @@ object SubscriptionHelper {
} else {
val subscriptions = Database.localSubscriptionDao().getAll().map { it.channelId }
when {
subscriptions.size > GET_SUBSCRIPTIONS_LIMIT -> RetrofitInstance.authApi
.unauthenticatedSubscriptions(subscriptions)
subscriptions.size > GET_SUBSCRIPTIONS_LIMIT ->
RetrofitInstance.authApi
.unauthenticatedSubscriptions(subscriptions)
else -> RetrofitInstance.authApi.unauthenticatedSubscriptions(
subscriptions.joinToString(",")
@ -116,8 +117,9 @@ object SubscriptionHelper {
} else {
val subscriptions = Database.localSubscriptionDao().getAll().map { it.channelId }
when {
subscriptions.size > GET_SUBSCRIPTIONS_LIMIT -> RetrofitInstance.authApi
.getUnauthenticatedFeed(subscriptions)
subscriptions.size > GET_SUBSCRIPTIONS_LIMIT ->
RetrofitInstance.authApi
.getUnauthenticatedFeed(subscriptions)
else -> RetrofitInstance.authApi.getUnauthenticatedFeed(
subscriptions.joinToString(",")

View File

@ -143,11 +143,19 @@ class PlaylistAdapter(
}
val shortTitle = TextUtils.limitTextToLength(video.title.orEmpty(), 50)
val snackBarText = rootView.context.getString(R.string.successfully_removed_from_playlist, shortTitle)
val snackBarText = rootView.context.getString(
R.string.successfully_removed_from_playlist,
shortTitle
)
Snackbar.make(rootView, snackBarText, Snackbar.LENGTH_LONG)
.setTextMaxLines(3)
.setAction(R.string.undo) {
reAddToPlaylist(appContext, video, sortedFeedPosition, originalPlaylistPosition)
reAddToPlaylist(
appContext,
video,
sortedFeedPosition,
originalPlaylistPosition
)
}
.show()
} catch (e: Exception) {

View File

@ -65,7 +65,8 @@ class AddToPlaylistDialog : DialogFragment() {
getButton(DialogInterface.BUTTON_NEGATIVE).setOnClickListener {
CreatePlaylistDialog().show(childFragmentManager, null)
}
getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener {val index = binding.playlistsSpinner.selectedItemPosition
getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener {
val index = binding.playlistsSpinner.selectedItemPosition
val playlist = playlists[index]
viewModel.lastSelectedPlaylistId = playlist.id!!
dialog?.hide()
@ -73,7 +74,6 @@ class AddToPlaylistDialog : DialogFragment() {
addToPlaylist(playlist.id, playlist.name!!)
dialog?.dismiss()
}
}
}
}

View File

@ -40,7 +40,11 @@ class CustomInstanceDialog : DialogFragment() {
}
} else {
// at least one empty input
Toast.makeText(requireContext(), R.string.empty_instance, Toast.LENGTH_SHORT).show()
Toast.makeText(
requireContext(),
R.string.empty_instance,
Toast.LENGTH_SHORT
).show()
}
}
.setNegativeButton(R.string.cancel, null)

View File

@ -25,11 +25,11 @@ import com.github.libretube.helpers.PreferenceHelper
import com.github.libretube.parcelable.DownloadData
import com.github.libretube.util.TextUtils
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import java.io.IOException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import retrofit2.HttpException
import java.io.IOException
class DownloadDialog : DialogFragment() {
private lateinit var videoId: String

View File

@ -5,7 +5,6 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.core.os.bundleOf
import androidx.core.view.children
import androidx.core.view.isGone
@ -32,11 +31,11 @@ import com.github.libretube.ui.adapters.VideosAdapter
import com.github.libretube.ui.dialogs.ShareDialog
import com.github.libretube.ui.extensions.setupSubscriptionButton
import com.github.libretube.util.deArrow
import java.io.IOException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import retrofit2.HttpException
import java.io.IOException
class ChannelFragment : Fragment() {
private var _binding: FragmentChannelBinding? = null

View File

@ -115,16 +115,16 @@ import com.github.libretube.util.TextUtils.toTimeInSeconds
import com.github.libretube.util.YoutubeHlsPlaylistParser
import com.github.libretube.util.deArrow
import com.google.android.material.elevation.SurfaceColors
import java.io.IOException
import java.util.*
import java.util.concurrent.Executors
import kotlin.math.abs
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlinx.serialization.encodeToString
import retrofit2.HttpException
import java.io.IOException
import java.util.*
import java.util.concurrent.Executors
import kotlin.math.abs
@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
class PlayerFragment : Fragment(), OnlinePlayerOptions {
@ -596,8 +596,11 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
binding.relatedRecView.layoutManager = LinearLayoutManager(
context,
if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT)
LinearLayoutManager.HORIZONTAL else LinearLayoutManager.VERTICAL,
if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
LinearLayoutManager.HORIZONTAL
} else {
LinearLayoutManager.VERTICAL
},
false
)
@ -874,7 +877,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
val videoStream = streams.videoStreams.firstOrNull()
val isShort = PlayingQueue.getCurrent()?.isShort == true ||
(videoStream?.height ?: 0) > (videoStream?.width ?: 0)
(videoStream?.height ?: 0) > (videoStream?.width ?: 0)
PlayingQueue.setOnQueueTapListener { streamItem ->
streamItem.url?.toID()?.let { playNextVideo(it) }
@ -887,8 +890,8 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
// set media sources for the player
initStreamSources()
if (PreferenceHelper.getBoolean(PreferenceKeys.AUTO_FULLSCREEN_SHORTS, false)
&& isShort && binding.playerMotionLayout.progress == 0f
if (PreferenceHelper.getBoolean(PreferenceKeys.AUTO_FULLSCREEN_SHORTS, false) &&
isShort && binding.playerMotionLayout.progress == 0f
) {
setFullscreen()
playerBinding.fullscreen.isVisible = true
@ -912,7 +915,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
if (binding.playerMotionLayout.progress != 1.0f) {
// show controllers when not in picture in picture mode
val inPipMode = PlayerHelper.pipEnabled &&
PictureInPictureCompat.isInPictureInPictureMode(requireActivity())
PictureInPictureCompat.isInPictureInPictureMode(requireActivity())
if (!inPipMode) {
binding.player.useController = true
}
@ -1024,7 +1027,11 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
streams.relatedStreams.filter { !it.title.isNullOrBlank() }.toMutableList(),
forceMode = if (
resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT
) VideosAdapter.Companion.ForceMode.RELATED else VideosAdapter.Companion.ForceMode.TRENDING
) {
VideosAdapter.Companion.ForceMode.RELATED
} else {
VideosAdapter.Companion.ForceMode.TRENDING
}
)
}

View File

@ -19,11 +19,11 @@ import com.github.libretube.ui.activities.SettingsActivity
import com.github.libretube.ui.adapters.VideosAdapter
import com.github.libretube.util.deArrow
import com.google.android.material.snackbar.Snackbar
import java.io.IOException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import retrofit2.HttpException
import java.io.IOException
class TrendsFragment : Fragment() {
private var _binding: FragmentTrendsBinding? = null

View File

@ -6,7 +6,6 @@ import android.view.View
import android.view.ViewGroup
import android.view.ViewGroup.MarginLayoutParams
import androidx.core.view.isVisible
import androidx.core.view.setMargins
import androidx.core.view.updateLayoutParams
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager

View File

@ -212,8 +212,11 @@ open class CustomExoPlayerView(
fun toggleSystemBars(showBars: Boolean) {
getWindow().toggleSystemBars(
types = if (showBars) WindowHelper.getGestureControlledBars(context)
else WindowInsetsCompat.Type.systemBars(),
types = if (showBars) {
WindowHelper.getGestureControlledBars(context)
} else {
WindowInsetsCompat.Type.systemBars()
},
showBars = showBars
)
}

View File

@ -22,4 +22,4 @@ class ExpandableTextView(context: Context, attributeSet: AttributeSet? = null) :
companion object {
private const val DEFAULT_MAX_LINES = 2
}
}
}

View File

@ -6,9 +6,6 @@ import android.os.Build
import android.text.format.DateUtils
import com.github.libretube.R
import com.github.libretube.ui.dialogs.ShareDialog
import kotlinx.datetime.toJavaLocalDate
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import java.time.Instant
import java.time.LocalDateTime
import java.time.ZoneId
@ -17,6 +14,9 @@ import java.time.format.FormatStyle
import java.time.temporal.ChronoUnit
import kotlin.time.Duration
import kotlinx.datetime.LocalDate as KotlinLocalDate
import kotlinx.datetime.toJavaLocalDate
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
object TextUtils {
/**