mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
Merge branch 'master' into master
This commit is contained in:
commit
dab72f5720
@ -72,7 +72,6 @@ dependencies {
|
|||||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||||
implementation 'com.squareup.retrofit2:converter-jackson:2.9.0'
|
implementation 'com.squareup.retrofit2:converter-jackson:2.9.0'
|
||||||
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.13.2'
|
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.13.2'
|
||||||
implementation 'com.squareup.retrofit2:converter-scalars:2.1.0'
|
|
||||||
|
|
||||||
implementation 'com.arthenica:ffmpeg-kit-min:4.5.1.LTS'
|
implementation 'com.arthenica:ffmpeg-kit-min:4.5.1.LTS'
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import androidx.core.net.toUri
|
|||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import androidx.preference.PreferenceManager
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.github.libretube.adapters.TrendingAdapter
|
import com.github.libretube.adapters.TrendingAdapter
|
||||||
@ -49,6 +50,7 @@ import com.google.android.material.button.MaterialButton
|
|||||||
import com.squareup.picasso.Picasso
|
import com.squareup.picasso.Picasso
|
||||||
import retrofit2.HttpException
|
import retrofit2.HttpException
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
import java.net.URLEncoder
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
|
||||||
|
|
||||||
@ -250,10 +252,7 @@ class PlayerFragment : Fragment() {
|
|||||||
.setMimeType(response.subtitles!![0].mimeType!!) // The correct MIME type (required).
|
.setMimeType(response.subtitles!![0].mimeType!!) // The correct MIME type (required).
|
||||||
.setLanguage(response.subtitles!![0].code) // The subtitle language (optional).
|
.setLanguage(response.subtitles!![0].code) // The subtitle language (optional).
|
||||||
.build())}
|
.build())}
|
||||||
val mediaItem: MediaItem = MediaItem.Builder()
|
|
||||||
.setUri(response.hls)
|
|
||||||
.setSubtitleConfigurations(subtitle)
|
|
||||||
.build()
|
|
||||||
exoPlayer = ExoPlayer.Builder(view.context)
|
exoPlayer = ExoPlayer.Builder(view.context)
|
||||||
.setSeekBackIncrementMs(5000)
|
.setSeekBackIncrementMs(5000)
|
||||||
.setSeekForwardIncrementMs(5000)
|
.setSeekForwardIncrementMs(5000)
|
||||||
@ -264,7 +263,31 @@ class PlayerFragment : Fragment() {
|
|||||||
//exoPlayerView.controllerShowTimeoutMs = 1500
|
//exoPlayerView.controllerShowTimeoutMs = 1500
|
||||||
exoPlayerView.controllerHideOnTouch = true
|
exoPlayerView.controllerHideOnTouch = true
|
||||||
exoPlayerView.player = exoPlayer
|
exoPlayerView.player = exoPlayer
|
||||||
exoPlayer.setMediaItem(mediaItem)
|
if (response.hls != null) {
|
||||||
|
val mediaItem: MediaItem = MediaItem.Builder()
|
||||||
|
.setUri(response.hls)
|
||||||
|
.setSubtitleConfigurations(subtitle)
|
||||||
|
.build()
|
||||||
|
exoPlayer.setMediaItem(mediaItem)
|
||||||
|
}else{
|
||||||
|
val dataSourceFactory: DataSource.Factory =
|
||||||
|
DefaultHttpDataSource.Factory()
|
||||||
|
val videoItem: MediaItem = MediaItem.Builder()
|
||||||
|
.setUri(response.videoStreams[0].url)
|
||||||
|
.setSubtitleConfigurations(subtitle)
|
||||||
|
.build()
|
||||||
|
val videoSource: MediaSource = DefaultMediaSourceFactory(dataSourceFactory)
|
||||||
|
.createMediaSource(videoItem)
|
||||||
|
var audioSource: MediaSource = DefaultMediaSourceFactory(dataSourceFactory)
|
||||||
|
.createMediaSource(fromUri(response.audioStreams!![0].url!!))
|
||||||
|
if (response.videoStreams[0].quality=="720p" || response.videoStreams[0].quality=="1080p" || response.videoStreams[0].quality=="480p" ){
|
||||||
|
audioSource = ProgressiveMediaSource.Factory(dataSourceFactory)
|
||||||
|
.createMediaSource(fromUri(response.audioStreams!![getMostBitRate(response.audioStreams)].url!!))
|
||||||
|
}
|
||||||
|
val mergeSource: MediaSource = MergingMediaSource(videoSource,audioSource)
|
||||||
|
exoPlayer.setMediaSource(mergeSource)
|
||||||
|
}
|
||||||
|
|
||||||
///exoPlayer.getMediaItemAt(5)
|
///exoPlayer.getMediaItemAt(5)
|
||||||
exoPlayer.prepare()
|
exoPlayer.prepare()
|
||||||
exoPlayer.play()
|
exoPlayer.play()
|
||||||
@ -367,9 +390,14 @@ class PlayerFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
//share button
|
//share button
|
||||||
view.findViewById<RelativeLayout>(R.id.relPlayer_share).setOnClickListener {
|
view.findViewById<RelativeLayout>(R.id.relPlayer_share).setOnClickListener {
|
||||||
|
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||||
val intent= Intent()
|
val intent= Intent()
|
||||||
intent.action=Intent.ACTION_SEND
|
intent.action=Intent.ACTION_SEND
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, "https://piped.tokhmi.xyz/$videoId")
|
var url = "https://piped.kavin.rocks/watch?v=$videoId"
|
||||||
|
val instance = sharedPreferences.getString("instance", "https://pipedapi.kavin.rocks")!!
|
||||||
|
if (instance != "https://pipedapi.kavin.rocks")
|
||||||
|
url += "&instance=${URLEncoder.encode(instance, "UTF-8")}"
|
||||||
|
intent.putExtra(Intent.EXTRA_TEXT, url)
|
||||||
intent.type="text/plain"
|
intent.type="text/plain"
|
||||||
startActivity(Intent.createChooser(intent,"Share Url To:"))
|
startActivity(Intent.createChooser(intent,"Share Url To:"))
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import com.blankj.utilcode.util.UriUtils
|
|||||||
import com.github.libretube.obj.Subscribe
|
import com.github.libretube.obj.Subscribe
|
||||||
import retrofit2.HttpException
|
import retrofit2.HttpException
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
|
import retrofit2.HttpException
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.util.zip.ZipFile
|
import java.util.zip.ZipFile
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import androidx.preference.PreferenceManager
|
|||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
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 com.github.libretube.adapters.TrendingAdapter
|
import com.github.libretube.adapters.TrendingAdapter
|
||||||
@ -25,6 +26,7 @@ class Subscriptions : Fragment() {
|
|||||||
lateinit var token: String
|
lateinit var token: String
|
||||||
var isLoaded = false
|
var isLoaded = false
|
||||||
private var subscriptionAdapter: SubscriptionAdapter? =null
|
private var subscriptionAdapter: SubscriptionAdapter? =null
|
||||||
|
private var refreshLayout: SwipeRefreshLayout? = null
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
arguments?.let {
|
arguments?.let {
|
||||||
@ -44,8 +46,11 @@ class Subscriptions : Fragment() {
|
|||||||
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||||
token = sharedPref?.getString("token","")!!
|
token = sharedPref?.getString("token","")!!
|
||||||
Log.e(TAG,token)
|
Log.e(TAG,token)
|
||||||
|
refreshLayout = view.findViewById(R.id.sub_refresh)
|
||||||
if(token!=""){
|
if(token!=""){
|
||||||
view.findViewById<RelativeLayout>(R.id.loginOrRegister).visibility=View.GONE
|
view.findViewById<RelativeLayout>(R.id.loginOrRegister).visibility=View.GONE
|
||||||
|
refreshLayout?.isEnabled = true
|
||||||
|
|
||||||
var progressBar = view.findViewById<ProgressBar>(R.id.sub_progress)
|
var progressBar = view.findViewById<ProgressBar>(R.id.sub_progress)
|
||||||
progressBar.visibility=View.VISIBLE
|
progressBar.visibility=View.VISIBLE
|
||||||
|
|
||||||
@ -57,6 +62,11 @@ class Subscriptions : Fragment() {
|
|||||||
feedRecView.layoutManager = GridLayoutManager(view.context, resources.getInteger(R.integer.grid_items))
|
feedRecView.layoutManager = GridLayoutManager(view.context, resources.getInteger(R.integer.grid_items))
|
||||||
fetchFeed(feedRecView, progressBar)
|
fetchFeed(feedRecView, progressBar)
|
||||||
|
|
||||||
|
refreshLayout?.setOnRefreshListener {
|
||||||
|
fetchChannels(channelRecView)
|
||||||
|
fetchFeed(feedRecView, progressBar)
|
||||||
|
}
|
||||||
|
|
||||||
val scrollView = view.findViewById<ScrollView>(R.id.scrollview_sub)
|
val scrollView = view.findViewById<ScrollView>(R.id.scrollview_sub)
|
||||||
scrollView.viewTreeObserver
|
scrollView.viewTreeObserver
|
||||||
.addOnScrollChangedListener {
|
.addOnScrollChangedListener {
|
||||||
@ -64,11 +74,15 @@ class Subscriptions : Fragment() {
|
|||||||
== (scrollView.height + scrollView.scrollY)) {
|
== (scrollView.height + scrollView.scrollY)) {
|
||||||
//scroll view is at bottom
|
//scroll view is at bottom
|
||||||
if(isLoaded){
|
if(isLoaded){
|
||||||
|
refreshLayout?.isRefreshing = true
|
||||||
subscriptionAdapter?.updateItems()
|
subscriptionAdapter?.updateItems()
|
||||||
|
refreshLayout?.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
refreshLayout?.isEnabled = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +98,8 @@ class Subscriptions : Fragment() {
|
|||||||
} catch (e: HttpException) {
|
} catch (e: HttpException) {
|
||||||
Log.e(TAG, "HttpException, unexpected response")
|
Log.e(TAG, "HttpException, unexpected response")
|
||||||
return@launchWhenCreated
|
return@launchWhenCreated
|
||||||
|
} finally {
|
||||||
|
refreshLayout?.isRefreshing = false
|
||||||
}
|
}
|
||||||
if (response.isNotEmpty()){
|
if (response.isNotEmpty()){
|
||||||
subscriptionAdapter = SubscriptionAdapter(response)
|
subscriptionAdapter = SubscriptionAdapter(response)
|
||||||
@ -109,6 +125,8 @@ class Subscriptions : Fragment() {
|
|||||||
} catch (e: HttpException) {
|
} catch (e: HttpException) {
|
||||||
Log.e(TAG, "HttpException, unexpected response")
|
Log.e(TAG, "HttpException, unexpected response")
|
||||||
return@launchWhenCreated
|
return@launchWhenCreated
|
||||||
|
} finally {
|
||||||
|
refreshLayout?.isRefreshing = false
|
||||||
}
|
}
|
||||||
if (response.isNotEmpty()){
|
if (response.isNotEmpty()){
|
||||||
channelRecView?.adapter=SubscriptionChannelAdapter(response.toMutableList())
|
channelRecView?.adapter=SubscriptionChannelAdapter(response.toMutableList())
|
||||||
|
@ -4,22 +4,21 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".Subscriptions">
|
tools:context=".Subscriptions">
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/sub_progress"
|
android:id="@+id/sub_progress"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:visibility="gone"
|
android:layout_centerVertical="true"
|
||||||
/>
|
android:visibility="gone" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/loginOrRegister"
|
android:id="@+id/loginOrRegister"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
>
|
android:layout_centerVertical="true">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/boogh"
|
android:id="@+id/boogh"
|
||||||
@ -40,36 +39,46 @@
|
|||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
<ScrollView
|
|
||||||
android:id="@+id/scrollview_sub"
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
|
android:id="@+id/sub_refresh"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
<LinearLayout
|
|
||||||
|
<ScrollView
|
||||||
|
android:id="@+id/scrollview_sub"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:orientation="vertical">
|
|
||||||
<RelativeLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:descendantFocusability="blocksDescendants">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<RelativeLayout
|
||||||
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"
|
||||||
android:nestedScrollingEnabled="false" />
|
android:descendantFocusability="blocksDescendants">
|
||||||
</RelativeLayout>
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:descendantFocusability="blocksDescendants">
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/sub_feed"
|
android:id="@+id/sub_channels"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:nestedScrollingEnabled="false" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:nestedScrollingEnabled="false" />
|
android:descendantFocusability="blocksDescendants">
|
||||||
</RelativeLayout>
|
|
||||||
</LinearLayout>
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
</ScrollView>
|
android:id="@+id/sub_feed"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:nestedScrollingEnabled="false" />
|
||||||
|
</RelativeLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
Loading…
x
Reference in New Issue
Block a user