mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
Merge pull request #2089 from Bnyro/pip-button
Replace `Open with` with PiP
This commit is contained in:
commit
558ab149c6
@ -85,7 +85,6 @@ object PreferenceKeys {
|
||||
const val QUEUE_AUTO_INSERT_RELATED = "queue_insert_related_videos"
|
||||
const val PLAYER_SWIPE_CONTROLS = "player_swipe_controls"
|
||||
const val PLAYER_SCREEN_BRIGHTNESS = "player_screen_brightness"
|
||||
const val SHOW_OPEN_WITH = "show_open_with"
|
||||
|
||||
/**
|
||||
* Background mode
|
||||
|
@ -4,7 +4,6 @@ import android.annotation.SuppressLint
|
||||
import android.app.ActivityManager
|
||||
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
|
||||
@ -153,11 +152,6 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
private lateinit var exoPlayerView: StyledPlayerView
|
||||
private var subtitles = mutableListOf<SubtitleConfiguration>()
|
||||
|
||||
/**
|
||||
* user preferences
|
||||
*/
|
||||
private var videoShownInExternalPlayer = false
|
||||
|
||||
/**
|
||||
* for the player notification
|
||||
*/
|
||||
@ -283,6 +277,11 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
}
|
||||
|
||||
if (usePiP()) (activity as MainActivity).setPictureInPictureParams(getPipParams())
|
||||
|
||||
if (SDK_INT < Build.VERSION_CODES.O) {
|
||||
binding.relPlayerPip.visibility = View.GONE
|
||||
binding.optionsLL.weightSum = 4f
|
||||
}
|
||||
}
|
||||
|
||||
// actions that don't depend on video information
|
||||
@ -388,11 +387,6 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
LinearLayoutManager.HORIZONTAL,
|
||||
false
|
||||
)
|
||||
|
||||
if (!PreferenceHelper.getBoolean(PreferenceKeys.SHOW_OPEN_WITH, false)) {
|
||||
binding.relPlayerOpen.visibility = View.GONE
|
||||
binding.optionsLL.weightSum = 4f
|
||||
}
|
||||
}
|
||||
|
||||
private fun setFullscreen() {
|
||||
@ -459,13 +453,6 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
|
||||
// Assuming the video is not playing in external player when returning to app
|
||||
videoShownInExternalPlayer = false
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
// pauses the player if the screen is turned off
|
||||
|
||||
@ -889,25 +876,12 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
}
|
||||
|
||||
if (response.hls != null) {
|
||||
binding.relPlayerOpen.setOnClickListener {
|
||||
// Do not start picture in picture when playing in external player
|
||||
videoShownInExternalPlayer = true
|
||||
|
||||
// start an intent with video as mimetype using the hls stream
|
||||
val uri: Uri = Uri.parse(response.hls)
|
||||
val intent = Intent()
|
||||
|
||||
intent.action = Intent.ACTION_VIEW
|
||||
intent.setDataAndType(uri, "video/*")
|
||||
intent.putExtra(Intent.EXTRA_TITLE, streams.title)
|
||||
intent.putExtra("title", streams.title)
|
||||
intent.putExtra("artist", streams.uploader)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
|
||||
binding.relPlayerPip.setOnClickListener {
|
||||
if (SDK_INT < Build.VERSION_CODES.O) return@setOnClickListener
|
||||
try {
|
||||
startActivity(intent)
|
||||
activity?.enterPictureInPictureMode(getPipParams())
|
||||
} catch (e: Exception) {
|
||||
Toast.makeText(context, R.string.no_player_found, Toast.LENGTH_SHORT).show()
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1388,8 +1362,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
|
||||
private fun shouldStartPiP(): Boolean {
|
||||
if (!PlayerHelper.pipEnabled ||
|
||||
exoPlayer.playbackState == PlaybackState.STATE_PAUSED ||
|
||||
videoShownInExternalPlayer
|
||||
exoPlayer.playbackState == PlaybackState.STATE_PAUSED
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
@ -184,7 +184,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/relPlayer_open"
|
||||
android:id="@+id/relPlayer_pip"
|
||||
style="@style/PlayerActionsLayout"
|
||||
android:layout_weight="1">
|
||||
|
||||
@ -198,7 +198,7 @@
|
||||
style="@style/PlayerActionsText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/open" />
|
||||
android:text="@string/pop_up" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
@ -400,7 +400,5 @@
|
||||
<string name="swipe_controls_summary">Parlaqlığı və səs səviyyəsini nizamlamaq üçün sürüşdürmə jesti istifadə et.</string>
|
||||
<string name="volume">Səs səviyyəsi</string>
|
||||
<string name="swipe_controls">Sürüşdürmə nəzarətləri</string>
|
||||
<string name="show_open_with">İlə aç</string>
|
||||
<string name="defaults">Defolt</string>
|
||||
<string name="show_open_with_summary">Videonu oynadıcıda 3-cü tərəf tətbiq ilə açmaq üçün düymə göstər.</string>
|
||||
</resources>
|
@ -401,6 +401,4 @@
|
||||
<string name="brightness">Brillo</string>
|
||||
<string name="swipe_controls_summary">Use el gesto de deslizar para ajustar el brillo y el volumen.</string>
|
||||
<string name="defaults">Por defecto</string>
|
||||
<string name="show_open_with">Abrir con</string>
|
||||
<string name="show_open_with_summary">Mostrar un botón para abrir el vídeo con una aplicación de terceros en el reproductor.</string>
|
||||
</resources>
|
@ -314,7 +314,6 @@
|
||||
<string name="require_restart_message">नए परिवर्तनों का उपयोग करने के लिए ऐप को पुनरारंभ करें।</string>
|
||||
<string name="no_player_found">कोई बाहरी प्लेयर नहीं मिला। कृपया सुनिश्चित करें कि आपके पास एक इन्स्टाल है।</string>
|
||||
<string name="defaults">डिफ़ॉल्टस</string>
|
||||
<string name="show_open_with">के साथ खोलें</string>
|
||||
<string name="least_recent">सबसे पुराने</string>
|
||||
<string name="playerVideoFormat">प्लेयर के लिए विडिओ फॉर्मेट</string>
|
||||
<string name="no_video">विडियो नहीं</string>
|
||||
@ -402,5 +401,4 @@
|
||||
<string name="playerAudioQuality">ऑडियो गुणवत्ता</string>
|
||||
<string name="best_quality">श्रेष्ठ</string>
|
||||
<string name="worst_quality">न्यूनतम</string>
|
||||
<string name="show_open_with_summary">वीडियो को तीसरे पक्ष के ऐप्लिकेशन के साथ प्लेयर पर खोलने के लिए बटन दिखाएं।</string>
|
||||
</resources>
|
@ -399,8 +399,6 @@
|
||||
<string name="auto">Otomatis</string>
|
||||
<string name="swipe_controls">Kendali usap</string>
|
||||
<string name="swipe_controls_summary">Gunakan gestur usap untuk mengatur kecerahan dan volume.</string>
|
||||
<string name="show_open_with">Buka Dengan</string>
|
||||
<string name="defaults">Bawaan</string>
|
||||
<string name="show_open_with_summary">Tampilkan tombol dalam pemain untuk membuka video dengan aplikasi pihak ketiga.</string>
|
||||
<string name="brightness">Kecerahan</string>
|
||||
</resources>
|
@ -401,6 +401,4 @@
|
||||
<string name="volume">Garsas</string>
|
||||
<string name="swipe_controls_summary">Braukimo gestu sureguliuokite ryškumą ir garsumą.</string>
|
||||
<string name="defaults">Numatyti</string>
|
||||
<string name="show_open_with">Atidaryti naudojant</string>
|
||||
<string name="show_open_with_summary">Rodyti mygtuką grotuve, kad galima būtų atidaryti vaizdo įrašą naudojant trečiosios šalies programėlę.</string>
|
||||
</resources>
|
@ -397,10 +397,8 @@
|
||||
<string name="select_other_start_tab">Velg en annen startfane først.</string>
|
||||
<string name="swipe_controls">Dragningskontroller</string>
|
||||
<string name="swipe_controls_summary">Bruk dragnings-håndvendinger for å justere lys- og lydstyrke.</string>
|
||||
<string name="show_open_with">Åpne med</string>
|
||||
<string name="defaults">Forvalg</string>
|
||||
<string name="brightness">Lysstyrke</string>
|
||||
<string name="volume">Lydstyrke</string>
|
||||
<string name="auto">Auto</string>
|
||||
<string name="show_open_with_summary">Vis en knapp i avspilleren for å åpne video med tredjepartsprogram.</string>
|
||||
</resources>
|
@ -401,6 +401,4 @@
|
||||
<string name="swipe_controls">Sterowanie gestami</string>
|
||||
<string name="swipe_controls_summary">Steruj jasnością i głośnością za pomocą gestów.</string>
|
||||
<string name="defaults">Domyślne</string>
|
||||
<string name="show_open_with">Przycisk „Otwórz w…”</string>
|
||||
<string name="show_open_with_summary">Pozwala pzekierować odtwarzanie do zewnętrznej aplikacji.</string>
|
||||
</resources>
|
@ -401,6 +401,4 @@
|
||||
<string name="swipe_controls_summary">Для регулювання яскравості та гучності використовувати жест посування.</string>
|
||||
<string name="volume">Гучність</string>
|
||||
<string name="defaults">Типові</string>
|
||||
<string name="show_open_with">Відкрити в</string>
|
||||
<string name="show_open_with_summary">Показувати на програвачі кнопку для відкриття відео за допомогою стороннього застосунку.</string>
|
||||
</resources>
|
@ -396,11 +396,9 @@
|
||||
<string name="brightness">Độ sáng</string>
|
||||
<string name="volume">Âm lượng</string>
|
||||
<string name="auto">Tự động</string>
|
||||
<string name="show_open_with">Mở với</string>
|
||||
<string name="defaults">Mặc định</string>
|
||||
<string name="select_other_start_tab">Vui lòng chọn một tab bắt đầu khác trước tiên!</string>
|
||||
<string name="swipe_controls">Điều khiển vuốt</string>
|
||||
<string name="swipe_controls_summary">Sử dụng thao tác vuốt để điều chỉnh độ sáng và âm lượng.</string>
|
||||
<string name="show_open_with_summary">Hiển thị một nút trong trình phát để mở video bằng ứng dụng của bên thứ ba.</string>
|
||||
<string name="bookmark">Đánh dấu trang</string>
|
||||
</resources>
|
@ -395,8 +395,8 @@
|
||||
<string name="swipe_controls">Swipe controls</string>
|
||||
<string name="swipe_controls_summary">Use swipe gesture to adjust the brightness and volume.</string>
|
||||
<string name="defaults">Defaults</string>
|
||||
<string name="show_open_with">Open With</string>
|
||||
<string name="show_open_with_summary">Show a button in the player to open the video with a third-party app.</string>
|
||||
<string name="pop_up">Pop-Up</string>
|
||||
|
||||
<!-- Notification channel strings -->
|
||||
<string name="download_channel_name">Download Service</string>
|
||||
<string name="download_channel_description">Shows a notification when downloading media.</string>
|
||||
|
@ -134,13 +134,6 @@
|
||||
app:key="pause_screen_off"
|
||||
app:title="@string/pauseOnScreenOff" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:icon="@drawable/ic_open"
|
||||
android:summary="@string/show_open_with_summary"
|
||||
app:defaultValue="false"
|
||||
app:key="show_open_with"
|
||||
app:title="@string/show_open_with" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user