Merge pull request #190 from Bnyro/translation

Subs and video count translation, video duration in search view
This commit is contained in:
Farbod 2022-05-12 11:28:33 +04:30 committed by GitHub
commit 2b0eb19b5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package com.github.libretube.adapters package com.github.libretube.adapters
import android.os.Bundle import android.os.Bundle
import android.text.format.DateUtils
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -52,6 +53,8 @@ class CustomViewHolder1(private val v: View): RecyclerView.ViewHolder(v){
private fun bindWatch(item: SearchItem) { private fun bindWatch(item: SearchItem) {
val thumbnailImage = v.findViewById<ImageView>(R.id.search_thumbnail) val thumbnailImage = v.findViewById<ImageView>(R.id.search_thumbnail)
Picasso.get().load(item.thumbnail).into(thumbnailImage) Picasso.get().load(item.thumbnail).into(thumbnailImage)
val thumbnailDuration = v.findViewById<TextView>(R.id.search_thumbnail_duration)
thumbnailDuration.text = DateUtils.formatElapsedTime(item.duration!!)
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).into(channelImage) Picasso.get().load(item.uploaderAvatar).into(channelImage)
val title = v.findViewById<TextView>(R.id.search_description) val title = v.findViewById<TextView>(R.id.search_description)
@ -89,7 +92,7 @@ class CustomViewHolder1(private val v: View): RecyclerView.ViewHolder(v){
val channelName = v.findViewById<TextView>(R.id.search_channel_name) val channelName = v.findViewById<TextView>(R.id.search_channel_name)
channelName.text = item.name channelName.text = item.name
val channelViews = v.findViewById<TextView>(R.id.search_views) val channelViews = v.findViewById<TextView>(R.id.search_views)
channelViews.text = item.subscribers.formatShort() + " subscribers • "+ item.videos + " videos" channelViews.text = v.context.getString(R.string.subscribers, item.subscribers.formatShort()) + "" + v.context.getString(R.string.videoCount, item.videos.toString())
v.setOnClickListener { v.setOnClickListener {
val activity = v.context as MainActivity val activity = v.context as MainActivity
val bundle = bundleOf("channel_id" to item.url) val bundle = bundleOf("channel_id" to item.url)

View File

@ -34,6 +34,18 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:srcCompat="@tools:sample/backgrounds/scenic" /> tools:srcCompat="@tools:sample/backgrounds/scenic" />
<TextView
android:id="@+id/search_thumbnail_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginRight="5dp"
android:layout_marginBottom="3dp"
android:textSize="11dp"
android:textColor="@color/duration_text_color"
android:background="@color/duration_background_color"
android:padding="0.5dp"/>
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
<TextView <TextView

View File

@ -63,6 +63,7 @@
<string name="lightTheme">Light Theme</string> <string name="lightTheme">Light Theme</string>
<string name="darkTheme">Dark Theme</string> <string name="darkTheme">Dark Theme</string>
<string name="subscribers">%1$s subscribers</string> <string name="subscribers">%1$s subscribers</string>
<string name="videoCount">%1$s videos</string>
<string name="noInternet">No Internet Connection</string> <string name="noInternet">No Internet Connection</string>
<string name="retry">Retry</string> <string name="retry">Retry</string>
<string name="comments">Comments</string> <string name="comments">Comments</string>