Search in sources :

Example 16 with CaptionStyle

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

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 17 with CaptionStyle

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

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 18 with CaptionStyle

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

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 19 with CaptionStyle

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

the class Cea608CCWidget method updateDisplay.

private void updateDisplay() {
    if (mListener != null) {
        CaptionStyle captionStyle = mListener.getCaptionStyle();
        mListener.onDisplayChanged(mDisplay.getStyledText(captionStyle));
    }
}
Also used : CaptionStyle(android.view.accessibility.CaptioningManager.CaptionStyle)

Example 20 with CaptionStyle

use of android.view.accessibility.CaptioningManager.CaptionStyle in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class CaptionPropertiesFragment method refreshPreviewText.

private void refreshPreviewText() {
    final Context context = getActivity();
    if (context == null) {
        // We've been destroyed, abort!
        return;
    }
    final SubtitleView preview = mPreviewText;
    if (preview != null) {
        final int styleId = mCaptioningManager.getRawUserStyle();
        applyCaptionProperties(mCaptioningManager, preview, mPreviewViewport, styleId);
        final Locale locale = mCaptioningManager.getLocale();
        if (locale != null) {
            final CharSequence localizedText = AccessibilityUtils.getTextForLocale(context, locale, R.string.captioning_preview_text);
            preview.setText(localizedText);
        } else {
            preview.setText(R.string.captioning_preview_text);
        }
        final CaptionStyle style = mCaptioningManager.getUserStyle();
        if (style.hasWindowColor()) {
            mPreviewWindow.setBackgroundColor(style.windowColor);
        } else {
            final CaptionStyle defStyle = CaptionStyle.DEFAULT;
            mPreviewWindow.setBackgroundColor(defStyle.windowColor);
        }
    }
}
Also used : Context(android.content.Context) Locale(java.util.Locale) SubtitleView(com.android.internal.widget.SubtitleView) 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