Fix UI menu not dismissing on API level 22 and earlier

Issue: #8272
PiperOrigin-RevId: 347010412
This commit is contained in:
olly 2020-12-11 17:09:26 +00:00 committed by Ian Baker
parent a028ce8964
commit 3a0b1f7da7
2 changed files with 12 additions and 0 deletions

View file

@ -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)).

View file

@ -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;