Merge pull request #23 from MaintainTeam/revert-21-master

Revert "Changing playback speed (tempo) via gesture on main player screen"
This commit is contained in:
Aliberk Sandıkçı 2025-01-20 20:38:32 +03:00 committed by GitHub
commit df6401b5ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 10 additions and 146 deletions

View file

@ -14,12 +14,10 @@ import org.schabi.newpipe.ktx.AnimationType
import org.schabi.newpipe.ktx.animate import org.schabi.newpipe.ktx.animate
import org.schabi.newpipe.player.Player import org.schabi.newpipe.player.Player
import org.schabi.newpipe.player.helper.AudioReactor import org.schabi.newpipe.player.helper.AudioReactor
import org.schabi.newpipe.player.helper.PlaybackParameterDialog
import org.schabi.newpipe.player.helper.PlayerHelper import org.schabi.newpipe.player.helper.PlayerHelper
import org.schabi.newpipe.player.ui.MainPlayerUi import org.schabi.newpipe.player.ui.MainPlayerUi
import org.schabi.newpipe.util.ThemeHelper.getAndroidDimenPx import org.schabi.newpipe.util.ThemeHelper.getAndroidDimenPx
import kotlin.math.abs import kotlin.math.abs
import kotlin.math.roundToInt
/** /**
* GestureListener for the player * GestureListener for the player
@ -104,7 +102,6 @@ class MainPlayerGestureListener(
binding.volumeRelativeLayout.animate(true, 200, AnimationType.SCALE_AND_ALPHA) binding.volumeRelativeLayout.animate(true, 200, AnimationType.SCALE_AND_ALPHA)
} }
binding.brightnessRelativeLayout.isVisible = false binding.brightnessRelativeLayout.isVisible = false
binding.playbackSpeedRelativeLayout.isVisible = false
} }
private fun onScrollBrightness(distanceY: Float) { private fun onScrollBrightness(distanceY: Float) {
@ -150,42 +147,6 @@ class MainPlayerGestureListener(
binding.brightnessRelativeLayout.animate(true, 200, AnimationType.SCALE_AND_ALPHA) binding.brightnessRelativeLayout.animate(true, 200, AnimationType.SCALE_AND_ALPHA)
} }
binding.volumeRelativeLayout.isVisible = false binding.volumeRelativeLayout.isVisible = false
binding.playbackSpeedRelativeLayout.isVisible = false
}
private fun onScrollPlaybackSpeed(distanceY: Float) {
val bar: ProgressBar = binding.playbackSpeedProgressBar
val maxPlaybackSpeed: Float = PlaybackParameterDialog.getMaxPitchOrSpeed()
val minPlaybackSpeed: Float = PlaybackParameterDialog.getMinPitchOrSpeed()
val playbackSpeedStep: Float = PlaybackParameterDialog.getCurrentStepSize(player.context) / maxPlaybackSpeed
// If we just started sliding, change the progress bar to match the current playback speed
if (!binding.playbackSpeedRelativeLayout.isVisible) {
val playbackSpeedPercent: Float = player.playbackSpeed / maxPlaybackSpeed
bar.progress = (playbackSpeedPercent * bar.max).toInt()
}
// Update progress bar
bar.incrementProgressBy(distanceY.toInt())
// Update playback speed
val currentProgressPercent: Float = (bar.progress / bar.max.toFloat() / playbackSpeedStep).roundToInt() * playbackSpeedStep
val currentPlaybackSpeed: Float = (currentProgressPercent * maxPlaybackSpeed).coerceIn(minPlaybackSpeed, maxPlaybackSpeed)
player.playbackSpeed = currentPlaybackSpeed
if (DEBUG) {
Log.d(TAG, "onScroll().playbackSpeedControl, currentPlaybackSpeed = $currentPlaybackSpeed")
}
// Update player center image
binding.playbackSpeedTextView.text = PlayerHelper.formatSpeed(currentPlaybackSpeed.toDouble())
// Make sure the correct layout is visible
if (!binding.playbackSpeedRelativeLayout.isVisible) {
binding.playbackSpeedRelativeLayout.animate(true, 200, AnimationType.SCALE_AND_ALPHA)
}
binding.brightnessRelativeLayout.isVisible = false
binding.volumeRelativeLayout.isVisible = false
} }
override fun onScrollEnd(event: MotionEvent) { override fun onScrollEnd(event: MotionEvent) {
@ -196,9 +157,6 @@ class MainPlayerGestureListener(
if (binding.brightnessRelativeLayout.isVisible) { if (binding.brightnessRelativeLayout.isVisible) {
binding.brightnessRelativeLayout.animate(false, 200, AnimationType.SCALE_AND_ALPHA, 200) binding.brightnessRelativeLayout.animate(false, 200, AnimationType.SCALE_AND_ALPHA, 200)
} }
if (binding.playbackSpeedRelativeLayout.isVisible) {
binding.playbackSpeedRelativeLayout.animate(false, 200, AnimationType.SCALE_AND_ALPHA, 200)
}
} }
override fun onScroll( override fun onScroll(
@ -232,35 +190,23 @@ class MainPlayerGestureListener(
isMoving = true isMoving = true
// -- Brightness Volume and Tempo control -- // -- Brightness and Volume control --
if (getDisplayPortion(initialEvent) == DisplayPortion.RIGHT) { if (getDisplayHalfPortion(initialEvent) == DisplayPortion.RIGHT_HALF) {
when (PlayerHelper.getActionForRightGestureSide(player.context)) { when (PlayerHelper.getActionForRightGestureSide(player.context)) {
player.context.getString(R.string.volume_control_key) -> player.context.getString(R.string.volume_control_key) ->
onScrollVolume(distanceY) onScrollVolume(distanceY)
player.context.getString(R.string.brightness_control_key) -> player.context.getString(R.string.brightness_control_key) ->
onScrollBrightness(distanceY) onScrollBrightness(distanceY)
player.context.getString(R.string.playback_speed_control_key) ->
onScrollPlaybackSpeed(distanceY)
} }
} else if (getDisplayPortion(initialEvent) == DisplayPortion.LEFT) { } else {
when (PlayerHelper.getActionForLeftGestureSide(player.context)) { when (PlayerHelper.getActionForLeftGestureSide(player.context)) {
player.context.getString(R.string.volume_control_key) -> player.context.getString(R.string.volume_control_key) ->
onScrollVolume(distanceY) onScrollVolume(distanceY)
player.context.getString(R.string.brightness_control_key) -> player.context.getString(R.string.brightness_control_key) ->
onScrollBrightness(distanceY) onScrollBrightness(distanceY)
player.context.getString(R.string.playback_speed_control_key) ->
onScrollPlaybackSpeed(distanceY)
}
} else {
when (PlayerHelper.getActionForMiddleGestureSide(player.context)) {
player.context.getString(R.string.volume_control_key) ->
onScrollVolume(distanceY)
player.context.getString(R.string.brightness_control_key) ->
onScrollBrightness(distanceY)
player.context.getString(R.string.playback_speed_control_key) ->
onScrollPlaybackSpeed(distanceY)
} }
} }
return true return true
} }

View file

@ -590,19 +590,6 @@ public class PlaybackParameterDialog extends DialogFragment {
return PlayerHelper.formatPitch(percent); return PlayerHelper.formatPitch(percent);
} }
public static float getCurrentStepSize(final Context context) {
return PreferenceManager.getDefaultSharedPreferences(context)
.getFloat(context.getString(R.string.adjustment_step_key), (float) DEFAULT_STEP);
}
public static float getMinPitchOrSpeed() {
return (float) MIN_PITCH_OR_SPEED;
}
public static float getMaxPitchOrSpeed() {
return (float) MAX_PITCH_OR_SPEED;
}
public interface Callback { public interface Callback {
void onPlaybackParameterChanged(float playbackTempo, float playbackPitch, void onPlaybackParameterChanged(float playbackTempo, float playbackPitch,
boolean playbackSkipSilence); boolean playbackSkipSilence);

View file

@ -234,12 +234,6 @@ public final class PlayerHelper {
context.getString(R.string.default_right_gesture_control_value)); context.getString(R.string.default_right_gesture_control_value));
} }
public static String getActionForMiddleGestureSide(@NonNull final Context context) {
return getPreferences(context)
.getString(context.getString(R.string.middle_gesture_control_key),
context.getString(R.string.default_middle_gesture_control_value));
}
public static String getActionForLeftGestureSide(@NonNull final Context context) { public static String getActionForLeftGestureSide(@NonNull final Context context) {
return getPreferences(context) return getPreferences(context)
.getString(context.getString(R.string.left_gesture_control_key), .getString(context.getString(R.string.left_gesture_control_key),

View file

@ -555,7 +555,6 @@ public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutCh
binding.volumeProgressBar.setMax(maxGestureLength); binding.volumeProgressBar.setMax(maxGestureLength);
binding.brightnessProgressBar.setMax(maxGestureLength); binding.brightnessProgressBar.setMax(maxGestureLength);
binding.playbackSpeedProgressBar.setMax(maxGestureLength);
setInitialGestureValues(); setInitialGestureValues();
binding.itemsListPanel.getLayoutParams().height = binding.itemsListPanel.getLayoutParams().height =

View file

@ -758,34 +758,6 @@
tools:src="@drawable/ic_brightness_high" /> tools:src="@drawable/ic_brightness_high" />
</RelativeLayout> </RelativeLayout>
<RelativeLayout
android:id="@+id/playbackSpeedRelativeLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/background_oval_black_transparent"
android:visibility="gone"
tools:visibility="visible">
<ProgressBar
android:id="@+id/playbackSpeedProgressBar"
style="?android:progressBarStyleHorizontal"
android:layout_width="128dp"
android:layout_height="128dp"
android:indeterminate="false"
android:progressDrawable="@drawable/progress_circular_white" />
<TextView
android:id="@+id/playbackSpeedTextView"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_centerInParent="true"
android:gravity="center"
android:textColor="@color/white"
android:textSize="18sp"
tools:ignore="ContentDescription" />
</RelativeLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/unskipButton" android:id="@+id/unskipButton"
android:visibility="gone" android:visibility="gone"

View file

@ -729,9 +729,8 @@
<string name="feed_show_upcoming">Demnächst</string> <string name="feed_show_upcoming">Demnächst</string>
<string name="feed_show_watched">Vollständig angeschaut</string> <string name="feed_show_watched">Vollständig angeschaut</string>
<string name="feed_show_partially_watched">Teilweise angeschaut</string> <string name="feed_show_partially_watched">Teilweise angeschaut</string>
<string name="left_gesture_control_summary">Geste für den linken Teil des Player-Bildschirms auswählen</string> <string name="left_gesture_control_summary">Geste für die linke Hälfte des Player-Bildschirms auswählen</string>
<string name="middle_gesture_control_title">Mittlere Gestenaktion</string> <string name="right_gesture_control_summary">Geste für die rechte Hälfte des Player-Bildschirms auswählen</string>
<string name="right_gesture_control_summary">Geste für den rechten Teil des Player-Bildschirms auswählen</string>
<string name="none">Keine</string> <string name="none">Keine</string>
<string name="right_gesture_control_title">Rechte Gestenaktion</string> <string name="right_gesture_control_title">Rechte Gestenaktion</string>
<string name="left_gesture_control_title">Linke Gestenaktion</string> <string name="left_gesture_control_title">Linke Gestenaktion</string>
@ -827,5 +826,4 @@
\nMöchtest du wirklich fortfahren?</string> \nMöchtest du wirklich fortfahren?</string>
<string name="import_settings_vulnerable_format">Die Einstellungen in dem zu importierenden Export verwenden ein angreifbares Format, das seit NewPipe 0.27.0 veraltet ist. Stellen Sie sicher, dass der zu importierende Export aus einer vertrauenswürdigen Quelle stammt, und verwenden Sie in Zukunft nur noch Exporte, die aus NewPipe 0.27.0 oder neuer stammen. Die Unterstützung für den Import von Einstellungen in diesem angreifbaren Format wird bald vollständig entfernt werden, und dann werden alte Versionen von NewPipe nicht mehr in der Lage sein, Einstellungen von Exporten aus neuen Versionen zu importieren.</string> <string name="import_settings_vulnerable_format">Die Einstellungen in dem zu importierenden Export verwenden ein angreifbares Format, das seit NewPipe 0.27.0 veraltet ist. Stellen Sie sicher, dass der zu importierende Export aus einer vertrauenswürdigen Quelle stammt, und verwenden Sie in Zukunft nur noch Exporte, die aus NewPipe 0.27.0 oder neuer stammen. Die Unterstützung für den Import von Einstellungen in diesem angreifbaren Format wird bald vollständig entfernt werden, und dann werden alte Versionen von NewPipe nicht mehr in der Lage sein, Einstellungen von Exporten aus neuen Versionen zu importieren.</string>
<string name="audio_track_type_secondary">Sekundär</string> <string name="audio_track_type_secondary">Sekundär</string>
<string name="middle_gesture_control_summary">Geste für den mittleren Teil des Player-Bildschirms auswählen</string>
</resources> </resources>

View file

@ -204,48 +204,28 @@
<string name="default_left_gesture_control_value">@string/brightness_control_key</string> <string name="default_left_gesture_control_value">@string/brightness_control_key</string>
<string name="brightness_control_key">brightness_control</string> <string name="brightness_control_key">brightness_control</string>
<string name="volume_control_key">volume_control</string> <string name="volume_control_key">volume_control</string>
<string name="playback_speed_control_key">playback_speed_control</string>
<string name="none_control_key">none_control</string> <string name="none_control_key">none_control</string>
<string-array name="left_gesture_control_description"> <string-array name="left_gesture_control_description">
<item>@string/brightness</item> <item>@string/brightness</item>
<item>@string/volume</item> <item>@string/volume</item>
<item>@string/playback_tempo</item>
<item>@string/none</item> <item>@string/none</item>
</string-array> </string-array>
<string-array name="left_gesture_control_values"> <string-array name="left_gesture_control_values">
<item>@string/brightness_control_key</item> <item>@string/brightness_control_key</item>
<item>@string/volume_control_key</item> <item>@string/volume_control_key</item>
<item>@string/playback_speed_control_key</item>
<item>@string/none_control_key</item>
</string-array>
<string name="middle_gesture_control_key">middle_gesture_control</string>
<string name="default_middle_gesture_control_value">@string/playback_speed_control_key</string>
<string-array name="middle_gesture_control_description">
<item>@string/brightness</item>
<item>@string/volume</item>
<item>@string/playback_tempo</item>
<item>@string/none</item>
</string-array>
<string-array name="middle_gesture_control_values">
<item>@string/brightness_control_key</item>
<item>@string/volume_control_key</item>
<item>@string/playback_speed_control_key</item>
<item>@string/none_control_key</item> <item>@string/none_control_key</item>
</string-array> </string-array>
<string name="right_gesture_control_key">right_gesture_control</string> <string name="right_gesture_control_key">right_gesture_control</string>
<string name="default_right_gesture_control_value">@string/volume_control_key</string> <string name="default_right_gesture_control_value">@string/volume_control_key</string>
<string-array name="right_gesture_control_description"> <string-array name="right_gesture_control_description">
<item>@string/brightness</item>
<item>@string/volume</item> <item>@string/volume</item>
<item>@string/playback_tempo</item> <item>@string/brightness</item>
<item>@string/none</item> <item>@string/none</item>
</string-array> </string-array>
<string-array name="right_gesture_control_values"> <string-array name="right_gesture_control_values">
<item>@string/brightness_control_key</item>
<item>@string/volume_control_key</item> <item>@string/volume_control_key</item>
<item>@string/playback_speed_control_key</item> <item>@string/brightness_control_key</item>
<item>@string/none_control_key</item> <item>@string/none_control_key</item>
</string-array> </string-array>

View file

@ -106,11 +106,9 @@
<string name="auto_queue_title">Auto-enqueue next stream</string> <string name="auto_queue_title">Auto-enqueue next stream</string>
<string name="auto_queue_summary">Continue ending (non-repeating) playback queue by appending a related stream</string> <string name="auto_queue_summary">Continue ending (non-repeating) playback queue by appending a related stream</string>
<string name="auto_queue_toggle">Auto-enqueuing</string> <string name="auto_queue_toggle">Auto-enqueuing</string>
<string name="left_gesture_control_summary">Choose gesture for left part of player screen</string> <string name="left_gesture_control_summary">Choose gesture for left half of player screen</string>
<string name="left_gesture_control_title">Left gesture action</string> <string name="left_gesture_control_title">Left gesture action</string>
<string name="middle_gesture_control_summary">Choose gesture for middle part of player screen</string> <string name="right_gesture_control_summary">Choose gesture for right half of player screen</string>
<string name="middle_gesture_control_title">Middle gesture action</string>
<string name="right_gesture_control_summary">Choose gesture for right part of player screen</string>
<string name="right_gesture_control_title">Right gesture action</string> <string name="right_gesture_control_title">Right gesture action</string>
<string name="brightness">Brightness</string> <string name="brightness">Brightness</string>
<string name="volume">Volume</string> <string name="volume">Volume</string>

View file

@ -198,16 +198,6 @@
app:singleLineTitle="false" app:singleLineTitle="false"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<ListPreference
android:defaultValue="@string/default_middle_gesture_control_value"
android:entries="@array/middle_gesture_control_description"
android:entryValues="@array/middle_gesture_control_values"
android:key="@string/middle_gesture_control_key"
android:summary="@string/middle_gesture_control_summary"
android:title="@string/middle_gesture_control_title"
app:singleLineTitle="false"
app:iconSpaceReserved="false" />
<ListPreference <ListPreference
android:defaultValue="@string/default_right_gesture_control_value" android:defaultValue="@string/default_right_gesture_control_value"
android:entries="@array/right_gesture_control_description" android:entries="@array/right_gesture_control_description"