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

Remember adjustment step size for playback controls (speed and pitch) #7728

Merged
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 @@ -71,7 +71,6 @@ public class PlaybackParameterDialog extends DialogFragment {
private double tempo = DEFAULT_TEMPO;
private double pitch = DEFAULT_PITCH;
private int semitones = DEFAULT_SEMITONES;
private double stepSize = DEFAULT_STEP;

@Nullable
private SeekBar tempoSlider;
Expand Down Expand Up @@ -147,7 +146,6 @@ public void onCreate(@Nullable final Bundle savedInstanceState) {
tempo = savedInstanceState.getDouble(TEMPO_KEY, DEFAULT_TEMPO);
pitch = savedInstanceState.getDouble(PITCH_KEY, DEFAULT_PITCH);
semitones = percentToSemitones(pitch);
stepSize = savedInstanceState.getDouble(STEP_SIZE_KEY, DEFAULT_STEP);
}
}

Expand All @@ -159,7 +157,6 @@ public void onSaveInstanceState(final Bundle outState) {

outState.putDouble(TEMPO_KEY, getCurrentTempo());
outState.putDouble(PITCH_KEY, getCurrentPitch());
outState.putDouble(STEP_SIZE_KEY, getCurrentStepSize());
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -203,7 +200,7 @@ private void setupControlViews(@NonNull final View rootView) {

togglePitchSliderType(rootView);

setStepSize(stepSize);
setupStepSizeSelector(rootView);
}

private void togglePitchSliderType(@NonNull final View rootView) {
Expand Down Expand Up @@ -380,6 +377,10 @@ private void setupAdjustBySemitonesControl(@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));

final TextView stepSizeOnePercentText = rootView.findViewById(R.id.stepSizeOnePercent);
final TextView stepSizeFivePercentText = rootView.findViewById(R.id.stepSizeFivePercent);
final TextView stepSizeTenPercentText = rootView.findViewById(R.id.stepSizeTenPercent);
Expand Down Expand Up @@ -438,7 +439,10 @@ private void setupCombinedStepSizeSelector(@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));
Expand Down Expand Up @@ -665,10 +669,6 @@ private int getCurrentSemitones() {
return semitoneSlider == null ? semitones : semitoneSlider.getProgress() - 12;
}

private double getCurrentStepSize() {
return stepSize;
}

private boolean getCurrentSkipSilence() {
return skipSilenceCheckbox != null && skipSilenceCheckbox.isChecked();
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/settings_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
<string name="main_page_content_key">main_page_content</string>
<string name="enable_playback_resume_key">enable_playback_resume</string>
<string name="enable_playback_state_lists_key">enable_playback_state_lists</string>
<string name="adjustment_step_key">adjustment_step_key</string>
<string name="playback_unhook_key">playback_unhook_key</string>
<string name="playback_speed_key">playback_speed_key</string>
<string name="playback_pitch_key">playback_pitch_key</string>
Expand Down