bump kotlin gradle plugin

This commit is contained in:
Bnyro 2022-06-14 15:09:47 +02:00
parent a8f90405a9
commit e9af0fb5bb
3 changed files with 82 additions and 82 deletions

View File

@ -3,7 +3,6 @@ package com.github.libretube.fragments
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.NotificationManager import android.app.NotificationManager
import android.content.Context import android.content.Context
import android.content.DialogInterface
import android.content.Intent import android.content.Intent
import android.content.pm.ActivityInfo import android.content.pm.ActivityInfo
import android.graphics.Rect import android.graphics.Rect
@ -101,7 +100,7 @@ class PlayerFragment : Fragment() {
private var whichQuality = 0 private var whichQuality = 0
private var isZoomed: Boolean = false private var isZoomed: Boolean = false
var isSubscribed: Boolean = false private var isSubscribed: Boolean = false
private lateinit var relatedRecView: RecyclerView private lateinit var relatedRecView: RecyclerView
private lateinit var commentsRecView: RecyclerView private lateinit var commentsRecView: RecyclerView
@ -491,7 +490,7 @@ class PlayerFragment : Fragment() {
view.findViewById<TextView>(R.id.player_description).text = response.description view.findViewById<TextView>(R.id.player_description).text = response.description
// Listener for play and pause icon change // Listener for play and pause icon change
exoPlayer.addListener(object : com.google.android.exoplayer2.Player.Listener { exoPlayer.addListener(object : Player.Listener {
override fun onIsPlayingChanged(isPlaying: Boolean) { override fun onIsPlayingChanged(isPlaying: Boolean) {
if (isPlaying && SponsorBlockSettings.sponsorBlockEnabled) { if (isPlaying && SponsorBlockSettings.sponsorBlockEnabled) {
exoPlayerView.postDelayed( exoPlayerView.postDelayed(
@ -500,7 +499,7 @@ class PlayerFragment : Fragment() {
) )
} }
} }
@Deprecated(message = "Deprecated", level = DeprecationLevel.HIDDEN)
override fun onPlayerStateChanged( override fun onPlayerStateChanged(
playWhenReady: Boolean, playWhenReady: Boolean,
playbackState: Int playbackState: Int
@ -541,7 +540,7 @@ class PlayerFragment : Fragment() {
relDownloadVideo.setOnClickListener { relDownloadVideo.setOnClickListener {
if (!IS_DOWNLOAD_RUNNING) { if (!IS_DOWNLOAD_RUNNING) {
val newFragment = DownloadDialog() val newFragment = DownloadDialog()
var bundle = Bundle() val bundle = Bundle()
bundle.putString("video_id", videoId) bundle.putString("video_id", videoId)
bundle.putParcelable("streams", response) bundle.putParcelable("streams", response)
newFragment.arguments = bundle newFragment.arguments = bundle
@ -609,7 +608,7 @@ class PlayerFragment : Fragment() {
isSubscribed(subButton, channelId!!) isSubscribed(subButton, channelId!!)
view.findViewById<LinearLayout>(R.id.save).setOnClickListener { view.findViewById<LinearLayout>(R.id.save).setOnClickListener {
val newFragment = AddtoPlaylistDialog() val newFragment = AddtoPlaylistDialog()
var bundle = Bundle() val bundle = Bundle()
bundle.putString("videoId", videoId) bundle.putString("videoId", videoId)
newFragment.arguments = bundle newFragment.arguments = bundle
newFragment.show(childFragmentManager, "AddToPlaylist") newFragment.show(childFragmentManager, "AddToPlaylist")
@ -650,7 +649,7 @@ class PlayerFragment : Fragment() {
val name = vid.quality + " " + vid.format val name = vid.quality + " " + vid.format
videosNameArray += name videosNameArray += name
} }
var subtitle = mutableListOf<SubtitleConfiguration>() val subtitle = mutableListOf<SubtitleConfiguration>()
if (response.subtitles!!.isNotEmpty()) { if (response.subtitles!!.isNotEmpty()) {
subtitle.add( subtitle.add(
SubtitleConfiguration.Builder(response.subtitles[0].url!!.toUri()) SubtitleConfiguration.Builder(response.subtitles[0].url!!.toUri())
@ -760,70 +759,69 @@ class PlayerFragment : Fragment() {
val builder: MaterialAlertDialogBuilder? = activity?.let { val builder: MaterialAlertDialogBuilder? = activity?.let {
MaterialAlertDialogBuilder(it) MaterialAlertDialogBuilder(it)
} }
var lastPosition = exoPlayer.currentPosition val lastPosition = exoPlayer.currentPosition
builder!!.setTitle(R.string.choose_quality_dialog) builder!!.setTitle(R.string.choose_quality_dialog)
.setItems( .setItems(
videosNameArray, videosNameArray
DialogInterface.OnClickListener { _, which -> ) { _, which ->
whichQuality = which whichQuality = which
if (response.subtitles.isNotEmpty()) { if (response.subtitles.isNotEmpty()) {
var subtitle = val subtitle =
mutableListOf<SubtitleConfiguration>() mutableListOf<SubtitleConfiguration>()
subtitle.add( subtitle.add(
SubtitleConfiguration.Builder( SubtitleConfiguration.Builder(
response.subtitles[0].url!!.toUri() response.subtitles[0].url!!.toUri()
)
.setMimeType(response.subtitles[0].mimeType!!) // The correct MIME type (required).
.setLanguage(response.subtitles[0].code) // The subtitle language (optional).
.build()
) )
} .setMimeType(response.subtitles[0].mimeType!!) // The correct MIME type (required).
if (which == 0) { .setLanguage(response.subtitles[0].code) // The subtitle language (optional).
val mediaItem: MediaItem = MediaItem.Builder()
.setUri(response.hls)
.setSubtitleConfigurations(subtitle)
.build() .build()
exoPlayer.setMediaItem(mediaItem) )
} else {
val dataSourceFactory: DataSource.Factory =
DefaultHttpDataSource.Factory()
val videoItem: MediaItem = MediaItem.Builder()
.setUri(response.videoStreams[which - 1].url)
.setSubtitleConfigurations(subtitle)
.build()
val videoSource: MediaSource =
DefaultMediaSourceFactory(dataSourceFactory)
.createMediaSource(videoItem)
var audioSource: MediaSource =
DefaultMediaSourceFactory(dataSourceFactory)
.createMediaSource(
fromUri(response.audioStreams!![0].url!!)
)
if (response.videoStreams[which - 1].quality == "720p" ||
response.videoStreams[which - 1].quality == "1080p" ||
response.videoStreams[which - 1].quality == "480p"
) {
audioSource =
ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(
fromUri(
response.audioStreams[
getMostBitRate(
response.audioStreams
)
].url!!
)
)
}
val mergeSource: MediaSource =
MergingMediaSource(videoSource, audioSource)
exoPlayer.setMediaSource(mergeSource)
}
exoPlayer.seekTo(lastPosition)
view.findViewById<TextView>(R.id.quality_text).text =
videosNameArray[which]
} }
) if (which == 0) {
val mediaItem: MediaItem = MediaItem.Builder()
.setUri(response.hls)
.setSubtitleConfigurations(subtitle)
.build()
exoPlayer.setMediaItem(mediaItem)
} else {
val dataSourceFactory: DataSource.Factory =
DefaultHttpDataSource.Factory()
val videoItem: MediaItem = MediaItem.Builder()
.setUri(response.videoStreams[which - 1].url)
.setSubtitleConfigurations(subtitle)
.build()
val videoSource: MediaSource =
DefaultMediaSourceFactory(dataSourceFactory)
.createMediaSource(videoItem)
var audioSource: MediaSource =
DefaultMediaSourceFactory(dataSourceFactory)
.createMediaSource(
fromUri(response.audioStreams!![0].url!!)
)
if (response.videoStreams[which - 1].quality == "720p" ||
response.videoStreams[which - 1].quality == "1080p" ||
response.videoStreams[which - 1].quality == "480p"
) {
audioSource =
ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(
fromUri(
response.audioStreams[
getMostBitRate(
response.audioStreams
)
].url!!
)
)
}
val mergeSource: MediaSource =
MergingMediaSource(videoSource, audioSource)
exoPlayer.setMediaSource(mergeSource)
}
exoPlayer.seekTo(lastPosition)
view.findViewById<TextView>(R.id.quality_text).text =
videosNameArray[which]
}
val dialog = builder.create() val dialog = builder.create()
dialog.show() dialog.show()
} }

View File

@ -29,40 +29,42 @@ class AboutFragment : Fragment() {
val topBarText = activity?.findViewById<TextView>(R.id.topBar_textView) val topBarText = activity?.findViewById<TextView>(R.id.topBar_textView)
topBarText?.text = getString(R.string.about) topBarText?.text = getString(R.string.about)
val appVersion = view?.findViewById<TextView>(R.id.app_version) val appVersion = view.findViewById<TextView>(R.id.app_version)
appVersion.text = BuildConfig.VERSION_NAME appVersion.text = BuildConfig.VERSION_NAME
val website = view?.findViewById<LinearLayout>(R.id.website) val website = view.findViewById<LinearLayout>(R.id.website)
website?.setOnClickListener { website.setOnClickListener {
openLinkFromHref("https://libre-tube.github.io/") openLinkFromHref("https://libre-tube.github.io/")
} }
val authors = view?.findViewById<LinearLayout>(R.id.authors) val authors = view.findViewById<LinearLayout>(R.id.authors)
authors?.setOnClickListener { authors.setOnClickListener {
openLinkFromHref("https://github.com/libre-tube/LibreTube/graphs/contributors") openLinkFromHref("https://github.com/libre-tube/LibreTube/graphs/contributors")
} }
val donate = view?.findViewById<LinearLayout>(R.id.donate) val donate = view.findViewById<LinearLayout>(R.id.donate)
donate?.setOnClickListener { donate.setOnClickListener {
openLinkFromHref("https://libre-tube.github.io/#donate") openLinkFromHref("https://libre-tube.github.io/#donate")
} }
val contributing = view?.findViewById<LinearLayout>(R.id.contributing) val contributing = view.findViewById<LinearLayout>(R.id.contributing)
contributing?.setOnClickListener { contributing.setOnClickListener {
openLinkFromHref("https://github.com/libre-tube/LibreTube") openLinkFromHref("https://github.com/libre-tube/LibreTube")
} }
val license = view.findViewById<LinearLayout>(R.id.license) val license = view.findViewById<LinearLayout>(R.id.license)
license?.setOnClickListener { license.setOnClickListener {
val licenseString = view?.context?.assets!! val licenseString = view.context.assets
.open("gpl3.html").bufferedReader().use { .open("gpl3.html").bufferedReader().use {
it.readText() it.readText()
} }
val licenseHtml = if (Build.VERSION.SDK_INT >= 24) Html.fromHtml(licenseString, 1) val licenseHtml = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
else Html.fromHtml(licenseString) Html.fromHtml(licenseString, 1)
} else {
Html.fromHtml(licenseString)
}
MaterialAlertDialogBuilder(view?.context!!) MaterialAlertDialogBuilder(view.context!!)
.setPositiveButton(getString(R.string.okay)) { _, _ -> } .setPositiveButton(getString(R.string.okay)) { _, _ -> }
.setMessage(licenseHtml) .setMessage(licenseHtml)
.create() .create()
.show() .show()
true
} }
} }

View File

@ -6,7 +6,7 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:7.2.1' classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21' classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files