fix: issues with expandable text views

This commit is contained in:
Bnyro 2024-08-23 17:01:16 +02:00
parent 8b0e6ce68f
commit a88329504c
5 changed files with 15 additions and 8 deletions

View File

@ -34,6 +34,7 @@ import com.github.libretube.extensions.togglePlayPauseState
import com.github.libretube.extensions.updateIfChanged
import com.github.libretube.helpers.AudioHelper
import com.github.libretube.helpers.BackgroundHelper
import com.github.libretube.helpers.ClipboardHelper
import com.github.libretube.helpers.ImageHelper
import com.github.libretube.helpers.NavBarHelper
import com.github.libretube.helpers.NavigationHelper
@ -117,6 +118,11 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
binding.title.isSelected = true
binding.uploader.isSelected = true
binding.title.setOnLongClickListener {
ClipboardHelper.save(requireContext(), text = binding.title.text.toString())
true
}
binding.minimizePlayer.setOnClickListener {
val mainMotionLayout = mainActivity.binding.mainMotionLayout
mainMotionLayout.transitionToStart()

View File

@ -2,9 +2,11 @@ package com.github.libretube.ui.views
import android.content.Context
import android.text.TextUtils
import android.text.util.Linkify
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView
import com.github.libretube.R
import com.github.libretube.helpers.ClipboardHelper
class ExpandableTextView(context: Context, attributeSet: AttributeSet? = null) :
AppCompatTextView(context, attributeSet) {
@ -13,10 +15,15 @@ class ExpandableTextView(context: Context, attributeSet: AttributeSet? = null) :
maxLines = DEFAULT_MAX_LINES
ellipsize = TextUtils.TruncateAt.END
setBackgroundResource(R.drawable.rounded_ripple)
autoLinkMask = Linkify.WEB_URLS
setOnClickListener {
maxLines = if (maxLines == DEFAULT_MAX_LINES) Int.MAX_VALUE else DEFAULT_MAX_LINES
}
setOnLongClickListener {
ClipboardHelper.save(context, text = text.toString())
true
}
}
companion object {

View File

@ -137,7 +137,6 @@
style="@style/TextViewMarquee"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textIsSelectable="true"
android:textSize="24sp" />
<TextView

View File

@ -150,9 +150,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="5dp"
android:autoLink="web"
android:padding="10dp"
android:textIsSelectable="true" />
android:padding="10dp" />
</LinearLayout>

View File

@ -93,7 +93,6 @@
android:layout_weight="1"
android:paddingHorizontal="5dp"
android:paddingVertical="2dp"
android:textIsSelectable="true"
android:textSize="20sp"
android:textStyle="bold" />
@ -147,11 +146,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="5dp"
android:autoLink="web"
android:paddingHorizontal="10dp"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:textIsSelectable="true" />
android:paddingBottom="10dp" />
<LinearLayout
android:layout_width="match_parent"