From 3a0b1f7da7938239cb29b879850afe9410864152 Mon Sep 17 00:00:00 2001 From: olly Date: Fri, 11 Dec 2020 17:09:26 +0000 Subject: [PATCH] Fix UI menu not dismissing on API level 22 and earlier Issue: #8272 PiperOrigin-RevId: 347010412 --- RELEASENOTES.md | 5 +++++ .../android/exoplayer2/ui/StyledPlayerControlView.java | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index fc655e4e9f..b9252d1789 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -2,6 +2,11 @@ ### 2.12.3 (???-??-??) ### +* UI: + * Fix issue where pop-up menus belonging to `StyledPlayerControlView` + would not be dismissed when tapping outside of the menu area or pressing + the back button, on API level 22 and earlier + ([#8272](https://github.com/google/ExoPlayer/issues/8272)). * IMA extension: * Fix a condition where playback can get stuck before an empty ad ([#8205](https://github.com/google/ExoPlayer/issues/8205)). diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java index 3cff0ef3cb..ab09454c95 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java @@ -21,7 +21,9 @@ import android.annotation.SuppressLint; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; +import android.graphics.Color; import android.graphics.Typeface; +import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.os.Looper; import android.util.AttributeSet; @@ -673,6 +675,11 @@ public class StyledPlayerControlView extends FrameLayout { settingsView.setLayoutManager(new LinearLayoutManager(getContext())); settingsWindow = new PopupWindow(settingsView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true); + if (Util.SDK_INT < 23) { + // Work around issue where tapping outside of the menu area or pressing the back button + // doesn't dismiss the menu as expected. See: https://github.com/google/ExoPlayer/issues/8272. + settingsWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + } settingsWindow.setOnDismissListener(componentListener); needToHideBars = true;