Fields Summary |
---|
private static final int | DEFAULT_ENABLEDDefault captioning enabled value. |
private static final int | DEFAULT_PRESETDefault style preset as an index into {@link CaptionStyle#PRESETS}. |
private static final float | DEFAULT_FONT_SCALEDefault scaling value for caption fonts. |
private final ArrayList | mListeners |
private final android.os.Handler | mHandler |
private final android.content.ContentResolver | mContentResolver |
private final android.database.ContentObserver | mContentObserver |
private final Runnable | mStyleChangedRunnableRunnable posted when user style properties change. This is used to
prevent unnecessary change notifications when multiple properties change
in rapid succession. |
Methods Summary |
---|
public void | addCaptioningChangeListener(android.view.accessibility.CaptioningManager$CaptioningChangeListener listener)Adds a listener for changes in the user's preferred captioning enabled
state and visual properties.
synchronized (mListeners) {
if (mListeners.isEmpty()) {
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_ENABLED);
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR);
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR);
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_WINDOW_COLOR);
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_EDGE_TYPE);
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_EDGE_COLOR);
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_TYPEFACE);
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE);
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_LOCALE);
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_PRESET);
}
mListeners.add(listener);
}
|
public final float | getFontScale()
return Secure.getFloat(
mContentResolver, Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE, DEFAULT_FONT_SCALE);
|
public final java.util.Locale | getLocale()
final String rawLocale = getRawLocale();
if (!TextUtils.isEmpty(rawLocale)) {
final String[] splitLocale = rawLocale.split("_");
switch (splitLocale.length) {
case 3:
return new Locale(splitLocale[0], splitLocale[1], splitLocale[2]);
case 2:
return new Locale(splitLocale[0], splitLocale[1]);
case 1:
return new Locale(splitLocale[0]);
}
}
return null;
|
public final java.lang.String | getRawLocale()
return Secure.getString(mContentResolver, Secure.ACCESSIBILITY_CAPTIONING_LOCALE);
|
public int | getRawUserStyle()
return Secure.getInt(
mContentResolver, Secure.ACCESSIBILITY_CAPTIONING_PRESET, DEFAULT_PRESET);
|
public android.view.accessibility.CaptioningManager$CaptionStyle | getUserStyle()
final int preset = getRawUserStyle();
if (preset == CaptionStyle.PRESET_CUSTOM) {
return CaptionStyle.getCustomStyle(mContentResolver);
}
return CaptionStyle.PRESETS[preset];
|
public final boolean | isEnabled()
return Secure.getInt(
mContentResolver, Secure.ACCESSIBILITY_CAPTIONING_ENABLED, DEFAULT_ENABLED) == 1;
|
private void | notifyEnabledChanged()
final boolean enabled = isEnabled();
synchronized (mListeners) {
for (CaptioningChangeListener listener : mListeners) {
listener.onEnabledChanged(enabled);
}
}
|
private void | notifyFontScaleChanged()
final float fontScale = getFontScale();
synchronized (mListeners) {
for (CaptioningChangeListener listener : mListeners) {
listener.onFontScaleChanged(fontScale);
}
}
|
private void | notifyLocaleChanged()
final Locale locale = getLocale();
synchronized (mListeners) {
for (CaptioningChangeListener listener : mListeners) {
listener.onLocaleChanged(locale);
}
}
|
private void | notifyUserStyleChanged()
final CaptionStyle userStyle = getUserStyle();
synchronized (mListeners) {
for (CaptioningChangeListener listener : mListeners) {
listener.onUserStyleChanged(userStyle);
}
}
|
private void | registerObserver(java.lang.String key)
mContentResolver.registerContentObserver(Secure.getUriFor(key), false, mContentObserver);
|
public void | removeCaptioningChangeListener(android.view.accessibility.CaptioningManager$CaptioningChangeListener listener)Removes a listener previously added using
{@link #addCaptioningChangeListener}.
synchronized (mListeners) {
mListeners.remove(listener);
if (mListeners.isEmpty()) {
mContentResolver.unregisterContentObserver(mContentObserver);
}
}
|