mirror of
https://github.com/androidx/media.git
synced 2025-05-12 01:59:50 +08:00
Merge pull request #7804 from yoobi:TrackSelectionDialogBuilderTheme
PiperOrigin-RevId: 328726246
This commit is contained in:
commit
237cb9df54
@ -3,7 +3,7 @@
|
||||
# Constructor method accessed via reflection in TrackSelectionDialogBuilder
|
||||
-dontnote androidx.appcompat.app.AlertDialog.Builder
|
||||
-keepclassmembers class androidx.appcompat.app.AlertDialog$Builder {
|
||||
<init>(android.content.Context);
|
||||
<init>(android.content.Context, int);
|
||||
public android.content.Context getContext();
|
||||
public androidx.appcompat.app.AlertDialog$Builder setTitle(java.lang.CharSequence);
|
||||
public androidx.appcompat.app.AlertDialog$Builder setView(android.view.View);
|
||||
|
@ -24,6 +24,7 @@ import android.content.DialogInterface;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StyleRes;
|
||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector.SelectionOverride;
|
||||
@ -49,6 +50,7 @@ public final class TrackSelectionDialogBuilder {
|
||||
}
|
||||
|
||||
private final Context context;
|
||||
@StyleRes private int themeResId;
|
||||
private final CharSequence title;
|
||||
private final MappedTrackInfo mappedTrackInfo;
|
||||
private final int rendererIndex;
|
||||
@ -121,6 +123,17 @@ public final class TrackSelectionDialogBuilder {
|
||||
newOverrides.isEmpty() ? null : newOverrides.get(0)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the resource ID of the theme used to inflate this dialog.
|
||||
*
|
||||
* @param themeResId The resource ID of the theme.
|
||||
* @return This builder, for convenience.
|
||||
*/
|
||||
public TrackSelectionDialogBuilder setTheme(@StyleRes int themeResId) {
|
||||
this.themeResId = themeResId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the selection is initially shown as disabled.
|
||||
*
|
||||
@ -214,7 +227,7 @@ public final class TrackSelectionDialogBuilder {
|
||||
}
|
||||
|
||||
private Dialog buildForPlatform() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context, themeResId);
|
||||
|
||||
// Inflate with the builder's context to ensure the correct style is used.
|
||||
LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
|
||||
@ -238,8 +251,8 @@ public final class TrackSelectionDialogBuilder {
|
||||
// the APK size even with shrinking. See https://issuetracker.google.com/161514204.
|
||||
// LINT.IfChange
|
||||
Class<?> builderClazz = Class.forName("androidx.appcompat.app.AlertDialog$Builder");
|
||||
Constructor<?> builderConstructor = builderClazz.getConstructor(Context.class);
|
||||
Object builder = builderConstructor.newInstance(context);
|
||||
Constructor<?> builderConstructor = builderClazz.getConstructor(Context.class, int.class);
|
||||
Object builder = builderConstructor.newInstance(context, themeResId);
|
||||
|
||||
// Inflate with the builder's context to ensure the correct style is used.
|
||||
Context builderContext = (Context) builderClazz.getMethod("getContext").invoke(builder);
|
||||
|
Loading…
x
Reference in New Issue
Block a user