mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40:30 +05:30
Merge branch 'master' into sponsorblock-integration
This commit is contained in:
commit
d1823a775a
@ -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)
|
||||||
|
@ -18,6 +18,7 @@ import android.view.*
|
|||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
import androidx.constraintlayout.motion.widget.MotionLayout
|
import androidx.constraintlayout.motion.widget.MotionLayout
|
||||||
@ -93,6 +94,12 @@ class MainActivity : AppCompatActivity() {
|
|||||||
navController = findNavController(R.id.fragment)
|
navController = findNavController(R.id.fragment)
|
||||||
bottomNavigationView.setupWithNavController(navController)
|
bottomNavigationView.setupWithNavController(navController)
|
||||||
|
|
||||||
|
when (sharedPreferences.getString("default_tab", "home")!!) {
|
||||||
|
"home" -> navController.navigate(R.id.home2)
|
||||||
|
"subscriptions" -> navController.navigate(R.id.subscriptions)
|
||||||
|
"library" -> navController.navigate(R.id.library)
|
||||||
|
}
|
||||||
|
|
||||||
bottomNavigationView.setOnItemSelectedListener {
|
bottomNavigationView.setOnItemSelectedListener {
|
||||||
when (it.itemId) {
|
when (it.itemId) {
|
||||||
R.id.home2 -> {
|
R.id.home2 -> {
|
||||||
|
@ -606,9 +606,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
|
||||||
|
@ -73,7 +73,7 @@ class PlaylistFragment : Fragment() {
|
|||||||
val sharedPref2 = context?.getSharedPreferences("username", Context.MODE_PRIVATE)
|
val sharedPref2 = context?.getSharedPreferences("username", Context.MODE_PRIVATE)
|
||||||
val user = sharedPref2?.getString("username","")
|
val user = sharedPref2?.getString("username","")
|
||||||
var isOwner = false
|
var isOwner = false
|
||||||
if(response.uploaderUrl == null && response.uploader == user){
|
if(response.uploaderUrl == null && response.uploader.equals(user, true)){
|
||||||
isOwner = true
|
isOwner = true
|
||||||
}
|
}
|
||||||
playlistAdapter = PlaylistAdapter(response.relatedStreams!!.toMutableList(), playlist_id!!, isOwner, requireActivity())
|
playlistAdapter = PlaylistAdapter(response.relatedStreams!!.toMutableList(), playlist_id!!, isOwner, requireActivity())
|
||||||
|
@ -8,6 +8,7 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.*
|
import android.widget.*
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
@ -16,6 +17,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
import com.github.libretube.adapters.SubscriptionAdapter
|
import com.github.libretube.adapters.SubscriptionAdapter
|
||||||
import com.github.libretube.adapters.SubscriptionChannelAdapter
|
import com.github.libretube.adapters.SubscriptionChannelAdapter
|
||||||
|
import org.chromium.base.ThreadUtils.runOnUiThread
|
||||||
import retrofit2.HttpException
|
import retrofit2.HttpException
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
@ -52,8 +54,6 @@ class Subscriptions : Fragment() {
|
|||||||
progressBar.visibility=View.VISIBLE
|
progressBar.visibility=View.VISIBLE
|
||||||
|
|
||||||
var channelRecView = view.findViewById<RecyclerView>(R.id.sub_channels)
|
var channelRecView = view.findViewById<RecyclerView>(R.id.sub_channels)
|
||||||
channelRecView?.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
|
||||||
fetchChannels(channelRecView)
|
|
||||||
|
|
||||||
var feedRecView = view.findViewById<RecyclerView>(R.id.sub_feed)
|
var feedRecView = view.findViewById<RecyclerView>(R.id.sub_feed)
|
||||||
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||||
@ -66,6 +66,25 @@ class Subscriptions : Fragment() {
|
|||||||
fetchFeed(feedRecView, progressBar, view)
|
fetchFeed(feedRecView, progressBar, view)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var toggleSubs = view.findViewById<RelativeLayout>(R.id.toggle_subs)
|
||||||
|
toggleSubs.visibility = View.VISIBLE
|
||||||
|
var loadedSubbedChannels = false
|
||||||
|
toggleSubs.setOnClickListener {
|
||||||
|
if (!channelRecView.isVisible) {
|
||||||
|
if (!loadedSubbedChannels) {
|
||||||
|
channelRecView?.layoutManager = GridLayoutManager(context, 4)
|
||||||
|
fetchChannels(channelRecView)
|
||||||
|
loadedSubbedChannels = true
|
||||||
|
}
|
||||||
|
channelRecView.visibility = View.VISIBLE
|
||||||
|
feedRecView.visibility = View.GONE
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
channelRecView.visibility = View.GONE
|
||||||
|
feedRecView.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val scrollView = view.findViewById<ScrollView>(R.id.scrollview_sub)
|
val scrollView = view.findViewById<ScrollView>(R.id.scrollview_sub)
|
||||||
scrollView.viewTreeObserver
|
scrollView.viewTreeObserver
|
||||||
.addOnScrollChangedListener {
|
.addOnScrollChangedListener {
|
||||||
|
@ -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 {
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
>
|
>
|
||||||
<de.hdodenhof.circleimageview.CircleImageView
|
<de.hdodenhof.circleimageview.CircleImageView
|
||||||
android:id="@+id/subscription_channel_image"
|
android:id="@+id/subscription_channel_image"
|
||||||
android:layout_width="60dp"
|
android:layout_width="50dp"
|
||||||
android:layout_height="60dp"
|
android:layout_height="50dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_marginBottom="4dp"/>
|
android:layout_marginBottom="4dp"/>
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -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"
|
||||||
|
@ -54,12 +54,35 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/toggle_subs"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="12dp"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/subscriptions"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:src="@drawable/ic_arrow_down"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:descendantFocusability="blocksDescendants">
|
android:descendantFocusability="blocksDescendants">
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:visibility="gone"
|
||||||
android:id="@+id/sub_channels"
|
android:id="@+id/sub_channels"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -470,6 +470,19 @@
|
|||||||
<item>L</item>
|
<item>L</item>
|
||||||
<item>D</item>
|
<item>D</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="tabs">
|
||||||
|
<item>@string/startpage</item>
|
||||||
|
<item>@string/subscriptions</item>
|
||||||
|
<item>@string/library</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="tabsValue">
|
||||||
|
<item>home</item>
|
||||||
|
<item>subscriptions</item>
|
||||||
|
<item>library</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
<string-array name="defres">
|
<string-array name="defres">
|
||||||
<item>HLS</item>
|
<item>HLS</item>
|
||||||
<item>1080p</item>
|
<item>1080p</item>
|
||||||
|
@ -72,6 +72,7 @@
|
|||||||
<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>
|
||||||
|
<string name="defaultTab">Default Tab</string>
|
||||||
<string name="sponsorblock">SponsorBlock</string>
|
<string name="sponsorblock">SponsorBlock</string>
|
||||||
<string name="sponsorblock_summary">Uses API from https://sponsor.ajay.app/</string>
|
<string name="sponsorblock_summary">Uses API from https://sponsor.ajay.app/</string>
|
||||||
<string name="segment_skipped">Skipped segment.</string>
|
<string name="segment_skipped">Skipped segment.</string>
|
||||||
@ -87,5 +88,5 @@
|
|||||||
<string name="category_intro">Intermission/Intro Animation</string>
|
<string name="category_intro">Intermission/Intro Animation</string>
|
||||||
<string name="category_intro_description">An interval without actual content. Could be a pause, static frame, repeating animation. This should not be used for transitions containing information.</string>
|
<string name="category_intro_description">An interval without actual content. Could be a pause, static frame, repeating animation. This should not be used for transitions containing information.</string>
|
||||||
<string name="category_outro">Endcards/Credits</string>
|
<string name="category_outro">Endcards/Credits</string>
|
||||||
<string name="category_outro_description">Credits or when the YouTube endcards appear. Not for conclusions with information.</string>
|
<string name="category_outro_description">Credits or when the YouTube endcards appear. Not for conclusions with information.</string
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -71,6 +71,15 @@
|
|||||||
android:icon="@drawable/ic_theme"
|
android:icon="@drawable/ic_theme"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
app:title="@string/defaultTab"
|
||||||
|
app:key="default_tab"
|
||||||
|
app:entries="@array/tabs"
|
||||||
|
app:entryValues="@array/tabsValue"
|
||||||
|
app:defaultValue="home"
|
||||||
|
android:icon="@drawable/ic_home"
|
||||||
|
/>
|
||||||
|
|
||||||
<androidx.preference.Preference
|
<androidx.preference.Preference
|
||||||
app:title="@string/sponsorblock"
|
app:title="@string/sponsorblock"
|
||||||
app:key="sponsorblock"
|
app:key="sponsorblock"
|
||||||
|
Loading…
Reference in New Issue
Block a user