mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
cleanup
This commit is contained in:
parent
06688c6faf
commit
cd47970eac
@ -169,13 +169,7 @@
|
|||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.SEND" />
|
<action android:name="android.intent.action.SEND" />
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
<data android:mimeType="application/*" />
|
<data android:mimeType="text/plain" />
|
||||||
<data android:mimeType="audio/*" />
|
|
||||||
<data android:mimeType="image/*" />
|
|
||||||
<data android:mimeType="message/*" />
|
|
||||||
<data android:mimeType="multipart/*" />
|
|
||||||
<data android:mimeType="text/*" />
|
|
||||||
<data android:mimeType="video/*" />
|
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<!-- youtube -->
|
<!-- youtube -->
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.github.libretube
|
package com.github.libretube
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.app.ProgressDialog.show
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.ActivityInfo
|
import android.content.pm.ActivityInfo
|
||||||
@ -33,6 +34,7 @@ import androidx.preference.PreferenceManager
|
|||||||
import com.github.libretube.util.CronetHelper
|
import com.github.libretube.util.CronetHelper
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
import com.google.android.material.color.DynamicColors
|
import com.google.android.material.color.DynamicColors
|
||||||
|
import kotlinx.coroutines.NonDisposableHandle.parent
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
val TAG = "MainActivity"
|
val TAG = "MainActivity"
|
||||||
@ -142,111 +144,108 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
val data: Uri? = intent?.data
|
val intentData: Uri? = intent?.data
|
||||||
Log.d(TAG, "dafaq" + data.toString())
|
if (intentData != null && intentData.host != null && intentData.path != null) {
|
||||||
|
Log.d("intentData", "${intentData.host} ${intentData.path} ")
|
||||||
|
loadIntentData(intentData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (data != null) {
|
private fun loadIntentData(data: Uri) {
|
||||||
Log.d("dafaq", data.host + " ${data.path} ")
|
// channel
|
||||||
if (data.host != null) {
|
if (data.path!!.contains("/channel/") ||
|
||||||
if (data.path != null) {
|
data.path!!.contains("/c/") ||
|
||||||
// channel
|
data.path!!.contains("/user/")
|
||||||
if (data.path!!.contains("/channel/") ||
|
) {
|
||||||
data.path!!.contains("/c/") ||
|
Log.i(TAG, "URI Type: Channel")
|
||||||
data.path!!.contains("/user/")
|
var channel = data.path
|
||||||
) {
|
channel = channel!!.replace("/c/", "")
|
||||||
Log.i(TAG, "URI Type: Channel")
|
channel = channel.replace("/user/", "")
|
||||||
var channel = data.path
|
val bundle = bundleOf("channel_id" to channel)
|
||||||
channel = channel!!.replace("/c/", "")
|
navController.navigate(R.id.channel, bundle)
|
||||||
channel = channel.replace("/user/", "")
|
} else if (data.path!!.contains("/playlist")) {
|
||||||
Log.i(TAG, channel)
|
Log.i(TAG, "URI Type: Playlist")
|
||||||
val bundle = bundleOf("channel_id" to channel)
|
var playlist = data.query!!
|
||||||
navController.navigate(R.id.channel, bundle)
|
if (playlist.contains("&")) {
|
||||||
} else if (data.path!!.contains("/playlist")) {
|
var playlists = playlist.split("&")
|
||||||
Log.i(TAG, "URI Type: Playlist")
|
for (v in playlists) {
|
||||||
var playlist = data.query!!
|
if (v.contains("list=")) {
|
||||||
if (playlist.contains("&")) {
|
playlist = v
|
||||||
var playlists = playlist.split("&")
|
break
|
||||||
for (v in playlists) {
|
|
||||||
if (v.contains("list=")) {
|
|
||||||
playlist = v
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
playlist = playlist.replace("list=", "")
|
|
||||||
val bundle = bundleOf("playlist_id" to playlist)
|
|
||||||
navController.navigate(R.id.playlistFragment, bundle)
|
|
||||||
} else if (data.path!!.contains("/shorts/") ||
|
|
||||||
data.path!!.contains("/embed/") ||
|
|
||||||
data.path!!.contains("/v/")
|
|
||||||
) {
|
|
||||||
Log.i(TAG, "URI Type: Video")
|
|
||||||
val watch = data.path!!
|
|
||||||
.replace("/shorts/", "")
|
|
||||||
.replace("/v/", "")
|
|
||||||
.replace("/embed/", "")
|
|
||||||
val bundle = Bundle()
|
|
||||||
bundle.putString("videoId", watch)
|
|
||||||
val frag = PlayerFragment()
|
|
||||||
frag.arguments = bundle
|
|
||||||
supportFragmentManager.beginTransaction()
|
|
||||||
.remove(PlayerFragment())
|
|
||||||
.commit()
|
|
||||||
supportFragmentManager.beginTransaction()
|
|
||||||
.replace(R.id.container, frag)
|
|
||||||
.commitNow()
|
|
||||||
Handler().postDelayed({
|
|
||||||
val motionLayout = findViewById<MotionLayout>(R.id.playerMotionLayout)
|
|
||||||
motionLayout.transitionToEnd()
|
|
||||||
motionLayout.transitionToStart()
|
|
||||||
}, 100)
|
|
||||||
} else if (data.path!!.contains("/watch") && data.query != null) {
|
|
||||||
Log.d("dafaq", data.query!!)
|
|
||||||
var watch = data.query!!
|
|
||||||
if (watch.contains("&")) {
|
|
||||||
var watches = watch.split("&")
|
|
||||||
for (v in watches) {
|
|
||||||
if (v.contains("v=")) {
|
|
||||||
watch = v
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var bundle = Bundle()
|
|
||||||
bundle.putString("videoId", watch.replace("v=", ""))
|
|
||||||
var frag = PlayerFragment()
|
|
||||||
frag.arguments = bundle
|
|
||||||
supportFragmentManager.beginTransaction()
|
|
||||||
.remove(PlayerFragment())
|
|
||||||
.commit()
|
|
||||||
supportFragmentManager.beginTransaction()
|
|
||||||
.replace(R.id.container, frag)
|
|
||||||
.commitNow()
|
|
||||||
Handler().postDelayed({
|
|
||||||
val motionLayout = findViewById<MotionLayout>(R.id.playerMotionLayout)
|
|
||||||
motionLayout.transitionToEnd()
|
|
||||||
motionLayout.transitionToStart()
|
|
||||||
}, 100)
|
|
||||||
} else {
|
|
||||||
var watch = data.path!!.replace("/", "")
|
|
||||||
var bundle = Bundle()
|
|
||||||
bundle.putString("videoId", watch)
|
|
||||||
var frag = PlayerFragment()
|
|
||||||
frag.arguments = bundle
|
|
||||||
supportFragmentManager.beginTransaction()
|
|
||||||
.remove(PlayerFragment())
|
|
||||||
.commit()
|
|
||||||
supportFragmentManager.beginTransaction()
|
|
||||||
.replace(R.id.container, frag)
|
|
||||||
.commitNow()
|
|
||||||
Handler().postDelayed({
|
|
||||||
val motionLayout = findViewById<MotionLayout>(R.id.playerMotionLayout)
|
|
||||||
motionLayout.transitionToEnd()
|
|
||||||
motionLayout.transitionToStart()
|
|
||||||
}, 100)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
playlist = playlist.replace("list=", "")
|
||||||
|
val bundle = bundleOf("playlist_id" to playlist)
|
||||||
|
navController.navigate(R.id.playlistFragment, bundle)
|
||||||
|
} else if (data.path!!.contains("/shorts/") ||
|
||||||
|
data.path!!.contains("/embed/") ||
|
||||||
|
data.path!!.contains("/v/")
|
||||||
|
) {
|
||||||
|
Log.i(TAG, "URI Type: Video")
|
||||||
|
val watch = data.path!!
|
||||||
|
.replace("/shorts/", "")
|
||||||
|
.replace("/v/", "")
|
||||||
|
.replace("/embed/", "")
|
||||||
|
val bundle = Bundle()
|
||||||
|
bundle.putString("videoId", watch)
|
||||||
|
val frag = PlayerFragment()
|
||||||
|
frag.arguments = bundle
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.remove(PlayerFragment())
|
||||||
|
.commit()
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(R.id.container, frag)
|
||||||
|
.commitNow()
|
||||||
|
Handler().postDelayed({
|
||||||
|
val motionLayout = findViewById<MotionLayout>(R.id.playerMotionLayout)
|
||||||
|
motionLayout.transitionToEnd()
|
||||||
|
motionLayout.transitionToStart()
|
||||||
|
}, 100)
|
||||||
|
} else if (data.path!!.contains("/watch") && data.query != null) {
|
||||||
|
Log.d("dafaq", data.query!!)
|
||||||
|
var watch = data.query!!
|
||||||
|
if (watch.contains("&")) {
|
||||||
|
var watches = watch.split("&")
|
||||||
|
for (v in watches) {
|
||||||
|
if (v.contains("v=")) {
|
||||||
|
watch = v
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var bundle = Bundle()
|
||||||
|
bundle.putString("videoId", watch.replace("v=", ""))
|
||||||
|
var frag = PlayerFragment()
|
||||||
|
frag.arguments = bundle
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.remove(PlayerFragment())
|
||||||
|
.commit()
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(R.id.container, frag)
|
||||||
|
.commitNow()
|
||||||
|
Handler().postDelayed({
|
||||||
|
val motionLayout = findViewById<MotionLayout>(R.id.playerMotionLayout)
|
||||||
|
motionLayout.transitionToEnd()
|
||||||
|
motionLayout.transitionToStart()
|
||||||
|
}, 100)
|
||||||
|
} else {
|
||||||
|
var watch = data.path!!.replace("/", "")
|
||||||
|
var bundle = Bundle()
|
||||||
|
bundle.putString("videoId", watch)
|
||||||
|
var frag = PlayerFragment()
|
||||||
|
frag.arguments = bundle
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.remove(PlayerFragment())
|
||||||
|
.commit()
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(R.id.container, frag)
|
||||||
|
.commitNow()
|
||||||
|
Handler().postDelayed({
|
||||||
|
val motionLayout = findViewById<MotionLayout>(R.id.playerMotionLayout)
|
||||||
|
motionLayout.transitionToEnd()
|
||||||
|
motionLayout.transitionToStart()
|
||||||
|
}, 100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,8 +13,11 @@ class RouterActivity : AppCompatActivity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
when (intent?.action) {
|
when (intent?.action) {
|
||||||
Intent.ACTION_SEND -> {
|
Intent.ACTION_SEND -> {
|
||||||
if ("text/plain" == intent.type) {
|
if (intent.type == "text/plain") {
|
||||||
handleSendText(intent) // Handle text being sent
|
handleSendText(intent)
|
||||||
|
} else {
|
||||||
|
// start app as normal if wrong intent type
|
||||||
|
restartMainActivity(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user