Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added preference to remove double tap to seek splash and seek time text #196

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class PlayerPreferences(
val horizontalSeekGesture = preferenceStore.getBoolean("horizontal_seek_gesture", true)
val showSeekBarWhenSeeking = preferenceStore.getBoolean("show_seekbar_when_seeking")
val preciseSeeking = preferenceStore.getBoolean("precise_seeking")
val showDoubleTapOvals = preferenceStore.getBoolean("show_double_tap_ovals", true)
val showSeekIcon = preferenceStore.getBoolean("show_seek_icons", true)
val showSeekTimeWhileSeeking = preferenceStore.getBoolean("show_seek_time_while_seeking", true)

val brightnessGesture = preferenceStore.getBoolean("gestures_brightness", true)
val volumeGesture = preferenceStore.getBoolean("volume_brightness", true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ fun GestureHandler(
@Composable
fun DoubleTapToSeekOvals(
amount: Int,
showOvals: Boolean,
showSeekIcon: Boolean,
showSeekTime: Boolean,
interactionSource: MutableInteractionSource,
modifier: Modifier = Modifier,
) {
Expand All @@ -291,26 +294,30 @@ fun DoubleTapToSeekOvals(
.fillMaxWidth(0.4f), // 2 fifths
contentAlignment = Alignment.Center,
) {
Box(
modifier = Modifier
.fillMaxSize()
.clip(if (amount > 0) RightSideOvalShape else LeftSideOvalShape)
.background(Color.White.copy(alpha))
.indication(interactionSource, ripple()),
)
AndroidView(
factory = { DoubleTapSeekSecondsView(it, null) },
update = {
if (amount != 0) {
it.isForward = amount > 0
it.seconds = amount
it.visibility = View.VISIBLE
it.start()
} else {
it.visibility = View.GONE
}
},
)
if (showOvals) {
Box(
modifier = Modifier
.fillMaxSize()
.clip(if (amount > 0) RightSideOvalShape else LeftSideOvalShape)
.background(Color.White.copy(alpha))
.indication(interactionSource, ripple()),
)
}
if (showSeekIcon || showSeekTime) {
AndroidView(
factory = { DoubleTapSeekSecondsView(it, showSeekIcon, showSeekTime, null) },
update = {
if (amount != 0) {
it.isForward = amount > 0
it.seconds = amount
it.visibility = View.VISIBLE
it.start()
} else {
it.visibility = View.GONE
}
},
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ fun PlayerControls(
val paused by viewModel.paused.collectAsState()
val gestureSeekAmount by viewModel.gestureSeekAmount.collectAsState()
val doubleTapSeekAmount by viewModel.doubleTapSeekAmount.collectAsState()
val showDoubleTapOvals by playerPreferences.showDoubleTapOvals.collectAsState()
val showSeekIcon by playerPreferences.showSeekIcon.collectAsState()
val showSeekTime by playerPreferences.showSeekTimeWhileSeeking.collectAsState()
var isSeeking by remember { mutableStateOf(false) }
var resetControls by remember { mutableStateOf(true) }
val currentChapter by viewModel.currentChapter.collectAsState()
Expand Down Expand Up @@ -159,7 +162,7 @@ fun PlayerControls(
viewModel = viewModel,
interactionSource = interactionSource,
)
DoubleTapToSeekOvals(doubleTapSeekAmount, interactionSource)
DoubleTapToSeekOvals(doubleTapSeekAmount, showDoubleTapOvals, showSeekIcon, showSeekTime, interactionSource)
CompositionLocalProvider(
LocalRippleConfiguration provides playerRippleConfiguration,
LocalPlayerButtonsClickEvent provides { resetControls = !resetControls },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.animation.ValueAnimator
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
import androidx.annotation.DrawableRes
import live.mehiz.mpvkt.R
Expand All @@ -15,7 +16,12 @@ import live.mehiz.mpvkt.databinding.PlayerDoubleTapSeekViewBinding
* Originally from https://github.com/aniyomiorg/aniyomi
* Thanks @Quickdesh for allowing me to use it
*/
class DoubleTapSeekSecondsView(context: Context, attrs: AttributeSet?) : LinearLayout(context, attrs) {
class DoubleTapSeekSecondsView(
context: Context,
showSeekIcon: Boolean,
showSeekTime: Boolean,
attrs: AttributeSet?
) : LinearLayout(context, attrs) {

var binding: PlayerDoubleTapSeekViewBinding

Expand Down Expand Up @@ -63,6 +69,8 @@ class DoubleTapSeekSecondsView(context: Context, attrs: AttributeSet?) : LinearL
binding = PlayerDoubleTapSeekViewBinding.inflate(LayoutInflater.from(context), this)
orientation = VERTICAL
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)
binding.triangleContainer.visibility = if (showSeekIcon) View.VISIBLE else View.GONE
binding.doubleTapSeconds.visibility = if (showSeekTime) View.VISIBLE else View.GONE
}

fun start() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,24 @@ object PlayerPreferencesScreen : Screen() {
title = { Text(stringResource(R.string.pref_player_precise_seeking_title)) },
summary = { Text(stringResource(R.string.pref_player_precise_seeking_summary)) }
)
val showDoubleTapOvals by preferences.showDoubleTapOvals.collectAsState()
SwitchPreference(
value = showDoubleTapOvals,
onValueChange = preferences.showDoubleTapOvals::set,
title = { Text(stringResource(R.string.show_splash_ovals_on_double_tap_to_seek)) },
)
val showSeekIcon by preferences.showSeekIcon.collectAsState()
SwitchPreference(
value = showSeekIcon,
onValueChange = preferences.showSeekIcon::set,
title = { Text("Show seek icon") },
)
val showSeekTimeWhileSeeking by preferences.showSeekTimeWhileSeeking.collectAsState()
SwitchPreference(
value = showSeekTimeWhileSeeking,
onValueChange = preferences.showSeekTimeWhileSeeking::set,
title = { Text("Show seek time") },
)
PreferenceCategory(
title = { Text(stringResource(R.string.pref_player_gestures)) },
)
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@
<string name="swap_the_volume_and_brightness_slider">Swap volume and brightness slider</string>
<string name="pref_player_display_reduce_player_animation">Reduce player animation</string>
<string name="pref_player_display_hide_player_control_time">Hide player control time</string>
<string name="show_splash_ovals_on_double_tap_to_seek">Show ripple when double tap seeking</string>

<plurals name="plural_items">
<item quantity="one">%1$d item</item>
Expand Down