Merge pull request #1603 from Bnyro/master

Minimize the channel description by default
This commit is contained in:
Bnyro 2022-10-19 20:09:07 +02:00 committed by GitHub
commit 19df0c4ef5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 79 additions and 42 deletions

View File

@ -40,9 +40,9 @@
<activity <activity
android:name=".ui.activities.OfflinePlayerActivity" android:name=".ui.activities.OfflinePlayerActivity"
android:supportsPictureInPicture="true"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:label="@string/player" /> android:label="@string/player"
android:supportsPictureInPicture="true" />
<activity <activity
android:name=".ui.activities.MainActivity" android:name=".ui.activities.MainActivity"

View File

@ -12,5 +12,5 @@ data class Channel(
var nextpage: String? = null, var nextpage: String? = null,
var subscriberCount: Long = 0, var subscriberCount: Long = 0,
var verified: Boolean = false, var verified: Boolean = false,
var relatedStreams: List<com.github.libretube.api.obj.StreamItem>? = null var relatedStreams: List<StreamItem>? = null
) )

View File

@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
data class CommentsPage( data class CommentsPage(
val comments: MutableList<com.github.libretube.api.obj.Comment> = arrayListOf(), val comments: MutableList<Comment> = arrayListOf(),
val disabled: Boolean? = null, val disabled: Boolean? = null,
val nextpage: String? = "" val nextpage: String? = ""
) )

View File

@ -12,5 +12,5 @@ data class Playlist(
var uploaderUrl: String? = null, var uploaderUrl: String? = null,
var uploaderAvatar: String? = null, var uploaderAvatar: String? = null,
var videos: Int? = 0, var videos: Int? = 0,
var relatedStreams: List<com.github.libretube.api.obj.StreamItem>? = null var relatedStreams: List<StreamItem>? = null
) )

View File

@ -4,5 +4,5 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
data class Segments( data class Segments(
val segments: MutableList<com.github.libretube.api.obj.Segment> = arrayListOf() val segments: MutableList<Segment> = arrayListOf()
) )

View File

