Skip to content

Commit

Permalink
remember playback adjustment step size in (speed and pitch)
Browse files Browse the repository at this point in the history
..in PlaybackParameterDialog

Co-Authored-By: ktprograms <71804605+ktprograms@users.noreply.github.com>
Co-Authored-By: InfinityLoop1308 <96324692+infinityloop1308@users.noreply.github.com>
  • Loading branch information
3 people committed Nov 10, 2024
1 parent 5bfcf02 commit 7cf0225
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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());
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -177,7 +174,6 @@ private void setupControlViews(@NonNull final View rootView) {
setupTempoControl(rootView);
setupPitchControl(rootView);

setStepSize(stepSize);
setupStepSizeSelector(rootView);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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();
}
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 @@ -204,6 +204,7 @@
<string name="main_page_content_key" translatable="false">main_page_content</string>
<string name="enable_playback_resume_key" translatable="false">enable_playback_resume</string>
<string name="enable_playback_state_lists_key" translatable="false">enable_playback_state_lists</string>
<string name="adjustment_step_key">adjustment_step_key</string>
<string name="playback_unhook_key" translatable="false">playback_unhook_key</string>
<string name="playback_speed_key" translatable="false">playback_speed_key</string>
<string name="playback_pitch_key" translatable="false">playback_pitch_key</string>
Expand Down

0 comments on commit 7cf0225

Please sign in to comment.