watch history fragment

This commit is contained in:
Bnyro 2022-07-01 18:29:47 +02:00
parent e7e4cf7c07
commit e9226313f4
14 changed files with 103 additions and 30 deletions

View File

@ -79,28 +79,28 @@ class MainActivity : AppCompatActivity() {
// hide the trending page if enabled // hide the trending page if enabled
val hideTrendingPage = PreferenceHelper.getBoolean(this, "hide_trending_page", false) val hideTrendingPage = PreferenceHelper.getBoolean(this, "hide_trending_page", false)
if (hideTrendingPage) bottomNavigationView.menu.findItem(R.id.home2).isVisible = false if (hideTrendingPage) bottomNavigationView.menu.findItem(R.id.homeFragment).isVisible = false
// navigate to the default start tab // navigate to the default start tab
when (PreferenceHelper.getString(this, "default_tab", "home")) { when (PreferenceHelper.getString(this, "default_tab", "home")) {
"home" -> navController.navigate(R.id.home2) "home" -> navController.navigate(R.id.homeFragment)
"subscriptions" -> navController.navigate(R.id.subscriptions) "subscriptions" -> navController.navigate(R.id.subscriptionsFragment)
"library" -> navController.navigate(R.id.library) "library" -> navController.navigate(R.id.libraryFragment)
} }
binding.bottomNav.setOnItemSelectedListener { binding.bottomNav.setOnItemSelectedListener {
when (it.itemId) { when (it.itemId) {
R.id.home2 -> { R.id.homeFragment -> {
navController.backQueue.clear() navController.backQueue.clear()
navController.navigate(R.id.home2) navController.navigate(R.id.homeFragment)
} }
R.id.subscriptions -> { R.id.subscriptionsFragment -> {
// navController.backQueue.clear() // navController.backQueue.clear()
navController.navigate(R.id.subscriptions) navController.navigate(R.id.subscriptionsFragment)
} }
R.id.library -> { R.id.libraryFragment -> {
// navController.backQueue.clear() // navController.backQueue.clear()
navController.navigate(R.id.library) navController.navigate(R.id.libraryFragment)
} }
} }
false false
@ -176,7 +176,7 @@ class MainActivity : AppCompatActivity() {
channel = channel!!.replace("/c/", "") channel = channel!!.replace("/c/", "")
channel = channel.replace("/user/", "") channel = channel.replace("/user/", "")
val bundle = bundleOf("channel_id" to channel) val bundle = bundleOf("channel_id" to channel)
navController.navigate(R.id.channel, bundle) navController.navigate(R.id.channelFragment, bundle)
} else if (data.path!!.contains("/playlist")) { } else if (data.path!!.contains("/playlist")) {
Log.i(TAG, "URI Type: Playlist") Log.i(TAG, "URI Type: Playlist")
var playlist = data.query!! var playlist = data.query!!

View File

@ -69,7 +69,7 @@ class CommentsAdapter(
commentorImage.setOnClickListener { commentorImage.setOnClickListener {
val activity = holder.v.context as MainActivity val activity = holder.v.context as MainActivity
val bundle = bundleOf("channel_id" to comment.commentorUrl) val bundle = bundleOf("channel_id" to comment.commentorUrl)
activity.navController.navigate(R.id.channel, bundle) activity.navController.navigate(R.id.channelFragment, bundle)
try { try {
val mainMotionLayout = val mainMotionLayout =
activity.findViewById<MotionLayout>(R.id.mainMotionLayout) activity.findViewById<MotionLayout>(R.id.mainMotionLayout)

View File

@ -61,7 +61,7 @@ class RepliesAdapter(
commentorImage.setOnClickListener { commentorImage.setOnClickListener {
val activity = holder.v.context as MainActivity val activity = holder.v.context as MainActivity
val bundle = bundleOf("channel_id" to reply.commentorUrl) val bundle = bundleOf("channel_id" to reply.commentorUrl)
activity.navController.navigate(R.id.channel, bundle) activity.navController.navigate(R.id.channelFragment, bundle)
try { try {
val mainMotionLayout = val mainMotionLayout =
activity.findViewById<MotionLayout>(R.id.mainMotionLayout) activity.findViewById<MotionLayout>(R.id.mainMotionLayout)

View File

@ -117,7 +117,7 @@ class SearchViewHolder(
channelImage.setOnClickListener { channelImage.setOnClickListener {
val activity = v.context as MainActivity val activity = v.context as MainActivity
val bundle = bundleOf("channel_id" to item.uploaderUrl) val bundle = bundleOf("channel_id" to item.uploaderUrl)
activity.navController.navigate(R.id.channel, bundle) activity.navController.navigate(R.id.channelFragment, bundle)
} }
} }
@ -134,7 +134,7 @@ class SearchViewHolder(
v.setOnClickListener { v.setOnClickListener {
val activity = v.context as MainActivity val activity = v.context as MainActivity
val bundle = bundleOf("channel_id" to item.url) val bundle = bundleOf("channel_id" to item.url)
activity.navController.navigate(R.id.channel, bundle) activity.navController.navigate(R.id.channelFragment, bundle)
} }
// todo sub button // todo sub button
} }

View File

@ -62,7 +62,7 @@ class SubscriptionAdapter(
channelImage.setOnClickListener { channelImage.setOnClickListener {
val activity = holder.v.context as MainActivity val activity = holder.v.context as MainActivity
val bundle = bundleOf("channel_id" to trending.uploaderUrl) val bundle = bundleOf("channel_id" to trending.uploaderUrl)
activity.navController.navigate(R.id.channel, bundle) activity.navController.navigate(R.id.channelFragment, bundle)
try { try {
val mainMotionLayout = val mainMotionLayout =
activity.findViewById<MotionLayout>(R.id.mainMotionLayout) activity.findViewById<MotionLayout>(R.id.mainMotionLayout)

View File

@ -48,7 +48,7 @@ class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscrip
root.setOnClickListener { root.setOnClickListener {
val activity = holder.v.context as MainActivity val activity = holder.v.context as MainActivity
val bundle = bundleOf("channel_id" to subscription.url) val bundle = bundleOf("channel_id" to subscription.url)
activity.navController.navigate(R.id.channel, bundle) activity.navController.navigate(R.id.channelFragment, bundle)
} }
subscriptionSubscribe.setOnClickListener { subscriptionSubscribe.setOnClickListener {
if (!isLoading) { if (!isLoading) {

View File

@ -53,7 +53,7 @@ class TrendingAdapter(
channelImage.setOnClickListener { channelImage.setOnClickListener {
val activity = holder.v.context as MainActivity val activity = holder.v.context as MainActivity
val bundle = bundleOf("channel_id" to trending.uploaderUrl) val bundle = bundleOf("channel_id" to trending.uploaderUrl)
activity.navController.navigate(R.id.channel, bundle) activity.navController.navigate(R.id.channelFragment, bundle)
try { try {
val mainMotionLayout = val mainMotionLayout =
activity.findViewById<MotionLayout>(R.id.mainMotionLayout) activity.findViewById<MotionLayout>(R.id.mainMotionLayout)

View File

@ -8,6 +8,7 @@ import android.view.ViewGroup
import android.widget.Toast import android.widget.Toast
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.adapters.PlaylistsAdapter import com.github.libretube.adapters.PlaylistsAdapter
@ -43,6 +44,11 @@ class LibraryFragment : Fragment() {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
binding.playlistRecView.layoutManager = LinearLayoutManager(view.context) binding.playlistRecView.layoutManager = LinearLayoutManager(view.context)
token = PreferenceHelper.getToken(requireContext()) token = PreferenceHelper.getToken(requireContext())
binding.showWatchHistory.setOnClickListener {
findNavController().navigate(R.id.watchHistoryFragment)
}
if (token != "") { if (token != "") {
binding.boogh.visibility = View.GONE binding.boogh.visibility = View.GONE
binding.textLike.visibility = View.GONE binding.textLike.visibility = View.GONE

View File

@ -746,7 +746,7 @@ class PlayerFragment : Fragment() {
binding.playerChannel.setOnClickListener { binding.playerChannel.setOnClickListener {
val activity = view.context as MainActivity val activity = view.context as MainActivity
val bundle = bundleOf("channel_id" to response.uploaderUrl) val bundle = bundleOf("channel_id" to response.uploaderUrl)
activity.navController.navigate(R.id.channel, bundle) activity.navController.navigate(R.id.channelFragment, bundle)
activity.binding.mainMotionLayout.transitionToEnd() activity.binding.mainMotionLayout.transitionToEnd()
binding.playerMotionLayout.transitionToEnd() binding.playerMotionLayout.transitionToEnd()
} }

View File

@ -0,0 +1,26 @@
package com.github.libretube.fragments
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.github.libretube.databinding.FragmentWatchHistoryBinding
class WatchHistoryFragment : Fragment() {
private val TAG = "WatchHistoryFragment"
private lateinit var binding: FragmentWatchHistoryBinding
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = FragmentWatchHistoryBinding.inflate(layoutInflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
}

View File

@ -6,6 +6,26 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".fragments.LibraryFragment"> tools:context=".fragments.LibraryFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/showWatchHistory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/watch_history"
android:textSize="20sp"/>
</LinearLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/loginOrRegister2" android:id="@+id/loginOrRegister2"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -64,6 +84,8 @@
</ScrollView> </ScrollView>
</com.github.libretube.util.CustomSwipeToRefresh> </com.github.libretube.util.CustomSwipeToRefresh>
</LinearLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/create_playlist" android:id="@+id/create_playlist"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/watch_history" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/watchHistoryRecView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"/>
</LinearLayout>

View File

@ -2,15 +2,15 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item <item
android:id="@+id/home2" android:id="@+id/homeFragment"
android:icon="@drawable/ic_home" android:icon="@drawable/ic_home"
android:title="@string/startpage" /> android:title="@string/startpage" />
<item <item
android:id="@+id/subscriptions" android:id="@+id/subscriptionsFragment"
android:icon="@drawable/ic_subscriptions" android:icon="@drawable/ic_subscriptions"
android:title="@string/subscriptions" /> android:title="@string/subscriptions" />
<item <item
android:id="@+id/library" android:id="@+id/libraryFragment"
android:icon="@drawable/ic_library" android:icon="@drawable/ic_library"
android:title="@string/library" /> android:title="@string/library" />

View File

@ -3,20 +3,20 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav" android:id="@+id/nav"
app:startDestination="@id/home2"> app:startDestination="@id/homeFragment">
<fragment <fragment
android:id="@+id/home2" android:id="@+id/homeFragment"
android:name="com.github.libretube.fragments.HomeFragment" android:name="com.github.libretube.fragments.HomeFragment"
android:label="fragment_home" android:label="fragment_home"
tools:layout="@layout/fragment_home" /> tools:layout="@layout/fragment_home" />
<fragment <fragment
android:id="@+id/subscriptions" android:id="@+id/subscriptionsFragment"
android:name="com.github.libretube.fragments.SubscriptionsFragment" android:name="com.github.libretube.fragments.SubscriptionsFragment"
android:label="fragment_subscriptions" android:label="fragment_subscriptions"
tools:layout="@layout/fragment_subscriptions" /> tools:layout="@layout/fragment_subscriptions" />
<fragment <fragment
android:id="@+id/library" android:id="@+id/libraryFragment"
android:name="com.github.libretube.fragments.LibraryFragment" android:name="com.github.libretube.fragments.LibraryFragment"
android:label="fragment_library" android:label="fragment_library"
tools:layout="@layout/fragment_library"></fragment> tools:layout="@layout/fragment_library"></fragment>
@ -26,7 +26,7 @@
android:label="fragment_search" android:label="fragment_search"
tools:layout="@layout/fragment_search" /> tools:layout="@layout/fragment_search" />
<fragment <fragment
android:id="@+id/channel" android:id="@+id/channelFragment"
android:name="com.github.libretube.fragments.ChannelFragment" android:name="com.github.libretube.fragments.ChannelFragment"
android:label="channel" android:label="channel"
tools:layout="@layout/fragment_channel"> tools:layout="@layout/fragment_channel">
@ -44,7 +44,8 @@
app:argType="string" /> app:argType="string" />
</fragment> </fragment>
<fragment <fragment
android:id="@+id/settings" android:id="@+id/watchHistoryFragment"
android:name="com.github.libretube.SettingsActivity$SettingsFragment" android:name="com.github.libretube.fragments.WatchHistoryFragment"
android:label="Settings" /> android:label="@string/watch_history"
tools:layout="@layout/fragment_watch_history"/>
</navigation> </navigation>