mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
Merge pull request #217 from Bnyro/subs
New Channels Layout in Subscriptions Tab and Option to change App startup page
This commit is contained in:
commit
2907bebd41
@ -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
|
||||||
@ -86,6 +87,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 -> {
|
||||||
|
@ -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 {
|
||||||
|
@ -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
|
||||||
|
@ -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,4 +72,5 @@
|
|||||||
<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>
|
||||||
</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"
|
||||||
|
/>
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
app:title="@string/defres"
|
app:title="@string/defres"
|
||||||
app:key="default_res"
|
app:key="default_res"
|
||||||
|
Loading…
Reference in New Issue
Block a user