From 658e0e17b844837f9aeb43e6a4ee5945aa686bcb Mon Sep 17 00:00:00 2001 From: ibaker Date: Tue, 28 Jan 2020 16:56:48 +0000 Subject: [PATCH] Make SubtitleWebView 'invisible' to touch events Without this, tapping the main video playback doesn't bring up the controls. PiperOrigin-RevId: 291943063 --- .../android/exoplayer2/ui/SubtitleWebView.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitleWebView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitleWebView.java index 06039c9016..7fa6e4165a 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitleWebView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitleWebView.java @@ -22,6 +22,7 @@ import static com.google.android.exoplayer2.ui.SubtitleView.DEFAULT_TEXT_SIZE_FR import android.content.Context; import android.graphics.Color; import android.util.AttributeSet; +import android.view.MotionEvent; import android.view.ViewGroup; import android.webkit.WebView; import androidx.annotation.Nullable; @@ -65,7 +66,22 @@ import java.util.List; style = CaptionStyleCompat.DEFAULT; bottomPaddingFraction = DEFAULT_BOTTOM_PADDING_FRACTION; - webView = new WebView(context, attrs); + webView = + new WebView(context, attrs) { + @Override + public boolean onTouchEvent(MotionEvent event) { + super.onTouchEvent(event); + // Return false so that touch events are allowed down into @id/exo_content_frame below. + return false; + } + + @Override + public boolean performClick() { + super.performClick(); + // Return false so that clicks are allowed down into @id/exo_content_frame below. + return false; + } + }; webView.setBackgroundColor(Color.TRANSPARENT); addView(webView); }