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

Commit 5a4af17e authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "Clean up drawable theming APIs" into lmp-preview-dev

parents 0bec6388 6dbe51b5
Loading
Loading
Loading
Loading
+2 −7
Original line number Original line Diff line number Diff line
@@ -11236,14 +11236,11 @@ package android.graphics.drawable {
    method public static android.graphics.drawable.Drawable createFromPath(java.lang.String);
    method public static android.graphics.drawable.Drawable createFromPath(java.lang.String);
    method public static android.graphics.drawable.Drawable createFromResourceStream(android.content.res.Resources, android.util.TypedValue, java.io.InputStream, java.lang.String);
    method public static android.graphics.drawable.Drawable createFromResourceStream(android.content.res.Resources, android.util.TypedValue, java.io.InputStream, java.lang.String);
    method public static android.graphics.drawable.Drawable createFromResourceStream(android.content.res.Resources, android.util.TypedValue, java.io.InputStream, java.lang.String, android.graphics.BitmapFactory.Options);
    method public static android.graphics.drawable.Drawable createFromResourceStream(android.content.res.Resources, android.util.TypedValue, java.io.InputStream, java.lang.String, android.graphics.BitmapFactory.Options);
    method public static android.graphics.drawable.Drawable createFromResourceStreamThemed(android.content.res.Resources, android.util.TypedValue, java.io.InputStream, java.lang.String, android.content.res.Resources.Theme);
    method public static android.graphics.drawable.Drawable createFromResourceStreamThemed(android.content.res.Resources, android.util.TypedValue, java.io.InputStream, java.lang.String, android.graphics.BitmapFactory.Options, android.content.res.Resources.Theme);
    method public static android.graphics.drawable.Drawable createFromStream(java.io.InputStream, java.lang.String);
    method public static android.graphics.drawable.Drawable createFromStream(java.io.InputStream, java.lang.String);
    method public static android.graphics.drawable.Drawable createFromStreamThemed(java.io.InputStream, java.lang.String, android.content.res.Resources.Theme);
    method public static android.graphics.drawable.Drawable createFromXml(android.content.res.Resources, org.xmlpull.v1.XmlPullParser) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public static android.graphics.drawable.Drawable createFromXml(android.content.res.Resources, org.xmlpull.v1.XmlPullParser) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public static android.graphics.drawable.Drawable createFromXml(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.content.res.Resources.Theme) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public static android.graphics.drawable.Drawable createFromXmlInner(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public static android.graphics.drawable.Drawable createFromXmlInner(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public static android.graphics.drawable.Drawable createFromXmlInnerThemed(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet, android.content.res.Resources.Theme) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public static android.graphics.drawable.Drawable createFromXmlInner(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet, android.content.res.Resources.Theme) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public static android.graphics.drawable.Drawable createFromXmlThemed(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.content.res.Resources.Theme) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public abstract void draw(android.graphics.Canvas);
    method public abstract void draw(android.graphics.Canvas);
    method public int getAlpha();
    method public int getAlpha();
    method public final android.graphics.Rect getBounds();
    method public final android.graphics.Rect getBounds();
@@ -11519,7 +11516,6 @@ package android.graphics.drawable {
    method public android.graphics.Paint getPaint();
    method public android.graphics.Paint getPaint();
    method public android.graphics.drawable.ShapeDrawable.ShaderFactory getShaderFactory();
    method public android.graphics.drawable.ShapeDrawable.ShaderFactory getShaderFactory();
    method public android.graphics.drawable.shapes.Shape getShape();
    method public android.graphics.drawable.shapes.Shape getShape();
    method public android.content.res.ColorStateList getTint();
    method protected boolean inflateTag(java.lang.String, android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet);
    method protected boolean inflateTag(java.lang.String, android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet);
    method protected void onDraw(android.graphics.drawable.shapes.Shape, android.graphics.Canvas, android.graphics.Paint);
    method protected void onDraw(android.graphics.drawable.shapes.Shape, android.graphics.Canvas, android.graphics.Paint);
    method public void setAlpha(int);
    method public void setAlpha(int);
@@ -11530,7 +11526,6 @@ package android.graphics.drawable {
    method public void setPadding(android.graphics.Rect);
    method public void setPadding(android.graphics.Rect);
    method public void setShaderFactory(android.graphics.drawable.ShapeDrawable.ShaderFactory);
    method public void setShaderFactory(android.graphics.drawable.ShapeDrawable.ShaderFactory);
    method public void setShape(android.graphics.drawable.shapes.Shape);
    method public void setShape(android.graphics.drawable.shapes.Shape);
    method public void setTint(android.content.res.ColorStateList);
  }
  }
  public static abstract class ShapeDrawable.ShaderFactory {
  public static abstract class ShapeDrawable.ShaderFactory {
+15 −3
Original line number Original line Diff line number Diff line
@@ -702,12 +702,17 @@ public class Resources {
     * Context.obtainStyledAttributes} with
     * Context.obtainStyledAttributes} with
     * an array containing the resource ID of interest to create the TypedArray.</p>
     * an array containing the resource ID of interest to create the TypedArray.</p>
     *
     *
     * <p class="note"><strong>Note:</strong> To obtain a themed drawable, use
     * {@link android.content.Context#getDrawable(int) Context.getDrawable(int)}
     * or {@link #getDrawable(int, Theme)} passing the desired theme.</p>
     *
     * @param id The desired resource identifier, as generated by the aapt
     * @param id The desired resource identifier, as generated by the aapt
     *           tool. This integer encodes the package, type, and resource
     *           tool. This integer encodes the package, type, and resource
     *           entry. The value 0 is an invalid identifier.
     *           entry. The value 0 is an invalid identifier.
     * @return Drawable An object that can be used to draw this resource.
     * @return Drawable An object that can be used to draw this resource.
     * @throws NotFoundException Throws NotFoundException if the given ID does
     * @throws NotFoundException Throws NotFoundException if the given ID does
     *         not exist.
     *         not exist.
     * @see #getDrawable(int, Theme)
     */
     */
    public Drawable getDrawable(int id) throws NotFoundException {
    public Drawable getDrawable(int id) throws NotFoundException {
        return getDrawable(id, null);
        return getDrawable(id, null);
@@ -715,7 +720,9 @@ public class Resources {


    /**
    /**
     * Return a drawable object associated with a particular resource ID and
     * Return a drawable object associated with a particular resource ID and
     * styled for the specified theme.
     * styled for the specified theme. Various types of objects will be
     * returned depending on the underlying resource -- for example, a solid
     * color, PNG image, scalable image, etc.
     *
     *
     * @param id The desired resource identifier, as generated by the aapt
     * @param id The desired resource identifier, as generated by the aapt
     *           tool. This integer encodes the package, type, and resource
     *           tool. This integer encodes the package, type, and resource
@@ -755,6 +762,11 @@ public class Resources {
     * image, scalable image, etc. The Drawable API hides these implementation
     * image, scalable image, etc. The Drawable API hides these implementation
     * details.
     * details.
     *
     *
     * <p class="note"><strong>Note:</strong> To obtain a themed drawable, use
     * {@link android.content.Context#getDrawable(int) Context.getDrawable(int)}
     * or {@link #getDrawableForDensity(int, int, Theme)} passing the desired
     * theme.</p>
     *
     * @param id The desired resource identifier, as generated by the aapt tool.
     * @param id The desired resource identifier, as generated by the aapt tool.
     *            This integer encodes the package, type, and resource entry.
     *            This integer encodes the package, type, and resource entry.
     *            The value 0 is an invalid identifier.
     *            The value 0 is an invalid identifier.
@@ -2340,12 +2352,12 @@ public class Resources {
            if (file.endsWith(".xml")) {
            if (file.endsWith(".xml")) {
                final XmlResourceParser rp = loadXmlResourceParser(
                final XmlResourceParser rp = loadXmlResourceParser(
                        file, id, value.assetCookie, "drawable");
                        file, id, value.assetCookie, "drawable");
                dr = Drawable.createFromXmlThemed(this, rp, theme);
                dr = Drawable.createFromXml(this, rp, theme);
                rp.close();
                rp.close();
            } else {
            } else {
                final InputStream is = mAssets.openNonAsset(
                final InputStream is = mAssets.openNonAsset(
                        value.assetCookie, file, AssetManager.ACCESS_STREAMING);
                        value.assetCookie, file, AssetManager.ACCESS_STREAMING);
                dr = Drawable.createFromResourceStreamThemed(this, value, is, file, null, theme);
                dr = Drawable.createFromResourceStream(this, value, is, file, null);
                is.close();
                is.close();
            }
            }
        } catch (Exception e) {
        } catch (Exception e) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -664,7 +664,7 @@ public class ImageView extends View {
                InputStream stream = null;
                InputStream stream = null;
                try {
                try {
                    stream = mContext.getContentResolver().openInputStream(mUri);
                    stream = mContext.getContentResolver().openInputStream(mUri);
                    d = Drawable.createFromStreamThemed(stream, null, mContext.getTheme());
                    d = Drawable.createFromStream(stream, null);
                } catch (Exception e) {
                } catch (Exception e) {
                    Log.w("ImageView", "Unable to open content: " + mUri, e);
                    Log.w("ImageView", "Unable to open content: " + mUri, e);
                } finally {
                } finally {
+2 −3
Original line number Original line Diff line number Diff line
@@ -357,9 +357,8 @@ public class ProgressBar extends View {
                    Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
                    Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
            shapeDrawable.getPaint().setShader(bitmapShader);
            shapeDrawable.getPaint().setShader(bitmapShader);


            // Ensure the color filter and tint are propagated.
            // Ensure the tint and filter are propagated in the correct order.
            shapeDrawable.setTint(bitmap.getTint());
            shapeDrawable.setTint(bitmap.getTint(), bitmap.getTintMode());
            shapeDrawable.setTintMode(bitmap.getTintMode());
            shapeDrawable.setColorFilter(bitmap.getColorFilter());
            shapeDrawable.setColorFilter(bitmap.getColorFilter());


            return clip ? new ClipDrawable(
            return clip ? new ClipDrawable(
+1 −1
Original line number Original line Diff line number Diff line
@@ -574,7 +574,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter implements OnClickListene
                    throw new FileNotFoundException("Failed to open " + uri);
                    throw new FileNotFoundException("Failed to open " + uri);
                }
                }
                try {
                try {
                    return Drawable.createFromStreamThemed(stream, null, mContext.getTheme());
                    return Drawable.createFromStream(stream, null);
                } finally {
                } finally {
                    try {
                    try {
                        stream.close();
                        stream.close();
Loading