mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
chapter timestamps
This commit is contained in:
parent
6578921fe3
commit
51bdc79d34
@ -1,6 +1,7 @@
|
|||||||
package com.github.libretube.ui.adapters
|
package com.github.libretube.ui.adapters
|
||||||
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
import android.text.format.DateUtils
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
@ -27,15 +28,15 @@ class ChaptersAdapter(
|
|||||||
holder.binding.apply {
|
holder.binding.apply {
|
||||||
ImageHelper.loadImage(chapter.image, chapterImage)
|
ImageHelper.loadImage(chapter.image, chapterImage)
|
||||||
chapterTitle.text = chapter.title
|
chapterTitle.text = chapter.title
|
||||||
|
timeStamp.text = chapter.start?.let { DateUtils.formatElapsedTime(it) }
|
||||||
|
|
||||||
if (selectedPosition == position) {
|
val color = if (selectedPosition == position) {
|
||||||
// get the color for highlighted controls
|
ThemeHelper.getThemeColor(root.context, android.R.attr.colorControlHighlight)
|
||||||
val color =
|
|
||||||
ThemeHelper.getThemeColor(root.context, android.R.attr.colorControlHighlight)
|
|
||||||
chapterLL.setBackgroundColor(color)
|
|
||||||
} else {
|
} else {
|
||||||
chapterLL.setBackgroundColor(Color.TRANSPARENT)
|
Color.TRANSPARENT
|
||||||
}
|
}
|
||||||
|
chapterLL.setBackgroundColor(color)
|
||||||
|
|
||||||
root.setOnClickListener {
|
root.setOnClickListener {
|
||||||
updateSelectedPosition(position)
|
updateSelectedPosition(position)
|
||||||
val chapterStart = chapter.start!! * 1000 // s -> ms
|
val chapterStart = chapter.start!! * 1000 // s -> ms
|
||||||
|
@ -991,10 +991,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
binding.chaptersRecView.adapter = ChaptersAdapter(chapters, exoPlayer)
|
binding.chaptersRecView.adapter = ChaptersAdapter(chapters, exoPlayer)
|
||||||
|
|
||||||
// enable the chapters dialog in the player
|
// enable the chapters dialog in the player
|
||||||
val titles = mutableListOf<String>()
|
val titles = chapters.map { "${it.title} (${it.start?.let { DateUtils.formatElapsedTime(it) }})" }
|
||||||
chapters.forEach {
|
|
||||||
titles += it.title!!
|
|
||||||
}
|
|
||||||
playerBinding.chapterLL.setOnClickListener {
|
playerBinding.chapterLL.setOnClickListener {
|
||||||
if (viewModel.isFullscreen.value!!) {
|
if (viewModel.isFullscreen.value!!) {
|
||||||
MaterialAlertDialogBuilder(requireContext())
|
MaterialAlertDialogBuilder(requireContext())
|
||||||
|
@ -15,12 +15,40 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingHorizontal="5dp">
|
android:paddingHorizontal="5dp">
|
||||||
|
|
||||||
<com.google.android.material.imageview.ShapeableImageView
|
<FrameLayout
|
||||||
android:id="@+id/chapter_image"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="55dp"
|
android:layout_height="55dp">
|
||||||
android:src="@mipmap/ic_launcher"
|
|
||||||
app:shapeAppearanceOverlay="@style/roundedImageViewRounded" />
|
<com.google.android.material.imageview.ShapeableImageView
|
||||||
|
android:id="@+id/chapter_image"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:shapeAppearanceOverlay="@style/roundedImageViewRounded"
|
||||||
|
tools:src="@tools:sample/backgrounds/scenic" />
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_marginEnd="5dp"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
app:cardBackgroundColor="@color/duration_background_color"
|
||||||
|
app:cardCornerRadius="8dp"
|
||||||
|
app:cardElevation="0dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/timeStamp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingHorizontal="2dp"
|
||||||
|
android:textColor="@color/duration_text_color"
|
||||||
|
android:textSize="10sp"
|
||||||
|
tools:ignore="SmallSp"
|
||||||
|
tools:text="05:36" />
|
||||||
|
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/chapter_title"
|
android:id="@+id/chapter_title"
|
||||||
|
Loading…
Reference in New Issue
Block a user