Merge pull request #2395 from Bnyro/master

Open with button behavior on long pressing `Share`
This commit is contained in:
Bnyro 2022-12-16 14:55:28 +01:00 committed by GitHub
commit a9ab8e0ad6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ package com.github.libretube.ui.fragments
import android.annotation.SuppressLint
import android.app.PictureInPictureParams
import android.content.Context
import android.content.Intent
import android.content.pm.ActivityInfo
import android.content.res.Configuration
import android.media.session.PlaybackState
@ -379,6 +380,27 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
shareDialog.show(childFragmentManager, ShareDialog::class.java.name)
}
binding.relPlayerShare.setOnLongClickListener {
streams.hls ?: return@setOnLongClickListener true
// start an intent with video as mimetype using the hls stream
val uri: Uri = Uri.parse(streams.hls)
val intent = Intent(Intent.ACTION_VIEW).apply {
setDataAndType(uri, "video/*")
putExtra(Intent.EXTRA_TITLE, streams.title)
putExtra("title", streams.title)
putExtra("artist", streams.uploader)
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}
try {
startActivity(intent)
} catch (e: Exception) {
Toast.makeText(context, R.string.no_player_found, Toast.LENGTH_SHORT).show()
}
true
}
binding.relPlayerBackground.setOnClickListener {
// pause the current player
exoPlayer.pause()