diff --git a/app/src/main/java/com/github/libretube/ChannelFragment.kt b/app/src/main/java/com/github/libretube/ChannelFragment.kt index 96d3d77e9..b745a9b70 100644 --- a/app/src/main/java/com/github/libretube/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/ChannelFragment.kt @@ -4,8 +4,8 @@ package com.github.libretube import android.annotation.SuppressLint import android.app.Activity import android.content.Context -import android.opengl.Visibility import android.os.Bundle +import android.text.TextUtils.substring import android.util.Log import android.util.TypedValue import android.view.LayoutInflater @@ -208,9 +208,11 @@ class ChannelFragment : Fragment() { refreshLayout?.isRefreshing = false; runOnUiThread { view.findViewById(R.id.channel_scrollView).visibility = View.VISIBLE - view.findViewById(R.id.channel_name).text=response.name + view.findViewById(R.id.channel_name).text = if (response.name?.length!! > 19) response.name.toString().substring(0,16) + "..." else response.name + val channelVerified = view.findViewById(R.id.channel_verified) + if (response.verified) channelVerified.visibility = View.VISIBLE view.findViewById(R.id.channel_subs).text=resources.getString(R.string.subscribers, response.subscriberCount.formatShort()) - view.findViewById(R.id.channel_description).text=response.description + view.findViewById(R.id.channel_description).text=response.description?.trim() val bannerImage = view.findViewById(R.id.channel_banner) val channelImage = view.findViewById(R.id.channel_image) Picasso.get().load(response.bannerUrl).into(bannerImage) diff --git a/app/src/main/java/com/github/libretube/MainActivity.kt b/app/src/main/java/com/github/libretube/MainActivity.kt index 29e6d857e..3192af72b 100644 --- a/app/src/main/java/com/github/libretube/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/MainActivity.kt @@ -18,6 +18,7 @@ import android.view.* import android.view.inputmethod.InputMethodManager import android.widget.Button import android.widget.LinearLayout +import android.widget.Toast import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.widget.Toolbar import androidx.constraintlayout.motion.widget.MotionLayout @@ -93,6 +94,12 @@ class MainActivity : AppCompatActivity() { navController = findNavController(R.id.fragment) 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 { when (it.itemId) { R.id.home2 -> { diff --git a/app/src/main/java/com/github/libretube/PlayerFragment.kt b/app/src/main/java/com/github/libretube/PlayerFragment.kt index 9c41a40dc..b0b24bae0 100644 --- a/app/src/main/java/com/github/libretube/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/PlayerFragment.kt @@ -606,9 +606,9 @@ class PlayerFragment : Fragment() { view.findViewById(R.id.player_description).text = 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 { - Html.fromHtml(response.description) + Html.fromHtml(response.description).trim() } view.findViewById(R.id.player_views_info).text = response.views.formatShort() + " views • " + response.uploadDate diff --git a/app/src/main/java/com/github/libretube/PlaylistFragment.kt b/app/src/main/java/com/github/libretube/PlaylistFragment.kt index 89943781a..ef6ab7f6d 100644 --- a/app/src/main/java/com/github/libretube/PlaylistFragment.kt +++ b/app/src/main/java/com/github/libretube/PlaylistFragment.kt @@ -73,7 +73,7 @@ class PlaylistFragment : Fragment() { val sharedPref2 = context?.getSharedPreferences("username", Context.MODE_PRIVATE) val user = sharedPref2?.getString("username","") var isOwner = false - if(response.uploaderUrl == null && response.uploader == user){ + if(response.uploaderUrl == null && response.uploader.equals(user, true)){ isOwner = true } playlistAdapter = PlaylistAdapter(response.relatedStreams!!.toMutableList(), playlist_id!!, isOwner, requireActivity()) diff --git a/app/src/main/java/com/github/libretube/Subscriptions.kt b/app/src/main/java/com/github/libretube/Subscriptions.kt index 3fbfb8387..5db11caac 100644 --- a/app/src/main/java/com/github/libretube/Subscriptions.kt +++ b/app/src/main/java/com/github/libretube/Subscriptions.kt @@ -8,6 +8,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.* +import androidx.core.view.isVisible import androidx.lifecycle.lifecycleScope import androidx.preference.PreferenceManager import androidx.recyclerview.widget.GridLayoutManager @@ -16,6 +17,7 @@ import androidx.recyclerview.widget.RecyclerView import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.github.libretube.adapters.SubscriptionAdapter import com.github.libretube.adapters.SubscriptionChannelAdapter +import org.chromium.base.ThreadUtils.runOnUiThread import retrofit2.HttpException import java.io.IOException @@ -52,8 +54,6 @@ class Subscriptions : Fragment() { progressBar.visibility=View.VISIBLE var channelRecView = view.findViewById(R.id.sub_channels) - channelRecView?.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false) - fetchChannels(channelRecView) var feedRecView = view.findViewById(R.id.sub_feed) val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext()) @@ -66,6 +66,25 @@ class Subscriptions : Fragment() { fetchFeed(feedRecView, progressBar, view) } + var toggleSubs = view.findViewById(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(R.id.scrollview_sub) scrollView.viewTreeObserver .addOnScrollChangedListener { diff --git a/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt b/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt index bdd0f0811..36bdcaf58 100644 --- a/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt @@ -1,11 +1,15 @@ package com.github.libretube.adapters +import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView +import androidx.constraintlayout.motion.widget.MotionLayout +import androidx.core.os.bundleOf import androidx.recyclerview.widget.RecyclerView +import com.github.libretube.MainActivity import com.github.libretube.R import com.github.libretube.formatShort import com.github.libretube.obj.Comment @@ -27,8 +31,8 @@ class CommentsAdapter(private val comments: MutableList): RecyclerView override fun onBindViewHolder(holder: ViewHolder, position: Int) { holder.v.findViewById(R.id.comment_infos).text = comments[position].author.toString() + " • " + comments[position].commentedTime.toString() holder.v.findViewById(R.id.comment_text).text = comments[position].commentText.toString() - val thumbnailImage = holder.v.findViewById(R.id.commentor_image) - Picasso.get().load(comments[position].thumbnail).fit().centerCrop().into(thumbnailImage) + val channelImage = holder.v.findViewById(R.id.commentor_image) + Picasso.get().load(comments[position].thumbnail).fit().centerCrop().into(channelImage) holder.v.findViewById(R.id.likes_textView).text = comments[position].likeCount?.toLong().formatShort() if (comments[position].verified == true) { holder.v.findViewById(R.id.verified_imageView).visibility = View.VISIBLE @@ -39,6 +43,20 @@ class CommentsAdapter(private val comments: MutableList): RecyclerView if (comments[position].hearted == true) { holder.v.findViewById(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(R.id.mainMotionLayout) + if (mainMotionLayout.progress == 0.toFloat()) { + mainMotionLayout.transitionToEnd() + activity.findViewById(R.id.playerMotionLayout).transitionToEnd() + } + }catch (e: Exception){ + + } + } } override fun getItemCount(): Int { diff --git a/app/src/main/res/layout/channel_subscription_row.xml b/app/src/main/res/layout/channel_subscription_row.xml index c9d1df987..97cbf0228 100644 --- a/app/src/main/res/layout/channel_subscription_row.xml +++ b/app/src/main/res/layout/channel_subscription_row.xml @@ -9,8 +9,8 @@ > + + + + + + - - + + + + + + + + L D + + + @string/startpage + @string/subscriptions + @string/library + + + + home + subscriptions + library + + HLS 1080p diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9197b2733..0920a44e9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -72,6 +72,7 @@ No Internet Connection Retry Comments + Default Tab SponsorBlock Uses API from https://sponsor.ajay.app/ Skipped segment. @@ -87,5 +88,5 @@ Intermission/Intro Animation An interval without actual content. Could be a pause, static frame, repeating animation. This should not be used for transitions containing information. Endcards/Credits - Credits or when the YouTube endcards appear. Not for conclusions with information. + Credits or when the YouTube endcards appear. Not for conclusions with information. diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml index 21b5e8632..fe7ab3ef1 100644 --- a/app/src/main/res/xml/settings.xml +++ b/app/src/main/res/xml/settings.xml @@ -71,6 +71,15 @@ android:icon="@drawable/ic_theme" /> + +