mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
open youtube links in app
This commit is contained in:
parent
f8193d251c
commit
f3d3ebc5ae
@ -7,6 +7,7 @@ import android.net.Uri
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Handler
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
@ -96,6 +97,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
val action: String? = intent?.action
|
val action: String? = intent?.action
|
||||||
val data: Uri? = intent?.data
|
val data: Uri? = intent?.data
|
||||||
Log.d(TAG, "dafaq"+data.toString())
|
Log.d(TAG, "dafaq"+data.toString())
|
||||||
@ -103,7 +109,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
if (data != null) {
|
if (data != null) {
|
||||||
Log.d("dafaq",data.host+" ${data.path} ")
|
Log.d("dafaq",data.host+" ${data.path} ")
|
||||||
if(data.host != null){
|
if(data.host != null){
|
||||||
if(data.host!!.contains("youtube.com",true)){
|
|
||||||
if(data.path != null){
|
if(data.path != null){
|
||||||
//channel
|
//channel
|
||||||
if(data.path!!.contains("/channel/") || data.path!!.contains("/c/") || data.path!!.contains("/user/")){
|
if(data.path!!.contains("/channel/") || data.path!!.contains("/c/") || data.path!!.contains("/user/")){
|
||||||
@ -113,8 +118,18 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val bundle = bundleOf("channel_id" to channel)
|
val bundle = bundleOf("channel_id" to channel)
|
||||||
navController.navigate(R.id.channel,bundle)
|
navController.navigate(R.id.channel,bundle)
|
||||||
}else if(data.path!!.contains("/playlist")){
|
}else if(data.path!!.contains("/playlist")){
|
||||||
var playlist = data.query
|
var playlist = data.query!!
|
||||||
playlist = playlist!!.replace("list=","")
|
if (playlist.contains("&"))
|
||||||
|
{
|
||||||
|
var playlists = playlist.split("&")
|
||||||
|
for (v in playlists){
|
||||||
|
if (v.contains("list=")){
|
||||||
|
playlist = v
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
playlist = playlist.replace("list=","")
|
||||||
val bundle = bundleOf("playlist_id" to playlist)
|
val bundle = bundleOf("playlist_id" to playlist)
|
||||||
navController.navigate(R.id.playlistFragment,bundle)
|
navController.navigate(R.id.playlistFragment,bundle)
|
||||||
}else if(data.path!!.contains("/shorts/") || data.path!!.contains("/embed/") || data.path!!.contains("/v/")){
|
}else if(data.path!!.contains("/shorts/") || data.path!!.contains("/embed/") || data.path!!.contains("/v/")){
|
||||||
@ -129,36 +144,45 @@ class MainActivity : AppCompatActivity() {
|
|||||||
supportFragmentManager.beginTransaction()
|
supportFragmentManager.beginTransaction()
|
||||||
.replace(R.id.container, frag)
|
.replace(R.id.container, frag)
|
||||||
.commitNow()
|
.commitNow()
|
||||||
|
Handler().postDelayed({
|
||||||
|
val motionLayout = findViewById<MotionLayout>(R.id.playerMotionLayout)
|
||||||
|
motionLayout.transitionToEnd()
|
||||||
|
motionLayout.transitionToStart()
|
||||||
|
}, 100)
|
||||||
}else if(data.path!!.contains("/watch") && data.query != null){
|
}else if(data.path!!.contains("/watch") && data.query != null){
|
||||||
Log.d("dafaq",data.query!!)
|
Log.d("dafaq",data.query!!)
|
||||||
var watch = data.query!!
|
var watch = data.query!!
|
||||||
var watches = watch.split("&")
|
if (watch.contains("&"))
|
||||||
if (watches.size >1){
|
{
|
||||||
|
var watches = watch.split("&")
|
||||||
for (v in watches){
|
for (v in watches){
|
||||||
if (v.contains("v=")){
|
if (v.contains("v=")){
|
||||||
var bundle = Bundle()
|
watch = v
|
||||||
bundle.putString("videoId",v.replace("v=",""))
|
|
||||||
var frag = PlayerFragment()
|
|
||||||
frag.arguments = bundle
|
|
||||||
supportFragmentManager.beginTransaction()
|
|
||||||
.remove(PlayerFragment())
|
|
||||||
.commit()
|
|
||||||
supportFragmentManager.beginTransaction()
|
|
||||||
.replace(R.id.container, frag)
|
|
||||||
.commitNow()
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var bundle = Bundle()
|
||||||
|
bundle.putString("videoId",watch.replace("v=",""))
|
||||||
|
var frag = PlayerFragment()
|
||||||
|
frag.arguments = bundle
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(R.id.container, frag)
|
||||||
|
.commitNow()
|
||||||
|
Handler().postDelayed({
|
||||||
|
val motionLayout = findViewById<MotionLayout>(R.id.playerMotionLayout)
|
||||||
|
motionLayout.transitionToEnd()
|
||||||
|
motionLayout.transitionToStart()
|
||||||
|
}, 100)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
try{
|
try{
|
||||||
val mainMotionLayout = findViewById<MotionLayout>(R.id.mainMotionLayout)
|
val mainMotionLayout = findViewById<MotionLayout>(R.id.mainMotionLayout)
|
||||||
|
Loading…
Reference in New Issue
Block a user