Merge pull request #792 from Bnyro/master

player options menu
This commit is contained in:
Bnyro 2022-07-15 11:43:43 +02:00 committed by GitHub
commit 061b71056b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 110 additions and 64 deletions

View File

@ -276,6 +276,16 @@ class PlayerFragment : Fragment() {
.remove(this)
.commit()
}
// show the advanced player options
playerBinding.toggleOptions.setOnClickListener {
if (playerBinding.advancedOptions.isVisible) {
playerBinding.toggleOptions.animate().rotationX(0F).setDuration(200).start()
playerBinding.advancedOptions.visibility = View.GONE
} else {
playerBinding.toggleOptions.animate().rotationX(180F).setDuration(200).start()
playerBinding.advancedOptions.visibility = View.VISIBLE
}
}
binding.playImageView.setOnClickListener {
paused = if (paused) {
binding.playImageView.setImageResource(R.drawable.ic_pause)

View File

@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
import com.google.android.exoplayer2.ui.StyledPlayerView
@ -13,6 +14,12 @@ internal class CustomExoPlayerView(
) : StyledPlayerView(context, attributeSet) {
val binding: ExoStyledPlayerControlViewBinding = ExoStyledPlayerControlViewBinding.bind(this)
override fun hideController() {
super.hideController()
binding.toggleOptions.animate().rotationX(0F).setDuration(1000).start()
binding.advancedOptions.visibility = View.GONE
}
@SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent): Boolean {
when (event.action) {

View File

@ -1,10 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#FFFFFF"
android:tint="@android:color/white"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M19,12h-2v3h-3v2h5v-5zM7,9h3L10,7L5,7v5h2L7,9zM21,3L3,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2L23,5c0,-1.1 -0.9,-2 -2,-2zM21,19.01L3,19.01L3,4.99h18v14.02z" />
<path
android:fillColor="#FF000000"
android:pathData="m20.403,1.197c1.918,0 3.486,1.499 3.595,3.39l0.006,0.212v14.405c0,1.918 -1.499,3.486 -3.39,3.595l-0.212,0.006L3.597,22.803c-1.918,0 -3.486,-1.499 -3.595,-3.39l-0.006,-0.212L-0.004,4.798c0,-1.918 1.499,-3.486 3.39,-3.595l0.212,-0.006zM20.403,3.597L3.597,3.597c-0.616,0 -1.123,0.463 -1.192,1.06l-0.008,0.14v14.405c0,0.616 0.463,1.123 1.06,1.192l0.14,0.008L20.403,20.403c0.616,0 1.123,-0.463 1.192,-1.06l0.008,-0.14L21.603,4.798c0,-0.616 -0.463,-1.123 -1.06,-1.192zM18.002,12c0.616,0 1.123,0.463 1.192,1.06l0.008,0.14v3.601c0,0.616 -0.463,1.123 -1.06,1.192l-0.14,0.008h-3.601c-0.663,0 -1.2,-0.537 -1.2,-1.2 0,-0.616 0.463,-1.123 1.06,-1.192l0.14,-0.008h2.401v-2.401c0,-0.616 0.463,-1.123 1.06,-1.192zM9.599,5.998c0.663,0 1.2,0.537 1.2,1.2 0,0.616 -0.463,1.123 -1.06,1.192L9.599,8.399L7.198,8.399v2.401c0,0.616 -0.463,1.123 -1.06,1.192l-0.14,0.008c-0.616,0 -1.123,-0.463 -1.192,-1.06l-0.008,-0.14L4.798,7.198c0,-0.616 0.463,-1.123 1.06,-1.192L5.998,5.998Z"
android:strokeWidth="1"/>
</vector>

View File

@ -34,8 +34,10 @@
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:stateListAnimator="@null"
android:text="@string/subscribe"
android:textColor="?android:attr/textColorPrimary"
android:textSize="12sp"
app:cornerRadius="20dp" />
app:cornerRadius="20dp"
app:elevation="20dp" />
</RelativeLayout>

View File

@ -11,73 +11,105 @@
<LinearLayout
android:id="@+id/exo_top_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/exo_styled_bottom_bar_height"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginBottom="@dimen/exo_styled_bottom_bar_margin_top"
android:layoutDirection="ltr">
android:animateLayoutChanges="true"
android:orientation="vertical"
android:paddingStart="5dp"
android:paddingEnd="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="5dp"
android:layoutDirection="ltr">
<ImageView
android:id="@+id/close_imageButton"
style="@style/PlayerControlTop"
android:src="@drawable/ic_close"
app:tint="@android:color/white" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layoutDirection="ltr">
<ImageView
android:id="@+id/lock_player"
style="@style/PlayerControlTop"
android:layout_marginStart="-5dp"
android:scaleX=".9"
android:scaleY=".9"
android:src="@drawable/ic_unlocked" />
<ImageView
android:id="@+id/close_imageButton"
style="@style/PlayerControlTop"
android:src="@drawable/ic_close"
app:tint="@android:color/white" />
<ImageView
android:id="@+id/lock_player"
style="@style/PlayerControlTop"
android:layout_marginStart="-5dp"
android:scaleX=".9"
android:scaleY=".9"
android:src="@drawable/ic_unlocked" />
</LinearLayout>
<TextView
android:id="@+id/exo_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginHorizontal="10dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@android:color/white"
android:textSize="18sp"
android:visibility="invisible" />
<LinearLayout
android:id="@+id/exo_top_bar_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layoutDirection="ltr">
<TextView
android:id="@+id/speed_text"
style="@style/PlayerControlTop"
android:text="1x" />
<TextView
android:id="@+id/quality_text"
style="@style/PlayerControlTop"
android:text="@string/hls" />
<ImageButton
android:id="@+id/toggle_options"
style="@style/PlayerControlTop"
android:layout_marginTop="-.5dp"
android:src="@drawable/ic_arrow_down"
app:tint="@android:color/white" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/exo_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginHorizontal="10dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@android:color/white"
android:textSize="18sp"
android:visibility="invisible" />
<LinearLayout
android:id="@+id/exo_top_bar_right"
android:id="@+id/advanced_options"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="10dp"
android:layoutDirection="ltr">
android:layout_gravity="right"
android:layout_marginTop="-10dp"
android:orientation="horizontal"
android:visibility="gone">
<ImageButton
android:id="@id/exo_subtitle"
style="@style/PlayerControlBottom" />
<ImageButton
android:id="@+id/repeat_toggle"
style="@style/PlayerControlTop"
android:src="@drawable/ic_repeat"
app:tint="@android:color/darker_gray" />
<ImageView
android:id="@+id/aspect_ratio_button"
style="@style/PlayerControlTop"
android:layout_marginTop="-1dp"
android:scaleX=".9"
android:scaleY=".9"
android:src="@drawable/ic_aspect_ratio" />
<TextView
android:id="@+id/speed_text"
style="@style/PlayerControlTop"
android:text="1x" />
<TextView
android:id="@+id/quality_text"
style="@style/PlayerControlTop"
android:text="@string/hls" />
</LinearLayout>
</LinearLayout>
@ -150,19 +182,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/repeat_toggle"
style="@style/PlayerControlBottom"
android:src="@drawable/ic_repeat"
app:tint="@android:color/darker_gray" />
<ImageButton
android:id="@id/exo_subtitle"
style="@style/PlayerControlBottom" />
<ImageButton
android:id="@+id/fullscreen"
style="@style/PlayerControlBottom"
android:layout_marginEnd="5dp"
android:src="@drawable/ic_fullscreen"
app:tint="@android:color/white" />

View File

@ -83,6 +83,8 @@
android:text="@string/subscribe"
android:textColor="?android:attr/textColorPrimary"
android:textSize="12sp"
android:stateListAnimator="@null"
app:elevation="20dp"
app:cornerRadius="20dp" />
</LinearLayout>

View File

@ -379,7 +379,7 @@
android:id="@+id/doubleTapOverlayLL"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginVertical="50dp">
android:layout_marginVertical="60dp">
<!-- double tap rewind btn -->
<FrameLayout

View File

@ -67,6 +67,7 @@
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:visibility="gone"
app:cardElevation="20dp"
app:cardCornerRadius="18dp">
<LinearLayout