package com.google.android.exoplayer2.ui; import android.content.Context; import android.content.res.Resources; import android.util.AttributeSet; import android.util.TypedValue; import android.view.View; import android.view.accessibility.CaptioningManager; import android.widget.FrameLayout; import androidx.annotation.Dimension; import androidx.annotation.Nullable; import com.amazonaws.handlers.HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0; import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.util.Util; import java.util.ArrayList; import java.util.Collections; import java.util.List; /* loaded from: classes2.dex */ public final class SubtitleView extends FrameLayout { public boolean applyEmbeddedFontSizes; public boolean applyEmbeddedStyles; public float bottomPaddingFraction; public List cues; public float defaultTextSize; public int defaultTextSizeType; public View innerSubtitleView; public Output output; public CaptionStyleCompat style; public int viewType; public interface Output { void update(List list, CaptionStyleCompat captionStyleCompat, float f, int i, float f2); } public SubtitleView(Context context) { this(context, null); } public SubtitleView(Context context, @Nullable AttributeSet attributeSet) { super(context, attributeSet); this.cues = Collections.emptyList(); this.style = CaptionStyleCompat.DEFAULT; this.defaultTextSizeType = 0; this.defaultTextSize = 0.0533f; this.bottomPaddingFraction = 0.08f; this.applyEmbeddedStyles = true; this.applyEmbeddedFontSizes = true; CanvasSubtitleOutput canvasSubtitleOutput = new CanvasSubtitleOutput(context); this.output = canvasSubtitleOutput; this.innerSubtitleView = canvasSubtitleOutput; addView(canvasSubtitleOutput); this.viewType = 1; } public void setCues(@Nullable List list) { if (list == null) { list = Collections.emptyList(); } this.cues = list; updateOutput(); } public void setViewType(int i) { if (this.viewType == i) { return; } if (i == 1) { setView(new CanvasSubtitleOutput(getContext())); } else if (i == 2) { setView(new WebViewSubtitleOutput(getContext())); } else { throw new IllegalArgumentException(); } this.viewType = i; } /* JADX WARN: Multi-variable type inference failed */ public final void setView(View view) { removeView(this.innerSubtitleView); View view2 = this.innerSubtitleView; if (view2 instanceof WebViewSubtitleOutput) { ((WebViewSubtitleOutput) view2).destroy(); } this.innerSubtitleView = view; this.output = (Output) view; addView(view); } public void setFixedTextSize(@Dimension int i, float f) { Resources resources; Context context = getContext(); if (context == null) { resources = Resources.getSystem(); } else { resources = context.getResources(); } setTextSize(2, TypedValue.applyDimension(i, f, resources.getDisplayMetrics())); } public void setUserDefaultTextSize() { setFractionalTextSize(getUserCaptionFontScale() * 0.0533f); } public void setFractionalTextSize(float f) { setFractionalTextSize(f, false); } public void setFractionalTextSize(float f, boolean z) { setTextSize(z ? 1 : 0, f); } public final void setTextSize(int i, float f) { this.defaultTextSizeType = i; this.defaultTextSize = f; updateOutput(); } public void setApplyEmbeddedStyles(boolean z) { this.applyEmbeddedStyles = z; updateOutput(); } public void setApplyEmbeddedFontSizes(boolean z) { this.applyEmbeddedFontSizes = z; updateOutput(); } public void setUserDefaultStyle() { setStyle(getUserCaptionStyle()); } public void setStyle(CaptionStyleCompat captionStyleCompat) { this.style = captionStyleCompat; updateOutput(); } public void setBottomPaddingFraction(float f) { this.bottomPaddingFraction = f; updateOutput(); } public final float getUserCaptionFontScale() { CaptioningManager captioningManager; if (Util.SDK_INT < 19 || isInEditMode() || (captioningManager = (CaptioningManager) getContext().getSystemService("captioning")) == null || !captioningManager.isEnabled()) { return 1.0f; } return captioningManager.getFontScale(); } public final CaptionStyleCompat getUserCaptionStyle() { if (Util.SDK_INT < 19 || isInEditMode()) { return CaptionStyleCompat.DEFAULT; } CaptioningManager captioningManager = (CaptioningManager) getContext().getSystemService("captioning"); if (captioningManager != null && captioningManager.isEnabled()) { return CaptionStyleCompat.createFromCaptionStyle(captioningManager.getUserStyle()); } return CaptionStyleCompat.DEFAULT; } public final void updateOutput() { this.output.update(getCuesWithStylingPreferencesApplied(), this.style, this.defaultTextSize, this.defaultTextSizeType, this.bottomPaddingFraction); } public final List getCuesWithStylingPreferencesApplied() { if (this.applyEmbeddedStyles && this.applyEmbeddedFontSizes) { return this.cues; } ArrayList arrayList = new ArrayList(this.cues.size()); for (int i = 0; i < this.cues.size(); i++) { HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0.m(this.cues.get(i)); removeEmbeddedStyling(null); arrayList.add(null); } return arrayList; } public final Cue removeEmbeddedStyling(Cue cue) { throw null; } }