mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 08:20:32 +05:30
Stats for nerds
This commit is contained in:
parent
4b4b025b42
commit
5fa4233561
@ -0,0 +1,42 @@
|
|||||||
|
package com.github.libretube.ui.dialogs
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.app.Dialog
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.fragment.app.DialogFragment
|
||||||
|
import com.github.libretube.R
|
||||||
|
import com.github.libretube.databinding.DialogStatsBinding
|
||||||
|
import com.github.libretube.util.TextUtils
|
||||||
|
import com.google.android.exoplayer2.ExoPlayer
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
|
||||||
|
class StatsDialog(
|
||||||
|
private val player: ExoPlayer,
|
||||||
|
private val videoId: String
|
||||||
|
) : DialogFragment() {
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
|
val binding = DialogStatsBinding.inflate(layoutInflater)
|
||||||
|
binding.videoId.setText(videoId)
|
||||||
|
binding.videoInfo.setText(
|
||||||
|
"${player.videoFormat?.codecs.orEmpty()} ${TextUtils.formatBitrate(
|
||||||
|
player.videoFormat?.bitrate
|
||||||
|
)}"
|
||||||
|
)
|
||||||
|
binding.audioInfo.setText(
|
||||||
|
"${player.audioFormat?.codecs.orEmpty()} ${TextUtils.formatBitrate(
|
||||||
|
player.audioFormat?.bitrate
|
||||||
|
)}"
|
||||||
|
)
|
||||||
|
binding.videoQuality.setText(
|
||||||
|
"${player.videoFormat?.width}x${player.videoFormat?.height} ${player.videoFormat?.frameRate?.toInt()}fps"
|
||||||
|
)
|
||||||
|
|
||||||
|
return MaterialAlertDialogBuilder(requireContext())
|
||||||
|
.setTitle(R.string.stats_for_nerds)
|
||||||
|
.setView(binding.root)
|
||||||
|
.setPositiveButton(R.string.okay, null)
|
||||||
|
.create()
|
||||||
|
}
|
||||||
|
}
|
@ -78,6 +78,7 @@ import com.github.libretube.ui.adapters.VideosAdapter
|
|||||||
import com.github.libretube.ui.dialogs.AddToPlaylistDialog
|
import com.github.libretube.ui.dialogs.AddToPlaylistDialog
|
||||||
import com.github.libretube.ui.dialogs.DownloadDialog
|
import com.github.libretube.ui.dialogs.DownloadDialog
|
||||||
import com.github.libretube.ui.dialogs.ShareDialog
|
import com.github.libretube.ui.dialogs.ShareDialog
|
||||||
|
import com.github.libretube.ui.dialogs.StatsDialog
|
||||||
import com.github.libretube.ui.extensions.setAspectRatio
|
import com.github.libretube.ui.extensions.setAspectRatio
|
||||||
import com.github.libretube.ui.extensions.setupSubscriptionButton
|
import com.github.libretube.ui.extensions.setupSubscriptionButton
|
||||||
import com.github.libretube.ui.interfaces.OnlinePlayerOptions
|
import com.github.libretube.ui.interfaces.OnlinePlayerOptions
|
||||||
@ -1379,6 +1380,12 @@ class PlayerFragment : Fragment(R.layout.fragment_player), OnlinePlayerOptions {
|
|||||||
.show(childFragmentManager)
|
.show(childFragmentManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onStatsClicked() {
|
||||||
|
if (!this::streams.isInitialized) return
|
||||||
|
StatsDialog(exoPlayer, videoId ?: return)
|
||||||
|
.show(childFragmentManager, null)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) {
|
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) {
|
||||||
super.onPictureInPictureModeChanged(isInPictureInPictureMode)
|
super.onPictureInPictureModeChanged(isInPictureInPictureMode)
|
||||||
if (isInPictureInPictureMode) {
|
if (isInPictureInPictureMode) {
|
||||||
|
@ -6,4 +6,6 @@ interface OnlinePlayerOptions {
|
|||||||
fun onQualityClicked()
|
fun onQualityClicked()
|
||||||
|
|
||||||
fun onAudioStreamClicked()
|
fun onAudioStreamClicked()
|
||||||
|
|
||||||
|
fun onStatsClicked()
|
||||||
}
|
}
|
||||||
|
@ -348,6 +348,12 @@ internal class CustomExoPlayerView(
|
|||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
it.onCaptionsClicked()
|
it.onCaptionsClicked()
|
||||||
|
},
|
||||||
|
BottomSheetItem(
|
||||||
|
context.getString(R.string.stats_for_nerds),
|
||||||
|
R.drawable.ic_info
|
||||||
|
) {
|
||||||
|
it.onStatsClicked()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -77,4 +77,9 @@ object TextUtils {
|
|||||||
DateUtils.getRelativeTimeSpanString(unixTime)
|
DateUtils.getRelativeTimeSpanString(unixTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun formatBitrate(bitrate: Int?): String {
|
||||||
|
bitrate ?: return ""
|
||||||
|
return "${bitrate / 1024}kbps"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
android:width="24dp"
|
android:width="24dp"
|
||||||
android:height="24dp"
|
android:height="24dp"
|
||||||
android:tint="?attr/colorControlNormal"
|
android:tint="?attr/colorControlNormal"
|
||||||
android:viewportWidth="48"
|
android:viewportWidth="24"
|
||||||
android:viewportHeight="48">
|
android:viewportHeight="24">
|
||||||
<path
|
<path
|
||||||
android:fillColor="#FF000000"
|
android:fillColor="@android:color/white"
|
||||||
android:pathData="M24,44Q19.75,44 16.1,42.475Q12.45,40.95 9.75,38.25Q7.05,35.55 5.525,31.9Q4,28.25 4,24Q4,19.8 5.525,16.15Q7.05,12.5 9.75,9.8Q12.45,7.1 16.1,5.55Q19.75,4 24,4Q28.2,4 31.85,5.55Q35.5,7.1 38.2,9.8Q40.9,12.5 42.45,16.15Q44,19.8 44,24Q44,28.25 42.45,31.9Q40.9,35.55 38.2,38.25Q35.5,40.95 31.85,42.475Q28.2,44 24,44ZM24,18.3Q24.7,18.3 25.175,17.85Q25.65,17.4 25.65,16.7Q25.65,16 25.175,15.5Q24.7,15 24,15Q23.3,15 22.825,15.5Q22.35,16 22.35,16.7Q22.35,17.4 22.825,17.85Q23.3,18.3 24,18.3ZM22.65,34H25.65V22H22.65Z" />
|
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z" />
|
||||||
</vector>
|
</vector>
|
||||||
|
47
app/src/main/res/layout/dialog_stats.xml
Normal file
47
app/src/main/res/layout/dialog_stats.xml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
style="@style/CustomDialogTextInputLayout"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:hint="@string/video_id">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/video_id"
|
||||||
|
style="@style/DisabledTextInput" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
style="@style/CustomDialogTextInputLayout"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:hint="@string/audio">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/audio_info"
|
||||||
|
style="@style/DisabledTextInput" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
style="@style/CustomDialogTextInputLayout"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:hint="@string/video">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/video_info"
|
||||||
|
style="@style/DisabledTextInput" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
style="@style/CustomDialogTextInputLayout"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:hint="@string/quality">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/video_quality"
|
||||||
|
style="@style/DisabledTextInput" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -444,6 +444,8 @@
|
|||||||
<string name="custom_playback_speed">Custom speed</string>
|
<string name="custom_playback_speed">Custom speed</string>
|
||||||
<string name="custom_playback_speed_summary">Use a different playback speed than for the normal player.</string>
|
<string name="custom_playback_speed_summary">Use a different playback speed than for the normal player.</string>
|
||||||
<string name="category">Category</string>
|
<string name="category">Category</string>
|
||||||
|
<string name="stats_for_nerds">Stats for nerds</string>
|
||||||
|
<string name="video_id">Video ID</string>
|
||||||
<!-- Notification channel strings -->
|
<!-- Notification channel strings -->
|
||||||
<string name="download_channel_name">Download Service</string>
|
<string name="download_channel_name">Download Service</string>
|
||||||
<string name="download_channel_description">Shows a notification when downloading media.</string>
|
<string name="download_channel_description">Shows a notification when downloading media.</string>
|
||||||
|
@ -64,6 +64,15 @@
|
|||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="DisabledTextInput">
|
||||||
|
|
||||||
|
<item name="android:layout_width">match_parent</item>
|
||||||
|
<item name="android:layout_height">wrap_content</item>
|
||||||
|
<item name="android:editable">false</item>
|
||||||
|
<item name="android:textIsSelectable">true</item>
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="PlayerActionsLayout">
|
<style name="PlayerActionsLayout">
|
||||||
|
|
||||||
<item name="android:layout_width">0dp</item>
|
<item name="android:layout_width">0dp</item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user