From 0356031720f4c56d23512e67a7493cb2dd492eda Mon Sep 17 00:00:00 2001 From: janisslsm <97699850+janisslsm@users.noreply.github.com> Date: Fri, 13 May 2022 07:33:29 +0300 Subject: [PATCH 1/8] Ignore case for response.uploader --- app/src/main/java/com/github/libretube/PlaylistFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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()) From d9b5c18cac796965e16cec54a397c805d54fbd85 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 14 May 2022 00:09:33 +0200 Subject: [PATCH 2/8] Added default tab on app startup --- .../main/java/com/github/libretube/MainActivity.kt | 7 +++++++ app/src/main/res/values/array.xml | 13 +++++++++++++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/settings.xml | 9 +++++++++ 4 files changed, 30 insertions(+) diff --git a/app/src/main/java/com/github/libretube/MainActivity.kt b/app/src/main/java/com/github/libretube/MainActivity.kt index 7cd322ee4..5678469bc 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 @@ -86,6 +87,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/res/values/array.xml b/app/src/main/res/values/array.xml index a68fe1239..05860585e 100644 --- a/app/src/main/res/values/array.xml +++ b/app/src/main/res/values/array.xml @@ -470,6 +470,19 @@ 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 51d9d8b8e..82c632a45 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -72,4 +72,5 @@ No Internet Connection Retry Comments + Default Tab diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml index 56ae14456..dccf89391 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" /> + + Date: Sat, 14 May 2022 18:14:53 +0200 Subject: [PATCH 3/8] Added Sub Toggle --- .../com/github/libretube/Subscriptions.kt | 8 ++++++- .../res/layout/channel_subscription_row.xml | 4 ++-- .../res/layout/fragment_subscriptions.xml | 22 +++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/github/libretube/Subscriptions.kt b/app/src/main/java/com/github/libretube/Subscriptions.kt index 3fbfb8387..eb63d6147 100644 --- a/app/src/main/java/com/github/libretube/Subscriptions.kt +++ b/app/src/main/java/com/github/libretube/Subscriptions.kt @@ -52,7 +52,7 @@ class Subscriptions : Fragment() { progressBar.visibility=View.VISIBLE var channelRecView = view.findViewById(R.id.sub_channels) - channelRecView?.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false) + channelRecView?.layoutManager = GridLayoutManager(context, 4) fetchChannels(channelRecView) var feedRecView = view.findViewById(R.id.sub_feed) @@ -66,6 +66,12 @@ class Subscriptions : Fragment() { fetchFeed(feedRecView, progressBar, view) } + var toggleSubs = view.findViewById(R.id.toggle_subs) + toggleSubs.setOnClickListener { + channelRecView.visibility = if (channelRecView.visibility == View.GONE) View.VISIBLE else View.GONE + feedRecView.visibility = if (feedRecView.visibility == View.GONE) View.VISIBLE else View.GONE + } + val scrollView = view.findViewById(R.id.scrollview_sub) scrollView.viewTreeObserver .addOnScrollChangedListener { 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 @@ > + + + + + + + + Date: Sun, 15 May 2022 08:34:43 +0200 Subject: [PATCH 4/8] Lazy Load Subs and hide when not logged in --- .../java/com/github/libretube/Subscriptions.kt | 16 ++++++++++++---- .../main/res/layout/fragment_subscriptions.xml | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/github/libretube/Subscriptions.kt b/app/src/main/java/com/github/libretube/Subscriptions.kt index eb63d6147..6dba0f985 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 @@ -52,8 +53,6 @@ class Subscriptions : Fragment() { progressBar.visibility=View.VISIBLE var channelRecView = view.findViewById(R.id.sub_channels) - channelRecView?.layoutManager = GridLayoutManager(context, 4) - fetchChannels(channelRecView) var feedRecView = view.findViewById(R.id.sub_feed) val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext()) @@ -67,9 +66,18 @@ class Subscriptions : Fragment() { } var toggleSubs = view.findViewById(R.id.toggle_subs) + toggleSubs.visibility = View.VISIBLE toggleSubs.setOnClickListener { - channelRecView.visibility = if (channelRecView.visibility == View.GONE) View.VISIBLE else View.GONE - feedRecView.visibility = if (feedRecView.visibility == View.GONE) View.VISIBLE else View.GONE + if (!channelRecView.isVisible) { + channelRecView?.layoutManager = GridLayoutManager(context, 4) + fetchChannels(channelRecView) + 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) diff --git a/app/src/main/res/layout/fragment_subscriptions.xml b/app/src/main/res/layout/fragment_subscriptions.xml index dec57928a..ec0bd7bc6 100644 --- a/app/src/main/res/layout/fragment_subscriptions.xml +++ b/app/src/main/res/layout/fragment_subscriptions.xml @@ -58,7 +58,8 @@ android:id="@+id/toggle_subs" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_margin="10dp"> + android:layout_margin="10dp" + android:visibility="gone"> Date: Sun, 15 May 2022 21:11:27 +0200 Subject: [PATCH 5/8] Added verified in Channel Page --- .../java/com/github/libretube/ChannelFragment.kt | 2 ++ app/src/main/res/layout/fragment_channel.xml | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/app/src/main/java/com/github/libretube/ChannelFragment.kt b/app/src/main/java/com/github/libretube/ChannelFragment.kt index 96d3d77e9..6288739dd 100644 --- a/app/src/main/java/com/github/libretube/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/ChannelFragment.kt @@ -4,6 +4,7 @@ package com.github.libretube import android.annotation.SuppressLint import android.app.Activity import android.content.Context +import android.media.Image import android.opengl.Visibility import android.os.Bundle import android.util.Log @@ -209,6 +210,7 @@ class ChannelFragment : Fragment() { runOnUiThread { view.findViewById(R.id.channel_scrollView).visibility = View.VISIBLE view.findViewById(R.id.channel_name).text=response.name + if (response.verified) view.findViewById(R.id.channel_verified).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 val bannerImage = view.findViewById(R.id.channel_banner) diff --git a/app/src/main/res/layout/fragment_channel.xml b/app/src/main/res/layout/fragment_channel.xml index 3e5005186..28c666278 100644 --- a/app/src/main/res/layout/fragment_channel.xml +++ b/app/src/main/res/layout/fragment_channel.xml @@ -44,6 +44,10 @@ android:layout_height="match_parent" android:orientation="vertical"> + + + + + + Date: Sun, 15 May 2022 21:16:46 +0200 Subject: [PATCH 6/8] Removed import --- app/src/main/java/com/github/libretube/ChannelFragment.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ChannelFragment.kt b/app/src/main/java/com/github/libretube/ChannelFragment.kt index 6288739dd..0894d58ff 100644 --- a/app/src/main/java/com/github/libretube/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/ChannelFragment.kt @@ -4,8 +4,6 @@ package com.github.libretube import android.annotation.SuppressLint import android.app.Activity import android.content.Context -import android.media.Image -import android.opengl.Visibility import android.os.Bundle import android.util.Log import android.util.TypedValue @@ -210,7 +208,8 @@ class ChannelFragment : Fragment() { runOnUiThread { view.findViewById(R.id.channel_scrollView).visibility = View.VISIBLE view.findViewById(R.id.channel_name).text=response.name - if (response.verified) view.findViewById(R.id.channel_verified).visibility = View.VISIBLE + 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 val bannerImage = view.findViewById(R.id.channel_banner) From af22e6ae778ba6fc3e24cf205a93ba2f2ba269a0 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 15 May 2022 23:40:33 +0200 Subject: [PATCH 7/8] Comment Channel Icons clickable, improved Channel View --- .../com/github/libretube/ChannelFragment.kt | 5 +++-- .../com/github/libretube/PlayerFragment.kt | 4 ++-- .../libretube/adapters/CommentsAdapter.kt | 22 +++++++++++++++++-- app/src/main/res/layout/fragment_channel.xml | 13 +---------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ChannelFragment.kt b/app/src/main/java/com/github/libretube/ChannelFragment.kt index 0894d58ff..b745a9b70 100644 --- a/app/src/main/java/com/github/libretube/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/ChannelFragment.kt @@ -5,6 +5,7 @@ import android.annotation.SuppressLint import android.app.Activity import android.content.Context import android.os.Bundle +import android.text.TextUtils.substring import android.util.Log import android.util.TypedValue import android.view.LayoutInflater @@ -207,11 +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/PlayerFragment.kt b/app/src/main/java/com/github/libretube/PlayerFragment.kt index 459a9809c..ce00bfca7 100644 --- a/app/src/main/java/com/github/libretube/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/PlayerFragment.kt @@ -536,9 +536,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/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/fragment_channel.xml b/app/src/main/res/layout/fragment_channel.xml index 28c666278..cf565285a 100644 --- a/app/src/main/res/layout/fragment_channel.xml +++ b/app/src/main/res/layout/fragment_channel.xml @@ -95,20 +95,9 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="10dp" - android:layout_marginBottom="5dp" + android:layout_marginBottom="15dp" android:text="" /> - - Date: Mon, 16 May 2022 17:33:22 +0200 Subject: [PATCH 8/8] Load channels only once --- app/src/main/java/com/github/libretube/Subscriptions.kt | 9 +++++++-- app/src/main/res/layout/fragment_subscriptions.xml | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/github/libretube/Subscriptions.kt b/app/src/main/java/com/github/libretube/Subscriptions.kt index 6dba0f985..5db11caac 100644 --- a/app/src/main/java/com/github/libretube/Subscriptions.kt +++ b/app/src/main/java/com/github/libretube/Subscriptions.kt @@ -17,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 @@ -67,10 +68,14 @@ class Subscriptions : Fragment() { var toggleSubs = view.findViewById(R.id.toggle_subs) toggleSubs.visibility = View.VISIBLE + var loadedSubbedChannels = false toggleSubs.setOnClickListener { if (!channelRecView.isVisible) { - channelRecView?.layoutManager = GridLayoutManager(context, 4) - fetchChannels(channelRecView) + if (!loadedSubbedChannels) { + channelRecView?.layoutManager = GridLayoutManager(context, 4) + fetchChannels(channelRecView) + loadedSubbedChannels = true + } channelRecView.visibility = View.VISIBLE feedRecView.visibility = View.GONE } diff --git a/app/src/main/res/layout/fragment_subscriptions.xml b/app/src/main/res/layout/fragment_subscriptions.xml index ec0bd7bc6..90f827f8e 100644 --- a/app/src/main/res/layout/fragment_subscriptions.xml +++ b/app/src/main/res/layout/fragment_subscriptions.xml @@ -58,7 +58,7 @@ android:id="@+id/toggle_subs" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_margin="10dp" + android:layout_margin="12dp" android:visibility="gone">