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
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
when (PreferenceHelper.getString(this, "default_tab", "home")) {
"home" -> navController.navigate(R.id.home2)
"subscriptions" -> navController.navigate(R.id.subscriptions)
"library" -> navController.navigate(R.id.library)
"home" -> navController.navigate(R.id.homeFragment)
"subscriptions" -> navController.navigate(R.id.subscriptionsFragment)
"library" -> navController.navigate(R.id.libraryFragment)
}
binding.bottomNav.setOnItemSelectedListener {
when (it.itemId) {
R.id.home2 -> {
R.id.homeFragment -> {
navController.backQueue.clear()
navController.navigate(R.id.home2)
navController.navigate(R.id.homeFragment)
}
R.id.subscriptions -> {
R.id.subscriptionsFragment -> {
// navController.backQueue.clear()
navController.navigate(R.id.subscriptions)
navController.navigate(R.id.subscriptionsFragment)
}
R.id.library -> {
R.id.libraryFragment -> {
// navController.backQueue.clear()
navController.navigate(R.id.library)
navController.navigate(R.id.libraryFragment)
}
}
false
@ -176,7 +176,7 @@ class MainActivity : AppCompatActivity() {
channel = channel!!.replace("/c/", "")
channel = channel.replace("/user/", "")
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")) {
Log.i(TAG, "URI Type: Playlist")
var playlist = data.query!!

View File

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

View File

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

View File

@ -117,7 +117,7 @@ class SearchViewHolder(
channelImage.setOnClickListener {
val activity = v.context as MainActivity
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 {
val activity = v.context as MainActivity
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
}

View File

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

View File

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

View File

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

View File

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

View File

@ -746,7 +746,7 @@ class PlayerFragment : Fragment() {
binding.playerChannel.setOnClickListener {
val activity = view.context as MainActivity
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()
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"
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
android:id="@+id/loginOrRegister2"
android:layout_width="match_parent"
@ -64,6 +84,8 @@
</ScrollView>
</com.github.libretube.util.CustomSwipeToRefresh>
</LinearLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/create_playlist"
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">
<item
android:id="@+id/home2"
android:id="@+id/homeFragment"
android:icon="@drawable/ic_home"
android:title="@string/startpage" />
<item
android:id="@+id/subscriptions"
android:id="@+id/subscriptionsFragment"
android:icon="@drawable/ic_subscriptions"
android:title="@string/subscriptions" />
<item
android:id="@+id/library"
android:id="@+id/libraryFragment"
android:icon="@drawable/ic_library"
android:title="@string/library" />

View File

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