Addressed comment in PR

This commit is contained in:
martin 2022-02-04 16:15:55 +01:00
parent 47798febed
commit 4049abf2c0
2 changed files with 28 additions and 53 deletions

View file

@ -82,8 +82,6 @@ public class PlaybackParameterDialog extends DialogFragment {
@Nullable @Nullable
private TextView tempoStepUpText; private TextView tempoStepUpText;
@Nullable @Nullable
private RelativeLayout pitchControl;
@Nullable
private SeekBar pitchSlider; private SeekBar pitchSlider;
@Nullable @Nullable
private TextView pitchCurrentText; private TextView pitchCurrentText;
@ -92,8 +90,6 @@ public class PlaybackParameterDialog extends DialogFragment {
@Nullable @Nullable
private TextView pitchStepUpText; private TextView pitchStepUpText;
@Nullable @Nullable
private RelativeLayout semitoneControl;
@Nullable
private SeekBar semitoneSlider; private SeekBar semitoneSlider;
@Nullable @Nullable
private TextView semitoneCurrentText; private TextView semitoneCurrentText;
@ -102,8 +98,6 @@ public class PlaybackParameterDialog extends DialogFragment {
@Nullable @Nullable
private TextView semitoneStepUpText; private TextView semitoneStepUpText;
@Nullable @Nullable
private View separatorStepSizeSelector;
@Nullable
private CheckBox unhookingCheckbox; private CheckBox unhookingCheckbox;
@Nullable @Nullable
private CheckBox skipSilenceCheckbox; private CheckBox skipSilenceCheckbox;
@ -213,11 +207,13 @@ public class PlaybackParameterDialog extends DialogFragment {
} }
private void togglePitchSliderType(@NonNull final View rootView) { private void togglePitchSliderType(@NonNull final View rootView) {
@Nullable
final RelativeLayout pitchControl = rootView.findViewById(R.id.pitchControl);
@Nullable
final RelativeLayout semitoneControl = rootView.findViewById(R.id.semitoneControl);
pitchControl = rootView.findViewById(R.id.pitchControl); @Nullable
semitoneControl = rootView.findViewById(R.id.semitoneControl); final View separatorStepSizeSelector = rootView.findViewById(R.id.separatorStepSizeSelector);
separatorStepSizeSelector = rootView.findViewById(R.id.separatorStepSizeSelector);
final RelativeLayout.LayoutParams params = final RelativeLayout.LayoutParams params =
(RelativeLayout.LayoutParams) separatorStepSizeSelector.getLayoutParams(); (RelativeLayout.LayoutParams) separatorStepSizeSelector.getLayoutParams();
if (pitchControl != null && semitoneControl != null && unhookingCheckbox != null) { if (pitchControl != null && semitoneControl != null && unhookingCheckbox != null) {
@ -364,10 +360,14 @@ public class PlaybackParameterDialog extends DialogFragment {
setPlaybackParameters( setPlaybackParameters(
getCurrentTempo(), getCurrentTempo(),
getCurrentPitch(), getCurrentPitch(),
percentToSemitones(getCurrentPitch()), Integer.min(12,
Integer.max(-12, percentToSemitones(getCurrentPitch())
)),
getCurrentSkipSilence() getCurrentSkipSilence()
); );
setSemitoneSlider(percentToSemitones(getCurrentPitch())); setSemitoneSlider(Integer.min(12,
Integer.max(-12, percentToSemitones(getCurrentPitch()))
));
} else { } else {
setPlaybackParameters( setPlaybackParameters(
getCurrentTempo(), getCurrentTempo(),
@ -546,7 +546,7 @@ public class PlaybackParameterDialog extends DialogFragment {
@Override @Override
public void onProgressChanged(final SeekBar seekBar, final int progress, public void onProgressChanged(final SeekBar seekBar, final int progress,
final boolean fromUser) { final boolean fromUser) {
// semitone slider supplies values 0 to 25, subtraction by 12 is required // semitone slider supplies values 0 to 24, subtraction by 12 is required
final int currentSemitones = progress - 12; final int currentSemitones = progress - 12;
if (fromUser) { // this change is first in chain if (fromUser) { // this change is first in chain
onSemitoneSliderUpdated(currentSemitones); onSemitoneSliderUpdated(currentSemitones);
@ -569,9 +569,6 @@ public class PlaybackParameterDialog extends DialogFragment {
} }
private void onTempoSliderUpdated(final double newTempo) { private void onTempoSliderUpdated(final double newTempo) {
if (unhookingCheckbox == null) {
return;
}
if (!unhookingCheckbox.isChecked()) { if (!unhookingCheckbox.isChecked()) {
setSliders(newTempo); setSliders(newTempo);
} else { } else {
@ -580,9 +577,6 @@ public class PlaybackParameterDialog extends DialogFragment {
} }
private void onPitchSliderUpdated(final double newPitch) { private void onPitchSliderUpdated(final double newPitch) {
if (unhookingCheckbox == null) {
return;
}
if (!unhookingCheckbox.isChecked()) { if (!unhookingCheckbox.isChecked()) {
setSliders(newPitch); setSliders(newPitch);
} else { } else {
@ -591,9 +585,6 @@ public class PlaybackParameterDialog extends DialogFragment {
} }
private void onSemitoneSliderUpdated(final int newSemitone) { private void onSemitoneSliderUpdated(final int newSemitone) {
if (unhookingCheckbox == null) {
return;
}
setSemitoneSlider(newSemitone); setSemitoneSlider(newSemitone);
} }

View file

@ -48,8 +48,7 @@
android:text="--%" android:text="--%"
android:textColor="?attr/colorAccent" android:textColor="?attr/colorAccent"
android:textStyle="bold" android:textStyle="bold"
tools:ignore="HardcodedText" tools:ignore="HardcodedText"/>
tools:text="-5%" />
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -73,8 +72,7 @@
android:gravity="center" android:gravity="center"
android:text="-.--x" android:text="-.--x"
android:textColor="?attr/colorAccent" android:textColor="?attr/colorAccent"
tools:ignore="HardcodedText" tools:ignore="HardcodedText"/>
tools:text="1.00x" />
<org.schabi.newpipe.views.NewPipeTextView <org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/tempoCurrentText" android:id="@+id/tempoCurrentText"
@ -85,8 +83,7 @@
android:text="---%" android:text="---%"
android:textColor="?attr/colorAccent" android:textColor="?attr/colorAccent"
android:textStyle="bold" android:textStyle="bold"
tools:ignore="HardcodedText" tools:ignore="HardcodedText"/>
tools:text="100%" />
<org.schabi.newpipe.views.NewPipeTextView <org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/tempoMaximumText" android:id="@+id/tempoMaximumText"
@ -99,8 +96,7 @@
android:gravity="center" android:gravity="center"
android:text="---%" android:text="---%"
android:textColor="?attr/colorAccent" android:textColor="?attr/colorAccent"
tools:ignore="HardcodedText" tools:ignore="HardcodedText"/>
tools:text="300%" />
<androidx.appcompat.widget.AppCompatSeekBar <androidx.appcompat.widget.AppCompatSeekBar
android:id="@+id/tempoSeekbar" android:id="@+id/tempoSeekbar"
@ -128,8 +124,7 @@
android:text="+-%" android:text="+-%"
android:textColor="?attr/colorAccent" android:textColor="?attr/colorAccent"
android:textStyle="bold" android:textStyle="bold"
tools:ignore="HardcodedText" tools:ignore="HardcodedText"/>
tools:text="+5%" />
</RelativeLayout> </RelativeLayout>
<View <View
@ -176,8 +171,7 @@
android:text="--%" android:text="--%"
android:textColor="?attr/colorAccent" android:textColor="?attr/colorAccent"
android:textStyle="bold" android:textStyle="bold"
tools:ignore="HardcodedText" tools:ignore="HardcodedText"/>
tools:text="-5%" />
<RelativeLayout <RelativeLayout
android:id="@+id/pitchDisplay" android:id="@+id/pitchDisplay"
@ -202,8 +196,7 @@
android:gravity="center" android:gravity="center"
android:text="---%" android:text="---%"
android:textColor="?attr/colorAccent" android:textColor="?attr/colorAccent"
tools:ignore="HardcodedText" tools:ignore="HardcodedText"/>
tools:text="25%" />
<org.schabi.newpipe.views.NewPipeTextView <org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/pitchCurrentText" android:id="@+id/pitchCurrentText"
@ -214,8 +207,7 @@
android:text="---%" android:text="---%"
android:textColor="?attr/colorAccent" android:textColor="?attr/colorAccent"
android:textStyle="bold" android:textStyle="bold"
tools:ignore="HardcodedText" tools:ignore="HardcodedText"/>
tools:text="100%" />
<org.schabi.newpipe.views.NewPipeTextView <org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/pitchMaximumText" android:id="@+id/pitchMaximumText"
@ -228,8 +220,7 @@
android:gravity="center" android:gravity="center"
android:text="---%" android:text="---%"
android:textColor="?attr/colorAccent" android:textColor="?attr/colorAccent"
tools:ignore="HardcodedText" tools:ignore="HardcodedText"/>
tools:text="300%" />
<androidx.appcompat.widget.AppCompatSeekBar <androidx.appcompat.widget.AppCompatSeekBar
android:id="@+id/pitchSeekbar" android:id="@+id/pitchSeekbar"
@ -257,8 +248,7 @@
android:text="+-%" android:text="+-%"
android:textColor="?attr/colorAccent" android:textColor="?attr/colorAccent"
android:textStyle="bold" android:textStyle="bold"
tools:ignore="HardcodedText" tools:ignore="HardcodedText"/>
tools:text="+5%" />
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout
@ -284,8 +274,7 @@
android:textColor="?attr/colorAccent" android:textColor="?attr/colorAccent"
android:textSize="24sp" android:textSize="24sp"
android:textStyle="bold" android:textStyle="bold"
tools:ignore="HardcodedText" tools:ignore="HardcodedText"/>
tools:text="♭" />
<RelativeLayout <RelativeLayout
android:id="@+id/semitoneDisplay" android:id="@+id/semitoneDisplay"
@ -310,8 +299,7 @@
android:gravity="center" android:gravity="center"
android:text="-12" android:text="-12"
android:textColor="?attr/colorAccent" android:textColor="?attr/colorAccent"
tools:ignore="HardcodedText" tools:ignore="HardcodedText"/>
tools:text="-12" />
<org.schabi.newpipe.views.NewPipeTextView <org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/semitoneCurrentText" android:id="@+id/semitoneCurrentText"
@ -319,11 +307,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:gravity="center" android:gravity="center"
android:text="--"
android:textColor="?attr/colorAccent" android:textColor="?attr/colorAccent"
android:textStyle="bold" android:textStyle="bold"
tools:ignore="HardcodedText" tools:ignore="HardcodedText"/>
tools:text="0" />
<org.schabi.newpipe.views.NewPipeTextView <org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/semitoneMaximumText" android:id="@+id/semitoneMaximumText"
@ -336,8 +322,7 @@
android:gravity="center" android:gravity="center"
android:text="+12" android:text="+12"
android:textColor="?attr/colorAccent" android:textColor="?attr/colorAccent"
tools:ignore="HardcodedText" tools:ignore="HardcodedText"/>
tools:text="+12" />
<androidx.appcompat.widget.AppCompatSeekBar <androidx.appcompat.widget.AppCompatSeekBar
android:id="@+id/semitoneSeekbar" android:id="@+id/semitoneSeekbar"
@ -367,8 +352,7 @@
android:textColor="?attr/colorAccent" android:textColor="?attr/colorAccent"
android:textSize="20sp" android:textSize="20sp"
android:textStyle="bold" android:textStyle="bold"
tools:ignore="HardcodedText" tools:ignore="HardcodedText"/>
tools:text="♯" />
</RelativeLayout> </RelativeLayout>
<View <View