Skip to content

Commit 83f8141

Browse files
authored
Merge pull request #11806 from Thompson3142/fix_subtitle_size
Fix caption sizes not being changed
2 parents 9253640 + 86203d6 commit 83f8141

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

app/src/main/java/org/schabi/newpipe/player/ui/MainPlayerUi.java

+3-7
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
import android.os.Handler;
2626
import android.os.Looper;
2727
import android.provider.Settings;
28-
import android.util.DisplayMetrics;
2928
import android.util.Log;
30-
import android.util.TypedValue;
3129
import android.view.KeyEvent;
3230
import android.view.View;
3331
import android.view.ViewGroup;
@@ -44,6 +42,7 @@
4442
import androidx.recyclerview.widget.ItemTouchHelper;
4543
import androidx.recyclerview.widget.RecyclerView;
4644

45+
import com.google.android.exoplayer2.ui.SubtitleView;
4746
import com.google.android.exoplayer2.video.VideoSize;
4847

4948
import org.schabi.newpipe.R;
@@ -522,11 +521,8 @@ private void showHideKodiButton() {
522521

523522
@Override
524523
protected void setupSubtitleView(final float captionScale) {
525-
final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
526-
final int minimumLength = Math.min(metrics.heightPixels, metrics.widthPixels);
527-
final float captionRatioInverse = 20f + 4f * (1.0f - captionScale);
528-
binding.subtitleView.setFixedTextSize(
529-
TypedValue.COMPLEX_UNIT_PX, minimumLength / captionRatioInverse);
524+
binding.subtitleView.setFractionalTextSize(
525+
SubtitleView.DEFAULT_TEXT_SIZE_FRACTION * captionScale);
530526
}
531527
//endregion
532528

app/src/main/java/org/schabi/newpipe/player/ui/PopupPlayerUi.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,8 @@ public void onCompleted() {
424424

425425
@Override
426426
protected void setupSubtitleView(final float captionScale) {
427-
final float captionRatio = (captionScale - 1.0f) / 5.0f + 1.0f;
428427
binding.subtitleView.setFractionalTextSize(
429-
SubtitleView.DEFAULT_TEXT_SIZE_FRACTION * captionRatio);
428+
SubtitleView.DEFAULT_TEXT_SIZE_FRACTION * captionScale);
430429
}
431430

432431
@Override

app/src/main/java/org/schabi/newpipe/player/ui/VideoPlayerUi.java

+4
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,10 @@ private void setupSubtitleView() {
14141414
binding.subtitleView.setStyle(captionStyle);
14151415
}
14161416

1417+
/**
1418+
*
1419+
* @param captionScale Value returned by {@link PlayerHelper#getCaptionScale}.
1420+
*/
14171421
protected abstract void setupSubtitleView(float captionScale);
14181422
//endregion
14191423

0 commit comments

Comments
 (0)