mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
Add button to close audio player
This commit is contained in:
parent
a5a3a552e6
commit
c0a1deaa8a
@ -38,6 +38,7 @@ import com.github.libretube.helpers.WindowHelper
|
||||
import com.github.libretube.services.ClosingService
|
||||
import com.github.libretube.ui.base.BaseActivity
|
||||
import com.github.libretube.ui.dialogs.ErrorDialog
|
||||
import com.github.libretube.ui.fragments.AudioPlayerFragment
|
||||
import com.github.libretube.ui.fragments.DownloadsFragment
|
||||
import com.github.libretube.ui.fragments.PlayerFragment
|
||||
import com.github.libretube.ui.models.PlayerViewModel
|
||||
@ -444,6 +445,7 @@ class MainActivity : BaseActivity() {
|
||||
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
|
||||
enableTransition(R.id.yt_transition, true)
|
||||
}
|
||||
(fragment as? AudioPlayerFragment)?.binding?.playerMotionLayout?.transitionToEnd()
|
||||
}
|
||||
|
||||
val playerViewModel = ViewModelProvider(this)[PlayerViewModel::class.java]
|
||||
|
@ -43,7 +43,7 @@ import kotlin.math.abs
|
||||
|
||||
class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
|
||||
private var _binding: FragmentAudioPlayerBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
val binding get() = _binding!!
|
||||
|
||||
private lateinit var audioHelper: AudioHelper
|
||||
private val mainActivity get() = context as MainActivity
|
||||
@ -101,6 +101,16 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
|
||||
binding.title.isSelected = true
|
||||
binding.uploader.isSelected = true
|
||||
|
||||
binding.minimizePlayer.setOnClickListener {
|
||||
val mainMotionLayout = mainActivity.binding.mainMotionLayout
|
||||
mainMotionLayout.transitionToStart()
|
||||
binding.playerMotionLayout.transitionToEnd()
|
||||
}
|
||||
|
||||
binding.dropdownMenu.setOnClickListener {
|
||||
onLongTap()
|
||||
}
|
||||
|
||||
binding.prev.setOnClickListener {
|
||||
val currentIndex = PlayingQueue.currentIndex()
|
||||
if (!PlayingQueue.hasPrev()) return@setOnClickListener
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.github.libretube.ui.views.SingleViewTouchableMotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<com.github.libretube.ui.views.SingleViewTouchableMotionLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/playerMotionLayout"
|
||||
@ -14,7 +15,7 @@
|
||||
android:background="?android:attr/colorBackground"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/audio_player_main"
|
||||
@ -26,6 +27,29 @@
|
||||
app:layout_constraintStart_toStartOf="@id/audio_player_container"
|
||||
app:layout_constraintTop_toTopOf="@id/audio_player_container">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="20dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_gravity="center|start"
|
||||
android:id="@+id/minimize_player"
|
||||
android:src="@drawable/ic_arrow_down"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dropdown_menu"
|
||||
android:src="@drawable/ic_three_dots"
|
||||
android:layout_gravity="center|end"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
@ -41,7 +65,7 @@
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
app:shapeAppearanceOverlay="@style/ShapeAppearance.Material3.Corner.Small"
|
||||
tools:src="@tools:sample/backgrounds/scenic" />
|
||||
tools:src="@tools:sample/backgrounds/scenic"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/volumeControls"
|
||||
@ -57,7 +81,7 @@
|
||||
android:id="@+id/volume_textView"
|
||||
style="@style/SwipeControlString"
|
||||
android:layout_gravity="center"
|
||||
app:autoSizeTextType="uniform" />
|
||||
app:autoSizeTextType="uniform"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/volume_progressBar"
|
||||
@ -66,7 +90,7 @@
|
||||
android:layout_height="100dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginVertical="4dp"
|
||||
android:progressDrawable="@drawable/vertical_progressbar" />
|
||||
android:progressDrawable="@drawable/vertical_progressbar"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/volume_imageView"
|
||||
@ -74,7 +98,7 @@
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center"
|
||||
android:contentDescription="@string/volume"
|
||||
android:src="@drawable/ic_volume_up" />
|
||||
android:src="@drawable/ic_volume_up"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@ -82,7 +106,7 @@
|
||||
android:id="@+id/progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center" />
|
||||
android:layout_gravity="center"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
@ -97,7 +121,7 @@
|
||||
style="@style/TextViewMarquee"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="24sp" />
|
||||
android:textSize="24sp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/uploader"
|
||||
@ -105,7 +129,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:textSize="18sp" />
|
||||
android:textSize="18sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@ -114,7 +138,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
app:labelBehavior="gone" />
|
||||
app:labelBehavior="gone"/>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -126,14 +150,14 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start|center"
|
||||
tools:text="00:00" />
|
||||
tools:text="00:00"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|center"
|
||||
tools:text="10:15" />
|
||||
tools:text="10:15"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
@ -151,7 +175,7 @@
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_prev" />
|
||||
android:src="@drawable/ic_prev"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/play_pause"
|
||||
@ -163,7 +187,7 @@
|
||||
android:insetBottom="0dp"
|
||||
app:icon="@drawable/ic_pause"
|
||||
app:iconSize="24dp"
|
||||
app:shapeAppearanceOverlay="@style/ShapeAppearance.Material3.Corner.Full" />
|
||||
app:shapeAppearanceOverlay="@style/ShapeAppearance.Material3.Corner.Full"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/next"
|
||||
@ -172,7 +196,7 @@
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_next" />
|
||||
android:src="@drawable/ic_next"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@ -193,29 +217,29 @@
|
||||
<ImageView
|
||||
android:id="@+id/open_queue"
|
||||
style="@style/AudioPlayerButton"
|
||||
android:src="@drawable/ic_queue" />
|
||||
android:src="@drawable/ic_queue"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/playback_options"
|
||||
style="@style/AudioPlayerButton"
|
||||
android:layout_width="27dp"
|
||||
android:layout_height="27dp"
|
||||
android:src="@drawable/ic_speed" />
|
||||
android:src="@drawable/ic_speed"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/open_video"
|
||||
style="@style/AudioPlayerButton"
|
||||
android:src="@drawable/ic_video" />
|
||||
android:src="@drawable/ic_video"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/share"
|
||||
style="@style/AudioPlayerButton"
|
||||
android:src="@drawable/ic_share" />
|
||||
android:src="@drawable/ic_share"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/close"
|
||||
style="@style/AudioPlayerButton"
|
||||
android:src="@drawable/ic_close" />
|
||||
android:src="@drawable/ic_close"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@ -239,7 +263,7 @@
|
||||
android:layout_width="96dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:padding="8dp" />
|
||||
android:padding="8dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/miniPlayerTitle"
|
||||
@ -250,7 +274,7 @@
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:paddingHorizontal="8dp"
|
||||
android:paddingVertical="15dp" />
|
||||
android:paddingVertical="15dp"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/miniPlayerPause"
|
||||
@ -259,7 +283,7 @@
|
||||
android:layout_gravity="center"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:padding="8dp"
|
||||
android:src="@drawable/ic_pause" />
|
||||
android:src="@drawable/ic_pause"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/miniPlayerClose"
|
||||
@ -268,7 +292,7 @@
|
||||
android:layout_gravity="center"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:padding="8dp"
|
||||
android:src="@drawable/ic_close" />
|
||||
android:src="@drawable/ic_close"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user