Merge pull request #222 from Bnyro/verified

Verified in Channel Page, Channel Images in Comments clickable
This commit is contained in:
Bnyro 2022-05-16 14:01:57 +02:00 committed by GitHub
commit a615ca0e81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 19 deletions

View File

@ -4,8 +4,8 @@ package com.github.libretube
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.Activity import android.app.Activity
import android.content.Context import android.content.Context
import android.opengl.Visibility
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils.substring
import android.util.Log import android.util.Log
import android.util.TypedValue import android.util.TypedValue
import android.view.LayoutInflater import android.view.LayoutInflater
@ -208,9 +208,11 @@ class ChannelFragment : Fragment() {
refreshLayout?.isRefreshing = false; refreshLayout?.isRefreshing = false;
runOnUiThread { runOnUiThread {
view.findViewById<ScrollView>(R.id.channel_scrollView).visibility = View.VISIBLE view.findViewById<ScrollView>(R.id.channel_scrollView).visibility = View.VISIBLE
view.findViewById<TextView>(R.id.channel_name).text=response.name view.findViewById<TextView>(R.id.channel_name).text = if (response.name?.length!! > 19) response.name.toString().substring(0,16) + "..." else response.name
val channelVerified = view.findViewById<ImageView>(R.id.channel_verified)
if (response.verified) channelVerified.visibility = View.VISIBLE
view.findViewById<TextView>(R.id.channel_subs).text=resources.getString(R.string.subscribers, response.subscriberCount.formatShort()) view.findViewById<TextView>(R.id.channel_subs).text=resources.getString(R.string.subscribers, response.subscriberCount.formatShort())
view.findViewById<TextView>(R.id.channel_description).text=response.description view.findViewById<TextView>(R.id.channel_description).text=response.description?.trim()
val bannerImage = view.findViewById<ImageView>(R.id.channel_banner) val bannerImage = view.findViewById<ImageView>(R.id.channel_banner)
val channelImage = view.findViewById<ImageView>(R.id.channel_image) val channelImage = view.findViewById<ImageView>(R.id.channel_image)
Picasso.get().load(response.bannerUrl).into(bannerImage) Picasso.get().load(response.bannerUrl).into(bannerImage)

View File

@ -536,9 +536,9 @@ class PlayerFragment : Fragment() {
view.findViewById<TextView>(R.id.player_description).text = view.findViewById<TextView>(R.id.player_description).text =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Html.fromHtml(response.description, Html.FROM_HTML_MODE_COMPACT) Html.fromHtml(response.description, Html.FROM_HTML_MODE_COMPACT).trim()
} else { } else {
Html.fromHtml(response.description) Html.fromHtml(response.description).trim()
} }
view.findViewById<TextView>(R.id.player_views_info).text = view.findViewById<TextView>(R.id.player_views_info).text =
response.views.formatShort() + " views • " + response.uploadDate response.views.formatShort() + " views • " + response.uploadDate

View File

@ -1,11 +1,15 @@
package com.github.libretube.adapters package com.github.libretube.adapters
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.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.formatShort import com.github.libretube.formatShort
import com.github.libretube.obj.Comment import com.github.libretube.obj.Comment
@ -27,8 +31,8 @@ class CommentsAdapter(private val comments: MutableList<Comment>): RecyclerView
override fun onBindViewHolder(holder: ViewHolder, position: Int) { override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.v.findViewById<TextView>(R.id.comment_infos).text = comments[position].author.toString() + "" + comments[position].commentedTime.toString() holder.v.findViewById<TextView>(R.id.comment_infos).text = comments[position].author.toString() + "" + comments[position].commentedTime.toString()
holder.v.findViewById<TextView>(R.id.comment_text).text = comments[position].commentText.toString() holder.v.findViewById<TextView>(R.id.comment_text).text = comments[position].commentText.toString()
val thumbnailImage = holder.v.findViewById<ImageView>(R.id.commentor_image) val channelImage = holder.v.findViewById<ImageView>(R.id.commentor_image)
Picasso.get().load(comments[position].thumbnail).fit().centerCrop().into(thumbnailImage) Picasso.get().load(comments[position].thumbnail).fit().centerCrop().into(channelImage)
holder.v.findViewById<TextView>(R.id.likes_textView).text = comments[position].likeCount?.toLong().formatShort() holder.v.findViewById<TextView>(R.id.likes_textView).text = comments[position].likeCount?.toLong().formatShort()
if (comments[position].verified == true) { if (comments[position].verified == true) {
holder.v.findViewById<ImageView>(R.id.verified_imageView).visibility = View.VISIBLE holder.v.findViewById<ImageView>(R.id.verified_imageView).visibility = View.VISIBLE
@ -39,6 +43,20 @@ class CommentsAdapter(private val comments: MutableList<Comment>): RecyclerView
if (comments[position].hearted == true) { if (comments[position].hearted == true) {
holder.v.findViewById<ImageView>(R.id.hearted_imageView).visibility = View.VISIBLE holder.v.findViewById<ImageView>(R.id.hearted_imageView).visibility = View.VISIBLE
} }
channelImage.setOnClickListener{
val activity = holder.v.context as MainActivity
val bundle = bundleOf("channel_id" to comments[position].commentorUrl)
activity.navController.navigate(R.id.channel, bundle)
try {
val mainMotionLayout = activity.findViewById<MotionLayout>(R.id.mainMotionLayout)
if (mainMotionLayout.progress == 0.toFloat()) {
mainMotionLayout.transitionToEnd()
activity.findViewById<MotionLayout>(R.id.playerMotionLayout).transitionToEnd()
}
}catch (e: Exception){
}
}
} }
override fun getItemCount(): Int { override fun getItemCount(): Int {

View File

@ -44,6 +44,10 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView <TextView
android:id="@+id/channel_name" android:id="@+id/channel_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -54,6 +58,16 @@
android:textSize="20sp" android:textSize="20sp"
android:textStyle="bold" /> android:textStyle="bold" />
<ImageView
android:id="@+id/channel_verified"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_margin="7dp"
android:visibility="gone"
android:src="@drawable/ic_verified" />
</LinearLayout>
<TextView <TextView
android:id="@+id/channel_subs" android:id="@+id/channel_subs"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -81,20 +95,9 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="15dp"
android:text="" /> android:text="" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="5dp"
android:text="@string/videos"
android:textSize="17sp"
android:textStyle="bold" />
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"