Skip to content

Commit 6f383e7

Browse files
authored
Merge pull request #30 from lm41/fix/ghost-clicks-on-chapter-select
Fix ghost clicks on chapter and stream select
2 parents 7efee58 + 57d1539 commit 6f383e7

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

new-player/src/main/java/net/newpipe/newplayer/ui/selection_ui/ChapterSelectUI.kt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import net.newpipe.newplayer.ui.common.getInsets
5050
internal fun ChapterSelectUI(
5151
viewModel: InternalNewPlayerViewModel,
5252
uiState: NewPlayerUIState,
53-
shownInAudioPlayer: Boolean
53+
shownInAudioPlayer: Boolean,
5454
) {
5555
val insets = getInsets()
5656

@@ -60,10 +60,11 @@ internal fun ChapterSelectUI(
6060
modifier = Modifier
6161
.fillMaxSize()
6262
.windowInsetsPadding(insets),
63-
containerColor = if (shownInAudioPlayer)
63+
containerColor = if (shownInAudioPlayer) {
6464
MaterialTheme.colorScheme.background
65-
else
66-
Color.Transparent,
65+
} else {
66+
Color.Transparent
67+
},
6768
topBar = {
6869
ChapterSelectTopBar(
6970
onClose = {
@@ -90,12 +91,16 @@ internal fun ChapterSelectUI(
9091
chapterStartInMs = chapter.chapterStartInMs,
9192
thumbnail = chapter.thumbnail,
9293
onClicked = {
94+
if (!uiState.uiMode.isChapterSelect) {
95+
// We don't select the chapter when we are not in chapter select mode
96+
return@ChapterItem
97+
}
9398
viewModel.chapterSelected(chapterIndex)
9499
},
95100
isCurrentChapter = isActiveChapter(
96-
chapterIndex,
101+
chapterId = chapterIndex,
97102
uiState.chapters,
98-
uiState.playbackPositionInMs
103+
playbackPosition = uiState.playbackPositionInMs
99104
)
100105
)
101106
}
@@ -118,4 +123,4 @@ private fun VideoPlayerChannelSelectUIPreview() {
118123
)
119124
}
120125
}
121-
}
126+
}

new-player/src/main/java/net/newpipe/newplayer/ui/selection_ui/StreamSelectUI.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,13 @@ internal fun ReorderableStreamItemsList(
120120
) { isDragging ->
121121
StreamItem(
122122
playlistItem = playlistItem,
123-
onClicked = { viewModel.streamSelected(index) },
123+
onClicked = {
124+
if (!uiState.uiMode.isStreamSelect) {
125+
// We don't select the stream when we are not in stream select mode
126+
return@StreamItem
127+
}
128+
viewModel.streamSelected(index)
129+
},
124130
reorderableScope = this@ReorderableItem,
125131
haptic = haptic,
126132
onDragFinished = viewModel::onStreamItemDragFinished,
@@ -148,4 +154,4 @@ private fun VideoPlayerStreamSelectUIPreview() {
148154
)
149155
}
150156
}
151-
}
157+
}

new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/VideoPlayerUI.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ package net.newpipe.newplayer.ui.videoplayer
2222

2323
import android.os.Build
2424
import androidx.annotation.OptIn
25+
import androidx.compose.animation.AnimatedVisibility
26+
import androidx.compose.foundation.clickable
2527
import androidx.compose.foundation.layout.Box
2628
import androidx.compose.foundation.layout.aspectRatio
2729
import androidx.compose.foundation.layout.fillMaxSize
@@ -129,9 +131,7 @@ internal fun VideoPlayerUi(viewModel: InternalNewPlayerViewModel, uiState: NewPl
129131
viewModel, uiState = uiState
130132
)
131133

132-
// Disable this animation as it induces ghost tabs
133-
//AnimatedVisibility(visible = uiState.uiMode.isStreamSelect) {
134-
if (uiState.uiMode.isStreamSelect) {
134+
AnimatedVisibility(visible = uiState.uiMode.isStreamSelect) {
135135
Surface(
136136
modifier = Modifier.fillMaxSize(),
137137
color = STREAMSELECT_UI_BACKGROUND_COLOR
@@ -144,9 +144,7 @@ internal fun VideoPlayerUi(viewModel: InternalNewPlayerViewModel, uiState: NewPl
144144
}
145145
}
146146

147-
// Disable this animation as it induces ghost tabs
148-
//AnimatedVisibility(visible = uiState.uiMode.isChapterSelect) {
149-
if (uiState.uiMode.isChapterSelect) {
147+
AnimatedVisibility(visible = uiState.uiMode.isChapterSelect) {
150148
Surface(
151149
modifier = Modifier.fillMaxSize(),
152150
color = STREAMSELECT_UI_BACKGROUND_COLOR

0 commit comments

Comments
 (0)