text length fixes

This commit is contained in:
Bnyro 2022-05-22 10:56:49 +02:00
parent dbef98c543
commit a5ff664e7e
7 changed files with 29 additions and 23 deletions

View File

@ -19,8 +19,9 @@ import com.github.libretube.adapters.ChannelAdapter
import com.github.libretube.obj.Subscribe import com.github.libretube.obj.Subscribe
import com.google.android.material.button.MaterialButton import com.google.android.material.button.MaterialButton
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
import java.io.IOException
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException
class ChannelFragment : Fragment() { class ChannelFragment : Fragment() {
@ -195,10 +196,11 @@ class ChannelFragment : Fragment() {
runOnUiThread { runOnUiThread {
view.findViewById<ScrollView>(R.id.channel_scrollView).visibility = View.VISIBLE view.findViewById<ScrollView>(R.id.channel_scrollView).visibility = View.VISIBLE
val channelName = view.findViewById<TextView>(R.id.channel_name) val channelName = view.findViewById<TextView>(R.id.channel_name)
channelName.text = if (response.name?.length!! > 18) response.name.toString() channelName.text = response.name
.substring(0, 16) + "..." else response.name if (response.verified) {
val channelVerified = view.findViewById<ImageView>(R.id.channel_verified) channelName.setCompoundDrawablesWithIntrinsicBounds(
if (response.verified) channelVerified.visibility = View.VISIBLE 0, 0, R.drawable.ic_verified, 0);
}
view.findViewById<TextView>(R.id.channel_subs).text = resources.getString( view.findViewById<TextView>(R.id.channel_subs).text = resources.getString(
R.string.subscribers, R.string.subscribers,
response.subscriberCount.formatShort() response.subscriberCount.formatShort()

View File

@ -66,8 +66,7 @@ class CustomViewHolder1(private val v: View) : RecyclerView.ViewHolder(v) {
val channelImage = v.findViewById<ImageView>(R.id.search_channel_image) val channelImage = v.findViewById<ImageView>(R.id.search_channel_image)
Picasso.get().load(item.uploaderAvatar).fit().centerCrop().into(channelImage) Picasso.get().load(item.uploaderAvatar).fit().centerCrop().into(channelImage)
val title = v.findViewById<TextView>(R.id.search_description) val title = v.findViewById<TextView>(R.id.search_description)
title.text = title.text = item.title
if (item.title!!.length > 60) item.title?.substring(0, 60) + "..." else item.title
val views = v.findViewById<TextView>(R.id.search_views) val views = v.findViewById<TextView>(R.id.search_views)
val viewsString = if (item.views?.toInt() != -1) item.views.formatShort() else "" val viewsString = if (item.views?.toInt() != -1) item.views.formatShort() else ""
val uploadDate = if (item.uploadedDate != null) item.uploadedDate else "" val uploadDate = if (item.uploadedDate != null) item.uploadedDate else ""

View File

@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="14dp"
android:height="24dp" android:height="14dp"
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24" android:viewportHeight="24"
android:tint="?attr/colorControlNormal"> android:tint="?attr/colorControlNormal">

View File

@ -31,6 +31,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="TextView" android:text="TextView"
android:textSize="16sp" android:textSize="16sp"
android:maxLines="1"
android:ellipsize="end"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />

View File

@ -33,16 +33,18 @@
android:id="@+id/channel_image" android:id="@+id/channel_image"
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp" android:layout_height="50dp"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal" />
android:layout_marginRight="10dp" />
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp">
<LinearLayout <LinearLayout
android:layout_marginTop="3.5dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
@ -51,18 +53,13 @@
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="left"
android:layout_marginTop="2dp"
android:text="Channel Name" android:text="Channel Name"
android:textSize="20sp" android:drawablePadding="3dip"
android:textStyle="bold" /> android:textSize="16sp"
android:textStyle="bold"
<ImageView android:maxLines="1"
android:id="@+id/channel_verified" android:ellipsize="end"
android:layout_width="16dp" />
android:layout_height="16dp"
android:layout_margin="7dp"
android:visibility="gone"
android:src="@drawable/ic_verified" />
</LinearLayout> </LinearLayout>

View File

@ -72,6 +72,8 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:maxLines="1"
android:ellipsize="end"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/card_playlist" app:layout_constraintStart_toEndOf="@+id/card_playlist"
app:layout_constraintTop_toBottomOf="@+id/search_description" /> app:layout_constraintTop_toBottomOf="@+id/search_description" />

View File

@ -54,6 +54,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
android:maxLines="2"
android:ellipsize="end"
app:layout_constraintStart_toEndOf="@+id/card_search_thumbnail" app:layout_constraintStart_toEndOf="@+id/card_search_thumbnail"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@ -82,6 +84,8 @@
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
android:maxLines="1"
android:ellipsize="end"
app:layout_constraintStart_toEndOf="@+id/search_channel_image" app:layout_constraintStart_toEndOf="@+id/search_channel_image"
app:layout_constraintTop_toBottomOf="@+id/search_views" /> app:layout_constraintTop_toBottomOf="@+id/search_views" />