Commit 3500f07b by tonihei Committed by Oliver Woodman

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
parent febb8c58
......@@ -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;
}
......
......@@ -15,8 +15,11 @@
-->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="TrackSelectionDialogThemeOverlay" parent="ThemeOverlay.AppCompat.Dialog.Alert">
<item name="windowNoTitle">false</item>
</style>
<style name="PlayerTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/black</item>
</style>
......
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