@ -19,10 +19,10 @@ fun View?.setWatchProgressLength(videoId: String, duration: Long) {
return return
} }
view.getViewTreeObserver() view.viewTreeObserver
.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener { .addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() { override fun onGlobalLayout() {
this@setWatchProgressLength.getViewTreeObserver().removeOnGlobalLayoutListener(this) this@setWatchProgressLength.viewTreeObserver.removeOnGlobalLayoutListener(this)
if (progress == null || duration == 0L) { if (progress == null || duration == 0L) {
view.visibility = View.GONE view.visibility = View.GONE
return return

View File

@ -432,7 +432,12 @@ class MainActivity : BaseActivity() {
private fun unsetFullscreen() { private fun unsetFullscreen() {
window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS) window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
showSystemBars() if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
@Suppress("DEPRECATION")
window.clearFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN
)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
window.attributes.layoutInDisplayCutoutMode = window.attributes.layoutInDisplayCutoutMode =

View File

@ -74,13 +74,15 @@ class RouterActivity : BaseActivity() {
val videoId = uri.getQueryParameter("v") val videoId = uri.getQueryParameter("v")
intent.putExtra(IntentData.videoId, videoId) intent.putExtra(IntentData.videoId, videoId)
uri.getQueryParameter("t")?.let { intent.putExtra(IntentData.timeStamp, it.toLong()) } uri.getQueryParameter("t")
?.let { intent.putExtra(IntentData.timeStamp, it.toLong()) }
} }
else -> { else -> {
val videoId = uri.path!!.replace("/", "") val videoId = uri.path!!.replace("/", "")
intent.putExtra(IntentData.videoId, videoId) intent.putExtra(IntentData.videoId, videoId)
uri.getQueryParameter("t")?.let { intent.putExtra(IntentData.timeStamp, it.toLong()) } uri.getQueryParameter("t")
?.let { intent.putExtra(IntentData.timeStamp, it.toLong()) }
} }
} }
return intent return intent

View File

@ -70,7 +70,10 @@ class CommentsAdapter(
if (comment.pinned == true) pinnedImageView.visibility = View.VISIBLE if (comment.pinned == true) pinnedImageView.visibility = View.VISIBLE
if (comment.hearted == true) heartedImageView.visibility = View.VISIBLE if (comment.hearted == true) heartedImageView.visibility = View.VISIBLE
if (comment.repliesPage != null) repliesAvailable.visibility = View.VISIBLE if (comment.repliesPage != null) repliesAvailable.visibility = View.VISIBLE
if ((comment.replyCount ?: -1L) > 0L) repliesCount.text = comment.replyCount?.formatShort() if ((comment.replyCount ?: -1L) > 0L) {
repliesCount.text =
comment.replyCount?.formatShort()
}
commentorImage.setOnClickListener { commentorImage.setOnClickListener {
NavigationHelper.navigateChannel(root.context, comment.commentorUrl) NavigationHelper.navigateChannel(root.context, comment.commentorUrl)

View File

@ -5,6 +5,7 @@ import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.github.libretube.R import com.github.libretube.R
@ -29,7 +30,7 @@ class ChannelFragment : BaseFragment() {
private var channelId: String? = null private var channelId: String? = null
private var channelName: String? = null private var channelName: String? = null
var nextPage: String? = null private var nextPage: String? = null
private var channelAdapter: ChannelAdapter? = null private var channelAdapter: ChannelAdapter? = null
private var isLoading = true private var isLoading = true
private var isSubscribed: Boolean? = false private var isSubscribed: Boolean? = false
@ -41,7 +42,6 @@ class ChannelFragment : BaseFragment() {
channelName = it.getString(IntentData.channelName) channelName = it.getString(IntentData.channelName)
?.replace("/c/", "") ?.replace("/c/", "")
?.replace("/user/", "") ?.replace("/user/", "")
Log.e(TAG(), channelName.toString())
} }
} }
@ -57,7 +57,6 @@ class ChannelFragment : BaseFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
binding.channelName.text = channelId
binding.channelRecView.layoutManager = LinearLayoutManager(context) binding.channelRecView.layoutManager = LinearLayoutManager(context)
val refreshChannel = { val refreshChannel = {
@ -94,7 +93,6 @@ class ChannelFragment : BaseFragment() {
} }
} catch (e: IOException) { } catch (e: IOException) {
binding.channelRefresh.isRefreshing = false binding.channelRefresh.isRefreshing = false
println(e)
Log.e(TAG(), "IOException, you might not have internet connection") Log.e(TAG(), "IOException, you might not have internet connection")
return@launchWhenCreated return@launchWhenCreated
} catch (e: HttpException) { } catch (e: HttpException) {
@ -157,6 +155,12 @@ class ChannelFragment : BaseFragment() {
binding.channelDescription.text = response.description?.trim() binding.channelDescription.text = response.description?.trim()
} }
binding.channelDescription.setOnClickListener {
(it as TextView).apply {
it.maxLines = if (it.maxLines == Int.MAX_VALUE) 2 else Int.MAX_VALUE
}
}
ImageHelper.loadImage(response.bannerUrl, binding.channelBanner) ImageHelper.loadImage(response.bannerUrl, binding.channelBanner)
ImageHelper.loadImage(response.avatarUrl, binding.channelImage) ImageHelper.loadImage(response.avatarUrl, binding.channelImage)

View File

@ -411,7 +411,8 @@ class PlayerFragment : BaseFragment() {
// FullScreen button trigger // FullScreen button trigger
// hide fullscreen button if auto rotation enabled // hide fullscreen button if auto rotation enabled
playerBinding.fullscreen.visibility = if (PlayerHelper.autoRotationEnabled) View.GONE else View.VISIBLE playerBinding.fullscreen.visibility =
if (PlayerHelper.autoRotationEnabled) View.GONE else View.VISIBLE
playerBinding.fullscreen.setOnClickListener { playerBinding.fullscreen.setOnClickListener {
// hide player controller // hide player controller
exoPlayerView.hideController() exoPlayerView.hideController()
@ -426,7 +427,8 @@ class PlayerFragment : BaseFragment() {
// share button // share button
binding.relPlayerShare.setOnClickListener { binding.relPlayerShare.setOnClickListener {
val shareDialog = ShareDialog(videoId!!, ShareObjectType.VIDEO, exoPlayer.currentPosition / 1000) val shareDialog =
ShareDialog(videoId!!, ShareObjectType.VIDEO, exoPlayer.currentPosition / 1000)
shareDialog.show(childFragmentManager, ShareDialog::class.java.name) shareDialog.show(childFragmentManager, ShareDialog::class.java.name)
} }
@ -670,7 +672,12 @@ class PlayerFragment : BaseFragment() {
if (binding.player.autoplayEnabled) setNextStream() if (binding.player.autoplayEnabled) setNextStream()
// add the video to the watch history // add the video to the watch history
if (PlayerHelper.watchHistoryEnabled) DatabaseHelper.addToWatchHistory(videoId!!, streams) if (PlayerHelper.watchHistoryEnabled) {
DatabaseHelper.addToWatchHistory(
videoId!!,
streams
)
}
} }
} }
} }
@ -818,7 +825,10 @@ class PlayerFragment : BaseFragment() {
playerTitle.text = response.title playerTitle.text = response.title
playerDescription.text = response.description playerDescription.text = response.description
playerChannelSubCount.text = context?.getString(R.string.subscribers, response.uploaderSubscriberCount?.formatShort()) playerChannelSubCount.text = context?.getString(
R.string.subscribers,
response.uploaderSubscriberCount?.formatShort()
)
} }
// duration that's not greater than 0 indicates that the video is live // duration that's not greater than 0 indicates that the video is live
@ -1000,7 +1010,8 @@ class PlayerFragment : BaseFragment() {
} else { } else {
View.INVISIBLE View.INVISIBLE
} }
playerBinding.skipNext.visibility = if (PlayerHelper.skipButtonsEnabled) View.VISIBLE else View.INVISIBLE playerBinding.skipNext.visibility =
if (PlayerHelper.skipButtonsEnabled) View.VISIBLE else View.INVISIBLE
playerBinding.skipPrev.setOnClickListener { playerBinding.skipPrev.setOnClickListener {
videoId = PlayingQueue.getPrev() videoId = PlayingQueue.getPrev()

View File

@ -83,6 +83,7 @@ object ImageHelper {
) )
) )
} }
private fun saveImage(context: Context, bitmapImage: Bitmap, imagePath: Uri) { private fun saveImage(context: Context, bitmapImage: Bitmap, imagePath: Uri) {
context.contentResolver.openFileDescriptor(imagePath, "w")?.use { context.contentResolver.openFileDescriptor(imagePath, "w")?.use {
FileOutputStream(it.fileDescriptor).use { fos -> FileOutputStream(it.fileDescriptor).use { fos ->

View File

@ -72,7 +72,12 @@ class NowPlayingNotification(
} }
} }
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT) PendingIntent.getActivity(
context,
0,
intent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)
} else { } else {
PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
} }

