Fix bottom sheet being hidden in certain conditions
This commit is contained in:
parent
822adcac4a
commit
b924a0c655
|
@ -40,6 +40,9 @@ import audio.funkwhale.ffa.utils.CommandBus
|
|||
import audio.funkwhale.ffa.utils.Event
|
||||
import audio.funkwhale.ffa.utils.EventBus
|
||||
import audio.funkwhale.ffa.utils.OAuth
|
||||
import audio.funkwhale.ffa.utils.Request
|
||||
import audio.funkwhale.ffa.utils.RequestBus
|
||||
import audio.funkwhale.ffa.utils.Response
|
||||
import audio.funkwhale.ffa.utils.Settings
|
||||
import audio.funkwhale.ffa.utils.Userinfo
|
||||
import audio.funkwhale.ffa.utils.authorize
|
||||
|
@ -48,6 +51,7 @@ import audio.funkwhale.ffa.utils.logError
|
|||
import audio.funkwhale.ffa.utils.mustNormalizeUrl
|
||||
import audio.funkwhale.ffa.utils.onApi
|
||||
import audio.funkwhale.ffa.utils.toast
|
||||
import audio.funkwhale.ffa.utils.wait
|
||||
import com.github.kittinunf.fuel.Fuel
|
||||
import com.github.kittinunf.fuel.coroutines.awaitStringResponse
|
||||
import com.google.android.exoplayer2.offline.DownloadService
|
||||
|
@ -56,8 +60,10 @@ import com.google.gson.Gson
|
|||
import com.preference.PowerPreference
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.Dispatchers.Main
|
||||
import kotlinx.coroutines.channels.consume
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.consumeAsFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import org.koin.java.KoinJavaComponent.inject
|
||||
|
||||
|
@ -83,7 +89,6 @@ class MainActivity : AppCompatActivity() {
|
|||
AppContext.init(this)
|
||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
|
||||
binding.nowPlayingBottomSheet.hide()
|
||||
binding.nowPlayingBottomSheet.addBottomSheetCallback(
|
||||
object : BottomSheetBehavior.BottomSheetCallback() {
|
||||
override fun onStateChanged(bottomSheet: View, newState: Int) {
|
||||
|
@ -125,9 +130,17 @@ class MainActivity : AppCompatActivity() {
|
|||
MediaControlsManager.NOTIFICATION_ACTION_OPEN_QUEUE.toString() -> launchDialog(QueueFragment())
|
||||
}
|
||||
|
||||
lifecycleScope.launch {
|
||||
RequestBus.send(Request.GetQueue).wait<Response.Queue>()?.let {
|
||||
if(it.queue.isNotEmpty()) binding.nowPlayingBottomSheet.show()
|
||||
else binding.nowPlayingBottomSheet.hide()
|
||||
}
|
||||
// Watch the event bus only after to prevent concurrency in displaying the bottom sheet
|
||||
watchEventBus()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
|
|
|
@ -3,12 +3,9 @@ package audio.funkwhale.ffa.fragments
|
|||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.SeekBar
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import androidx.customview.widget.Openable
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.distinctUntilChanged
|
||||
|
@ -21,9 +18,18 @@ import audio.funkwhale.ffa.model.Track
|
|||
import audio.funkwhale.ffa.repositories.FavoritedRepository
|
||||
import audio.funkwhale.ffa.repositories.FavoritesRepository
|
||||
import audio.funkwhale.ffa.repositories.Repository
|
||||
import audio.funkwhale.ffa.utils.*
|
||||
import audio.funkwhale.ffa.utils.BottomSheetIneractable
|
||||
import audio.funkwhale.ffa.utils.Command
|
||||
import audio.funkwhale.ffa.utils.CommandBus
|
||||
import audio.funkwhale.ffa.utils.CoverArt
|
||||
import audio.funkwhale.ffa.utils.Event
|
||||
import audio.funkwhale.ffa.utils.EventBus
|
||||
import audio.funkwhale.ffa.utils.FFACache
|
||||
import audio.funkwhale.ffa.utils.ProgressBus
|
||||
import audio.funkwhale.ffa.utils.maybeNormalizeUrl
|
||||
import audio.funkwhale.ffa.utils.toIntOrElse
|
||||
import audio.funkwhale.ffa.utils.untilNetwork
|
||||
import audio.funkwhale.ffa.viewmodel.NowPlayingViewModel
|
||||
import audio.funkwhale.ffa.views.NowPlayingBottomSheet
|
||||
import jp.wasabeef.picasso.transformations.RoundedCornersTransformation
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
|
|
@ -98,7 +98,8 @@ object CommandBus {
|
|||
}
|
||||
|
||||
object RequestBus {
|
||||
private var _requests = MutableSharedFlow<Request>()
|
||||
// `replay` allows send requests before the PlayerService starts listening
|
||||
private var _requests = MutableSharedFlow<Request>(replay = 100)
|
||||
var requests = _requests.asSharedFlow()
|
||||
fun send(request: Request): Channel<Response> {
|
||||
return Channel<Response>().also {
|
||||
|
|
|
@ -13,19 +13,13 @@
|
|||
android:id="@+id/header"
|
||||
layout="@layout/partial_now_playing_header" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cover_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/header">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
<audio.funkwhale.ffa.views.SquareImageView
|
||||
android:id="@+id/now_playing_detail_cover"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:layout_constraintTop_toBottomOf="@id/header"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="H,1:1"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:srcCompat="@drawable/cover"
|
||||
|
@ -43,8 +37,8 @@
|
|||
android:src="@drawable/more"
|
||||
app:layout_constraintEnd_toEndOf="@id/now_playing_detail_cover"
|
||||
app:layout_constraintTop_toTopOf="@id/now_playing_detail_cover"
|
||||
app:tint="@color/controlForeground" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
app:tint="@color/controlForeground"
|
||||
/>
|
||||
|
||||
|
||||
<include
|
||||
|
@ -57,7 +51,7 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/header"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/cover_container"
|
||||
app:layout_constraintStart_toEndOf="@id/now_playing_detail_cover"
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -13,23 +13,14 @@
|
|||
android:id="@+id/header"
|
||||
layout="@layout/partial_now_playing_header" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cover_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:padding="8dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/header"
|
||||
app:layout_constraintBottom_toTopOf="@id/controls">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
<audio.funkwhale.ffa.views.SquareImageView
|
||||
android:id="@+id/now_playing_detail_cover"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/header"
|
||||
app:srcCompat="@drawable/cover"
|
||||
tools:src="@tools:sample/avatars" />
|
||||
tools:src="@tools:sample/avatars"
|
||||
/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/now_playing_details_info"
|
||||
|
@ -44,7 +35,6 @@
|
|||
android:contentDescription="@string/alt_track_info"
|
||||
android:src="@drawable/more"
|
||||
app:tint="@color/controlForeground" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<include
|
||||
android:id="@+id/controls"
|
||||
|
@ -53,6 +43,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/now_playing_detail_cover"
|
||||
/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
|
@ -48,7 +48,7 @@
|
|||
app:layout_constraintEnd_toEndOf="@id/now_playing_cover"
|
||||
android:indeterminate="true"
|
||||
android:indeterminateTint="@color/controlForeground"
|
||||
android:visibility="@{isBuffering ? View.VISIBLE : View.GONE, default=gone}" />
|
||||
android:visibility="@{isBuffering ? View.VISIBLE : View.INVISIBLE, default=invisible}" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/header_controls"
|
||||
|
|
Loading…
Reference in New Issue