Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 682a433d authored by Alan Viverette's avatar Alan Viverette
Browse files

Fix application of default dialog theme

Cleans up lint annotations.

Bug: 20149703
Change-Id: I2ed4eb002b6679a55ea4d5fcc1ea958a4dcb08df
parent caa41648
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.annotation.ArrayRes;
import android.annotation.AttrRes;
import android.annotation.DrawableRes;
import android.annotation.StringRes;
import android.annotation.StyleRes;
import android.content.Context;
import android.content.DialogInterface;
import android.database.Cursor;
@@ -191,11 +192,11 @@ public class AlertDialog extends Dialog implements DialogInterface {
     *                   {@code context}'s default alert dialog theme
     * @see android.R.styleable#Theme_alertDialogTheme
     */
    protected AlertDialog(Context context, @AttrRes int themeResId) {
    protected AlertDialog(Context context, @StyleRes int themeResId) {
        this(context, themeResId, true);
    }

    AlertDialog(Context context, @AttrRes int themeResId, boolean createContextThemeWrapper) {
    AlertDialog(Context context, @StyleRes int themeResId, boolean createContextThemeWrapper) {
        super(context, createContextThemeWrapper ? resolveDialogTheme(context, themeResId) : 0,
                createContextThemeWrapper);

@@ -204,9 +205,7 @@ public class AlertDialog extends Dialog implements DialogInterface {
    }

    static int resolveDialogTheme(Context context, int themeResId) {
        if (themeResId == 0) {
            return 0;
        } else if (themeResId == THEME_TRADITIONAL) {
        if (themeResId == THEME_TRADITIONAL) {
            return R.style.Theme_Dialog_Alert;
        } else if (themeResId == THEME_HOLO_DARK) {
            return R.style.Theme_Holo_Dialog_Alert;
+14 −12
Original line number Diff line number Diff line
@@ -20,9 +20,11 @@ import android.annotation.CallSuper;
import android.annotation.DrawableRes;
import android.annotation.IdRes;
import android.annotation.LayoutRes;
import android.annotation.NonNull;
import android.annotation.StringRes;

import android.annotation.Nullable;
import android.annotation.StyleRes;
import android.content.ComponentName;
import android.content.Context;
import android.content.ContextWrapper;
@@ -140,7 +142,7 @@ public class Dialog implements DialogInterface, Window.Callback,
     * @param context the context in which the dialog should run
     * @see android.R.styleable#Theme_dialogTheme
     */
    public Dialog(Context context) {
    public Dialog(@NonNull Context context) {
        this(context, 0, true);
    }

@@ -156,21 +158,21 @@ public class Dialog implements DialogInterface, Window.Callback,
     * using styles.
     *
     * @param context the context in which the dialog should run
     * @param theme a style resource describing the theme to use for the
     * @param themeResId 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);
    public Dialog(@NonNull Context context, @StyleRes int themeResId) {
        this(context, themeResId, true);
    }

    Dialog(Context context, int theme, boolean createContextThemeWrapper) {
    Dialog(@NonNull Context context, @StyleRes int themeResId, boolean createContextThemeWrapper) {
        if (createContextThemeWrapper) {
            if (theme == 0) {
            if (themeResId == 0) {
                final TypedValue outValue = new TypedValue();
                context.getTheme().resolveAttribute(R.attr.dialogTheme, outValue, true);
                theme = outValue.resourceId;
                themeResId = outValue.resourceId;
            }
            mContext = new ContextThemeWrapper(context, theme);
            mContext = new ContextThemeWrapper(context, themeResId);
        } else {
            mContext = context;
        }
@@ -192,14 +194,13 @@ public class Dialog implements DialogInterface, Window.Callback,
     * @hide
     */
    @Deprecated
    protected Dialog(Context context, boolean cancelable,
            Message cancelCallback) {
    protected Dialog(@NonNull Context context, boolean cancelable, Message cancelCallback) {
        this(context);
        mCancelable = cancelable;
        mCancelMessage = cancelCallback;
    }

    protected Dialog(Context context, boolean cancelable,
    protected Dialog(@NonNull Context context, boolean cancelable,
            OnCancelListener cancelListener) {
        this(context);
        mCancelable = cancelable;
@@ -211,6 +212,7 @@ public class Dialog implements DialogInterface, Window.Callback,
     * 
     * @return Context The Context used by the Dialog.
     */
    @NonNull
    public final Context getContext() {
        return mContext;
    }