Skip to content
Closed
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 @@ -23,6 +23,7 @@ data class PlayerPreferences(
// Controls (Gestures)
val useSwipeControls: Boolean = true,
val useSeekControls: Boolean = true,
val seekStepMilliseconds: Int = 1000,
val useZoomControls: Boolean = true,
val doubleTapGesture: DoubleTapGesture = DoubleTapGesture.BOTH,
val useLongPressControls: Boolean = false,
Expand Down
2 changes: 2 additions & 0 deletions core/ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@
<string name="controller_timeout">Controller timeout</string>
<string name="seek_increment">Seek increment</string>
<string name="seconds">%1$s seconds</string>
<string name="milliseconds">%1$s milliseconds</string>
<string name="seek_step_gesture_increment">Seek increment gesture</string>
<string name="share">Share</string>
<string name="delete">Delete</string>
<string name="delete_file">The following file will be deleted permanently</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class PlayerGestureHelper(
if (currentGestureAction != GestureAction.SEEK) return false

val distanceDiff = abs(Utils.pxToDp(distanceX) / 4).coerceIn(0.5f, 10f)
val change = (distanceDiff * SEEK_STEP_MS).toLong()
val change = (distanceDiff * prefs.seekStepMilliseconds).toLong()

playerView.player?.run {
if (distanceX < 0L) {
Expand Down Expand Up @@ -296,7 +296,6 @@ class PlayerGestureHelper(
companion object {
const val FULL_SWIPE_RANGE_SCREEN_RATIO = 0.66f
const val GESTURE_EXCLUSION_AREA = 20f
const val SEEK_STEP_MS = 1000L
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ fun PlayerPreferencesScreen(
isChecked = preferences.useSeekControls,
onClick = viewModel::toggleUseSeekControls,
)
SeekStepMillisecondsPreference(
currentValue = preferences.seekStepMilliseconds,
onClick = { viewModel.showDialog(PlayerPreferenceDialog.SeekStepMillisecondsDialog) },
)
SwipeGestureSetting(
isChecked = preferences.useSwipeControls,
onClick = viewModel::toggleUseSwipeControls,
Expand Down Expand Up @@ -379,6 +383,36 @@ fun PlayerPreferencesScreen(
},
)
}
PlayerPreferenceDialog.SeekStepMillisecondsDialog -> {
var seekStepMilliseconds by remember {
mutableIntStateOf(preferences.seekStepMilliseconds)
}

NextDialogWithDoneAndCancelButtons(
title = stringResource(R.string.seek_step_gesture_increment
),
onDoneClick = {
viewModel.updateSeekStepMilliseconds(seekStepMilliseconds)
viewModel.hideDialog()
},
onDismissClick = viewModel::hideDialog,
content = {
Text(
text = stringResource(R.string.milliseconds, seekStepMilliseconds),
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 20.dp),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.titleMedium,
)
Slider(
value = seekStepMilliseconds.toFloat(),
onValueChange = { seekStepMilliseconds = it.toInt() },
valueRange = 1.0f..1000.0f,
)
},
)
}
}
}
}
Expand Down Expand Up @@ -471,6 +505,18 @@ fun SeekIncrementPreference(
onClick = onClick,
)
}
@Composable
fun SeekStepMillisecondsPreference(
currentValue: Int,
onClick: () -> Unit,
) {
ClickablePreferenceItem(
title = stringResource(R.string.seek_step_gesture_increment),
description = stringResource(R.string.milliseconds, currentValue),
icon = NextIcons.Replay,
onClick = onClick,
)
}

@Composable
fun ControllerTimeoutPreference(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ class PlayerPreferencesViewModel @Inject constructor(
}
}
}
fun updateSeekStepMilliseconds (value: Int) {
viewModelScope.launch {
preferencesRepository.updatePlayerPreferences {
it.copy(seekStepMilliseconds = value)
}
}
}
}

data class PlayerPreferencesUIState(
Expand All @@ -223,6 +230,7 @@ sealed interface PlayerPreferenceDialog {
object LongPressControlsSpeedDialog : PlayerPreferenceDialog
object ControllerTimeoutDialog : PlayerPreferenceDialog
object SeekIncrementDialog : PlayerPreferenceDialog
object SeekStepMillisecondsDialog : PlayerPreferenceDialog
}

sealed interface PlayerPreferencesEvent {
Expand Down
Loading