From d9b5c18cac796965e16cec54a397c805d54fbd85 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 14 May 2022 00:09:33 +0200 Subject: [PATCH 1/4] 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 2/4] 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 3/4] 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: Mon, 16 May 2022 17:33:22 +0200 Subject: [PATCH 4/4] 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">