mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 08:20:32 +05:30
refactor: make audio player more accessible and redesign
This commit is contained in:
parent
a593da17c1
commit
f7db69fb77
@ -168,28 +168,7 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.download.setOnClickListener {
|
binding.openChapters.setOnClickListener {
|
||||||
val videoId = PlayingQueue.getCurrent()?.url?.toID() ?: return@setOnClickListener
|
|
||||||
|
|
||||||
val newFragment = DownloadDialog()
|
|
||||||
newFragment.arguments = bundleOf(IntentData.videoId to videoId)
|
|
||||||
newFragment.show(childFragmentManager, DownloadDialog::class.java.name)
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.share.setOnClickListener {
|
|
||||||
val currentVideo = PlayingQueue.getCurrent() ?: return@setOnClickListener
|
|
||||||
|
|
||||||
val bundle = bundleOf(
|
|
||||||
IntentData.id to currentVideo.url!!.toID(),
|
|
||||||
IntentData.shareObjectType to ShareObjectType.VIDEO,
|
|
||||||
IntentData.shareData to ShareData(currentVideo = currentVideo.title)
|
|
||||||
)
|
|
||||||
val newShareDialog = ShareDialog()
|
|
||||||
newShareDialog.arguments = bundle
|
|
||||||
newShareDialog.show(childFragmentManager, null)
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.chapters.setOnClickListener {
|
|
||||||
val playerService = playerService ?: return@setOnClickListener
|
val playerService = playerService ?: return@setOnClickListener
|
||||||
viewModel.chaptersLiveData.value = playerService.streams?.chapters.orEmpty()
|
viewModel.chaptersLiveData.value = playerService.streams?.chapters.orEmpty()
|
||||||
|
|
||||||
@ -197,6 +176,12 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
|
|||||||
.show(childFragmentManager)
|
.show(childFragmentManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.close.setOnClickListener {
|
||||||
|
activity?.unbindService(connection)
|
||||||
|
BackgroundHelper.stopBackgroundPlay(requireContext())
|
||||||
|
killFragment()
|
||||||
|
}
|
||||||
|
|
||||||
binding.miniPlayerClose.setOnClickListener {
|
binding.miniPlayerClose.setOnClickListener {
|
||||||
activity?.unbindService(connection)
|
activity?.unbindService(connection)
|
||||||
BackgroundHelper.stopBackgroundPlay(requireContext())
|
BackgroundHelper.stopBackgroundPlay(requireContext())
|
||||||
@ -214,6 +199,10 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
|
|||||||
if (isPaused) playerService?.play() else playerService?.pause()
|
if (isPaused) playerService?.play() else playerService?.pause()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.showMore.setOnClickListener {
|
||||||
|
onLongTap()
|
||||||
|
}
|
||||||
|
|
||||||
// load the stream info into the UI
|
// load the stream info into the UI
|
||||||
updateStreamInfo()
|
updateStreamInfo()
|
||||||
|
|
||||||
@ -371,7 +360,7 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
|
|||||||
}
|
}
|
||||||
playerService?.onNewVideo = { streams, videoId ->
|
playerService?.onNewVideo = { streams, videoId ->
|
||||||
updateStreamInfo(streams.toStreamItem(videoId))
|
updateStreamInfo(streams.toStreamItem(videoId))
|
||||||
_binding?.chapters?.isVisible = streams.chapters.isNotEmpty()
|
_binding?.openChapters?.isVisible = streams.chapters.isNotEmpty()
|
||||||
}
|
}
|
||||||
initializeSeekBar()
|
initializeSeekBar()
|
||||||
}
|
}
|
||||||
@ -400,7 +389,7 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
|
|||||||
override fun onLongTap() {
|
override fun onLongTap() {
|
||||||
val current = PlayingQueue.getCurrent() ?: return
|
val current = PlayingQueue.getCurrent() ?: return
|
||||||
VideoOptionsBottomSheet()
|
VideoOptionsBottomSheet()
|
||||||
.apply { arguments = bundleOf(IntentData.shareData to current) }
|
.apply { arguments = bundleOf(IntentData.streamItem to current) }
|
||||||
.show(childFragmentManager)
|
.show(childFragmentManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,22 @@
|
|||||||
app:track="@drawable/player_switch_track"
|
app:track="@drawable/player_switch_track"
|
||||||
app:trackTint="?colorControlNormal" />
|
app:trackTint="?colorControlNormal" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/open_video"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginHorizontal="6dp"
|
||||||
|
android:src="@drawable/ic_video" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/close"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginHorizontal="6dp"
|
||||||
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
@ -259,52 +275,64 @@
|
|||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
style="@style/Widget.Material3.CardView.Elevated"
|
style="@style/Widget.Material3.CardView.Elevated"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_marginBottom="30dp"
|
android:layout_marginTop="30dp"
|
||||||
app:cardCornerRadius="18dp">
|
app:shapeAppearanceOverlay="@style/CardOnlyBottomCorners">
|
||||||
|
|
||||||
<LinearLayout
|
<FrameLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:padding="15dp">
|
android:padding="15dp">
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/open_queue"
|
|
||||||
style="@style/AudioPlayerButton"
|
|
||||||
android:src="@drawable/ic_queue" />
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/playback_options"
|
android:id="@+id/playback_options"
|
||||||
style="@style/AudioPlayerButton"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="27dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="27dp"
|
android:layout_gravity="start|center_vertical"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:scaleX="0.9"
|
||||||
|
android:scaleY="0.9"
|
||||||
android:src="@drawable/ic_speed" />
|
android:src="@drawable/ic_speed" />
|
||||||
|
|
||||||
<ImageView
|
<LinearLayout
|
||||||
android:id="@+id/open_video"
|
android:layout_width="wrap_content"
|
||||||
style="@style/AudioPlayerButton"
|
android:layout_height="wrap_content"
|
||||||
android:src="@drawable/ic_video" />
|
android:layout_gravity="center"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/open_chapters"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:scaleX="0.9"
|
||||||
|
android:scaleY="0.9"
|
||||||
|
android:src="@drawable/ic_frame" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/open_queue"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:src="@drawable/ic_queue" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/download"
|
android:id="@+id/show_more"
|
||||||
style="@style/AudioPlayerButton"
|
android:layout_width="wrap_content"
|
||||||
android:src="@drawable/ic_download" />
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end|center_vertical"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:scaleX="0.9"
|
||||||
|
android:scaleY="0.9"
|
||||||
|
android:src="@drawable/ic_three_dots" />
|
||||||
|
|
||||||
<ImageView
|
</FrameLayout>
|
||||||
android:id="@+id/share"
|
|
||||||
style="@style/AudioPlayerButton"
|
|
||||||
android:src="@drawable/ic_share" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/chapters"
|
|
||||||
style="@style/AudioPlayerButton"
|
|
||||||
android:src="@drawable/ic_frame"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
@ -196,6 +196,14 @@
|
|||||||
<item name="android:drawableTint" tools:targetApi="m">?android:attr/textColorPrimary</item>
|
<item name="android:drawableTint" tools:targetApi="m">?android:attr/textColorPrimary</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="CardOnlyBottomCorners">
|
||||||
|
<item name="cornerFamily">rounded</item>
|
||||||
|
<item name="cornerSizeTopRight">0dp</item>
|
||||||
|
<item name="cornerSizeTopLeft">0dp</item>
|
||||||
|
<item name="cornerSizeBottomRight">18dp</item>
|
||||||
|
<item name="cornerSizeBottomLeft">18dp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="HomeCategoryTitle">
|
<style name="HomeCategoryTitle">
|
||||||
|
|
||||||
<item name="android:layout_width">match_parent</item>
|
<item name="android:layout_width">match_parent</item>
|
||||||
@ -209,16 +217,6 @@
|
|||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AudioPlayerButton">
|
|
||||||
|
|
||||||
<item name="android:layout_width">30dp</item>
|
|
||||||
<item name="android:layout_height">30dp</item>
|
|
||||||
<item name="android:background">?attr/selectableItemBackgroundBorderless</item>
|
|
||||||
<item name="android:layout_marginStart">10dp</item>
|
|
||||||
<item name="android:layout_marginEnd">10dp</item>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="TextViewMarquee">
|
<style name="TextViewMarquee">
|
||||||
|
|
||||||
<item name="android:singleLine">true</item>
|
<item name="android:singleLine">true</item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user