Commit ff6e641f by olly Committed by Ian Baker

Rollback of https://github.com/google/ExoPlayer/commit/20282151b5ea0e6a4d94710b3ab2a6806148d056

*** Original commit ***

Fix PlayerView touch handling

Overriding onTouchEvent was causing multiple issues, and
appears to be unnecessary. Removing the override fixes:

1. StyledPlayerView accessibility issue where "hide player
   controls" actually toggled play/pause.
2. Delivery of events to a registered OnClickListener when
   useController is false.
3. Delivery of events to a registered OnLongClickListener
   in all configurations.
4. Incorrectly treating a sequence of touch events that
   exit the bounds of the vi...

***

PiperOrigin-RevId: 433262414
parent 82a50154
...@@ -35,17 +35,6 @@ ...@@ -35,17 +35,6 @@
views to be used with other `Player` implementations, and removes the views to be used with other `Player` implementations, and removes the
dependency from the UI module to the ExoPlayer module. This is a dependency from the UI module to the ExoPlayer module. This is a
breaking change. breaking change.
* UI:
* Fix delivery of events to `OnClickListener`s set on `StyledPlayerView`
and `PlayerView`, in the case that `useController=false`
([#9605](https://github.com/google/ExoPlayer/issues/9605)). Also fix
delivery of events to `OnLongClickListener` for all view configurations.
* Fix incorrectly treating a sequence of touch events that exit the bounds
of `StyledPlayerView` and `PlayerView` before `ACTION_UP` as a click
([#9861](https://github.com/google/ExoPlayer/issues/9861)).
* Fix `StyledPlayerView` accessibility issue where it was not possible to
tapping would toggle playback rather than hiding the controls
([#8627](https://github.com/google/ExoPlayer/issues/8627)).
* RTSP: * RTSP:
* Add RTP reader for HEVC * Add RTP reader for HEVC
([#36](https://github.com/androidx/media/pull/36)). ([#36](https://github.com/androidx/media/pull/36)).
......
...@@ -397,7 +397,6 @@ public class PlayerView extends FrameLayout implements AdViewProvider { ...@@ -397,7 +397,6 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
LayoutInflater.from(context).inflate(playerLayoutId, this); LayoutInflater.from(context).inflate(playerLayoutId, this);
setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
setClickable(true);
// Content frame. // Content frame.
contentFrame = findViewById(R.id.exo_content_frame); contentFrame = findViewById(R.id.exo_content_frame);
...@@ -1074,9 +1073,30 @@ public class PlayerView extends FrameLayout implements AdViewProvider { ...@@ -1074,9 +1073,30 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
} }
@Override @Override
public boolean onTouchEvent(MotionEvent event) {
if (!useController() || player == null) {
return false;
}
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
isTouching = true;
return true;
case MotionEvent.ACTION_UP:
if (isTouching) {
isTouching = false;
performClick();
return true;
}
return false;
default:
return false;
}
}
@Override
public boolean performClick() { public boolean performClick() {
toggleControllerVisibility(); super.performClick();
return super.performClick(); return toggleControllerVisibility();
} }
@Override @Override
...@@ -1172,15 +1192,16 @@ public class PlayerView extends FrameLayout implements AdViewProvider { ...@@ -1172,15 +1192,16 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
return false; return false;
} }
private void toggleControllerVisibility() { private boolean toggleControllerVisibility() {
if (!useController() || player == null) { if (!useController() || player == null) {
return; return false;
} }
if (!controller.isVisible()) { if (!controller.isVisible()) {
maybeShowController(true); maybeShowController(true);
} else if (controllerHideOnTouch) { } else if (controllerHideOnTouch) {
controller.hide(); controller.hide();
} }
return true;
} }
/** Shows the playback controls, but only if forced or shown indefinitely. */ /** Shows the playback controls, but only if forced or shown indefinitely. */
......
...@@ -311,7 +311,6 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider { ...@@ -311,7 +311,6 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
LayoutInflater.from(context).inflate(playerLayoutId, this); LayoutInflater.from(context).inflate(playerLayoutId, this);
setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
setClickable(true);
// Content frame. // Content frame.
contentFrame = findViewById(R.id.exo_content_frame); contentFrame = findViewById(R.id.exo_content_frame);
...@@ -1020,9 +1019,29 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider { ...@@ -1020,9 +1019,29 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
} }
@Override @Override
public boolean onTouchEvent(MotionEvent event) {
if (!useController() || player == null) {
return false;
}
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
isTouching = true;
return true;
case MotionEvent.ACTION_UP:
if (isTouching) {
isTouching = false;
return performClick();
}
return false;
default:
return false;
}
}
@Override
public boolean performClick() { public boolean performClick() {
toggleControllerVisibility(); super.performClick();
return super.performClick(); return toggleControllerVisibility();
} }
@Override @Override
...@@ -1118,15 +1137,18 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider { ...@@ -1118,15 +1137,18 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
return false; return false;
} }
private void toggleControllerVisibility() { private boolean toggleControllerVisibility() {
if (!useController() || player == null) { if (!useController() || player == null) {
return; return false;
} }
if (!controller.isFullyVisible()) { if (!controller.isFullyVisible()) {
maybeShowController(true); maybeShowController(true);
return true;
} else if (controllerHideOnTouch) { } else if (controllerHideOnTouch) {
controller.hide(); controller.hide();
return true;
} }
return false;
} }
/** Shows the playback controls, but only if forced or shown indefinitely. */ /** Shows the playback controls, but only if forced or shown indefinitely. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment