Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support sharing live links to LibreTube #3435

Merged
merged 2 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@
<data android:pathPrefix="/embed/" />
<data android:pathPrefix="/watch" />
<data android:pathPrefix="/shorts/" />
<data android:pathPrefix="/live/" />
<!-- channel prefix -->
<data android:pathPrefix="/channel/" />
<data android:pathPrefix="/user/" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class RouterActivity : BaseActivity() {
// start processing the given text
handleSendText(Uri.parse(intent.getStringExtra(Intent.EXTRA_TEXT)!!))
} else if (intent.data != null) {
val uri = intent.data
handleSendText(uri!!)
// link shared as text to the app
handleSendText(intent.data!!)
} else {
// start app as normal if unknown action, shouldn't be reachable
NavigationHelper.restartMainActivity(this)
Expand All @@ -30,17 +30,21 @@ class RouterActivity : BaseActivity() {
* Resolve the uri and return a bundle with the arguments
*/
private fun resolveType(intent: Intent, uri: Uri): Intent {
val channelNamePaths = listOf("/c/", "/user/")
val videoPaths = listOf("/shorts/", "/embed/", "/v/", "/live/")
when {
uri.path!!.contains("/channel/") -> {
val channelId = uri.path!!
.replace("/channel/", "")

intent.putExtra(IntentData.channelId, channelId)
}
uri.path!!.contains("/c/") || uri.path!!.contains("/user/") -> {
val channelName = uri.path!!
.replace("/c/", "")
.replace("/user/", "")
channelNamePaths.any { uri.path!!.contains(it) } -> {
var channelName = uri.path!!

channelNamePaths.forEach {
channelName = channelName.replace(it, "")
}

intent.putExtra(IntentData.channelName, channelName)
}
Expand All @@ -49,16 +53,17 @@ class RouterActivity : BaseActivity() {

intent.putExtra(IntentData.playlistId, playlistId)
}
uri.path!!.contains("/shorts/") ||
uri.path!!.contains("/embed/") ||
uri.path!!.contains("/v/")
-> {
val videoId = uri.path!!
.replace("/shorts/", "")
.replace("/v/", "")
.replace("/embed/", "")
videoPaths.any { uri.path!!.contains(it) } -> {
var videoId = uri.path!!

videoPaths.forEach {
videoId = videoId.replace(it, "")
}

intent.putExtra(IntentData.videoId, videoId)

uri.getQueryParameter("t")
?.let { intent.putExtra(IntentData.timeStamp, it.toTimeInSeconds()) }
}
uri.path!!.contains("/watch") && uri.query != null -> {
val videoId = uri.getQueryParameter("v")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {

if (PlayerHelper.swipeGestureEnabled) {
binding.playerMotionLayout.addSwipeUpListener {
if(this::streams.isInitialized) {
if (this::streams.isInitialized) {
binding.player.hideController()
setFullscreen()
}
Expand Down