Toggle the channel description

This commit is contained in:
Bnyro 2022-10-19 19:46:54 +02:00
parent b1362744fc
commit 31f20219d5
3 changed files with 21 additions and 7 deletions

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

@ -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
@ -57,7 +58,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 +94,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 +156,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

@ -28,6 +28,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="10dp" android:layout_margin="10dp"
android:layout_gravity="center"
android:orientation="horizontal"> android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView <de.hdodenhof.circleimageview.CircleImageView
@ -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"
@ -106,11 +107,14 @@
<TextView <TextView
android:id="@+id/channel_description" android:id="@+id/channel_description"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:background="@drawable/rounded_ripple"
android:layout_height="18dp"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginEnd="10dp" android:layout_marginEnd="10dp"
android:layout_marginBottom="15dp" android:layout_marginBottom="15dp"
android:autoLink="web" /> android:autoLink="web"
android:ellipsize="end"
android:maxLines="2" />
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"