Skip to content

Commit

Permalink
fix: issues with expandable text views
Browse files Browse the repository at this point in the history
  • Loading branch information
Bnyro committed Aug 23, 2024
1 parent 8b0e6ce commit a883295
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/fragment_audio_player.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@
style="@style/TextViewMarquee"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textIsSelectable="true"
android:textSize="24sp" />

<TextView
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/res/layout/fragment_channel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
5 changes: 1 addition & 4 deletions app/src/main/res/layout/fragment_playlist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
android:layout_weight="1"
android:paddingHorizontal="5dp"
android:paddingVertical="2dp"
android:textIsSelectable="true"
android:textSize="20sp"
android:textStyle="bold" />

Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit a883295

Please sign in to comment.