View File

@ -243,7 +243,8 @@ object PlayerHelper {
false false
) )
val pipEnabled: Boolean get() = PreferenceHelper.getBoolean( val pipEnabled: Boolean
get() = PreferenceHelper.getBoolean(
PreferenceKeys.PICTURE_IN_PICTURE, PreferenceKeys.PICTURE_IN_PICTURE,
true true
) )

View File

@ -10,10 +10,10 @@
<de.hdodenhof.circleimageview.CircleImageView <de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/subscription_channel_image" android:id="@+id/subscription_channel_image"
android:layout_marginStart="8dp"
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_centerVertical="true" /> android:layout_centerVertical="true"
android:layout_marginStart="8dp" />
<TextView <TextView
android:id="@+id/subscription_channel_name" android:id="@+id/subscription_channel_name"
@ -34,10 +34,10 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="8dp"
android:stateListAnimator="@null" android:stateListAnimator="@null"
android:text="@string/unsubscribe" android:text="@string/unsubscribe"
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
android:layout_marginEnd="8dp"
android:textSize="12sp" android:textSize="12sp"
app:cornerRadius="20dp"/> app:cornerRadius="20dp" />
</RelativeLayout> </RelativeLayout>

View File

@ -28,14 +28,14 @@
</LinearLayout> </LinearLayout>
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
android:visibility="gone"
android:id="@+id/timeStampLayout" android:id="@+id/timeStampLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginHorizontal="25dp" android:layout_marginHorizontal="25dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="25dp" android:layout_marginBottom="25dp"
android:hint="@string/time_code"> android:hint="@string/time_code"
android:visibility="gone">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/timeStamp" android:id="@+id/timeStamp"

View File

@ -27,6 +27,7 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_margin="10dp" android:layout_margin="10dp"
android:orientation="horizontal"> android:orientation="horizontal">
@ -53,7 +54,7 @@
android:id="@+id/channel_name" android:id="@+id/channel_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="left" android:layout_gravity="start"
android:drawablePadding="3dip" android:drawablePadding="3dip"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
@ -105,12 +106,14 @@
<TextView <TextView
android:id="@+id/channel_description" android:id="@+id/channel_description"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="10dp" android:layout_marginHorizontal="5dp"
android:layout_marginEnd="10dp" android:autoLink="web"
android:layout_marginBottom="15dp" android:background="@drawable/rounded_ripple"
android:autoLink="web" /> android:ellipsize="end"
android:maxLines="2"
android:padding="10dp" />
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -244,7 +244,7 @@
android:layout_marginTop="15dp" android:layout_marginTop="15dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:layout_marginBottom="15dp" android:layout_marginBottom="15dp"
android:background="?android:attr/selectableItemBackground" android:background="@drawable/rounded_ripple"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:paddingRight="8dp"> android:paddingRight="8dp">
@ -258,9 +258,9 @@
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView

View File

@ -30,7 +30,9 @@
android:id="@+id/watchHistoryRecView" android:id="@+id/watchHistoryRecView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clipToPadding="false"
android:nestedScrollingEnabled="false" android:nestedScrollingEnabled="false"
android:paddingBottom="64dp"
android:visibility="gone" /> android:visibility="gone" />
</FrameLayout> </FrameLayout>

View File

@ -31,7 +31,7 @@
android:id="@+id/delete_history" android:id="@+id/delete_history"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackgroundBorderless"
android:padding="5dp" android:padding="5dp"
android:src="@drawable/ic_close" android:src="@drawable/ic_close"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"