From 7cf02253863df331c12459d1f0f778d606e5d41d Mon Sep 17 00:00:00 2001
From: ShareASmile <60492161+ShareASmile@users.noreply.github.com>
Date: Mon, 11 Nov 2024 04:30:33 +0530
Subject: [PATCH] remember playback adjustment step size in (speed and pitch)
..in PlaybackParameterDialog
Co-Authored-By: ktprograms <71804605+ktprograms@users.noreply.github.com>
Co-Authored-By: InfinityLoop1308 <96324692+infinityloop1308@users.noreply.github.com>
---
.../player/helper/PlaybackParameterDialog.java | 17 ++++++++---------
app/src/main/res/values/settings_keys.xml | 1 +
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/app/src/main/java/org/schabi/newpipelegacy/player/helper/PlaybackParameterDialog.java b/app/src/main/java/org/schabi/newpipelegacy/player/helper/PlaybackParameterDialog.java
index dbe94a289..9a0cdfaa5 100644
--- a/app/src/main/java/org/schabi/newpipelegacy/player/helper/PlaybackParameterDialog.java
+++ b/app/src/main/java/org/schabi/newpipelegacy/player/helper/PlaybackParameterDialog.java
@@ -66,7 +66,6 @@ public class PlaybackParameterDialog extends DialogFragment {
private boolean initialSkipSilence = DEFAULT_SKIP_SILENCE;
private double tempo = DEFAULT_TEMPO;
private double pitch = DEFAULT_PITCH;
- private double stepSize = DEFAULT_STEP;
@Nullable
private SeekBar tempoSlider;
@@ -127,7 +126,6 @@ public void onCreate(@Nullable final Bundle savedInstanceState) {
tempo = savedInstanceState.getDouble(TEMPO_KEY, DEFAULT_TEMPO);
pitch = savedInstanceState.getDouble(PITCH_KEY, DEFAULT_PITCH);
- stepSize = savedInstanceState.getDouble(STEP_SIZE_KEY, DEFAULT_STEP);
}
}
@@ -139,7 +137,6 @@ public void onSaveInstanceState(final Bundle outState) {
outState.putDouble(TEMPO_KEY, getCurrentTempo());
outState.putDouble(PITCH_KEY, getCurrentPitch());
- outState.putDouble(STEP_SIZE_KEY, getCurrentStepSize());
}
/*//////////////////////////////////////////////////////////////////////////
@@ -177,7 +174,6 @@ private void setupControlViews(@NonNull final View rootView) {
setupTempoControl(rootView);
setupPitchControl(rootView);
- setStepSize(stepSize);
setupStepSizeSelector(rootView);
}
@@ -265,6 +261,10 @@ private void setupSkipSilenceControl(@NonNull final View rootView) {
}
private void setupStepSizeSelector(@NonNull final View rootView) {
+ setStepSize(PreferenceManager
+ .getDefaultSharedPreferences(requireContext())
+ .getFloat(getString(R.string.adjustment_step_key), (float) DEFAULT_STEP));
+
TextView stepSizeOnePercentText = rootView.findViewById(R.id.stepSizeOnePercent);
TextView stepSizeFivePercentText = rootView.findViewById(R.id.stepSizeFivePercent);
TextView stepSizeTenPercentText = rootView.findViewById(R.id.stepSizeTenPercent);
@@ -307,7 +307,10 @@ private void setupStepSizeSelector(@NonNull final View rootView) {
}
private void setStepSize(final double stepSize) {
- this.stepSize = stepSize;
+ PreferenceManager.getDefaultSharedPreferences(requireContext())
+ .edit()
+ .putFloat(getString(R.string.adjustment_step_key), (float) stepSize)
+ .apply();
if (tempoStepUpText != null) {
tempoStepUpText.setText(getStepUpPercentString(stepSize));
@@ -466,10 +469,6 @@ private double getCurrentPitch() {
return pitchSlider == null ? pitch : strategy.valueOf(pitchSlider.getProgress());
}
- private double getCurrentStepSize() {
- return stepSize;
- }
-
private boolean getCurrentSkipSilence() {
return skipSilenceCheckbox != null && skipSilenceCheckbox.isChecked();
}
diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml
index edb3c03ae..a06ccde4b 100644
--- a/app/src/main/res/values/settings_keys.xml
+++ b/app/src/main/res/values/settings_keys.xml
@@ -204,6 +204,7 @@
main_page_content
enable_playback_resume
enable_playback_state_lists
+ adjustment_step_key
playback_unhook_key
playback_speed_key
playback_pitch_key