mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Fix DefaultTimeBar accessibility class name
See https://support.google.com/accessibility/android/answer/7661305. Also fix/suppress nullability warnings. Issue: #4611 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=207245115
This commit is contained in:
parent
e92d65533f
commit
4cd57e0963
2 changed files with 27 additions and 21 deletions
|
|
@ -39,6 +39,8 @@
|
||||||
([#4348](https://github.com/google/ExoPlayer/issues/4348)).
|
([#4348](https://github.com/google/ExoPlayer/issues/4348)).
|
||||||
* Fix issue when switching track selection from an embedded track to a primary
|
* Fix issue when switching track selection from an embedded track to a primary
|
||||||
track in DASH ([#4477](https://github.com/google/ExoPlayer/issues/4477)).
|
track in DASH ([#4477](https://github.com/google/ExoPlayer/issues/4477)).
|
||||||
|
* Fix accessibility class name for `DefaultTimeBar`
|
||||||
|
([#4611](https://github.com/google/ExoPlayer/issues/4611)).
|
||||||
* Improved compatibility with FireOS devices.
|
* Improved compatibility with FireOS devices.
|
||||||
|
|
||||||
### 2.8.2 ###
|
### 2.8.2 ###
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,12 @@ public class DefaultTimeBar extends View implements TimeBar {
|
||||||
private static final long STOP_SCRUBBING_TIMEOUT_MS = 1000;
|
private static final long STOP_SCRUBBING_TIMEOUT_MS = 1000;
|
||||||
private static final int DEFAULT_INCREMENT_COUNT = 20;
|
private static final int DEFAULT_INCREMENT_COUNT = 20;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the Android SDK view that most closely resembles this custom view. Used as the
|
||||||
|
* class name for accessibility.
|
||||||
|
*/
|
||||||
|
private static final String ACCESSIBILITY_CLASS_NAME = "android.widget.SeekBar";
|
||||||
|
|
||||||
private final Rect seekBounds;
|
private final Rect seekBounds;
|
||||||
private final Rect progressBar;
|
private final Rect progressBar;
|
||||||
private final Rect bufferedBar;
|
private final Rect bufferedBar;
|
||||||
|
|
@ -184,7 +190,7 @@ public class DefaultTimeBar extends View implements TimeBar {
|
||||||
private final Paint adMarkerPaint;
|
private final Paint adMarkerPaint;
|
||||||
private final Paint playedAdMarkerPaint;
|
private final Paint playedAdMarkerPaint;
|
||||||
private final Paint scrubberPaint;
|
private final Paint scrubberPaint;
|
||||||
private final Drawable scrubberDrawable;
|
private final @Nullable Drawable scrubberDrawable;
|
||||||
private final int barHeight;
|
private final int barHeight;
|
||||||
private final int touchTargetHeight;
|
private final int touchTargetHeight;
|
||||||
private final int adMarkerWidth;
|
private final int adMarkerWidth;
|
||||||
|
|
@ -197,12 +203,12 @@ public class DefaultTimeBar extends View implements TimeBar {
|
||||||
private final Formatter formatter;
|
private final Formatter formatter;
|
||||||
private final Runnable stopScrubbingRunnable;
|
private final Runnable stopScrubbingRunnable;
|
||||||
private final CopyOnWriteArraySet<OnScrubListener> listeners;
|
private final CopyOnWriteArraySet<OnScrubListener> listeners;
|
||||||
|
private final int[] locationOnScreen;
|
||||||
|
private final Point touchPosition;
|
||||||
|
|
||||||
private int keyCountIncrement;
|
private int keyCountIncrement;
|
||||||
private long keyTimeIncrement;
|
private long keyTimeIncrement;
|
||||||
private int lastCoarseScrubXPosition;
|
private int lastCoarseScrubXPosition;
|
||||||
private int[] locationOnScreen;
|
|
||||||
private Point touchPosition;
|
|
||||||
|
|
||||||
private boolean scrubbing;
|
private boolean scrubbing;
|
||||||
private long scrubPosition;
|
private long scrubPosition;
|
||||||
|
|
@ -210,12 +216,12 @@ public class DefaultTimeBar extends View implements TimeBar {
|
||||||
private long position;
|
private long position;
|
||||||
private long bufferedPosition;
|
private long bufferedPosition;
|
||||||
private int adGroupCount;
|
private int adGroupCount;
|
||||||
private long[] adGroupTimesMs;
|
private @Nullable long[] adGroupTimesMs;
|
||||||
private boolean[] playedAdGroups;
|
private @Nullable boolean[] playedAdGroups;
|
||||||
|
|
||||||
/**
|
/** Creates a new time bar. */
|
||||||
* Creates a new time bar.
|
// Suppress warnings due to usage of View methods in the constructor.
|
||||||
*/
|
@SuppressWarnings("nullness:method.invocation.invalid")
|
||||||
public DefaultTimeBar(Context context, AttributeSet attrs) {
|
public DefaultTimeBar(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
seekBounds = new Rect();
|
seekBounds = new Rect();
|
||||||
|
|
@ -230,6 +236,8 @@ public class DefaultTimeBar extends View implements TimeBar {
|
||||||
scrubberPaint = new Paint();
|
scrubberPaint = new Paint();
|
||||||
scrubberPaint.setAntiAlias(true);
|
scrubberPaint.setAntiAlias(true);
|
||||||
listeners = new CopyOnWriteArraySet<>();
|
listeners = new CopyOnWriteArraySet<>();
|
||||||
|
locationOnScreen = new int[2];
|
||||||
|
touchPosition = new Point();
|
||||||
|
|
||||||
// Calculate the dimensions and paints for drawn elements.
|
// Calculate the dimensions and paints for drawn elements.
|
||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
|
|
@ -299,12 +307,7 @@ public class DefaultTimeBar extends View implements TimeBar {
|
||||||
}
|
}
|
||||||
formatBuilder = new StringBuilder();
|
formatBuilder = new StringBuilder();
|
||||||
formatter = new Formatter(formatBuilder, Locale.getDefault());
|
formatter = new Formatter(formatBuilder, Locale.getDefault());
|
||||||
stopScrubbingRunnable = new Runnable() {
|
stopScrubbingRunnable = () -> stopScrubbing(/* canceled= */ false);
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
stopScrubbing(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (scrubberDrawable != null) {
|
if (scrubberDrawable != null) {
|
||||||
scrubberPadding = (scrubberDrawable.getMinimumWidth() + 1) / 2;
|
scrubberPadding = (scrubberDrawable.getMinimumWidth() + 1) / 2;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -593,14 +596,14 @@ public class DefaultTimeBar extends View implements TimeBar {
|
||||||
if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SELECTED) {
|
if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SELECTED) {
|
||||||
event.getText().add(getProgressText());
|
event.getText().add(getProgressText());
|
||||||
}
|
}
|
||||||
event.setClassName(DefaultTimeBar.class.getName());
|
event.setClassName(ACCESSIBILITY_CLASS_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(21)
|
@TargetApi(21)
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
|
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
|
||||||
super.onInitializeAccessibilityNodeInfo(info);
|
super.onInitializeAccessibilityNodeInfo(info);
|
||||||
info.setClassName(DefaultTimeBar.class.getCanonicalName());
|
info.setClassName(ACCESSIBILITY_CLASS_NAME);
|
||||||
info.setContentDescription(getProgressText());
|
info.setContentDescription(getProgressText());
|
||||||
if (duration <= 0) {
|
if (duration <= 0) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -616,7 +619,7 @@ public class DefaultTimeBar extends View implements TimeBar {
|
||||||
|
|
||||||
@TargetApi(16)
|
@TargetApi(16)
|
||||||
@Override
|
@Override
|
||||||
public boolean performAccessibilityAction(int action, Bundle args) {
|
public boolean performAccessibilityAction(int action, @Nullable Bundle args) {
|
||||||
if (super.performAccessibilityAction(action, args)) {
|
if (super.performAccessibilityAction(action, args)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -693,10 +696,6 @@ public class DefaultTimeBar extends View implements TimeBar {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Point resolveRelativeTouchPosition(MotionEvent motionEvent) {
|
private Point resolveRelativeTouchPosition(MotionEvent motionEvent) {
|
||||||
if (locationOnScreen == null) {
|
|
||||||
locationOnScreen = new int[2];
|
|
||||||
touchPosition = new Point();
|
|
||||||
}
|
|
||||||
getLocationOnScreen(locationOnScreen);
|
getLocationOnScreen(locationOnScreen);
|
||||||
touchPosition.set(
|
touchPosition.set(
|
||||||
((int) motionEvent.getRawX()) - locationOnScreen[0],
|
((int) motionEvent.getRawX()) - locationOnScreen[0],
|
||||||
|
|
@ -736,6 +735,11 @@ public class DefaultTimeBar extends View implements TimeBar {
|
||||||
if (scrubberBar.width() > 0) {
|
if (scrubberBar.width() > 0) {
|
||||||
canvas.drawRect(scrubberBar.left, barTop, scrubberBar.right, barBottom, playedPaint);
|
canvas.drawRect(scrubberBar.left, barTop, scrubberBar.right, barBottom, playedPaint);
|
||||||
}
|
}
|
||||||
|
if (adGroupCount == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long[] adGroupTimesMs = Assertions.checkNotNull(this.adGroupTimesMs);
|
||||||
|
boolean[] playedAdGroups = Assertions.checkNotNull(this.playedAdGroups);
|
||||||
int adMarkerOffset = adMarkerWidth / 2;
|
int adMarkerOffset = adMarkerWidth / 2;
|
||||||
for (int i = 0; i < adGroupCount; i++) {
|
for (int i = 0; i < adGroupCount; i++) {
|
||||||
long adGroupTimeMs = Util.constrainValue(adGroupTimesMs[i], 0, duration);
|
long adGroupTimeMs = Util.constrainValue(adGroupTimesMs[i], 0, duration);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue