Merge branch 'libre-tube:master' into master

This commit is contained in:
XelXen 2022-06-15 20:00:44 +05:30 committed by GitHub
commit e12d30fdb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 194 additions and 84 deletions

View File

@ -11,7 +11,6 @@ import com.google.android.exoplayer2.MediaItem
import com.google.android.exoplayer2.audio.AudioAttributes import com.google.android.exoplayer2.audio.AudioAttributes
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector
import com.google.android.exoplayer2.ui.PlayerNotificationManager import com.google.android.exoplayer2.ui.PlayerNotificationManager
import gen._base._base_java__rjava_resources.srcjar.R.id.title
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
@ -45,14 +44,16 @@ class BackgroundMode {
*/ */
private lateinit var playerNotification: PlayerNotificationManager private lateinit var playerNotification: PlayerNotificationManager
/**
* The [AudioAttributes] handle the audio focus of the [player]
*/
private lateinit var audioAttributes: AudioAttributes
/** /**
* Initializes the [player] with the [MediaItem]. * Initializes the [player] with the [MediaItem].
*/ */
private fun initializePlayer(c: Context) { private fun initializePlayer(c: Context) {
/** audioAttributes = AudioAttributes.Builder()
* The [audioAttributes] handle the audio focus of the [player]
*/
val audioAttributes = AudioAttributes.Builder()
.setUsage(C.USAGE_MEDIA) .setUsage(C.USAGE_MEDIA)
.setContentType(C.CONTENT_TYPE_MUSIC) .setContentType(C.CONTENT_TYPE_MUSIC)
.build() .build()
@ -68,12 +69,16 @@ class BackgroundMode {
/** /**
* Initializes the [playerNotification] attached to the [player] and shows it. * Initializes the [playerNotification] attached to the [player] and shows it.
*/ */
private fun initializePlayerNotification(c: Context, streams: Streams) { private fun initializePlayerNotification(c: Context) {
playerNotification = PlayerNotificationManager playerNotification = PlayerNotificationManager
.Builder(c, 1, "background_mode") .Builder(c, 1, "background_mode")
// set the description of the notification // set the description of the notification
.setMediaDescriptionAdapter( .setMediaDescriptionAdapter(
DescriptionAdapter(streams.title!!, streams.uploader!!, streams.thumbnailUrl!!) DescriptionAdapter(
response?.title!!,
response?.uploader!!,
response?.thumbnailUrl!!
)
) )
.build() .build()
playerNotification.apply { playerNotification.apply {
@ -113,7 +118,7 @@ class BackgroundMode {
job.join() job.join()
initializePlayer(c) initializePlayer(c)
initializePlayerNotification(c, response!!) initializePlayerNotification(c)
player?.apply { player?.apply {
playWhenReady = playWhenReadyPlayer playWhenReady = playWhenReadyPlayer

View File

@ -0,0 +1,7 @@
package com.github.libretube
const val GITHUB_API_URL = "https://api.github.com/repos/libre-tube/LibreTube/releases/latest"
const val WEBSITE_URL = "https://libre-tube.github.io/"
const val AUTHORS_URL = "https://github.com/libre-tube/LibreTube/graphs/contributors"
const val DONATE_URL = "https://libre-tube.github.io/#donate"
const val CONTRIBUTING_URL = "https://github.com/libre-tube/LibreTube#donate"

View File

@ -32,7 +32,7 @@ class ChaptersAdapter(
chapterTitle.text = chapter.title chapterTitle.text = chapter.title
holder.v.setOnClickListener { holder.v.setOnClickListener {
val chapterStart = chapter.start!!.toLong() * 1000 // multiply by thousand for ms -> s val chapterStart = chapter.start!!.toLong() * 1000 // s -> ms
exoPlayer.seekTo(chapterStart) exoPlayer.seekTo(chapterStart)
} }
} }

View File

@ -828,6 +828,10 @@ class PlayerFragment : Fragment() {
} }
private fun createExoPlayer(view: View) { private fun createExoPlayer(view: View) {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
val playbackSpeed = sharedPreferences.getString("playback_speed", "1F")?.toFloat()
val bufferingGoal = sharedPreferences.getString("buffering_goal", "50")?.toInt()!!
val cronetEngine: CronetEngine = CronetHelper.getCronetEngine() val cronetEngine: CronetEngine = CronetHelper.getCronetEngine()
val cronetDataSourceFactory: CronetDataSource.Factory = val cronetDataSourceFactory: CronetDataSource.Factory =
CronetDataSource.Factory(cronetEngine, Executors.newCachedThreadPool()) CronetDataSource.Factory(cronetEngine, Executors.newCachedThreadPool())
@ -847,6 +851,12 @@ class PlayerFragment : Fragment() {
val loadControl = DefaultLoadControl.Builder() val loadControl = DefaultLoadControl.Builder()
// cache the last three minutes // cache the last three minutes
.setBackBuffer(1000 * 60 * 3, true) .setBackBuffer(1000 * 60 * 3, true)
.setBufferDurationsMs(
DefaultLoadControl.DEFAULT_MIN_BUFFER_MS,
bufferingGoal * 1000, // buffering goal, s -> ms
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS,
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS
)
.build() .build()
exoPlayer = ExoPlayer.Builder(view.context) exoPlayer = ExoPlayer.Builder(view.context)
@ -858,8 +868,6 @@ class PlayerFragment : Fragment() {
exoPlayer.setAudioAttributes(audioAttributes, true) exoPlayer.setAudioAttributes(audioAttributes, true)
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
val playbackSpeed = sharedPreferences.getString("playback_speed", "1F")?.toFloat()
exoPlayer.setPlaybackSpeed(playbackSpeed!!) exoPlayer.setPlaybackSpeed(playbackSpeed!!)
} }

View File

@ -0,0 +1,7 @@
package com.github.libretube.obj
// data class for the update info, required to return the data
data class UpdateInfo(
val updateUrl: String,
val tagName: String
)

View File

@ -11,8 +11,12 @@ import android.view.ViewGroup
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import com.github.libretube.AUTHORS_URL
import com.github.libretube.BuildConfig import com.github.libretube.BuildConfig
import com.github.libretube.CONTRIBUTING_URL
import com.github.libretube.DONATE_URL
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.WEBSITE_URL
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
class AboutFragment : Fragment() { class AboutFragment : Fragment() {
@ -34,19 +38,19 @@ class AboutFragment : Fragment() {
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(WEBSITE_URL)
} }
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(AUTHORS_URL)
} }
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(DONATE_URL)
} }
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(CONTRIBUTING_URL)
} }
val license = view.findViewById<LinearLayout>(R.id.license) val license = view.findViewById<LinearLayout>(R.id.license)
license.setOnClickListener { license.setOnClickListener {

View File

@ -7,7 +7,10 @@ import com.google.android.exoplayer2.Player
import com.google.android.exoplayer2.ui.PlayerNotificationManager import com.google.android.exoplayer2.ui.PlayerNotificationManager
import java.net.URL import java.net.URL
// used to show title and thumbnail of the video in the notification /**
* The [DescriptionAdapter] is used to show title, uploaderName and thumbnail of the video in the notification
* Basic example [here](https://github.com/AnthonyMarkD/AudioPlayerSampleTest)
*/
class DescriptionAdapter( class DescriptionAdapter(
private val title: String, private val title: String,
private val channelName: String, private val channelName: String,

View File

@ -3,8 +3,10 @@ package com.github.libretube.util
import android.util.Log import android.util.Log
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import com.github.libretube.BuildConfig import com.github.libretube.BuildConfig
import com.github.libretube.GITHUB_API_URL
import com.github.libretube.dialogs.NoUpdateAvailableDialog import com.github.libretube.dialogs.NoUpdateAvailableDialog
import com.github.libretube.dialogs.UpdateAvailableDialog import com.github.libretube.dialogs.UpdateAvailableDialog
import com.github.libretube.obj.UpdateInfo
import java.io.BufferedReader import java.io.BufferedReader
import java.io.InputStreamReader import java.io.InputStreamReader
import java.net.URL import java.net.URL
@ -40,7 +42,7 @@ fun checkUpdate(childFragmentManager: FragmentManager) {
} }
fun getUpdateInfo(): UpdateInfo? { fun getUpdateInfo(): UpdateInfo? {
val latest = URL("https://api.github.com/repos/libre-tube/LibreTube/releases/latest") val latest = URL(GITHUB_API_URL)
val json = StringBuilder() val json = StringBuilder()
val urlConnection: HttpsURLConnection? val urlConnection: HttpsURLConnection?
urlConnection = latest.openConnection() as HttpsURLConnection urlConnection = latest.openConnection() as HttpsURLConnection
@ -49,7 +51,7 @@ fun getUpdateInfo(): UpdateInfo? {
var line: String? var line: String?
while (br.readLine().also { line = it } != null) json.append(line) while (br.readLine().also { line = it } != null) json.append(line)
// Parse and return json data // Parse and return the json data
val jsonRoot = JSONObject(json.toString()) val jsonRoot = JSONObject(json.toString())
if (jsonRoot.has("tag_name") && if (jsonRoot.has("tag_name") &&
jsonRoot.has("html_url") && jsonRoot.has("html_url") &&
@ -63,7 +65,7 @@ fun getUpdateInfo(): UpdateInfo? {
val name = jsonAsset.getString("name") val name = jsonAsset.getString("name")
if (name.endsWith(".apk")) { if (name.endsWith(".apk")) {
val tagName = jsonRoot.getString("name") val tagName = jsonRoot.getString("name")
Log.i("", "Lastest version: $tagName") Log.i("", "Latest version: $tagName")
return UpdateInfo(updateUrl, tagName) return UpdateInfo(updateUrl, tagName)
} }
} }
@ -71,9 +73,3 @@ fun getUpdateInfo(): UpdateInfo? {
} }
return null return null
} }
// data class for the update info, required to return the data
data class UpdateInfo(
val updateUrl: String,
val tagName: String
)

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?android:attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/black"
android:pathData="M16.24,7.76C15.07,6.59 13.54,6 12,6v6l-4.24,4.24c2.34,2.34 6.14,2.34 8.49,0 2.34,-2.34 2.34,-6.14 -0.01,-8.48zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z" />
</vector>

View File

@ -2,12 +2,12 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/video_search"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="8dp" android:layout_margin="8dp"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground">
android:id="@+id/video_search">
<androidx.constraintlayout.widget.Guideline <androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline" android:id="@+id/guideline"
@ -18,17 +18,17 @@
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:id="@+id/card_search_thumbnail" android:id="@+id/card_search_thumbnail"
app:cardCornerRadius="8dp"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
app:strokeWidth="0dp" app:cardCornerRadius="8dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="16:9" app:layout_constraintDimensionRatio="16:9"
app:layout_constraintEnd_toStartOf="@+id/guideline"
app:layout_constraintHorizontal_bias="0.0" app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" app:layout_constraintVertical_bias="0.0"
app:layout_constraintEnd_toStartOf="@+id/guideline"> app:strokeWidth="0dp">
<ImageView <ImageView
android:id="@+id/playlist_thumbnail" android:id="@+id/playlist_thumbnail"
@ -36,15 +36,27 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:srcCompat="@tools:sample/backgrounds/scenic" /> tools:srcCompat="@tools:sample/backgrounds/scenic" />
<TextView <androidx.cardview.widget.CardView
android:id="@+id/playlist_duration"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:layout_margin="5dp" android:layout_margin="5dp"
android:textColor="@color/duration_text_color" app:cardBackgroundColor="@color/duration_background_color"
android:background="@color/duration_background_color" app:cardCornerRadius="8dp"
android:padding="0.5dp" /> app:cardElevation="0dp">
<TextView
android:id="@+id/playlist_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="6dp"
android:paddingTop="2dp"
android:paddingEnd="6dp"
android:paddingBottom="2dp"
android:textColor="@color/duration_text_color"
tools:text="05:36" />
</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
<TextView <TextView
@ -71,11 +83,11 @@
android:id="@+id/delete_playlist" android:id="@+id/delete_playlist"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:shapeAppearanceOverlay="@style/roundedImageViewRounded"
android:src="@drawable/ic_delete"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground"
android:padding="8dp" android:padding="8dp"
android:visibility="gone" /> android:src="@drawable/ic_delete"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearanceOverlay="@style/roundedImageViewRounded" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:background="?android:attr/selectableItemBackground" android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground">
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:id="@+id/thumbnailcard" android:id="@+id/thumbnailcard"
@ -13,28 +13,41 @@
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:elevation="10dp"
app:cardCornerRadius="8dp"
app:layout_constraintDimensionRatio="16:9" app:layout_constraintDimensionRatio="16:9"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent">
app:cardCornerRadius="8dp"
android:elevation="10dp">
<ImageView <ImageView
android:id="@+id/thumbnail" android:id="@+id/thumbnail"
android:src="@mipmap/ic_launcher"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent"
android:src="@mipmap/ic_launcher" />
<TextView <androidx.cardview.widget.CardView
android:id="@+id/thumbnail_duration"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:layout_margin="5dp" android:layout_margin="5dp"
android:textColor="@color/duration_text_color" app:cardBackgroundColor="@color/duration_background_color"
android:background="@color/duration_background_color" app:cardCornerRadius="8dp"
android:padding="0.5dp" /> app:cardElevation="0dp">
<TextView
android:id="@+id/thumbnail_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="6dp"
android:paddingTop="2dp"
android:paddingEnd="6dp"
android:paddingBottom="2dp"
android:textColor="@color/duration_text_color"
tools:text="05:36" />
</androidx.cardview.widget.CardView>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>
@ -45,24 +58,24 @@
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:ellipsize="end"
android:maxLines="2"
android:text="Title" android:text="Title"
android:textSize="15sp" android:textSize="15sp"
android:textStyle="bold" android:textStyle="bold"
app:layout_constraintEnd_toEndOf="@+id/thumbnailcard" app:layout_constraintEnd_toEndOf="@+id/thumbnailcard"
app:layout_constraintStart_toEndOf="@+id/channel_image" app:layout_constraintStart_toEndOf="@+id/channel_image"
app:layout_constraintTop_toBottomOf="@+id/thumbnailcard" app:layout_constraintTop_toBottomOf="@+id/thumbnailcard" />
android:ellipsize="end"
android:maxLines="2" />
<TextView <TextView
android:id="@+id/textView_channel" android:id="@+id/textView_channel"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="16dp"
android:text="Channel Name" android:text="Channel Name"
app:layout_constraintEnd_toEndOf="@+id/textView_title" app:layout_constraintEnd_toEndOf="@+id/textView_title"
app:layout_constraintStart_toStartOf="@+id/textView_title" app:layout_constraintStart_toStartOf="@+id/textView_title"
app:layout_constraintTop_toBottomOf="@+id/textView_title" app:layout_constraintTop_toBottomOf="@+id/textView_title" />
android:paddingBottom="16dp" />
<de.hdodenhof.circleimageview.CircleImageView <de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/channel_image" android:id="@+id/channel_image"

View File

@ -2,11 +2,11 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/video_search"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground">
android:id="@+id/video_search">
<androidx.constraintlayout.widget.Guideline <androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline" android:id="@+id/guideline"
@ -17,17 +17,17 @@
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:id="@+id/card_search_thumbnail" android:id="@+id/card_search_thumbnail"
app:cardCornerRadius="8dp"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
app:strokeWidth="0dp" app:cardCornerRadius="8dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="16:9" app:layout_constraintDimensionRatio="16:9"
app:layout_constraintEnd_toStartOf="@+id/guideline"
app:layout_constraintHorizontal_bias="0.0" app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" app:layout_constraintVertical_bias="0.0"
app:layout_constraintEnd_toStartOf="@+id/guideline"> app:strokeWidth="0dp">
<ImageView <ImageView
android:id="@+id/channel_thumbnail" android:id="@+id/channel_thumbnail"
@ -35,15 +35,28 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:srcCompat="@tools:sample/backgrounds/scenic" /> tools:srcCompat="@tools:sample/backgrounds/scenic" />
<TextView <androidx.cardview.widget.CardView
android:id="@+id/channel_duration"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:layout_margin="5dp" android:layout_margin="5dp"
android:textColor="@color/duration_text_color" app:cardBackgroundColor="@color/duration_background_color"
android:background="@color/duration_background_color" app:cardCornerRadius="8dp"
android:padding="0.5dp" /> app:cardElevation="0dp">
<TextView
android:id="@+id/channel_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="6dp"
android:paddingTop="2dp"
android:paddingEnd="6dp"
android:paddingBottom="2dp"
android:textColor="@color/duration_text_color"
tools:text="05:36" />
</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
<TextView <TextView

View File

@ -2,11 +2,11 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/video_search"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground">
android:id="@+id/video_search">
<androidx.constraintlayout.widget.Guideline <androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline" android:id="@+id/guideline"
@ -17,17 +17,17 @@
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:id="@+id/card_search_thumbnail" android:id="@+id/card_search_thumbnail"
app:cardCornerRadius="8dp"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
app:strokeWidth="0dp" app:cardCornerRadius="8dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="16:9" app:layout_constraintDimensionRatio="16:9"
app:layout_constraintEnd_toStartOf="@+id/guideline"
app:layout_constraintHorizontal_bias="0.0" app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" app:layout_constraintVertical_bias="0.0"
app:layout_constraintEnd_toStartOf="@+id/guideline"> app:strokeWidth="0dp">
<ImageView <ImageView
android:id="@+id/search_thumbnail" android:id="@+id/search_thumbnail"
@ -35,17 +35,30 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:srcCompat="@tools:sample/backgrounds/scenic" /> tools:srcCompat="@tools:sample/backgrounds/scenic" />
<TextView <androidx.cardview.widget.CardView
android:id="@+id/search_thumbnail_duration"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:layout_marginRight="5dp" android:layout_marginEnd="5dp"
android:layout_marginBottom="3dp" android:layout_marginBottom="3dp"
android:textSize="11dp" app:cardBackgroundColor="@color/duration_background_color"
android:textColor="@color/duration_text_color" app:cardCornerRadius="8dp"
android:background="@color/duration_background_color" app:cardElevation="0dp">
android:padding="0.5dp" />
<TextView
android:id="@+id/search_thumbnail_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="6dp"
android:paddingTop="2dp"
android:paddingEnd="6dp"
android:paddingBottom="2dp"
android:textColor="@color/duration_text_color"
android:textSize="11sp"
tools:text="05:36" />
</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
<TextView <TextView
@ -53,9 +66,9 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent"
android:maxLines="2"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/card_search_thumbnail" app:layout_constraintStart_toEndOf="@+id/card_search_thumbnail"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@ -83,9 +96,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
app:layout_constraintEnd_toEndOf="parent"
android:maxLines="1"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/search_channel_image" app:layout_constraintStart_toEndOf="@+id/search_channel_image"
app:layout_constraintTop_toBottomOf="@+id/search_views" /> app:layout_constraintTop_toBottomOf="@+id/search_views" />

View File

@ -659,4 +659,12 @@
<item>sdcard</item> <item>sdcard</item>
</string-array> </string-array>
<string-array name="bufferingGoal">
<item>50</item>
<item>100</item>
<item>200</item>
<item>300</item>
<item>450</item>
</string-array>
</resources> </resources>

View File

@ -181,4 +181,6 @@
<string name="related_streams_summary">Show related streams to videos.</string> <string name="related_streams_summary">Show related streams to videos.</string>
<string name="show_chapters">Show chapters</string> <string name="show_chapters">Show chapters</string>
<string name="hide_chapters">Hide chapters</string> <string name="hide_chapters">Hide chapters</string>
<string name="buffering_goal">Buffering goal</string>
<string name="buffering_goal_summary">The amount of seconds videos get preloaded at maximum.</string>
</resources> </resources>

View File

@ -22,6 +22,15 @@
app:title="@string/playback_speed" app:title="@string/playback_speed"
app:useSimpleSummaryProvider="true" /> app:useSimpleSummaryProvider="true" />
<ListPreference
android:icon="@drawable/ic_timelapse"
app:defaultValue="50"
app:entries="@array/bufferingGoal"
app:entryValues="@array/bufferingGoal"
app:key="buffering_goal"
app:title="@string/buffering_goal"
app:summary="@string/buffering_goal_summary" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory app:title="@string/downloads"> <PreferenceCategory app:title="@string/downloads">