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
This commit is contained in:
parent
febb8c589e
commit
3500f07be6
@ -28,7 +28,6 @@ import androidx.fragment.app.FragmentPagerAdapter;
|
|||||||
import androidx.viewpager.widget.ViewPager;
|
import androidx.viewpager.widget.ViewPager;
|
||||||
import androidx.appcompat.app.AppCompatDialog;
|
import androidx.appcompat.app.AppCompatDialog;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.util.TypedValue;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -165,13 +164,11 @@ public final class TrackSelectionDialog extends DialogFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
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
|
// We need to own the view to let tab layout work correctly on all API levels. We can't use
|
||||||
// can't use an AlertDialog as it owns its view itself. Using AppCompatDialog instead. We still
|
// AlertDialog because it owns the view itself, so we use AppCompatDialog instead, themed using
|
||||||
// want the "alertDialogTheme" style attribute of the current theme instead of AppCompatDialog's
|
// the AlertDialog theme overlay with force-enabled title.
|
||||||
// default "dialogTheme" style, so obtain that manually.
|
AppCompatDialog dialog =
|
||||||
TypedValue alertDialogStyle = new TypedValue();
|
new AppCompatDialog(getActivity(), R.style.TrackSelectionDialogThemeOverlay);
|
||||||
getActivity().getTheme().resolveAttribute(R.attr.alertDialogTheme, alertDialogStyle, true);
|
|
||||||
AppCompatDialog dialog = new AppCompatDialog(getActivity(), alertDialogStyle.resourceId);
|
|
||||||
dialog.setTitle(titleId);
|
dialog.setTitle(titleId);
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,11 @@
|
|||||||
-->
|
-->
|
||||||
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
<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">
|
<style name="PlayerTheme" parent="Theme.AppCompat.NoActionBar">
|
||||||
<item name="android:windowNoTitle">true</item>
|
|
||||||
<item name="android:windowBackground">@android:color/black</item>
|
<item name="android:windowBackground">@android:color/black</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user