@Override public View onCreateOverlayView() { LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); mSubtitleView = (SubtitleLayout) inflater.inflate(R.layout.subtitleview, null); // Configure the subtitle view. CaptionStyleCompat captionStyle; float captionTextSize = getCaptionFontSize(); captionStyle = CaptionStyleCompat .createFromCaptionStyle(mCaptioningManager.getUserStyle()); captionTextSize *= mCaptioningManager.getFontScale(); mSubtitleView.setStyle(captionStyle); mSubtitleView.setFixedTextSize(TEXT_UNIT_PIXELS, captionTextSize); mSubtitleView.setVisibility(View.VISIBLE); return mSubtitleView; }
public CaptionWindowLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); // Add a subtitle view to the layout. mSubtitleView = new SubtitleView(context); LayoutParams params = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); addView(mSubtitleView, params); // Set the system wide cc preferences to the subtitle view. CaptioningManager captioningManager = (CaptioningManager) context.getSystemService(Context.CAPTIONING_SERVICE); mFontScale = captioningManager.getFontScale(); mCaptionStyleCompat = CaptionStyleCompat.createFromCaptionStyle(captioningManager.getUserStyle()); mSubtitleView.setStyle(mCaptionStyleCompat); mSubtitleView.setText(""); captioningManager.addCaptioningChangeListener(new SystemWideCaptioningChangeListener()); updateWidestChar(); }
private void configureSubtitleView() { CaptionStyleCompat style; float fontScale; if (Util.SDK_INT >= 19) { style = getUserCaptionStyleV19(); fontScale = getUserCaptionFontScaleV19(); } else { style = CaptionStyleCompat.DEFAULT; fontScale = 1.0f; } subtitleLayout.setStyle(style); subtitleLayout.setFractionalTextSize(SubtitleLayout.DEFAULT_TEXT_SIZE_FRACTION * fontScale); }
public void configureSubtitleView() { CaptionStyleCompat captionStyle; float captionFontScale; if (Util.SDK_INT >= 19) { captionStyle = getUserCaptionStyleV19(); captionFontScale = getUserCaptionFontScaleV19(); } else { captionStyle = CaptionStyleCompat.DEFAULT; captionFontScale = 1.0f; } subtitleLayout.setStyle(captionStyle); subtitleLayout.setFontScale(captionFontScale); }
private void configureSubtitleView() { CaptionStyleCompat captionStyle; float fontScale; if (Util.SDK_INT >= 19) { captionStyle = getUserCaptionStyleV19(); fontScale = getUserCaptionFontScaleV19(); } else { captionStyle = CaptionStyleCompat.DEFAULT; fontScale = 1.0f; } subtitleLayout.setStyle(captionStyle); subtitleLayout.setFractionalTextSize(SubtitleLayout.DEFAULT_TEXT_SIZE_FRACTION * fontScale); }
private void configureSubtitleView() { CaptionStyleCompat captionStyle; float captionTextSize = getCaptionFontSize(); if (Util.SDK_INT >= 19) { captionStyle = getUserCaptionStyleV19(); captionTextSize *= getUserCaptionFontScaleV19(); } else { captionStyle = CaptionStyleCompat.DEFAULT; } subtitleView.setStyle(captionStyle); subtitleView.setTextSize(captionTextSize); }
private void configureSubtitleView() { CaptionStyleCompat captionStyle; float captionFontScale; if (Util.SDK_INT >= 19) { captionStyle = getUserCaptionStyleV19(); captionFontScale = getUserCaptionFontScaleV19(); } else { captionStyle = CaptionStyleCompat.DEFAULT; captionFontScale = 1.0f; } subtitleLayout.setStyle(captionStyle); subtitleLayout.setFontScale(captionFontScale); }
private void configureSubtitleView() { CaptionStyleCompat style; float fontScale; if (Util.SDK_INT >= 19) { style = getUserCaptionStyleV19(); fontScale = getUserCaptionFontScaleV19(); } else { style = CaptionStyleCompat.DEFAULT; fontScale = 1.0f; } if (mSubtView != null) { mSubtView.setStyle(style); mSubtView.setFractionalTextSize(SubtitleLayout.DEFAULT_TEXT_SIZE_FRACTION * fontScale); } }
@TargetApi(19) private CaptionStyleCompat getUserCaptionStyleV19() { CaptioningManager captioningManager = (CaptioningManager) getSystemService(Context.CAPTIONING_SERVICE); return CaptionStyleCompat.createFromCaptionStyle(captioningManager.getUserStyle()); }
@Override public void onUserStyleChanged(CaptionStyle userStyle) { mCaptionStyleCompat = CaptionStyleCompat.createFromCaptionStyle(userStyle); mSubtitleView.setStyle(mCaptionStyleCompat); updateWidestChar(); }
@TargetApi(19) private CaptionStyleCompat getUserCaptionStyleV19() { CaptioningManager captioningManager = (CaptioningManager) mContext.getSystemService(Context.CAPTIONING_SERVICE); return CaptionStyleCompat.createFromCaptionStyle(captioningManager.getUserStyle()); }
@TargetApi(19) private CaptionStyleCompat getUserCaptionStyleV19() { CaptioningManager captioningManager = (CaptioningManager) activity.getSystemService(Context.CAPTIONING_SERVICE); return CaptionStyleCompat.createFromCaptionStyle(captioningManager.getUserStyle()); }
@TargetApi(19) private CaptionStyleCompat getUserCaptionStyleV19() { CaptioningManager captioningManager = (CaptioningManager) getContext().getSystemService(Context.CAPTIONING_SERVICE); return CaptionStyleCompat.createFromCaptionStyle(captioningManager.getUserStyle()); }