From 8e133f79ca18edd0f6a9cc7a9af7463ffcbc7c31 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 20 Jul 2023 15:02:13 +0200 Subject: [PATCH] chore: fix project formatting --- .../java/com/github/libretube/LibreTubeApp.kt | 1 - .../github/libretube/api/RetrofitInstance.kt | 10 +-- .../libretube/api/obj/DeArrowContent.kt | 2 +- .../libretube/api/obj/DeArrowThumbnail.kt | 2 +- .../github/libretube/api/obj/DeArrowTitle.kt | 2 +- .../libretube/db/obj/WatchHistoryItem.kt | 22 +++--- .../libretube/extensions/FormatFileSize.kt | 4 +- .../github/libretube/extensions/LocalDate.kt | 2 +- .../github/libretube/helpers/BackupHelper.kt | 5 +- .../github/libretube/helpers/PlayerHelper.kt | 32 +++++---- .../github/libretube/helpers/ProxyHelper.kt | 1 - .../libretube/services/DownloadService.kt | 12 ++-- .../libretube/services/OnlinePlayerService.kt | 4 +- .../libretube/ui/adapters/DownloadsAdapter.kt | 4 +- .../ui/dialogs/AddToPlaylistDialog.kt | 10 ++- .../ui/fragments/AudioPlayerFragment.kt | 1 - .../ui/fragments/DownloadsFragment.kt | 6 +- .../libretube/ui/fragments/PlayerFragment.kt | 29 ++++---- .../ui/fragments/SubscriptionsFragment.kt | 2 - .../ui/sheets/DownloadOptionsBottomSheet.kt | 1 - .../libretube/ui/views/CustomExoPlayerView.kt | 1 - .../libretube/ui/views/OnlinePlayerView.kt | 72 +++++++++---------- .../com/github/libretube/util/DeArrowUtil.kt | 2 +- .../libretube/util/NowPlayingNotification.kt | 4 +- 24 files changed, 124 insertions(+), 107 deletions(-) diff --git a/app/src/main/java/com/github/libretube/LibreTubeApp.kt b/app/src/main/java/com/github/libretube/LibreTubeApp.kt index 68d63d64d..8a283c259 100644 --- a/app/src/main/java/com/github/libretube/LibreTubeApp.kt +++ b/app/src/main/java/com/github/libretube/LibreTubeApp.kt @@ -4,7 +4,6 @@ import android.app.Application import androidx.core.app.NotificationChannelCompat import androidx.core.app.NotificationManagerCompat import androidx.work.ExistingPeriodicWorkPolicy -import com.github.libretube.api.RetrofitInstance import com.github.libretube.constants.BACKGROUND_CHANNEL_ID import com.github.libretube.constants.DOWNLOAD_CHANNEL_ID import com.github.libretube.constants.PUSH_CHANNEL_ID diff --git a/app/src/main/java/com/github/libretube/api/RetrofitInstance.kt b/app/src/main/java/com/github/libretube/api/RetrofitInstance.kt index 0b9081719..12bec7bde 100644 --- a/app/src/main/java/com/github/libretube/api/RetrofitInstance.kt +++ b/app/src/main/java/com/github/libretube/api/RetrofitInstance.kt @@ -11,10 +11,12 @@ import retrofit2.create object RetrofitInstance { private val url get() = PreferenceHelper.getString(PreferenceKeys.FETCH_INSTANCE, PIPED_API_URL) private val authUrl - get() = when (PreferenceHelper.getBoolean( - PreferenceKeys.AUTH_INSTANCE_TOGGLE, - false - )) { + get() = when ( + PreferenceHelper.getBoolean( + PreferenceKeys.AUTH_INSTANCE_TOGGLE, + false + ) + ) { true -> PreferenceHelper.getString( PreferenceKeys.AUTH_INSTANCE, PIPED_API_URL diff --git a/app/src/main/java/com/github/libretube/api/obj/DeArrowContent.kt b/app/src/main/java/com/github/libretube/api/obj/DeArrowContent.kt index 0b060109b..f3d86800b 100644 --- a/app/src/main/java/com/github/libretube/api/obj/DeArrowContent.kt +++ b/app/src/main/java/com/github/libretube/api/obj/DeArrowContent.kt @@ -8,4 +8,4 @@ data class DeArrowContent( val titles: List, val randomTime: Float?, val videoDuration: Float? -) \ No newline at end of file +) diff --git a/app/src/main/java/com/github/libretube/api/obj/DeArrowThumbnail.kt b/app/src/main/java/com/github/libretube/api/obj/DeArrowThumbnail.kt index 84a17d198..d2775125d 100644 --- a/app/src/main/java/com/github/libretube/api/obj/DeArrowThumbnail.kt +++ b/app/src/main/java/com/github/libretube/api/obj/DeArrowThumbnail.kt @@ -10,4 +10,4 @@ data class DeArrowThumbnail( val thumbnail: String? = null, val timestamp: Float?, val votes: Int -) \ No newline at end of file +) diff --git a/app/src/main/java/com/github/libretube/api/obj/DeArrowTitle.kt b/app/src/main/java/com/github/libretube/api/obj/DeArrowTitle.kt index 76d392c2b..0a6154911 100644 --- a/app/src/main/java/com/github/libretube/api/obj/DeArrowTitle.kt +++ b/app/src/main/java/com/github/libretube/api/obj/DeArrowTitle.kt @@ -9,4 +9,4 @@ data class DeArrowTitle( val original: Boolean, val title: String, val votes: Int -) \ No newline at end of file +) diff --git a/app/src/main/java/com/github/libretube/db/obj/WatchHistoryItem.kt b/app/src/main/java/com/github/libretube/db/obj/WatchHistoryItem.kt index 26f27097c..1f7badf77 100644 --- a/app/src/main/java/com/github/libretube/db/obj/WatchHistoryItem.kt +++ b/app/src/main/java/com/github/libretube/db/obj/WatchHistoryItem.kt @@ -20,15 +20,15 @@ data class WatchHistoryItem( @ColumnInfo var thumbnailUrl: String? = null, @ColumnInfo val duration: Long? = null ) { - fun toStreamItem() = StreamItem( - url = videoId, - type = "stream", - title = title, - thumbnail = thumbnailUrl, - uploaderName = uploader, - uploaded = uploadDate?.toMillis(), - uploaderAvatar = uploaderAvatar, - uploaderUrl = uploaderUrl, - duration = duration - ) + fun toStreamItem() = StreamItem( + url = videoId, + type = "stream", + title = title, + thumbnail = thumbnailUrl, + uploaderName = uploader, + uploaded = uploadDate?.toMillis(), + uploaderAvatar = uploaderAvatar, + uploaderUrl = uploaderUrl, + duration = duration + ) } diff --git a/app/src/main/java/com/github/libretube/extensions/FormatFileSize.kt b/app/src/main/java/com/github/libretube/extensions/FormatFileSize.kt index b068964d7..ffc5fbbb9 100644 --- a/app/src/main/java/com/github/libretube/extensions/FormatFileSize.kt +++ b/app/src/main/java/com/github/libretube/extensions/FormatFileSize.kt @@ -15,7 +15,9 @@ fun Int.formatAsFileSize(): String { fun Long.formatAsFileSize(): String { return log2(if (this != 0L) toDouble() else 1.0).toInt().div(10).let { val precision = when (it) { - 0 -> 0; 1 -> 1; else -> 2 + 0 -> 0 + 1 -> 1 + else -> 2 } val prefix = arrayOf("", "K", "M", "G", "T", "P", "E", "Z", "Y") String.format("%.${precision}f ${prefix[it]}B", toDouble() / 2.0.pow(it * 10.0)) diff --git a/app/src/main/java/com/github/libretube/extensions/LocalDate.kt b/app/src/main/java/com/github/libretube/extensions/LocalDate.kt index d8eab8afc..370d9a17a 100644 --- a/app/src/main/java/com/github/libretube/extensions/LocalDate.kt +++ b/app/src/main/java/com/github/libretube/extensions/LocalDate.kt @@ -4,4 +4,4 @@ import kotlinx.datetime.LocalDate import kotlinx.datetime.TimeZone import kotlinx.datetime.atStartOfDayIn -fun LocalDate.toMillis() = this.atStartOfDayIn(TimeZone.UTC).toEpochMilliseconds() \ No newline at end of file +fun LocalDate.toMillis() = this.atStartOfDayIn(TimeZone.UTC).toEpochMilliseconds() diff --git a/app/src/main/java/com/github/libretube/helpers/BackupHelper.kt b/app/src/main/java/com/github/libretube/helpers/BackupHelper.kt index a1770ff7d..48f523741 100644 --- a/app/src/main/java/com/github/libretube/helpers/BackupHelper.kt +++ b/app/src/main/java/com/github/libretube/helpers/BackupHelper.kt @@ -92,7 +92,10 @@ object BackupHelper { is Int -> { when { // we only use integers for SponsorBlock colors and the start fragment - key == PreferenceKeys.START_FRAGMENT || key.orEmpty().contains("_color") -> putInt(key, value) + key == PreferenceKeys.START_FRAGMENT || key.orEmpty().contains("_color") -> putInt( + key, + value + ) else -> putLong(key, value.toLong()) } } diff --git a/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt b/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt index 34719292c..244f909df 100644 --- a/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt +++ b/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt @@ -41,10 +41,10 @@ import com.github.libretube.enums.SbSkipOptions import com.github.libretube.extensions.updateParameters import com.github.libretube.obj.PreviewFrame import com.google.android.material.dialog.MaterialAlertDialogBuilder -import kotlinx.coroutines.runBlocking import java.util.Locale import kotlin.math.absoluteValue import kotlin.math.roundToInt +import kotlinx.coroutines.runBlocking object PlayerHelper { private const val ACTION_MEDIA_CONTROL = "media_control" @@ -662,12 +662,15 @@ object PlayerHelper { val audioLanguage = audioLanguageAndRoleFlags.first return context.getString(R.string.audio_track_format) .format( - if (audioLanguage == null) context.getString(R.string.unknown_audio_language) - else Locale.forLanguageTag(audioLanguage) - .getDisplayLanguage( - LocaleHelper.getAppLocale() - ) - .ifEmpty { context.getString(R.string.unknown_audio_language) }, + if (audioLanguage == null) { + context.getString(R.string.unknown_audio_language) + } else { + Locale.forLanguageTag(audioLanguage) + .getDisplayLanguage( + LocaleHelper.getAppLocale() + ) + .ifEmpty { context.getString(R.string.unknown_audio_language) } + }, getDisplayAudioTrackTypeFromFormat(context, audioLanguageAndRoleFlags.second) ) } @@ -691,12 +694,15 @@ object PlayerHelper { // Filter unsupported tracks and keep only selected tracks if requested // Use a lambda expression to avoid checking on each audio format if we keep only selected // tracks or not - val trackFilter = if (keepOnlySelectedTracks) + val trackFilter = if (keepOnlySelectedTracks) { { group: Tracks.Group, trackIndex: Int -> group.isTrackSupported(trackIndex) && group.isTrackSelected( trackIndex ) - } else { group: Tracks.Group, trackIndex: Int -> group.isTrackSupported(trackIndex) } + } + } else { + { group: Tracks.Group, trackIndex: Int -> group.isTrackSupported(trackIndex) } + } return groups.filter { it.type == C.TRACK_TYPE_AUDIO @@ -729,9 +735,9 @@ object PlayerHelper { * @return whether the provided ExoPlayer flags contain a flag used for audio track types */ 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) + 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) } } diff --git a/app/src/main/java/com/github/libretube/helpers/ProxyHelper.kt b/app/src/main/java/com/github/libretube/helpers/ProxyHelper.kt index b6e15e581..aefa2f454 100644 --- a/app/src/main/java/com/github/libretube/helpers/ProxyHelper.kt +++ b/app/src/main/java/com/github/libretube/helpers/ProxyHelper.kt @@ -1,6 +1,5 @@ package com.github.libretube.helpers -import android.util.Log import com.github.libretube.api.CronetHelper import com.github.libretube.api.RetrofitInstance import com.github.libretube.constants.PreferenceKeys diff --git a/app/src/main/java/com/github/libretube/services/DownloadService.kt b/app/src/main/java/com/github/libretube/services/DownloadService.kt index e1899febd..47d353183 100644 --- a/app/src/main/java/com/github/libretube/services/DownloadService.kt +++ b/app/src/main/java/com/github/libretube/services/DownloadService.kt @@ -47,6 +47,11 @@ import java.net.URL import java.nio.file.Path import java.nio.file.StandardOpenOption import java.util.concurrent.Executors +import kotlin.io.path.absolute +import kotlin.io.path.createFile +import kotlin.io.path.deleteIfExists +import kotlin.io.path.fileSize +import kotlin.math.min import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -61,11 +66,6 @@ import kotlinx.coroutines.withContext import okio.buffer import okio.sink import okio.source -import kotlin.io.path.absolute -import kotlin.io.path.createFile -import kotlin.io.path.deleteIfExists -import kotlin.io.path.fileSize -import kotlin.math.min /** * Download service with custom implementation of downloading using [HttpURLConnection]. @@ -206,7 +206,7 @@ class DownloadService : LifecycleService() { notificationBuilder .setContentText( totalRead.formatAsFileSize() + " / " + - item.downloadSize.formatAsFileSize() + item.downloadSize.formatAsFileSize() ) .setProgress( item.downloadSize.toInt(), 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 3c858e81b..a5494583c 100644 --- a/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt +++ b/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt @@ -303,7 +303,9 @@ class OnlinePlayerService : LifecycleService() { val streams = streams ?: return val (uri, mimeType) = if (streams.audioStreams.isNotEmpty()) { - val disableProxy = ProxyHelper.useYouTubeSourceWithoutProxy(streams.videoStreams.first().url!!) + val disableProxy = ProxyHelper.useYouTubeSourceWithoutProxy( + streams.videoStreams.first().url!! + ) PlayerHelper.createDashSource( streams, this, diff --git a/app/src/main/java/com/github/libretube/ui/adapters/DownloadsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/DownloadsAdapter.kt index b8e9dd8b4..b7c9e9410 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/DownloadsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/DownloadsAdapter.kt @@ -20,10 +20,10 @@ import com.github.libretube.ui.sheets.DownloadOptionsBottomSheet import com.github.libretube.ui.viewholders.DownloadsViewHolder import com.github.libretube.util.TextUtils import com.google.android.material.dialog.MaterialAlertDialogBuilder -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.runBlocking import kotlin.io.path.deleteIfExists import kotlin.io.path.fileSize +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.runBlocking class DownloadsAdapter( private val context: Context, diff --git a/app/src/main/java/com/github/libretube/ui/dialogs/AddToPlaylistDialog.kt b/app/src/main/java/com/github/libretube/ui/dialogs/AddToPlaylistDialog.kt index 13978a957..42452f6cc 100644 --- a/app/src/main/java/com/github/libretube/ui/dialogs/AddToPlaylistDialog.kt +++ b/app/src/main/java/com/github/libretube/ui/dialogs/AddToPlaylistDialog.kt @@ -104,8 +104,12 @@ class AddToPlaylistDialog( appContext.toastFromMainDispatcher(R.string.unknown_error) return } - if (success) appContext.toastFromMainDispatcher( - appContext.getString(R.string.added_to_playlist, playlistName) - ) else appContext.toastFromMainDispatcher(R.string.fail) + if (success) { + appContext.toastFromMainDispatcher( + appContext.getString(R.string.added_to_playlist, playlistName) + ) + } else { + appContext.toastFromMainDispatcher(R.string.fail) + } } } diff --git a/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt index 150e92afd..585398e34 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt @@ -13,7 +13,6 @@ import android.text.format.DateUtils import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.Toast import androidx.constraintlayout.motion.widget.MotionLayout import androidx.constraintlayout.motion.widget.TransitionAdapter import androidx.core.view.isVisible diff --git a/app/src/main/java/com/github/libretube/ui/fragments/DownloadsFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/DownloadsFragment.kt index 236cd83f4..7960fb04e 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/DownloadsFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/DownloadsFragment.kt @@ -25,12 +25,12 @@ import com.github.libretube.receivers.DownloadReceiver import com.github.libretube.services.DownloadService import com.github.libretube.ui.adapters.DownloadsAdapter import com.github.libretube.ui.viewholders.DownloadsViewHolder +import kotlin.io.path.fileSize import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking -import kotlin.io.path.fileSize class DownloadsFragment : Fragment() { private var _binding: FragmentDownloadsBinding? = null @@ -113,7 +113,7 @@ class DownloadsFragment : Fragment() { binding.downloads.adapter = adapter - val itemTouchCallback = object: ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) { + val itemTouchCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) { override fun getMovementFlags( recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder @@ -196,7 +196,7 @@ class DownloadsFragment : Fragment() { if (progressBar.isIndeterminate) return progressBar.incrementProgressBy(status.progress.toInt()) val progressInfo = progressBar.progress.formatAsFileSize() + - " /\n" + progressBar.max.formatAsFileSize() + " /\n" + progressBar.max.formatAsFileSize() fileSize.text = progressInfo } 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 d9f4e0e46..4adb3ab53 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 @@ -115,16 +115,16 @@ import com.github.libretube.util.TextUtils import com.github.libretube.util.TextUtils.toTimeInSeconds import com.github.libretube.util.YoutubeHlsPlaylistParser import com.github.libretube.util.deArrow +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 { @@ -755,7 +755,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 } @@ -1298,9 +1298,11 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { ) && streams.videoStreams.isNotEmpty() -> { // only use the dash manifest generated by YT if either it's a livestream or no other source is available val dashUri = - if (streams.livestream && streams.dash != null) ProxyHelper.unwrapStreamUrl( - streams.dash!! - ).toUri() else { + if (streams.livestream && streams.dash != null) { + ProxyHelper.unwrapStreamUrl( + streams.dash!! + ).toUri() + } else { // skip LBRY urls when checking whether the stream source is usable val urlToTest = streams.videoStreams.firstOrNull { !it.quality.orEmpty().contains("LBRY") @@ -1324,7 +1326,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { val mediaSource = hlsMediaSourceFactory.createMediaSource( createMediaItem( ProxyHelper.unwrapStreamUrl(streams.hls!!).toUri(), - MimeTypes.APPLICATION_M3U8, + MimeTypes.APPLICATION_M3U8 ) ) exoPlayer.setMediaSource(mediaSource) @@ -1448,7 +1450,8 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { override fun onAudioStreamClicked() { val context = requireContext() val audioLanguagesAndRoleFlags = PlayerHelper.getAudioLanguagesAndRoleFlagsFromTrackGroups( - exoPlayer.currentTracks.groups, false + exoPlayer.currentTracks.groups, + false ) val audioLanguages = audioLanguagesAndRoleFlags.map { PlayerHelper.getAudioTrackNameFromFormat(context, it) @@ -1460,9 +1463,9 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { listOf(context.getString(R.string.unknown_or_no_audio)), null ) - } else if (audioLanguagesAndRoleFlags.size == 1 - && audioLanguagesAndRoleFlags[0].first == null - && !PlayerHelper.haveAudioTrackRoleFlagSet( + } else if (audioLanguagesAndRoleFlags.size == 1 && + audioLanguagesAndRoleFlags[0].first == null && + !PlayerHelper.haveAudioTrackRoleFlagSet( audioLanguagesAndRoleFlags[0].second ) ) { diff --git a/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt index b0d22af7a..6df337b7a 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt @@ -2,12 +2,10 @@ package com.github.libretube.ui.fragments import android.annotation.SuppressLint import android.os.Bundle -import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.view.ViewGroup.MarginLayoutParams -import android.widget.Toast import androidx.core.view.children import androidx.core.view.isGone import androidx.core.view.isVisible diff --git a/app/src/main/java/com/github/libretube/ui/sheets/DownloadOptionsBottomSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/DownloadOptionsBottomSheet.kt index 966dc9c8f..40b998826 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/DownloadOptionsBottomSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/DownloadOptionsBottomSheet.kt @@ -11,7 +11,6 @@ import com.github.libretube.helpers.NavigationHelper import com.github.libretube.obj.ShareData import com.github.libretube.services.OfflinePlayerService import com.github.libretube.ui.dialogs.ShareDialog -import com.google.android.material.dialog.MaterialAlertDialogBuilder class DownloadOptionsBottomSheet( private val download: Download, 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 b201f3c62..7424de151 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 @@ -84,7 +84,6 @@ open class CustomExoPlayerView( updateCurrentPosition() } - /** * Preferences */ diff --git a/app/src/main/java/com/github/libretube/ui/views/OnlinePlayerView.kt b/app/src/main/java/com/github/libretube/ui/views/OnlinePlayerView.kt index 39b061641..f5ce88fa8 100644 --- a/app/src/main/java/com/github/libretube/ui/views/OnlinePlayerView.kt +++ b/app/src/main/java/com/github/libretube/ui/views/OnlinePlayerView.kt @@ -28,41 +28,41 @@ class OnlinePlayerView( @androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class) override fun getOptionsMenuItems(): List { return super.getOptionsMenuItems() + - listOf( - BottomSheetItem( - context.getString(R.string.quality), - R.drawable.ic_hd, - { "${player?.videoSize?.height}p" } - ) { - playerOptions?.onQualityClicked() - }, - BottomSheetItem( - context.getString(R.string.audio_track), - R.drawable.ic_audio, - { getCurrentAudioTrackTitle() } - ) { - playerOptions?.onAudioStreamClicked() - }, - BottomSheetItem( - context.getString(R.string.captions), - R.drawable.ic_caption, - { - if (trackSelector != null && trackSelector!!.parameters.preferredTextLanguages.isNotEmpty()) { - trackSelector!!.parameters.preferredTextLanguages[0] - } else { - context.getString(R.string.none) - } + listOf( + BottomSheetItem( + context.getString(R.string.quality), + R.drawable.ic_hd, + { "${player?.videoSize?.height}p" } + ) { + playerOptions?.onQualityClicked() + }, + BottomSheetItem( + context.getString(R.string.audio_track), + R.drawable.ic_audio, + { getCurrentAudioTrackTitle() } + ) { + playerOptions?.onAudioStreamClicked() + }, + BottomSheetItem( + context.getString(R.string.captions), + R.drawable.ic_caption, + { + if (trackSelector != null && trackSelector!!.parameters.preferredTextLanguages.isNotEmpty()) { + trackSelector!!.parameters.preferredTextLanguages[0] + } else { + context.getString(R.string.none) } - ) { - playerOptions?.onCaptionsClicked() - }, - BottomSheetItem( - context.getString(R.string.stats_for_nerds), - R.drawable.ic_info - ) { - playerOptions?.onStatsClicked() } - ) + ) { + playerOptions?.onCaptionsClicked() + }, + BottomSheetItem( + context.getString(R.string.stats_for_nerds), + R.drawable.ic_info + ) { + playerOptions?.onStatsClicked() + } + ) } private fun getCurrentAudioTrackTitle(): String { @@ -86,9 +86,9 @@ class OnlinePlayerView( // format or quality val firstSelectedAudioFormat = selectedAudioLanguagesAndRoleFlags[0] - if (selectedAudioLanguagesAndRoleFlags.size == 1 - && firstSelectedAudioFormat.first == null - && !PlayerHelper.haveAudioTrackRoleFlagSet( + if (selectedAudioLanguagesAndRoleFlags.size == 1 && + firstSelectedAudioFormat.first == null && + !PlayerHelper.haveAudioTrackRoleFlagSet( firstSelectedAudioFormat.second ) ) { diff --git a/app/src/main/java/com/github/libretube/util/DeArrowUtil.kt b/app/src/main/java/com/github/libretube/util/DeArrowUtil.kt index 9114edeec..81af0236b 100644 --- a/app/src/main/java/com/github/libretube/util/DeArrowUtil.kt +++ b/app/src/main/java/com/github/libretube/util/DeArrowUtil.kt @@ -86,4 +86,4 @@ suspend fun List.deArrow() = DeArrowUtil.deArrowStreamItems(this) * provided by the DeArrow project */ @JvmName("deArrowContentItems") -suspend fun List.deArrow() = DeArrowUtil.deArrowContentItems(this) \ No newline at end of file +suspend fun List.deArrow() = DeArrowUtil.deArrowContentItems(this) diff --git a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt index d795b24ee..9388a824f 100644 --- a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt +++ b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt @@ -121,7 +121,9 @@ class NowPlayingNotification( private fun processBitmap(bitmap: Bitmap): Bitmap { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { bitmap - } else ImageHelper.getSquareBitmap(bitmap) + } else { + ImageHelper.getSquareBitmap(bitmap) + } } private val legacyNotificationButtons