Skip to content

Commit b7beb68

Browse files
authored
Merge pull request #139 from pravinyo/bookDetails_UI_bug
Book details ui bug
2 parents 8a03938 + 27f8634 commit b7beb68

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

feature_playerfullscreen/src/main/java/com/allsoftdroid/audiobook/feature/feature_playerfullscreen/domain/usecase/GetPlayingTrackProgressUsecase.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ class GetPlayingTrackProgressUsecase(private val audioManager: AudioManager) :
2828

2929
Timber.d("Current Progress is $progress")
3030

31-
mainHandler.postDelayed(this, 1000)
31+
if(progress<100){
32+
mainHandler.postDelayed(this, 1000)
33+
}
3234
}
3335
}
3436

feature_playerfullscreen/src/main/java/com/allsoftdroid/audiobook/feature/feature_playerfullscreen/presentation/MainPlayerFragment.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ class MainPlayerFragment : BaseContainerFragment(){
8787
setImageResource(R.drawable.play_circle_green)
8888
}
8989
}
90+
91+
is Finished -> {
92+
mainPlayerViewModel.bookFinished()
93+
}
9094
else -> Timber.d("Ignore event $event")
9195
}
9296
}
@@ -123,7 +127,7 @@ class MainPlayerFragment : BaseContainerFragment(){
123127

124128
private fun handleBackPressEvent(){
125129
this.findNavController().navigateUp()
126-
mainPlayerViewModel.showMiniPlayer()
130+
mainPlayerViewModel.showMiniPlayerIfPlaying()
127131
}
128132

129133
override fun onDestroyView() {

feature_playerfullscreen/src/main/java/com/allsoftdroid/audiobook/feature/feature_playerfullscreen/presentation/MainPlayerViewModel.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class MainPlayerViewModel(
5151
val playingTrackDetails : LiveData<PlayingTrackDetails> = _playingTrackDetails
5252

5353
private var currentPlayingIndex = 0
54+
private var isBookFinished:Boolean = false
5455

5556
val trackProgress:LiveData<Int>
5657
get() = trackProgressUsecase.trackProgress
@@ -106,6 +107,10 @@ class MainPlayerViewModel(
106107
shouldPlayEvent()
107108
}
108109

110+
fun bookFinished(isFinished: Boolean = true){
111+
isBookFinished = isFinished
112+
}
113+
109114
fun setBookDetails(bookId:String, bookName:String, trackName:String, currentPlayingTrack: Int, totalChapter:Int,isPlaying:Boolean){
110115

111116
_playingTrackDetails.value = PlayingTrackDetails(
@@ -166,8 +171,13 @@ class MainPlayerViewModel(
166171
}
167172
}
168173

169-
fun showMiniPlayer(){
170-
userActionEventStore.publish(Event(OpenMiniPlayerUI(this::class.java.simpleName)))
174+
fun showMiniPlayerIfPlaying(){
175+
if (!isBookFinished){
176+
Timber.d("Book is not finished: Sending open mini player")
177+
userActionEventStore.publish(Event(OpenMiniPlayerUI(this::class.java.simpleName)))
178+
}else{
179+
Timber.d("Book is finished: No action required")
180+
}
171181
}
172182

173183
private suspend fun initTrackProgress() {

feature_playerfullscreen/src/main/java/com/allsoftdroid/audiobook/feature/feature_playerfullscreen/utils/BindingUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fun setTrackBookBanner(cardView: CardView, item: PlayingTrackDetails?) {
103103
val dominant = it.getDominantColor(it.getVibrantColor(0))
104104
val light = it.getLightMutedColor(it.getLightVibrantColor(0))
105105

106-
cardView.setBackgroundColor(dominant)
106+
// cardView.setBackgroundColor(dominant)
107107

108108
with(cardView.rootView.findViewById<View>(R.id.parentContainer)){
109109
setBackgroundColor(dark)

services/src/main/java/com/allsoftdroid/audiobook/services/audio/utils/NotificationUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class NotificationUtils {
108108
if (Build.VERSION.SDK_INT>= Build.VERSION_CODES.O) {
109109
val notificationManager = applicationContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
110110
val name = applicationContext.getString(R.string.app_name)
111-
val importance = NotificationManager.IMPORTANCE_DEFAULT
111+
val importance = NotificationManager.IMPORTANCE_LOW
112112
NotificationChannel(NOTIFICATION_CHANNEL, name, importance).apply {
113113
enableLights(false)
114114
enableVibration(false)

0 commit comments

Comments
 (0)