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

Commit c459622d authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

Merge "Holo theme progress and assets!"

parents 118c8490 2fbf4de6
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -2352,6 +2352,17 @@
 visibility="public"
>
</field>
<field name="alertDialogTheme"
 type="int"
 transient="false"
 volatile="false"
 value="16843598"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="allContactsName"
 type="int"
 transient="false"
@@ -3617,6 +3628,17 @@
 visibility="public"
>
</field>
<field name="dialogTheme"
 type="int"
 transient="false"
 volatile="false"
 value="16843597"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="dialogTitle"
 type="int"
 transient="false"
+14 −14
Original line number Diff line number Diff line
@@ -22,9 +22,10 @@ import android.content.Context;
import android.content.DialogInterface;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.util.Log;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.View;
@@ -58,27 +59,29 @@ public class AlertDialog extends Dialog implements DialogInterface {
    private AlertController mAlert;

    protected AlertDialog(Context context) {
        this(context,
                context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB
                        ? com.android.internal.R.style.Theme_Holo_Dialog_Alert
                        : com.android.internal.R.style.Theme_Dialog_Alert);
        this(context, getDefaultDialogTheme(context));
    }

    protected AlertDialog(Context context, int theme) {
        super(context, theme);
        super(context, theme == 0 ? getDefaultDialogTheme(context) : theme);
        mAlert = new AlertController(context, this, getWindow());
    }

    protected AlertDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context,
                context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB
                ? com.android.internal.R.style.Theme_Holo_Dialog_Alert
                : com.android.internal.R.style.Theme_Dialog_Alert);
        super(context, getDefaultDialogTheme(context));
        setCancelable(cancelable);
        setOnCancelListener(cancelListener);
        mAlert = new AlertController(context, this, getWindow());
    }

    private static int getDefaultDialogTheme(Context context) {
        TypedValue outValue = new TypedValue();
        context.getTheme().resolveAttribute(com.android.internal.R.attr.alertDialogTheme,
                outValue, true);
        Log.d("AlertDialog", "getDefaultDialogTheme data " + outValue.data + " id " + outValue.resourceId);
        return outValue.resourceId;
    }

    /**
     * Gets one of the buttons used in the dialog.
     * <p>
@@ -280,10 +283,7 @@ public class AlertDialog extends Dialog implements DialogInterface {
         * Constructor using a context for this builder and the {@link AlertDialog} it creates.
         */
        public Builder(Context context) {
            this(context,
                    context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB
                    ? com.android.internal.R.style.Theme_Holo_Dialog_Alert
                    : com.android.internal.R.style.Theme_Dialog_Alert);
            this(context, getDefaultDialogTheme(context));
        }

        /**
+9 −5
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.TypedValue;
import android.view.ActionMode;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
@@ -140,11 +141,14 @@ public class Dialog implements DialogInterface, Window.Callback,
     * <var>context</var>.  If 0, the default dialog theme will be used.
     */
    public Dialog(Context context, int theme) {
        mContext = new ContextThemeWrapper(
            context, theme == 0 ? 
                    (context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB
                            ? com.android.internal.R.style.Theme_Holo_Dialog
                                    : com.android.internal.R.style.Theme_Dialog) : theme);
        if (theme == 0) {
            TypedValue outValue = new TypedValue();
            context.getTheme().resolveAttribute(com.android.internal.R.attr.dialogTheme,
                    outValue, true);
            theme = outValue.resourceId;
        }

        mContext = new ContextThemeWrapper(context, theme);
        mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
        Window w = PolicyManager.makeNewWindow(mContext);
        mWindow = w;
+29 −9
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
@@ -77,16 +78,17 @@ public class MenuBuilder implements Menu {

    private static final String VIEWS_TAG = "android:views";

    private static final int THEME_SYSTEM_DEFAULT = 0;
    private static final int THEME_APPLICATION = -1;
    private static final int THEME_ALERT_DIALOG = -2;

    // Order must be the same order as the TYPE_*
    // Special values:
    // 0: Use the system default theme
    // -1: Use the app's own theme
    static final int THEME_RES_FOR_TYPE[] = new int[] {
        com.android.internal.R.style.Theme_IconMenu,
        com.android.internal.R.style.Theme_ExpandedMenu,
        com.android.internal.R.style.Theme_Light,
        -1,
        -1,
        THEME_ALERT_DIALOG,
        THEME_APPLICATION,
        THEME_APPLICATION,
    };
    
    // Order must be the same order as the TYPE_*
@@ -206,6 +208,13 @@ public class MenuBuilder implements Menu {
    
    private boolean mOptionalIconsVisible = false;

    private static int getAlertDialogTheme(Context context) {
        TypedValue outValue = new TypedValue();
        context.getTheme().resolveAttribute(com.android.internal.R.attr.alertDialogTheme,
                outValue, true);
        return outValue.resourceId;
    }

    private MenuType[] mMenuTypes;
    class MenuType {
        private int mMenuType;
@@ -223,9 +232,20 @@ public class MenuBuilder implements Menu {
        LayoutInflater getInflater() {
            // Create an inflater that uses the given theme for the Views it inflates
            if (mInflater == null) {
                Context wrappedContext;
                int themeResForType = THEME_RES_FOR_TYPE[mMenuType];
                Context wrappedContext = themeResForType < 0 ? mContext :
                        new ContextThemeWrapper(mContext, themeResForType);
                switch (themeResForType) {
                    case THEME_APPLICATION:
                        wrappedContext = new ContextThemeWrapper(mContext, themeResForType);
                        break;
                    case THEME_ALERT_DIALOG:
                        wrappedContext = new ContextThemeWrapper(mContext,
                                getAlertDialogTheme(mContext));
                        break;
                    default:
                        wrappedContext = mContext;
                        break;
                }
                mInflater = (LayoutInflater) wrappedContext
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            }
+599 B
Loading image diff...
Loading