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

Commit 947f7824 authored by Adam Powell's avatar Adam Powell
Browse files

Fix bug 3245465 - Themed dialog icons

Added light/dark versions of holo dialog icons. Apps using
AlertDialogs that wish to use the system dialog icon should use
setIconAttribute(android.R.attr.alertDialogIcon) instead of
setIcon(android.R.drawable.ic_alert_dialog).

Change-Id: I40793a3164478be5ffa045ededfcab8210753a4b
parent 4d46ecb0
Loading
Loading
Loading
Loading
+37 −0
Original line number Original line Diff line number Diff line
@@ -2116,6 +2116,17 @@
 visibility="public"
 visibility="public"
>
>
</field>
</field>
<field name="alertDialogIcon"
 type="int"
 transient="false"
 volatile="false"
 value="16843607"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="alertDialogStyle"
<field name="alertDialogStyle"
 type="int"
 type="int"
 transient="false"
 transient="false"
@@ -26610,6 +26621,19 @@
<parameter name="icon" type="android.graphics.drawable.Drawable">
<parameter name="icon" type="android.graphics.drawable.Drawable">
</parameter>
</parameter>
</method>
</method>
<method name="setIconAttribute"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="attrId" type="int">
</parameter>
</method>
<method name="setInverseBackgroundForced"
<method name="setInverseBackgroundForced"
 return="void"
 return="void"
 abstract="false"
 abstract="false"
@@ -26807,6 +26831,19 @@
<parameter name="icon" type="android.graphics.drawable.Drawable">
<parameter name="icon" type="android.graphics.drawable.Drawable">
</parameter>
</parameter>
</method>
</method>
<method name="setIconAttribute"
 return="android.app.AlertDialog.Builder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="attrId" type="int">
</parameter>
</method>
<method name="setInverseBackgroundForced"
<method name="setInverseBackgroundForced"
 return="android.app.AlertDialog.Builder"
 return="android.app.AlertDialog.Builder"
 abstract="false"
 abstract="false"
+24 −1
Original line number Original line Diff line number Diff line
@@ -270,6 +270,17 @@ public class AlertDialog extends Dialog implements DialogInterface {
        mAlert.setIcon(icon);
        mAlert.setIcon(icon);
    }
    }


    /**
     * Set an icon as supplied by a theme attribute. e.g. android.R.attr.alertDialogIcon
     *
     * @param attrId ID of a theme attribute that points to a drawable resource.
     */
    public void setIconAttribute(int attrId) {
        TypedValue out = new TypedValue();
        mContext.getTheme().resolveAttribute(attrId, out, true);
        mAlert.setIcon(out.resourceId);
    }

    public void setInverseBackgroundForced(boolean forceInverseBackground) {
    public void setInverseBackgroundForced(boolean forceInverseBackground) {
        mAlert.setInverseBackgroundForced(forceInverseBackground);
        mAlert.setInverseBackgroundForced(forceInverseBackground);
    }
    }
@@ -400,6 +411,18 @@ public class AlertDialog extends Dialog implements DialogInterface {
            return this;
            return this;
        }
        }


        /**
         * Set an icon as supplied by a theme attribute. e.g. android.R.attr.alertDialogIcon
         *
         * @param attrId ID of a theme attribute that points to a drawable resource.
         */
        public Builder setIconAttribute(int attrId) {
            TypedValue out = new TypedValue();
            P.mContext.getTheme().resolveAttribute(attrId, out, true);
            P.mIconId = out.resourceId;
            return this;
        }

        /**
        /**
         * Set a listener to be invoked when the positive button of the dialog is pressed.
         * Set a listener to be invoked when the positive button of the dialog is pressed.
         * @param textId The resource id of the text to display in the positive button
         * @param textId The resource id of the text to display in the positive button
+4 −1
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.RemoteException;
import android.util.Log;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import android.view.View;
import android.view.Window;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.View.OnClickListener;
@@ -84,8 +85,10 @@ public class HeavyWeightSwitcherActivity extends Activity {
        button = findViewById((R.id.cancel));
        button = findViewById((R.id.cancel));
        button.setOnClickListener(mCancelListener);
        button.setOnClickListener(mCancelListener);
        
        
        TypedValue out = new TypedValue();
        getTheme().resolveAttribute(android.R.attr.alertDialogIcon, out, true);
        getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, 
        getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, 
                android.R.drawable.ic_dialog_alert);
                out.resourceId);
    }
    }


    void setText(int id, CharSequence text) {
    void setText(int id, CharSequence text) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -109,7 +109,7 @@ public final class ShutdownThread extends Thread {
        if (confirm) {
        if (confirm) {
            final CloseDialogReceiver closer = new CloseDialogReceiver(context);
            final CloseDialogReceiver closer = new CloseDialogReceiver(context);
            final AlertDialog dialog = new AlertDialog.Builder(context)
            final AlertDialog dialog = new AlertDialog.Builder(context)
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setIconAttribute(android.R.attr.alertDialogIcon)
                    .setTitle(com.android.internal.R.string.power_off)
                    .setTitle(com.android.internal.R.string.power_off)
                    .setMessage(resourceId)
                    .setMessage(resourceId)
                    .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() {
                    .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() {
+930 B
Loading image diff...
Loading