Commit df01386f authored by Geoffrey Métais's avatar Geoffrey Métais

Animate audio player controls transition

Fixes #614
parent f5e3b281
......@@ -47,30 +47,22 @@
android:paddingRight="0px"
android:progressDrawable="?attr/progress_mini_player" />
<LinearLayout
<android.support.constraint.ConstraintLayout
android:id="@+id/header"
android:layout_width="0dp"
android:layout_height="60dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/progressBar"
android:gravity="center_vertical"
android:orientation="horizontal"
android:fitsSystemWindows="true"
android:background="?attr/background_default_darker"
tools:layout_constraintRight_creator="1"
tools:layout_constraintLeft_creator="1">
android:background="?attr/background_default_darker" >
<ImageView
android:id="@+id/playlist_playasaudio_off"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_weight="0"
android:layout_marginStart="@dimen/default_margin"
android:layout_marginLeft="@dimen/default_margin"
android:layout_marginEnd="@dimen/half_default_margin"
android:layout_marginRight="@dimen/half_default_margin"
android:focusable="true"
android:scaleType="fitXY"
android:visibility="gone"
......@@ -80,17 +72,17 @@
<org.videolan.vlc.gui.view.HeaderMediaSwitcher
android:id="@+id/audio_media_switcher"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00000000"
android:layout_weight="1" />
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/barrier"
android:background="#00000000" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/playlist_search_text"
android:layout_marginEnd="2dp"
android:layout_marginRight="2dp"
android:focusable="true"
android:visibility="gone">
<EditText
......@@ -106,8 +98,9 @@
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_weight="0"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toStartOf="@+id/playlist_search"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"
android:focusable="true"
android:scaleType="fitXY"
......@@ -119,9 +112,9 @@
android:id="@+id/playlist_search"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_weight="0"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toStartOf="@+id/playlist_switch"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"
android:focusable="true"
android:scaleType="fitXY"
......@@ -133,8 +126,9 @@
android:id="@+id/playlist_switch"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_weight="0"
app:layout_constraintEnd_toStartOf="@+id/adv_function"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:focusable="true"
android:scaleType="fitXY"
android:onClick="@{fragment::onPlaylistSwitchClick}"
......@@ -145,8 +139,9 @@
android:id="@+id/adv_function"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_weight="0"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:focusable="true"
android:onClick="@{fragment::showAdvancedOptions}"
android:contentDescription="@string/advanced"
......@@ -156,10 +151,11 @@
android:id="@+id/header_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|left"
app:layout_constraintEnd_toStartOf="@+id/header_play_pause"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginLeft="@dimen/default_margin"
android:layout_marginRight="@dimen/default_margin"
android:layout_weight="0"
android:clickable="true"
android:onClick="@{fragment::onTimeLabelClick}"
android:text="@string/time_0"
......@@ -170,9 +166,10 @@
android:id="@+id/header_play_pause"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_marginRight="@dimen/default_margin"
android:layout_marginEnd="@dimen/default_margin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:contentDescription="@string/play"
android:focusable="true"
android:scaleType="fitXY"
......@@ -180,7 +177,16 @@
android:onLongClick="@{fragment::onStopClick}"
android:src="?attr/ic_pause" />
</LinearLayout>
<android.support.constraint.Barrier
android:id="@+id/barrier"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:barrierDirection="start"
app:constraint_referenced_ids="header_time, playlist_ab_repeat"/>
</android.support.constraint.ConstraintLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/songs_list"
......
......@@ -47,30 +47,22 @@
android:paddingRight="0px"
android:progressDrawable="?attr/progress_mini_player" />
<LinearLayout
<android.support.constraint.ConstraintLayout
android:id="@+id/header"
android:layout_width="0dp"
android:layout_height="60dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/progressBar"
android:gravity="center_vertical"
android:orientation="horizontal"
android:fitsSystemWindows="true"
android:background="?attr/background_default_darker"
tools:layout_constraintRight_creator="1"
tools:layout_constraintLeft_creator="1">
android:background="?attr/background_default_darker" >
<ImageView
android:id="@+id/playlist_playasaudio_off"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_weight="0"
android:layout_marginStart="@dimen/default_margin"
android:layout_marginLeft="@dimen/default_margin"
android:layout_marginEnd="@dimen/half_default_margin"
android:layout_marginRight="@dimen/half_default_margin"
android:focusable="true"
android:scaleType="fitXY"
android:visibility="gone"
......@@ -80,17 +72,17 @@
<org.videolan.vlc.gui.view.HeaderMediaSwitcher
android:id="@+id/audio_media_switcher"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00000000"
android:layout_weight="1" />
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/barrier"
android:background="#00000000" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/playlist_search_text"
android:layout_marginEnd="2dp"
android:layout_marginRight="2dp"
android:focusable="true"
android:visibility="gone">
<EditText
......@@ -106,8 +98,9 @@
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_weight="0"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toStartOf="@+id/playlist_search"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"
android:focusable="true"
android:scaleType="fitXY"
......@@ -119,9 +112,9 @@
android:id="@+id/playlist_search"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_weight="0"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toStartOf="@+id/playlist_switch"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"
android:focusable="true"
android:scaleType="fitXY"
......@@ -133,8 +126,9 @@
android:id="@+id/playlist_switch"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_weight="0"
app:layout_constraintEnd_toStartOf="@+id/adv_function"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:focusable="true"
android:scaleType="fitXY"
android:onClick="@{fragment::onPlaylistSwitchClick}"
......@@ -145,8 +139,9 @@
android:id="@+id/adv_function"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_weight="0"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:focusable="true"
android:onClick="@{fragment::showAdvancedOptions}"
android:contentDescription="@string/advanced"
......@@ -156,10 +151,11 @@
android:id="@+id/header_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|left"
app:layout_constraintEnd_toStartOf="@+id/header_play_pause"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginLeft="@dimen/default_margin"
android:layout_marginRight="@dimen/default_margin"
android:layout_weight="0"
android:clickable="true"
android:onClick="@{fragment::onTimeLabelClick}"
android:text="@string/time_0"
......@@ -170,9 +166,10 @@
android:id="@+id/header_play_pause"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_marginRight="@dimen/default_margin"
android:layout_marginEnd="@dimen/default_margin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:contentDescription="@string/play"
android:focusable="true"
android:scaleType="fitXY"
......@@ -180,7 +177,16 @@
android:onLongClick="@{fragment::onStopClick}"
android:src="?attr/ic_pause" />
</LinearLayout>
<android.support.constraint.Barrier
android:id="@+id/barrier"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:barrierDirection="start"
app:constraint_referenced_ids="header_time, playlist_ab_repeat"/>
</android.support.constraint.ConstraintLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/songs_list"
......
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="android.view.View" />
<variable
name="fragment"
type="org.videolan.vlc.gui.audio.AudioPlayer" />
</data>
<android.support.constraint.ConstraintLayout
android:id="@+id/header"
android:layout_width="0dp"
android:layout_height="60dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/progressBar"
android:fitsSystemWindows="true"
android:background="?attr/background_default_darker" >
<ImageView
android:id="@+id/playlist_playasaudio_off"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginStart="@dimen/default_margin"
android:layout_marginEnd="@dimen/half_default_margin"
android:focusable="true"
android:scaleType="fitXY"
android:visibility="gone"
android:onClick="@{fragment::onResumeToVideoClick}"
android:contentDescription="@string/play_as_audio"
android:src="?attr/ic_playasaudio_off" />
<org.videolan.vlc.gui.view.HeaderMediaSwitcher
android:id="@+id/audio_media_switcher"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/playlist_ab_repeat"
android:background="#00000000" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/playlist_search_text"
android:layout_marginEnd="2dp"
android:focusable="true"
android:visibility="gone">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/search_hint"
android:inputType="textFilter"
android:imeOptions="actionSearch"/>
</android.support.design.widget.TextInputLayout>
<ImageView
android:id="@+id/playlist_ab_repeat"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
app:layout_constraintEnd_toStartOf="@+id/playlist_search"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"
android:focusable="true"
android:scaleType="fitXY"
android:onClick="@{fragment::onABRepeat}"
android:contentDescription="@string/ab_repeat"
android:src="?attr/ic_repeat" />
<ImageView
android:id="@+id/playlist_search"
android:layout_width="32dp"
android:layout_height="32dp"
app:layout_constraintEnd_toStartOf="@+id/playlist_switch"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"
android:focusable="true"
android:scaleType="fitXY"
android:onClick="@{fragment::onSearchClick}"
android:contentDescription="@string/search"
android:src="?attr/ic_menu_search" />
<ImageView
android:id="@+id/playlist_switch"
android:layout_width="32dp"
android:layout_height="32dp"
app:layout_constraintEnd_toStartOf="@+id/adv_function"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:focusable="true"
android:scaleType="fitXY"
android:onClick="@{fragment::onPlaylistSwitchClick}"
android:contentDescription="@string/show_playlist"
android:src="?attr/ic_playlist_on" />
<ImageView
android:id="@+id/adv_function"
android:layout_width="40dp"
android:layout_height="40dp"
app:layout_constraintEnd_toStartOf="@+id/header_time"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:focusable="true"
android:onClick="@{fragment::showAdvancedOptions}"
android:contentDescription="@string/advanced"
android:src="?attr/ic_audio_player_more" />
<TextView
android:id="@+id/header_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toStartOf="@+id/header_play_pause"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginLeft="@dimen/default_margin"
android:layout_marginRight="@dimen/default_margin"
android:clickable="true"
android:onClick="@{fragment::onTimeLabelClick}"
android:text="@string/time_0"
android:textColor="?attr/audio_player_header_time"
android:textSize="18sp" />
<ImageView
android:id="@+id/header_play_pause"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginEnd="@dimen/default_margin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:contentDescription="@string/play"
android:focusable="true"
android:scaleType="fitXY"
android:onClick="@{fragment::onPlayPauseClick}"
android:onLongClick="@{fragment::onStopClick}"
android:src="?attr/ic_pause" />
</android.support.constraint.ConstraintLayout>
</layout>
......@@ -32,8 +32,11 @@ import android.os.Handler
import android.preference.PreferenceManager
import android.support.annotation.MainThread
import android.support.annotation.RequiresPermission
import android.support.constraint.ConstraintSet
import android.support.design.widget.BottomSheetBehavior
import android.support.design.widget.Snackbar
import android.support.transition.AutoTransition
import android.support.transition.TransitionManager
import android.support.v4.app.Fragment
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.helper.ItemTouchHelper
......@@ -93,6 +96,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, PlaybackSe
private var advFuncVisible = false
private var playlistSwitchVisible = false
private var searchVisible = false
private var abVisible = false
private var headerPlayPauseVisible = false
private var progressBarVisible = false
private var headerTimeVisible = false
......@@ -113,7 +117,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, PlaybackSe
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
binding = AudioPlayerBinding.inflate(inflater)
binding = AudioPlayerBinding.inflate(inflater)!!
return binding.root
}
......@@ -131,7 +135,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, PlaybackSe
val touchHelper = ItemTouchHelper(callback)
touchHelper.attachToRecyclerView(binding.songsList)
setHeaderVisibilities(false, false, true, true, true, false)
setHeaderVisibilities(false, false, true, true, true, false, false)
binding.fragment = this
binding.next.setOnTouchListener(LongSeekListener(true,
......@@ -285,7 +289,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, PlaybackSe
}
}
if ((activity as AudioPlayerContainerActivity).isAudioPlayerExpanded)
setHeaderVisibilities(true, true, false, false, false, true)
setHeaderVisibilities(true, true, false, false, false, true, true)
}
@MainThread
......@@ -382,32 +386,31 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, PlaybackSe
private fun setHeaderVisibilities(advFuncVisible: Boolean, playlistSwitchVisible: Boolean,
headerPlayPauseVisible: Boolean, progressBarVisible: Boolean,
headerTimeVisible: Boolean, searchVisible: Boolean) {
headerTimeVisible: Boolean, searchVisible: Boolean, abVisible: Boolean) {
this.advFuncVisible = advFuncVisible
this.playlistSwitchVisible = playlistSwitchVisible
this.headerPlayPauseVisible = headerPlayPauseVisible
this.progressBarVisible = progressBarVisible
this.headerTimeVisible = headerTimeVisible
this.searchVisible = searchVisible
this.abVisible = abVisible
restoreHeaderButtonVisibilities()
}
private fun restoreHeaderButtonVisibilities() {
binding.advFunction.visibility = if (advFuncVisible) View.VISIBLE else View.GONE
binding.playlistSwitch.visibility = if (playlistSwitchVisible) View.VISIBLE else View.GONE
binding.playlistSearch.visibility = if (searchVisible) View.VISIBLE else View.GONE
binding.headerPlayPause.visibility = if (headerPlayPauseVisible) View.VISIBLE else View.GONE
binding.progressBar.visibility = if (progressBarVisible) View.VISIBLE else View.GONE
binding.headerTime.visibility = if (headerTimeVisible) View.VISIBLE else View.GONE
}
private fun hideHeaderButtons() {
binding.advFunction.visibility = View.GONE
binding.playlistSwitch.visibility = View.GONE
binding.playlistSearch.visibility = View.GONE
binding.headerPlayPause.visibility = View.GONE
binding.progressBar.visibility = View.GONE
binding.headerTime.visibility = View.GONE
val cl = binding.header
TransitionManager.beginDelayedTransition(cl, AutoTransition().setDuration(200))
ConstraintSet().apply {
clone(cl)
setVisibility(R.id.playlist_ab_repeat, if (abVisible) ConstraintSet.VISIBLE else ConstraintSet.GONE)
setVisibility(R.id.playlist_search, if (searchVisible) ConstraintSet.VISIBLE else ConstraintSet.GONE)
setVisibility(R.id.playlist_switch, if (playlistSwitchVisible) ConstraintSet.VISIBLE else ConstraintSet.GONE)
setVisibility(R.id.adv_function, if (advFuncVisible) ConstraintSet.VISIBLE else ConstraintSet.GONE)
setVisibility(R.id.header_play_pause, if (headerPlayPauseVisible) ConstraintSet.VISIBLE else ConstraintSet.GONE)
setVisibility(R.id.header_time, if (headerTimeVisible) ConstraintSet.VISIBLE else ConstraintSet.GONE)
applyTo(cl)
}
}
fun onABRepeat(v: View) {
......@@ -562,15 +565,15 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, PlaybackSe
BottomSheetBehavior.STATE_COLLAPSED -> {
hideSearchField()
binding.header.setBackgroundResource(DEFAULT_BACKGROUND_DARKER_ID)
setHeaderVisibilities(false, false, true, true, true, false)
setHeaderVisibilities(false, false, true, true, true, false, false)
}
BottomSheetBehavior.STATE_EXPANDED -> {
binding.header.setBackgroundResource(0)
setHeaderVisibilities(true, true, false, false, false, true)
setHeaderVisibilities(true, true, false, false, false, true, true)
showPlaylistTips()
service?.apply { playlistAdapter.currentIndex = currentMediaPosition }
}
else -> binding.header.setBackgroundResource(0)
// else -> binding.header.setBackgroundResource(0)
}
}
......@@ -602,14 +605,14 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, PlaybackSe
}
}
override fun onTouchDown() = hideHeaderButtons()
override fun onTouchUp() = restoreHeaderButtonVisibilities()
override fun onTouchClick() {
val activity = activity as AudioPlayerContainerActivity
activity.slideUpOrDownAudioPlayer()
}
override fun onTouchDown() {}
override fun onTouchUp() {}
}
private val mCoverMediaSwitcherListener = object : AudioMediaSwitcherListener {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment