Loading core/java/android/app/AlertDialog.java +13 −5 Original line number Diff line number Diff line Loading @@ -134,6 +134,7 @@ public class AlertDialog extends Dialog implements DialogInterface { * {@code context}'s theme. * * @param context the parent context * @see android.R.styleable#Theme_alertDialogTheme */ protected AlertDialog(Context context) { this(context, 0); Loading @@ -155,6 +156,7 @@ public class AlertDialog extends Dialog implements DialogInterface { * {@code context}'s theme. * * @param context the parent context * @see android.R.styleable#Theme_alertDialogTheme */ protected AlertDialog(Context context, boolean cancelable, OnCancelListener cancelListener) { this(context, 0); Loading Loading @@ -187,16 +189,24 @@ public class AlertDialog extends Dialog implements DialogInterface { * @param themeResId the resource ID of the theme against which to inflate * this dialog, or {@code 0} to use the parent * {@code context}'s default alert dialog theme * @see android.R.styleable#Theme_alertDialogTheme */ protected AlertDialog(Context context, @AttrRes int themeResId) { super(context, resolveDialogTheme(context, themeResId)); this(context, themeResId, true); } AlertDialog(Context context, @AttrRes int themeResId, boolean createContextThemeWrapper) { super(context, createContextThemeWrapper ? resolveDialogTheme(context, themeResId) : 0, createContextThemeWrapper); mWindow.alwaysReadCloseOnTouchAttr(); mAlert = new AlertController(getContext(), this, getWindow()); } static int resolveDialogTheme(Context context, int themeResId) { if (themeResId == THEME_TRADITIONAL) { if (themeResId == 0) { return 0; } else if (themeResId == THEME_TRADITIONAL) { return R.style.Theme_Dialog_Alert; } else if (themeResId == THEME_HOLO_DARK) { return R.style.Theme_Holo_Dialog_Alert; Loading Loading @@ -428,7 +438,6 @@ public class AlertDialog extends Dialog implements DialogInterface { public static class Builder { private final AlertController.AlertParams P; private int mThemeResId; /** * Creates a builder for an alert dialog that uses the default alert Loading Loading @@ -473,7 +482,6 @@ public class AlertDialog extends Dialog implements DialogInterface { public Builder(Context context, int themeResId) { P = new AlertController.AlertParams(new ContextThemeWrapper( context, resolveDialogTheme(context, themeResId))); mThemeResId = themeResId; } /** Loading Loading @@ -1075,7 +1083,7 @@ public class AlertDialog extends Dialog implements DialogInterface { * create and display the dialog. */ public AlertDialog create() { final AlertDialog dialog = new AlertDialog(P.mContext, mThemeResId); final AlertDialog dialog = new AlertDialog(P.mContext); P.apply(dialog.mAlert); dialog.setCancelable(P.mCancelable); if (P.mCancelable) { Loading core/java/android/app/Dialog.java +27 −19 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import android.annotation.DrawableRes; import android.annotation.IdRes; import android.annotation.LayoutRes; import android.annotation.StringRes; import com.android.internal.app.WindowDecorActionBar; import android.annotation.Nullable; import android.content.ComponentName; Loading Loading @@ -56,6 +55,9 @@ import android.view.Window; import android.view.WindowManager; import android.view.accessibility.AccessibilityEvent; import com.android.internal.R; import com.android.internal.app.WindowDecorActionBar; import java.lang.ref.WeakReference; /** Loading Loading @@ -130,27 +132,32 @@ public class Dialog implements DialogInterface, Window.Callback, }; /** * Create a Dialog window that uses the default dialog frame style. * Creates a dialog window that uses the default dialog theme. * <p> * The supplied {@code context} is used to obtain the window manager and * base theme used to present the dialog. * * @param context The Context the Dialog is to run it. In particular, it * uses the window manager and theme in this context to * present its UI. * @param context the context in which the dialog should run * @see android.R.styleable#Theme_dialogTheme */ public Dialog(Context context) { this(context, 0, true); } /** * Create a Dialog window that uses a custom dialog style. * Creates a dialog window that uses a custom dialog style. * <p> * The supplied {@code context} is used to obtain the window manager and * base theme used to present the dialog. * <p> * The supplied {@code theme} is applied on top of the context's theme. See * <a href="{@docRoot}guide/topics/resources/available-resources.html#stylesandthemes"> * Style and Theme Resources</a> for more information about defining and * using styles. * * @param context The Context in which the Dialog should run. In particular, it * uses the window manager and theme from this context to * present its UI. * @param theme A style resource describing the theme to use for the * window. See <a href="{@docRoot}guide/topics/resources/available-resources.html#stylesandthemes">Style * and Theme Resources</a> for more information about defining and using * styles. This theme is applied on top of the current theme in * <var>context</var>. If 0, the default dialog theme will be used. * @param context the context in which the dialog should run * @param theme a style resource describing the theme to use for the * window, or {@code 0} to use the default dialog theme */ public Dialog(Context context, int theme) { this(context, theme, true); Loading @@ -159,9 +166,8 @@ public class Dialog implements DialogInterface, Window.Callback, Dialog(Context context, int theme, boolean createContextThemeWrapper) { if (createContextThemeWrapper) { if (theme == 0) { TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(com.android.internal.R.attr.dialogTheme, outValue, true); final TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.dialogTheme, outValue, true); theme = outValue.resourceId; } mContext = new ContextThemeWrapper(context, theme); Loading @@ -170,12 +176,14 @@ public class Dialog implements DialogInterface, Window.Callback, } mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); Window w = new PhoneWindow(mContext); final Window w = new PhoneWindow(mContext); mWindow = w; w.setCallback(this); w.setOnWindowDismissedCallback(this); w.setWindowManager(mWindowManager, null, null); w.setGravity(Gravity.CENTER); mListenersHandler = new ListenersHandler(this); } Loading Loading
core/java/android/app/AlertDialog.java +13 −5 Original line number Diff line number Diff line Loading @@ -134,6 +134,7 @@ public class AlertDialog extends Dialog implements DialogInterface { * {@code context}'s theme. * * @param context the parent context * @see android.R.styleable#Theme_alertDialogTheme */ protected AlertDialog(Context context) { this(context, 0); Loading @@ -155,6 +156,7 @@ public class AlertDialog extends Dialog implements DialogInterface { * {@code context}'s theme. * * @param context the parent context * @see android.R.styleable#Theme_alertDialogTheme */ protected AlertDialog(Context context, boolean cancelable, OnCancelListener cancelListener) { this(context, 0); Loading Loading @@ -187,16 +189,24 @@ public class AlertDialog extends Dialog implements DialogInterface { * @param themeResId the resource ID of the theme against which to inflate * this dialog, or {@code 0} to use the parent * {@code context}'s default alert dialog theme * @see android.R.styleable#Theme_alertDialogTheme */ protected AlertDialog(Context context, @AttrRes int themeResId) { super(context, resolveDialogTheme(context, themeResId)); this(context, themeResId, true); } AlertDialog(Context context, @AttrRes int themeResId, boolean createContextThemeWrapper) { super(context, createContextThemeWrapper ? resolveDialogTheme(context, themeResId) : 0, createContextThemeWrapper); mWindow.alwaysReadCloseOnTouchAttr(); mAlert = new AlertController(getContext(), this, getWindow()); } static int resolveDialogTheme(Context context, int themeResId) { if (themeResId == THEME_TRADITIONAL) { if (themeResId == 0) { return 0; } else if (themeResId == THEME_TRADITIONAL) { return R.style.Theme_Dialog_Alert; } else if (themeResId == THEME_HOLO_DARK) { return R.style.Theme_Holo_Dialog_Alert; Loading Loading @@ -428,7 +438,6 @@ public class AlertDialog extends Dialog implements DialogInterface { public static class Builder { private final AlertController.AlertParams P; private int mThemeResId; /** * Creates a builder for an alert dialog that uses the default alert Loading Loading @@ -473,7 +482,6 @@ public class AlertDialog extends Dialog implements DialogInterface { public Builder(Context context, int themeResId) { P = new AlertController.AlertParams(new ContextThemeWrapper( context, resolveDialogTheme(context, themeResId))); mThemeResId = themeResId; } /** Loading Loading @@ -1075,7 +1083,7 @@ public class AlertDialog extends Dialog implements DialogInterface { * create and display the dialog. */ public AlertDialog create() { final AlertDialog dialog = new AlertDialog(P.mContext, mThemeResId); final AlertDialog dialog = new AlertDialog(P.mContext); P.apply(dialog.mAlert); dialog.setCancelable(P.mCancelable); if (P.mCancelable) { Loading
core/java/android/app/Dialog.java +27 −19 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import android.annotation.DrawableRes; import android.annotation.IdRes; import android.annotation.LayoutRes; import android.annotation.StringRes; import com.android.internal.app.WindowDecorActionBar; import android.annotation.Nullable; import android.content.ComponentName; Loading Loading @@ -56,6 +55,9 @@ import android.view.Window; import android.view.WindowManager; import android.view.accessibility.AccessibilityEvent; import com.android.internal.R; import com.android.internal.app.WindowDecorActionBar; import java.lang.ref.WeakReference; /** Loading Loading @@ -130,27 +132,32 @@ public class Dialog implements DialogInterface, Window.Callback, }; /** * Create a Dialog window that uses the default dialog frame style. * Creates a dialog window that uses the default dialog theme. * <p> * The supplied {@code context} is used to obtain the window manager and * base theme used to present the dialog. * * @param context The Context the Dialog is to run it. In particular, it * uses the window manager and theme in this context to * present its UI. * @param context the context in which the dialog should run * @see android.R.styleable#Theme_dialogTheme */ public Dialog(Context context) { this(context, 0, true); } /** * Create a Dialog window that uses a custom dialog style. * Creates a dialog window that uses a custom dialog style. * <p> * The supplied {@code context} is used to obtain the window manager and * base theme used to present the dialog. * <p> * The supplied {@code theme} is applied on top of the context's theme. See * <a href="{@docRoot}guide/topics/resources/available-resources.html#stylesandthemes"> * Style and Theme Resources</a> for more information about defining and * using styles. * * @param context The Context in which the Dialog should run. In particular, it * uses the window manager and theme from this context to * present its UI. * @param theme A style resource describing the theme to use for the * window. See <a href="{@docRoot}guide/topics/resources/available-resources.html#stylesandthemes">Style * and Theme Resources</a> for more information about defining and using * styles. This theme is applied on top of the current theme in * <var>context</var>. If 0, the default dialog theme will be used. * @param context the context in which the dialog should run * @param theme a style resource describing the theme to use for the * window, or {@code 0} to use the default dialog theme */ public Dialog(Context context, int theme) { this(context, theme, true); Loading @@ -159,9 +166,8 @@ public class Dialog implements DialogInterface, Window.Callback, Dialog(Context context, int theme, boolean createContextThemeWrapper) { if (createContextThemeWrapper) { if (theme == 0) { TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(com.android.internal.R.attr.dialogTheme, outValue, true); final TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.dialogTheme, outValue, true); theme = outValue.resourceId; } mContext = new ContextThemeWrapper(context, theme); Loading @@ -170,12 +176,14 @@ public class Dialog implements DialogInterface, Window.Callback, } mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); Window w = new PhoneWindow(mContext); final Window w = new PhoneWindow(mContext); mWindow = w; w.setCallback(this); w.setOnWindowDismissedCallback(this); w.setWindowManager(mWindowManager, null, null); w.setGravity(Gravity.CENTER); mListenersHandler = new ListenersHandler(this); } Loading