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

Commit a42d2eaf authored by Tor Norbye's avatar Tor Norbye Committed by Android (Google) Code Review
Browse files

Merge "Add @ResourceInt annotations on APIs"

parents fbf25512 7b9c912f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package android.animation;

import android.annotation.AnimatorRes;
import android.content.Context;
import android.content.res.ConfigurationBoundResourceCache;
import android.content.res.ConstantState;
@@ -82,7 +83,7 @@ public class AnimatorInflater {
     * @return The animator object reference by the specified id
     * @throws android.content.res.Resources.NotFoundException when the animation cannot be loaded
     */
    public static Animator loadAnimator(Context context, int id)
    public static Animator loadAnimator(Context context, @AnimatorRes int id)
            throws NotFoundException {
        return loadAnimator(context.getResources(), context.getTheme(), id);
    }
+14 −11
Original line number Diff line number Diff line
@@ -16,9 +16,12 @@

package android.app;

import android.annotation.DrawableRes;
import android.annotation.IntDef;
import android.annotation.LayoutRes;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.StringRes;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
@@ -256,7 +259,7 @@ public abstract class ActionBar {
     *
     * @see #setDisplayOptions(int, int)
     */
    public abstract void setCustomView(int resId);
    public abstract void setCustomView(@LayoutRes int resId);

    /**
     * Set the icon to display in the 'home' section of the action bar.
@@ -271,7 +274,7 @@ public abstract class ActionBar {
     * @see #setDisplayUseLogoEnabled(boolean)
     * @see #setDisplayShowHomeEnabled(boolean)
     */
    public abstract void setIcon(int resId);
    public abstract void setIcon(@DrawableRes int resId);

    /**
     * Set the icon to display in the 'home' section of the action bar.
@@ -301,7 +304,7 @@ public abstract class ActionBar {
     * @see #setDisplayUseLogoEnabled(boolean)
     * @see #setDisplayShowHomeEnabled(boolean)
     */
    public abstract void setLogo(int resId);
    public abstract void setLogo(@DrawableRes int resId);

    /**
     * Set the logo to display in the 'home' section of the action bar.
@@ -397,7 +400,7 @@ public abstract class ActionBar {
     * @see #setTitle(CharSequence)
     * @see #setDisplayOptions(int, int)
     */
    public abstract void setTitle(int resId);
    public abstract void setTitle(@StringRes int resId);

    /**
     * Set the action bar's subtitle. This will only be displayed if
@@ -420,7 +423,7 @@ public abstract class ActionBar {
     * @see #setSubtitle(CharSequence)
     * @see #setDisplayOptions(int, int)
     */
    public abstract void setSubtitle(int resId);
    public abstract void setSubtitle(@StringRes int resId);

    /**
     * Set display options. This changes all display option bits at once. To change
@@ -892,7 +895,7 @@ public abstract class ActionBar {
     * @see #setDisplayHomeAsUpEnabled(boolean)
     * @see #setHomeActionContentDescription(int)
     */
    public void setHomeAsUpIndicator(int resId) { }
    public void setHomeAsUpIndicator(@DrawableRes int resId) { }

    /**
     * Set an alternate description for the Home/Up action, when enabled.
@@ -931,7 +934,7 @@ public abstract class ActionBar {
     * @see #setHomeAsUpIndicator(int)
     * @see #setHomeAsUpIndicator(android.graphics.drawable.Drawable)
     */
    public void setHomeActionContentDescription(int resId) { }
    public void setHomeActionContentDescription(@StringRes int resId) { }

    /**
     * Enable hiding the action bar on content scroll.
@@ -1154,7 +1157,7 @@ public abstract class ActionBar {
         * @param resId Resource ID referring to the drawable to use as an icon
         * @return The current instance for call chaining
         */
        public abstract Tab setIcon(int resId);
        public abstract Tab setIcon(@DrawableRes int resId);

        /**
         * Set the text displayed on this tab. Text may be truncated if there is not
@@ -1172,7 +1175,7 @@ public abstract class ActionBar {
         * @param resId A resource ID referring to the text that should be displayed
         * @return The current instance for call chaining
         */
        public abstract Tab setText(int resId);
        public abstract Tab setText(@StringRes int resId);

        /**
         * Set a custom view to be used for this tab. This overrides values set by
@@ -1190,7 +1193,7 @@ public abstract class ActionBar {
         * @param layoutResId A layout resource to inflate and use as a custom tab view
         * @return The current instance for call chaining
         */
        public abstract Tab setCustomView(int layoutResId);
        public abstract Tab setCustomView(@LayoutRes int layoutResId);

        /**
         * Retrieve a previously set custom view for this tab.
@@ -1235,7 +1238,7 @@ public abstract class ActionBar {
         * @see #setContentDescription(CharSequence)
         * @see #getContentDescription()
         */
        public abstract Tab setContentDescription(int resId);
        public abstract Tab setContentDescription(@StringRes int resId);

        /**
         * Set a description of this tab's content for use in accessibility support.
+10 −4
Original line number Diff line number Diff line
@@ -16,7 +16,13 @@

package android.app;

import android.annotation.DrawableRes;
import android.annotation.IdRes;
import android.annotation.IntDef;
import android.annotation.LayoutRes;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.StyleRes;
import android.os.PersistableBundle;
import android.transition.Scene;
import android.transition.TransitionManager;
@@ -2070,7 +2076,7 @@ public class Activity extends ContextThemeWrapper
     * @return The view if found or null otherwise.
     */
    @Nullable
    public View findViewById(int id) {
    public View findViewById(@IdRes int id) {
        return getWindow().findViewById(id);
    }

@@ -2143,7 +2149,7 @@ public class Activity extends ContextThemeWrapper
     * @see #setContentView(android.view.View)
     * @see #setContentView(android.view.View, android.view.ViewGroup.LayoutParams)
     */
    public void setContentView(int layoutResID) {
    public void setContentView(@LayoutRes int layoutResID) {
        getWindow().setContentView(layoutResID);
        initWindowDecorActionBar();
    }
@@ -3611,7 +3617,7 @@ public class Activity extends ContextThemeWrapper
     * Convenience for calling
     * {@link android.view.Window#setFeatureDrawableResource}.
     */
    public final void setFeatureDrawableResource(int featureId, int resId) {
    public final void setFeatureDrawableResource(int featureId, @DrawableRes int resId) {
        getWindow().setFeatureDrawableResource(featureId, resId);
    }

@@ -3666,7 +3672,7 @@ public class Activity extends ContextThemeWrapper
    }

    @Override
    protected void onApplyThemeResource(Resources.Theme theme, int resid,
    protected void onApplyThemeResource(Resources.Theme theme, @StyleRes int resid,
            boolean first) {
        if (mParent == null) {
            super.onApplyThemeResource(theme, resid, first);
+17 −13
Original line number Diff line number Diff line
@@ -18,6 +18,10 @@ package android.app;

import com.android.internal.app.AlertController;

import android.annotation.ArrayRes;
import android.annotation.AttrRes;
import android.annotation.DrawableRes;
import android.annotation.StringRes;
import android.content.Context;
import android.content.DialogInterface;
import android.database.Cursor;
@@ -117,7 +121,7 @@ public class AlertDialog extends Dialog implements DialogInterface {
     * or one of the constants {@link #THEME_TRADITIONAL},
     * {@link #THEME_HOLO_DARK}, or {@link #THEME_HOLO_LIGHT}.
     */
    protected AlertDialog(Context context, int theme) {
    protected AlertDialog(Context context, @AttrRes int theme) {
        this(context, theme, true);
    }

@@ -327,7 +331,7 @@ public class AlertDialog extends Dialog implements DialogInterface {
     * @param resId the resourceId of the drawable to use as the icon or 0
     * if you don't want an icon.
     */
    public void setIcon(int resId) {
    public void setIcon(@DrawableRes int resId) {
        mAlert.setIcon(resId);
    }
    
@@ -340,7 +344,7 @@ public class AlertDialog extends Dialog implements DialogInterface {
     *
     * @param attrId ID of a theme attribute that points to a drawable resource.
     */
    public void setIconAttribute(int attrId) {
    public void setIconAttribute(@AttrRes int attrId) {
        TypedValue out = new TypedValue();
        mContext.getTheme().resolveAttribute(attrId, out, true);
        mAlert.setIcon(out.resourceId);
@@ -413,7 +417,7 @@ public class AlertDialog extends Dialog implements DialogInterface {
         *
         * @return This Builder object to allow for chaining of calls to set methods
         */
        public Builder setTitle(int titleId) {
        public Builder setTitle(@StringRes int titleId) {
            P.mTitle = P.mContext.getText(titleId);
            return this;
        }
@@ -449,7 +453,7 @@ public class AlertDialog extends Dialog implements DialogInterface {
         *
         * @return This Builder object to allow for chaining of calls to set methods
         */
        public Builder setMessage(int messageId) {
        public Builder setMessage(@StringRes int messageId) {
            P.mMessage = P.mContext.getText(messageId);
            return this;
        }
@@ -471,7 +475,7 @@ public class AlertDialog extends Dialog implements DialogInterface {
         *
         * @return This Builder object to allow for chaining of calls to set methods
         */
        public Builder setIcon(int iconId) {
        public Builder setIcon(@DrawableRes int iconId) {
            P.mIconId = iconId;
            return this;
        }
@@ -495,7 +499,7 @@ public class AlertDialog extends Dialog implements DialogInterface {
         *
         * @param attrId ID of a theme attribute that points to a drawable resource.
         */
        public Builder setIconAttribute(int attrId) {
        public Builder setIconAttribute(@AttrRes int attrId) {
            TypedValue out = new TypedValue();
            P.mContext.getTheme().resolveAttribute(attrId, out, true);
            P.mIconId = out.resourceId;
@@ -509,7 +513,7 @@ public class AlertDialog extends Dialog implements DialogInterface {
         *
         * @return This Builder object to allow for chaining of calls to set methods
         */
        public Builder setPositiveButton(int textId, final OnClickListener listener) {
        public Builder setPositiveButton(@StringRes int textId, final OnClickListener listener) {
            P.mPositiveButtonText = P.mContext.getText(textId);
            P.mPositiveButtonListener = listener;
            return this;
@@ -535,7 +539,7 @@ public class AlertDialog extends Dialog implements DialogInterface {
         *
         * @return This Builder object to allow for chaining of calls to set methods
         */
        public Builder setNegativeButton(int textId, final OnClickListener listener) {
        public Builder setNegativeButton(@StringRes int textId, final OnClickListener listener) {
            P.mNegativeButtonText = P.mContext.getText(textId);
            P.mNegativeButtonListener = listener;
            return this;
@@ -561,7 +565,7 @@ public class AlertDialog extends Dialog implements DialogInterface {
         *
         * @return This Builder object to allow for chaining of calls to set methods
         */
        public Builder setNeutralButton(int textId, final OnClickListener listener) {
        public Builder setNeutralButton(@StringRes int textId, final OnClickListener listener) {
            P.mNeutralButtonText = P.mContext.getText(textId);
            P.mNeutralButtonListener = listener;
            return this;
@@ -634,7 +638,7 @@ public class AlertDialog extends Dialog implements DialogInterface {
         *
         * @return This Builder object to allow for chaining of calls to set methods
         */
        public Builder setItems(int itemsId, final OnClickListener listener) {
        public Builder setItems(@ArrayRes int itemsId, final OnClickListener listener) {
            P.mItems = P.mContext.getResources().getTextArray(itemsId);
            P.mOnClickListener = listener;
            return this;
@@ -706,7 +710,7 @@ public class AlertDialog extends Dialog implements DialogInterface {
         *
         * @return This Builder object to allow for chaining of calls to set methods
         */
        public Builder setMultiChoiceItems(int itemsId, boolean[] checkedItems, 
        public Builder setMultiChoiceItems(@ArrayRes int itemsId, boolean[] checkedItems,
                final OnMultiChoiceClickListener listener) {
            P.mItems = P.mContext.getResources().getTextArray(itemsId);
            P.mOnCheckboxClickListener = listener;
@@ -785,7 +789,7 @@ public class AlertDialog extends Dialog implements DialogInterface {
         *
         * @return This Builder object to allow for chaining of calls to set methods
         */
        public Builder setSingleChoiceItems(int itemsId, int checkedItem, 
        public Builder setSingleChoiceItems(@ArrayRes int itemsId, int checkedItem,
                final OnClickListener listener) {
            P.mItems = P.mContext.getResources().getTextArray(itemsId);
            P.mOnClickListener = listener;
+6 −3
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package android.app;

import android.annotation.DrawableRes;
import android.annotation.StringRes;
import android.annotation.XmlRes;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Intent;
@@ -730,7 +733,7 @@ final class ApplicationPackageManager extends PackageManager {
        }
    }

    @Override public Drawable getDrawable(String packageName, int resid,
    @Override public Drawable getDrawable(String packageName, @DrawableRes int resid,
                                          ApplicationInfo appInfo) {
        ResourceName name = new ResourceName(packageName, resid);
        Drawable dr = getCachedIcon(name);
@@ -1137,7 +1140,7 @@ final class ApplicationPackageManager extends PackageManager {
    }

    @Override
    public CharSequence getText(String packageName, int resid,
    public CharSequence getText(String packageName, @StringRes int resid,
                                ApplicationInfo appInfo) {
        ResourceName name = new ResourceName(packageName, resid);
        CharSequence text = getCachedString(name);
@@ -1170,7 +1173,7 @@ final class ApplicationPackageManager extends PackageManager {
    }

    @Override
    public XmlResourceParser getXml(String packageName, int resid,
    public XmlResourceParser getXml(String packageName, @XmlRes int resid,
                                    ApplicationInfo appInfo) {
        if (appInfo == null) {
            try {
Loading