Search in sources :

Example 11 with CaptionStyle

use of android.view.accessibility.CaptioningManager.CaptionStyle in project platform_frameworks_base by android.

the class WebVttRenderingWidget method manageChangeListener.

/**
     * Manages whether this renderer is listening for caption style changes.
     */
private void manageChangeListener() {
    final boolean needsListener = isAttachedToWindow() && getVisibility() == View.VISIBLE;
    if (mHasChangeListener != needsListener) {
        mHasChangeListener = needsListener;
        if (needsListener) {
            mManager.addCaptioningChangeListener(mCaptioningListener);
            final CaptionStyle captionStyle = mManager.getUserStyle();
            final float fontSize = mManager.getFontScale() * getHeight() * LINE_HEIGHT_RATIO;
            setCaptionStyle(captionStyle, fontSize);
        } else {
            mManager.removeCaptioningChangeListener(mCaptioningListener);
        }
    }
}
Also used : CaptionStyle(android.view.accessibility.CaptioningManager.CaptionStyle)

Example 12 with CaptionStyle

use of android.view.accessibility.CaptioningManager.CaptionStyle in project platform_frameworks_base by android.

the class SubtitleView method setStyle.

public void setStyle(int styleId) {
    final Context context = mContext;
    final ContentResolver cr = context.getContentResolver();
    final CaptionStyle style;
    if (styleId == CaptionStyle.PRESET_CUSTOM) {
        style = CaptionStyle.getCustomStyle(cr);
    } else {
        style = CaptionStyle.PRESETS[styleId];
    }
    final CaptionStyle defStyle = CaptionStyle.DEFAULT;
    mForegroundColor = style.hasForegroundColor() ? style.foregroundColor : defStyle.foregroundColor;
    mBackgroundColor = style.hasBackgroundColor() ? style.backgroundColor : defStyle.backgroundColor;
    mEdgeType = style.hasEdgeType() ? style.edgeType : defStyle.edgeType;
    mEdgeColor = style.hasEdgeColor() ? style.edgeColor : defStyle.edgeColor;
    mHasMeasurements = false;
    final Typeface typeface = style.getTypeface();
    setTypeface(typeface);
    requestLayout();
}
Also used : Context(android.content.Context) Typeface(android.graphics.Typeface) CaptionStyle(android.view.accessibility.CaptioningManager.CaptionStyle) ContentResolver(android.content.ContentResolver)

Example 13 with CaptionStyle

use of android.view.accessibility.CaptioningManager.CaptionStyle in project android_frameworks_base by DirtyUnicorns.

the class WebVttRenderingWidget method setActiveCues.

public void setActiveCues(Vector<SubtitleTrack.Cue> activeCues) {
    final Context context = getContext();
    final CaptionStyle captionStyle = mCaptionStyle;
    final float fontSize = mFontSize;
    prepForPrune();
    // Ensure we have all necessary cue and region boxes.
    final int count = activeCues.size();
    for (int i = 0; i < count; i++) {
        final TextTrackCue cue = (TextTrackCue) activeCues.get(i);
        final TextTrackRegion region = cue.mRegion;
        if (region != null) {
            RegionLayout regionBox = mRegionBoxes.get(region);
            if (regionBox == null) {
                regionBox = new RegionLayout(context, region, captionStyle, fontSize);
                mRegionBoxes.put(region, regionBox);
                addView(regionBox, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            }
            regionBox.put(cue);
        } else {
            CueLayout cueBox = mCueBoxes.get(cue);
            if (cueBox == null) {
                cueBox = new CueLayout(context, cue, captionStyle, fontSize);
                mCueBoxes.put(cue, cueBox);
                addView(cueBox, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            }
            cueBox.update();
            cueBox.setOrder(i);
        }
    }
    prune();
    // Force measurement and layout.
    final int width = getWidth();
    final int height = getHeight();
    setSize(width, height);
    if (mListener != null) {
        mListener.onChanged(this);
    }
}
Also used : Context(android.content.Context) CaptionStyle(android.view.accessibility.CaptioningManager.CaptionStyle)

Example 14 with CaptionStyle

use of android.view.accessibility.CaptioningManager.CaptionStyle in project android_frameworks_base by DirtyUnicorns.

the class WebVttRenderingWidget method manageChangeListener.

/**
     * Manages whether this renderer is listening for caption style changes.
     */
private void manageChangeListener() {
    final boolean needsListener = isAttachedToWindow() && getVisibility() == View.VISIBLE;
    if (mHasChangeListener != needsListener) {
        mHasChangeListener = needsListener;
        if (needsListener) {
            mManager.addCaptioningChangeListener(mCaptioningListener);
            final CaptionStyle captionStyle = mManager.getUserStyle();
            final float fontSize = mManager.getFontScale() * getHeight() * LINE_HEIGHT_RATIO;
            setCaptionStyle(captionStyle, fontSize);
        } else {
            mManager.removeCaptioningChangeListener(mCaptioningListener);
        }
    }
}
Also used : CaptionStyle(android.view.accessibility.CaptioningManager.CaptionStyle)

Example 15 with CaptionStyle

use of android.view.accessibility.CaptioningManager.CaptionStyle in project android_frameworks_base by AOSPA.

the class WebVttRenderingWidget method manageChangeListener.

/**
     * Manages whether this renderer is listening for caption style changes.
     */
private void manageChangeListener() {
    final boolean needsListener = isAttachedToWindow() && getVisibility() == View.VISIBLE;
    if (mHasChangeListener != needsListener) {
        mHasChangeListener = needsListener;
        if (needsListener) {
            mManager.addCaptioningChangeListener(mCaptioningListener);
            final CaptionStyle captionStyle = mManager.getUserStyle();
            final float fontSize = mManager.getFontScale() * getHeight() * LINE_HEIGHT_RATIO;
            setCaptionStyle(captionStyle, fontSize);
        } else {
            mManager.removeCaptioningChangeListener(mCaptioningListener);
        }
    }
}
Also used : CaptionStyle(android.view.accessibility.CaptioningManager.CaptionStyle)

Aggregations

CaptionStyle (android.view.accessibility.CaptioningManager.CaptionStyle)22 Context (android.content.Context)11 ContentResolver (android.content.ContentResolver)6 Typeface (android.graphics.Typeface)5 SubtitleView (com.android.internal.widget.SubtitleView)1 Locale (java.util.Locale)1