| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.view.accessibility; |
| 18 |
|
| 19 |
import android.Manifest; |
| 20 |
import android.annotation.NonNull; |
| 21 |
import android.annotation.Nullable; |
| 22 |
import android.annotation.RequiresPermission; |
| 23 |
import android.annotation.SystemApi; |
| 24 |
import android.annotation.SystemService; |
| 25 |
import android.compat.annotation.UnsupportedAppUsage; |
| 26 |
import android.content.ContentResolver; |
| 27 |
import android.content.Context; |
| 28 |
import android.content.res.Resources; |
| 29 |
import android.database.ContentObserver; |
| 30 |
import android.graphics.Color; |
| 31 |
import android.graphics.Typeface; |
| 32 |
import android.net.Uri; |
| 33 |
import android.os.Handler; |
| 34 |
import android.provider.Settings.Secure; |
| 35 |
import android.text.TextUtils; |
| 36 |
|
| 37 |
import com.android.internal.R; |
| 38 |
|
| 39 |
import java.util.ArrayList; |
| 40 |
import java.util.Locale; |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
@SystemService(Context.CAPTIONING_SERVICE) |
| 47 |
public class CaptioningManager { |
| 48 |
|
| 49 |
private static final int DEFAULT_ENABLED = 0; |
| 50 |
private static final boolean SYSTEM_AUDIO_CAPTIONING_DEFAULT_ENABLED = false; |
| 51 |
|
| 52 |
|
| 53 |
private static final int DEFAULT_PRESET = 0; |
| 54 |
|
| 55 |
|
| 56 |
private static final float DEFAULT_FONT_SCALE = 1; |
| 57 |
|
| 58 |
private final ArrayList<CaptioningChangeListener> mListeners = new ArrayList<>(); |
| 59 |
private final ContentResolver mContentResolver; |
| 60 |
private final ContentObserver mContentObserver; |
| 61 |
private final Resources mResources; |
| 62 |
private final Context mContext; |
| 63 |
private final AccessibilityManager mAccessibilityManager; |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
public CaptioningManager(Context context) { |
| 71 |
mContext = context; |
| 72 |
mContentResolver = context.getContentResolver(); |
| 73 |
mAccessibilityManager = mContext.getSystemService(AccessibilityManager.class); |
| 74 |
|
| 75 |
final Handler handler = new Handler(context.getMainLooper()); |
| 76 |
mContentObserver = new MyContentObserver(handler); |
| 77 |
mResources = context.getResources(); |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
public final boolean isEnabled() { |
| 84 |
return Secure.getInt( |
| 85 |
mContentResolver, Secure.ACCESSIBILITY_CAPTIONING_ENABLED, DEFAULT_ENABLED) == 1; |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
@Nullable |
| 94 |
public final String getRawLocale() { |
| 95 |
return Secure.getString(mContentResolver, Secure.ACCESSIBILITY_CAPTIONING_LOCALE); |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
@Nullable |
| 103 |
public final Locale getLocale() { |
| 104 |
final String rawLocale = getRawLocale(); |
| 105 |
if (!TextUtils.isEmpty(rawLocale)) { |
| 106 |
final String[] splitLocale = rawLocale.split("_"); |
| 107 |
switch (splitLocale.length) { |
| 108 |
case 3: |
| 109 |
return new Locale(splitLocale[0], splitLocale[1], splitLocale[2]); |
| 110 |
case 2: |
| 111 |
return new Locale(splitLocale[0], splitLocale[1]); |
| 112 |
case 1: |
| 113 |
return new Locale(splitLocale[0]); |
| 114 |
} |
| 115 |
} |
| 116 |
|
| 117 |
return null; |
| 118 |
} |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
public final float getFontScale() { |
| 125 |
return Secure.getFloat( |
| 126 |
mContentResolver, Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE, DEFAULT_FONT_SCALE); |
| 127 |
} |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
public int getRawUserStyle() { |
| 134 |
return Secure.getInt( |
| 135 |
mContentResolver, Secure.ACCESSIBILITY_CAPTIONING_PRESET, DEFAULT_PRESET); |
| 136 |
} |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
@NonNull |
| 143 |
public CaptionStyle getUserStyle() { |
| 144 |
final int preset = getRawUserStyle(); |
| 145 |
if (preset == CaptionStyle.PRESET_CUSTOM) { |
| 146 |
return CaptionStyle.getCustomStyle(mContentResolver); |
| 147 |
} |
| 148 |
|
| 149 |
return CaptionStyle.PRESETS[preset]; |
| 150 |
} |
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
public final boolean isSystemAudioCaptioningEnabled() { |
| 156 |
return Secure.getIntForUser(mContentResolver, Secure.ODI_CAPTIONS_ENABLED, |
| 157 |
SYSTEM_AUDIO_CAPTIONING_DEFAULT_ENABLED ? 1 : 0, mContext.getUserId()) == 1; |
| 158 |
} |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
@SystemApi |
| 171 |
@RequiresPermission(Manifest.permission.SET_SYSTEM_AUDIO_CAPTION) |
| 172 |
public final void setSystemAudioCaptioningEnabled(boolean isEnabled) { |
| 173 |
if (mAccessibilityManager != null) { |
| 174 |
mAccessibilityManager.setSystemAudioCaptioningEnabled(isEnabled, |
| 175 |
mContext.getUserId()); |
| 176 |
} |
| 177 |
} |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
public final boolean isSystemAudioCaptioningUiEnabled() { |
| 183 |
return mAccessibilityManager != null |
| 184 |
&& mAccessibilityManager.isSystemAudioCaptioningUiEnabled(mContext.getUserId()); |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
@SystemApi |
| 198 |
@RequiresPermission(Manifest.permission.SET_SYSTEM_AUDIO_CAPTION) |
| 199 |
public final void setSystemAudioCaptioningUiEnabled(boolean isEnabled) { |
| 200 |
if (mAccessibilityManager != null) { |
| 201 |
mAccessibilityManager.setSystemAudioCaptioningUiEnabled(isEnabled, |
| 202 |
mContext.getUserId()); |
| 203 |
} |
| 204 |
} |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
public void addCaptioningChangeListener(@NonNull CaptioningChangeListener listener) { |
| 213 |
synchronized (mListeners) { |
| 214 |
if (mListeners.isEmpty()) { |
| 215 |
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_ENABLED); |
| 216 |
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR); |
| 217 |
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR); |
| 218 |
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_WINDOW_COLOR); |
| 219 |
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_EDGE_TYPE); |
| 220 |
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_EDGE_COLOR); |
| 221 |
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_TYPEFACE); |
| 222 |
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE); |
| 223 |
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_LOCALE); |
| 224 |
registerObserver(Secure.ACCESSIBILITY_CAPTIONING_PRESET); |
| 225 |
registerObserver(Secure.ODI_CAPTIONS_ENABLED); |
| 226 |
registerObserver(Secure.ODI_CAPTIONS_VOLUME_UI_ENABLED); |
| 227 |
} |
| 228 |
|
| 229 |
mListeners.add(listener); |
| 230 |
} |
| 231 |
} |
| 232 |
|
| 233 |
private void registerObserver(String key) { |
| 234 |
mContentResolver.registerContentObserver(Secure.getUriFor(key), false, mContentObserver); |
| 235 |
} |
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
public void removeCaptioningChangeListener(@NonNull CaptioningChangeListener listener) { |
| 244 |
synchronized (mListeners) { |
| 245 |
mListeners.remove(listener); |
| 246 |
|
| 247 |
if (mListeners.isEmpty()) { |
| 248 |
mContentResolver.unregisterContentObserver(mContentObserver); |
| 249 |
} |
| 250 |
} |
| 251 |
} |
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
public boolean isCallCaptioningEnabled() { |
| 257 |
try { |
| 258 |
return mResources.getBoolean( |
| 259 |
R.bool.config_systemCaptionsServiceCallsEnabled); |
| 260 |
} catch (Resources.NotFoundException e) { |
| 261 |
|
| 262 |
return false; |
| 263 |
} |
| 264 |
} |
| 265 |
|
| 266 |
private void notifyEnabledChanged() { |
| 267 |
final boolean enabled = isEnabled(); |
| 268 |
synchronized (mListeners) { |
| 269 |
for (CaptioningChangeListener listener : mListeners) { |
| 270 |
listener.onEnabledChanged(enabled); |
| 271 |
} |
| 272 |
} |
| 273 |
} |
| 274 |
|
| 275 |
private void notifyUserStyleChanged() { |
| 276 |
final CaptionStyle userStyle = getUserStyle(); |
| 277 |
synchronized (mListeners) { |
| 278 |
for (CaptioningChangeListener listener : mListeners) { |
| 279 |
listener.onUserStyleChanged(userStyle); |
| 280 |
} |
| 281 |
} |
| 282 |
} |
| 283 |
|
| 284 |
private void notifyLocaleChanged() { |
| 285 |
final Locale locale = getLocale(); |
| 286 |
synchronized (mListeners) { |
| 287 |
for (CaptioningChangeListener listener : mListeners) { |
| 288 |
listener.onLocaleChanged(locale); |
| 289 |
} |
| 290 |
} |
| 291 |
} |
| 292 |
|
| 293 |
private void notifyFontScaleChanged() { |
| 294 |
final float fontScale = getFontScale(); |
| 295 |
synchronized (mListeners) { |
| 296 |
for (CaptioningChangeListener listener : mListeners) { |
| 297 |
listener.onFontScaleChanged(fontScale); |
| 298 |
} |
| 299 |
} |
| 300 |
} |
| 301 |
|
| 302 |
private void notifySystemAudioCaptionChanged() { |
| 303 |
final boolean enabled = isSystemAudioCaptioningEnabled(); |
| 304 |
synchronized (mListeners) { |
| 305 |
for (CaptioningChangeListener listener : mListeners) { |
| 306 |
listener.onSystemAudioCaptioningChanged(enabled); |
| 307 |
} |
| 308 |
} |
| 309 |
} |
| 310 |
|
| 311 |
private void notifySystemAudioCaptionUiChanged() { |
| 312 |
final boolean enabled = isSystemAudioCaptioningUiEnabled(); |
| 313 |
synchronized (mListeners) { |
| 314 |
for (CaptioningChangeListener listener : mListeners) { |
| 315 |
listener.onSystemAudioCaptioningUiChanged(enabled); |
| 316 |
} |
| 317 |
} |
| 318 |
} |
| 319 |
|
| 320 |
private class MyContentObserver extends ContentObserver { |
| 321 |
private final Handler mHandler; |
| 322 |
|
| 323 |
public MyContentObserver(Handler handler) { |
| 324 |
super(handler); |
| 325 |
|
| 326 |
mHandler = handler; |
| 327 |
} |
| 328 |
|
| 329 |
@Override |
| 330 |
public void onChange(boolean selfChange, Uri uri) { |
| 331 |
final String uriPath = uri.getPath(); |
| 332 |
final String name = uriPath.substring(uriPath.lastIndexOf('/') + 1); |
| 333 |
if (Secure.ACCESSIBILITY_CAPTIONING_ENABLED.equals(name)) { |
| 334 |
notifyEnabledChanged(); |
| 335 |
} else if (Secure.ACCESSIBILITY_CAPTIONING_LOCALE.equals(name)) { |
| 336 |
notifyLocaleChanged(); |
| 337 |
} else if (Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE.equals(name)) { |
| 338 |
notifyFontScaleChanged(); |
| 339 |
} else if (Secure.ODI_CAPTIONS_ENABLED.equals(name)) { |
| 340 |
notifySystemAudioCaptionChanged(); |
| 341 |
} else if (Secure.ODI_CAPTIONS_VOLUME_UI_ENABLED.equals(name)) { |
| 342 |
notifySystemAudioCaptionUiChanged(); |
| 343 |
} else { |
| 344 |
|
| 345 |
|
| 346 |
mHandler.removeCallbacks(mStyleChangedRunnable); |
| 347 |
mHandler.post(mStyleChangedRunnable); |
| 348 |
} |
| 349 |
} |
| 350 |
}; |
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
private final Runnable mStyleChangedRunnable = new Runnable() { |
| 358 |
@Override |
| 359 |
public void run() { |
| 360 |
notifyUserStyleChanged(); |
| 361 |
} |
| 362 |
}; |
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
public static final class CaptionStyle { |
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
private static final int COLOR_NONE_OPAQUE = 0x000000FF; |
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
public static final int COLOR_UNSPECIFIED = 0x00FFFFFF; |
| 382 |
|
| 383 |
private static final CaptionStyle WHITE_ON_BLACK; |
| 384 |
private static final CaptionStyle BLACK_ON_WHITE; |
| 385 |
private static final CaptionStyle YELLOW_ON_BLACK; |
| 386 |
private static final CaptionStyle YELLOW_ON_BLUE; |
| 387 |
private static final CaptionStyle DEFAULT_CUSTOM; |
| 388 |
private static final CaptionStyle UNSPECIFIED; |
| 389 |
|
| 390 |
|
| 391 |
public static final CaptionStyle DEFAULT; |
| 392 |
|
| 393 |
|
| 394 |
@UnsupportedAppUsage |
| 395 |
public static final CaptionStyle[] PRESETS; |
| 396 |
|
| 397 |
|
| 398 |
public static final int PRESET_CUSTOM = -1; |
| 399 |
|
| 400 |
|
| 401 |
public static final int EDGE_TYPE_UNSPECIFIED = -1; |
| 402 |
|
| 403 |
|
| 404 |
public static final int EDGE_TYPE_NONE = 0; |
| 405 |
|
| 406 |
|
| 407 |
public static final int EDGE_TYPE_OUTLINE = 1; |
| 408 |
|
| 409 |
|
| 410 |
public static final int EDGE_TYPE_DROP_SHADOW = 2; |
| 411 |
|
| 412 |
|
| 413 |
public static final int EDGE_TYPE_RAISED = 3; |
| 414 |
|
| 415 |
|
| 416 |
public static final int EDGE_TYPE_DEPRESSED = 4; |
| 417 |
|
| 418 |
|
| 419 |
public final int foregroundColor; |
| 420 |
|
| 421 |
|
| 422 |
public final int backgroundColor; |
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
public final int edgeType; |
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
public final int edgeColor; |
| 442 |
|
| 443 |
|
| 444 |
public final int windowColor; |
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
public final String mRawTypeface; |
| 450 |
|
| 451 |
private final boolean mHasForegroundColor; |
| 452 |
private final boolean mHasBackgroundColor; |
| 453 |
private final boolean mHasEdgeType; |
| 454 |
private final boolean mHasEdgeColor; |
| 455 |
private final boolean mHasWindowColor; |
| 456 |
|
| 457 |
|
| 458 |
private Typeface mParsedTypeface; |
| 459 |
|
| 460 |
private CaptionStyle(int foregroundColor, int backgroundColor, int edgeType, int edgeColor, |
| 461 |
int windowColor, String rawTypeface) { |
| 462 |
mHasForegroundColor = hasColor(foregroundColor); |
| 463 |
mHasBackgroundColor = hasColor(backgroundColor); |
| 464 |
mHasEdgeType = edgeType != EDGE_TYPE_UNSPECIFIED; |
| 465 |
mHasEdgeColor = hasColor(edgeColor); |
| 466 |
mHasWindowColor = hasColor(windowColor); |
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
this.foregroundColor = mHasForegroundColor ? foregroundColor : Color.WHITE; |
| 471 |
this.backgroundColor = mHasBackgroundColor ? backgroundColor : Color.BLACK; |
| 472 |
this.edgeType = mHasEdgeType ? edgeType : EDGE_TYPE_NONE; |
| 473 |
this.edgeColor = mHasEdgeColor ? edgeColor : Color.BLACK; |
| 474 |
this.windowColor = mHasWindowColor ? windowColor : COLOR_NONE_OPAQUE; |
| 475 |
|
| 476 |
mRawTypeface = rawTypeface; |
| 477 |
} |
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
public static boolean hasColor(int packedColor) { |
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
return (packedColor >>> 24) != 0 || (packedColor & 0xFFFF00) == 0; |
| 491 |
} |
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
@NonNull |
| 502 |
public CaptionStyle applyStyle(@NonNull CaptionStyle overlay) { |
| 503 |
final int newForegroundColor = overlay.hasForegroundColor() ? |
| 504 |
overlay.foregroundColor : foregroundColor; |
| 505 |
final int newBackgroundColor = overlay.hasBackgroundColor() ? |
| 506 |
overlay.backgroundColor : backgroundColor; |
| 507 |
final int newEdgeType = overlay.hasEdgeType() ? |
| 508 |
overlay.edgeType : edgeType; |
| 509 |
final int newEdgeColor = overlay.hasEdgeColor() ? |
| 510 |
overlay.edgeColor : edgeColor; |
| 511 |
final int newWindowColor = overlay.hasWindowColor() ? |
| 512 |
overlay.windowColor : windowColor; |
| 513 |
final String newRawTypeface = overlay.mRawTypeface != null ? |
| 514 |
overlay.mRawTypeface : mRawTypeface; |
| 515 |
return new CaptionStyle(newForegroundColor, newBackgroundColor, newEdgeType, |
| 516 |
newEdgeColor, newWindowColor, newRawTypeface); |
| 517 |
} |
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
public boolean hasBackgroundColor() { |
| 525 |
return mHasBackgroundColor; |
| 526 |
} |
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
public boolean hasForegroundColor() { |
| 534 |
return mHasForegroundColor; |
| 535 |
} |
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
public boolean hasEdgeType() { |
| 543 |
return mHasEdgeType; |
| 544 |
} |
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
public boolean hasEdgeColor() { |
| 552 |
return mHasEdgeColor; |
| 553 |
} |
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
public boolean hasWindowColor() { |
| 561 |
return mHasWindowColor; |
| 562 |
} |
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
@Nullable |
| 569 |
public Typeface getTypeface() { |
| 570 |
if (mParsedTypeface == null && !TextUtils.isEmpty(mRawTypeface)) { |
| 571 |
mParsedTypeface = Typeface.create(mRawTypeface, Typeface.NORMAL); |
| 572 |
} |
| 573 |
return mParsedTypeface; |
| 574 |
} |
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
@NonNull |
| 580 |
public static CaptionStyle getCustomStyle(ContentResolver cr) { |
| 581 |
final CaptionStyle defStyle = CaptionStyle.DEFAULT_CUSTOM; |
| 582 |
final int foregroundColor = Secure.getInt( |
| 583 |
cr, Secure.ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR, defStyle.foregroundColor); |
| 584 |
final int backgroundColor = Secure.getInt( |
| 585 |
cr, Secure.ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR, defStyle.backgroundColor); |
| 586 |
final int edgeType = Secure.getInt( |
| 587 |
cr, Secure.ACCESSIBILITY_CAPTIONING_EDGE_TYPE, defStyle.edgeType); |
| 588 |
final int edgeColor = Secure.getInt( |
| 589 |
cr, Secure.ACCESSIBILITY_CAPTIONING_EDGE_COLOR, defStyle.edgeColor); |
| 590 |
final int windowColor = Secure.getInt( |
| 591 |
cr, Secure.ACCESSIBILITY_CAPTIONING_WINDOW_COLOR, defStyle.windowColor); |
| 592 |
|
| 593 |
String rawTypeface = Secure.getString(cr, Secure.ACCESSIBILITY_CAPTIONING_TYPEFACE); |
| 594 |
if (rawTypeface == null) { |
| 595 |
rawTypeface = defStyle.mRawTypeface; |
| 596 |
} |
| 597 |
|
| 598 |
return new CaptionStyle(foregroundColor, backgroundColor, edgeType, edgeColor, |
| 599 |
windowColor, rawTypeface); |
| 600 |
} |
| 601 |
|
| 602 |
static { |
| 603 |
WHITE_ON_BLACK = new CaptionStyle(Color.WHITE, Color.BLACK, EDGE_TYPE_NONE, |
| 604 |
Color.BLACK, COLOR_NONE_OPAQUE, null); |
| 605 |
BLACK_ON_WHITE = new CaptionStyle(Color.BLACK, Color.WHITE, EDGE_TYPE_NONE, |
| 606 |
Color.BLACK, COLOR_NONE_OPAQUE, null); |
| 607 |
YELLOW_ON_BLACK = new CaptionStyle(Color.YELLOW, Color.BLACK, EDGE_TYPE_NONE, |
| 608 |
Color.BLACK, COLOR_NONE_OPAQUE, null); |
| 609 |
YELLOW_ON_BLUE = new CaptionStyle(Color.YELLOW, Color.BLUE, EDGE_TYPE_NONE, |
| 610 |
Color.BLACK, COLOR_NONE_OPAQUE, null); |
| 611 |
UNSPECIFIED = new CaptionStyle(COLOR_UNSPECIFIED, COLOR_UNSPECIFIED, |
| 612 |
EDGE_TYPE_UNSPECIFIED, COLOR_UNSPECIFIED, COLOR_UNSPECIFIED, null); |
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
PRESETS = new CaptionStyle[] { |
| 617 |
WHITE_ON_BLACK, BLACK_ON_WHITE, YELLOW_ON_BLACK, YELLOW_ON_BLUE, UNSPECIFIED |
| 618 |
}; |
| 619 |
|
| 620 |
DEFAULT_CUSTOM = WHITE_ON_BLACK; |
| 621 |
DEFAULT = WHITE_ON_BLACK; |
| 622 |
} |
| 623 |
} |
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
public static abstract class CaptioningChangeListener { |
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
public void onEnabledChanged(boolean enabled) {} |
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
public void onUserStyleChanged(@NonNull CaptionStyle userStyle) {} |
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
public void onLocaleChanged(@Nullable Locale locale) {} |
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
public void onFontScaleChanged(float fontScale) {} |
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
public void onSystemAudioCaptioningChanged(boolean enabled) {} |
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
public void onSystemAudioCaptioningUiChanged(boolean enabled) {} |
| 675 |
} |
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
public interface SystemAudioCaptioningAccessing { |
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
void setSystemAudioCaptioningEnabled(boolean isEnabled, int userId); |
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
boolean isSystemAudioCaptioningUiEnabled(int userId); |
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
void setSystemAudioCaptioningUiEnabled(boolean isEnabled, int userId); |
| 706 |
} |
| 707 |
} |