Skip to content

Commit 4049abf

Browse files
author
martin
committed
Addressed comment in PR
1 parent 47798fe commit 4049abf

2 files changed

Lines changed: 28 additions & 53 deletions

File tree

app/src/main/java/org/schabi/newpipe/player/helper/PlaybackParameterDialog.java

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ public class PlaybackParameterDialog extends DialogFragment {
8282
@Nullable
8383
private TextView tempoStepUpText;
8484
@Nullable
85-
private RelativeLayout pitchControl;
86-
@Nullable
8785
private SeekBar pitchSlider;
8886
@Nullable
8987
private TextView pitchCurrentText;
@@ -92,8 +90,6 @@ public class PlaybackParameterDialog extends DialogFragment {
9290
@Nullable
9391
private TextView pitchStepUpText;
9492
@Nullable
95-
private RelativeLayout semitoneControl;
96-
@Nullable
9793
private SeekBar semitoneSlider;
9894
@Nullable
9995
private TextView semitoneCurrentText;
@@ -102,8 +98,6 @@ public class PlaybackParameterDialog extends DialogFragment {
10298
@Nullable
10399
private TextView semitoneStepUpText;
104100
@Nullable
105-
private View separatorStepSizeSelector;
106-
@Nullable
107101
private CheckBox unhookingCheckbox;
108102
@Nullable
109103
private CheckBox skipSilenceCheckbox;
@@ -213,11 +207,13 @@ private void setupControlViews(@NonNull final View rootView) {
213207
}
214208

215209
private void togglePitchSliderType(@NonNull final View rootView) {
210+
@Nullable
211+
final RelativeLayout pitchControl = rootView.findViewById(R.id.pitchControl);
212+
@Nullable
213+
final RelativeLayout semitoneControl = rootView.findViewById(R.id.semitoneControl);
216214

217-
pitchControl = rootView.findViewById(R.id.pitchControl);
218-
semitoneControl = rootView.findViewById(R.id.semitoneControl);
219-
220-
separatorStepSizeSelector = rootView.findViewById(R.id.separatorStepSizeSelector);
215+
@Nullable
216+
final View separatorStepSizeSelector = rootView.findViewById(R.id.separatorStepSizeSelector);
221217
final RelativeLayout.LayoutParams params =
222218
(RelativeLayout.LayoutParams) separatorStepSizeSelector.getLayoutParams();
223219
if (pitchControl != null && semitoneControl != null && unhookingCheckbox != null) {
@@ -364,10 +360,14 @@ private void setupAdjustBySemitonesControl(@NonNull final View rootView) {
364360
setPlaybackParameters(
365361
getCurrentTempo(),
366362
getCurrentPitch(),
367-
percentToSemitones(getCurrentPitch()),
363+
Integer.min(12,
364+
Integer.max(-12, percentToSemitones(getCurrentPitch())
365+
)),
368366
getCurrentSkipSilence()
369367
);
370-
setSemitoneSlider(percentToSemitones(getCurrentPitch()));
368+
setSemitoneSlider(Integer.min(12,
369+
Integer.max(-12, percentToSemitones(getCurrentPitch()))
370+
));
371371
} else {
372372
setPlaybackParameters(
373373
getCurrentTempo(),
@@ -546,7 +546,7 @@ private SeekBar.OnSeekBarChangeListener getOnSemitoneChangedListener() {
546546
@Override
547547
public void onProgressChanged(final SeekBar seekBar, final int progress,
548548
final boolean fromUser) {
549-
// semitone slider supplies values 0 to 25, subtraction by 12 is required
549+
// semitone slider supplies values 0 to 24, subtraction by 12 is required
550550
final int currentSemitones = progress - 12;
551551
if (fromUser) { // this change is first in chain
552552
onSemitoneSliderUpdated(currentSemitones);
@@ -569,9 +569,6 @@ public void onStopTrackingTouch(final SeekBar seekBar) {
569569
}
570570

571571
private void onTempoSliderUpdated(final double newTempo) {
572-
if (unhookingCheckbox == null) {
573-
return;
574-
}
575572
if (!unhookingCheckbox.isChecked()) {
576573
setSliders(newTempo);
577574
} else {
@@ -580,9 +577,6 @@ private void onTempoSliderUpdated(final double newTempo) {
580577
}
581578

582579
private void onPitchSliderUpdated(final double newPitch) {
583-
if (unhookingCheckbox == null) {
584-
return;
585-
}
586580
if (!unhookingCheckbox.isChecked()) {
587581
setSliders(newPitch);
588582
} else {
@@ -591,9 +585,6 @@ private void onPitchSliderUpdated(final double newPitch) {
591585
}
592586

593587
private void onSemitoneSliderUpdated(final int newSemitone) {
594-
if (unhookingCheckbox == null) {
595-
return;
596-
}
597588
setSemitoneSlider(newSemitone);
598589
}
599590

app/src/main/res/layout/dialog_playback_parameter.xml

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
android:text="--%"
4949
android:textColor="?attr/colorAccent"
5050
android:textStyle="bold"
51-
tools:ignore="HardcodedText"
52-
tools:text="-5%" />
51+
tools:ignore="HardcodedText"/>
5352

5453
<RelativeLayout
5554
android:layout_width="match_parent"
@@ -73,8 +72,7 @@
7372
android:gravity="center"
7473
android:text="-.--x"
7574
android:textColor="?attr/colorAccent"
76-
tools:ignore="HardcodedText"
77-
tools:text="1.00x" />
75+
tools:ignore="HardcodedText"/>
7876

7977
<org.schabi.newpipe.views.NewPipeTextView
8078
android:id="@+id/tempoCurrentText"
@@ -85,8 +83,7 @@
8583
android:text="---%"
8684
android:textColor="?attr/colorAccent"
8785
android:textStyle="bold"
88-
tools:ignore="HardcodedText"
89-
tools:text="100%" />
86+
tools:ignore="HardcodedText"/>
9087

9188
<org.schabi.newpipe.views.NewPipeTextView
9289
android:id="@+id/tempoMaximumText"
@@ -99,8 +96,7 @@
9996
android:gravity="center"
10097
android:text="---%"
10198
android:textColor="?attr/colorAccent"
102-
tools:ignore="HardcodedText"
103-
tools:text="300%" />
99+
tools:ignore="HardcodedText"/>
104100

105101
<androidx.appcompat.widget.AppCompatSeekBar
106102
android:id="@+id/tempoSeekbar"
@@ -128,8 +124,7 @@
128124
android:text="+-%"
129125
android:textColor="?attr/colorAccent"
130126
android:textStyle="bold"
131-
tools:ignore="HardcodedText"
132-
tools:text="+5%" />
127+
tools:ignore="HardcodedText"/>
133128
</RelativeLayout>
134129

135130
<View
@@ -176,8 +171,7 @@
176171
android:text="--%"
177172
android:textColor="?attr/colorAccent"
178173
android:textStyle="bold"
179-
tools:ignore="HardcodedText"
180-
tools:text="-5%" />
174+
tools:ignore="HardcodedText"/>
181175

182176
<RelativeLayout
183177
android:id="@+id/pitchDisplay"
@@ -202,8 +196,7 @@
202196
android:gravity="center"
203197
android:text="---%"
204198
android:textColor="?attr/colorAccent"
205-
tools:ignore="HardcodedText"
206-
tools:text="25%" />
199+
tools:ignore="HardcodedText"/>
207200

208201
<org.schabi.newpipe.views.NewPipeTextView
209202
android:id="@+id/pitchCurrentText"
@@ -214,8 +207,7 @@
214207
android:text="---%"
215208
android:textColor="?attr/colorAccent"
216209
android:textStyle="bold"
217-
tools:ignore="HardcodedText"
218-
tools:text="100%" />
210+
tools:ignore="HardcodedText"/>
219211

220212
<org.schabi.newpipe.views.NewPipeTextView
221213
android:id="@+id/pitchMaximumText"
@@ -228,8 +220,7 @@
228220
android:gravity="center"
229221
android:text="---%"
230222
android:textColor="?attr/colorAccent"
231-
tools:ignore="HardcodedText"
232-
tools:text="300%" />
223+
tools:ignore="HardcodedText"/>
233224

234225
<androidx.appcompat.widget.AppCompatSeekBar
235226
android:id="@+id/pitchSeekbar"
@@ -257,8 +248,7 @@
257248
android:text="+-%"
258249
android:textColor="?attr/colorAccent"
259250
android:textStyle="bold"
260-
tools:ignore="HardcodedText"
261-
tools:text="+5%" />
251+
tools:ignore="HardcodedText"/>
262252
</RelativeLayout>
263253

264254
<RelativeLayout
@@ -284,8 +274,7 @@
284274
android:textColor="?attr/colorAccent"
285275
android:textSize="24sp"
286276
android:textStyle="bold"
287-
tools:ignore="HardcodedText"
288-
tools:text="" />
277+
tools:ignore="HardcodedText"/>
289278

290279
<RelativeLayout
291280
android:id="@+id/semitoneDisplay"
@@ -310,20 +299,17 @@
310299
android:gravity="center"
311300
android:text="-12"
312301
android:textColor="?attr/colorAccent"
313-
tools:ignore="HardcodedText"
314-
tools:text="-12" />
302+
tools:ignore="HardcodedText"/>
315303

316304
<org.schabi.newpipe.views.NewPipeTextView
317305
android:id="@+id/semitoneCurrentText"
318306
android:layout_width="wrap_content"
319307
android:layout_height="wrap_content"
320308
android:layout_centerHorizontal="true"
321309
android:gravity="center"
322-
android:text="--"
323310
android:textColor="?attr/colorAccent"
324311
android:textStyle="bold"
325-
tools:ignore="HardcodedText"
326-
tools:text="0" />
312+
tools:ignore="HardcodedText"/>
327313

328314
<org.schabi.newpipe.views.NewPipeTextView
329315
android:id="@+id/semitoneMaximumText"
@@ -336,8 +322,7 @@
336322
android:gravity="center"
337323
android:text="+12"
338324
android:textColor="?attr/colorAccent"
339-
tools:ignore="HardcodedText"
340-
tools:text="+12" />
325+
tools:ignore="HardcodedText"/>
341326

342327
<androidx.appcompat.widget.AppCompatSeekBar
343328
android:id="@+id/semitoneSeekbar"
@@ -367,8 +352,7 @@
367352
android:textColor="?attr/colorAccent"
368353
android:textSize="20sp"
369354
android:textStyle="bold"
370-
tools:ignore="HardcodedText"
371-
tools:text="" />
355+
tools:ignore="HardcodedText"/>
372356
</RelativeLayout>
373357

374358
<View

0 commit comments

Comments
 (0)