From 3500f07be6c266e0903bc42f1dfdb0df63b1c1b9 Mon Sep 17 00:00:00 2001 From: tonihei Date: Wed, 6 Mar 2019 10:49:13 +0000 Subject: [PATCH] Use theme overlay for track selection dialog. We currrently just inherit the acitivity's alertDialogTheme style (which is equivalent to ThemeOverlay.AppCompat.Dialog.Alert). Using the theme overlay directly and also force-enable the title such that the title is shown even if the activity disabled the title. PiperOrigin-RevId: 237012601 --- .../exoplayer2/demo/TrackSelectionDialog.java | 13 +++++-------- demos/main/src/main/res/values/styles.xml | 5 ++++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/demos/main/src/main/java/com/google/android/exoplayer2/demo/TrackSelectionDialog.java b/demos/main/src/main/java/com/google/android/exoplayer2/demo/TrackSelectionDialog.java index 56abe9fa40..f6d7eff526 100644 --- a/demos/main/src/main/java/com/google/android/exoplayer2/demo/TrackSelectionDialog.java +++ b/demos/main/src/main/java/com/google/android/exoplayer2/demo/TrackSelectionDialog.java @@ -28,7 +28,6 @@ import androidx.fragment.app.FragmentPagerAdapter; import androidx.viewpager.widget.ViewPager; import androidx.appcompat.app.AppCompatDialog; import android.util.SparseArray; -import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -165,13 +164,11 @@ public final class TrackSelectionDialog extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - // We need to own the view to let tab layout work correctly on all API levels. That's why we - // can't use an AlertDialog as it owns its view itself. Using AppCompatDialog instead. We still - // want the "alertDialogTheme" style attribute of the current theme instead of AppCompatDialog's - // default "dialogTheme" style, so obtain that manually. - TypedValue alertDialogStyle = new TypedValue(); - getActivity().getTheme().resolveAttribute(R.attr.alertDialogTheme, alertDialogStyle, true); - AppCompatDialog dialog = new AppCompatDialog(getActivity(), alertDialogStyle.resourceId); + // We need to own the view to let tab layout work correctly on all API levels. We can't use + // AlertDialog because it owns the view itself, so we use AppCompatDialog instead, themed using + // the AlertDialog theme overlay with force-enabled title. + AppCompatDialog dialog = + new AppCompatDialog(getActivity(), R.style.TrackSelectionDialogThemeOverlay); dialog.setTitle(titleId); return dialog; } diff --git a/demos/main/src/main/res/values/styles.xml b/demos/main/src/main/res/values/styles.xml index 8dfa4f0e1f..04c5b90edc 100644 --- a/demos/main/src/main/res/values/styles.xml +++ b/demos/main/src/main/res/values/styles.xml @@ -15,8 +15,11 @@ --> + +