diff options
Diffstat (limited to 'graphics/java')
8 files changed, 46 insertions, 19 deletions
diff --git a/graphics/java/android/graphics/drawable/BitmapDrawable.java b/graphics/java/android/graphics/drawable/BitmapDrawable.java index a0c407f..f059727 100644 --- a/graphics/java/android/graphics/drawable/BitmapDrawable.java +++ b/graphics/java/android/graphics/drawable/BitmapDrawable.java @@ -363,7 +363,7 @@ public class BitmapDrawable extends Drawable { } @Override - public boolean getDither() { + public boolean isDither() { return mBitmapState.mPaint.isDither(); } diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java index 415af0d..6090cf0 100644 --- a/graphics/java/android/graphics/drawable/Drawable.java +++ b/graphics/java/android/graphics/drawable/Drawable.java @@ -279,7 +279,7 @@ public abstract class Drawable { * @return whether this drawable dithers its colors * @see #setDither(boolean) */ - public boolean getDither() { + public boolean isDither() { return false; } diff --git a/graphics/java/android/graphics/drawable/DrawableContainer.java b/graphics/java/android/graphics/drawable/DrawableContainer.java index 8b801c3..1759f53 100644 --- a/graphics/java/android/graphics/drawable/DrawableContainer.java +++ b/graphics/java/android/graphics/drawable/DrawableContainer.java @@ -167,7 +167,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { } @Override - public boolean getDither() { + public boolean isDither() { return mDrawableContainerState.mDither; } diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java index ed47eed..626991d 100644 --- a/graphics/java/android/graphics/drawable/GradientDrawable.java +++ b/graphics/java/android/graphics/drawable/GradientDrawable.java @@ -826,7 +826,7 @@ public class GradientDrawable extends Drawable { } @Override - public boolean getDither() { + public boolean isDither() { return mGradientState.mDither; } diff --git a/graphics/java/android/graphics/drawable/Icon.java b/graphics/java/android/graphics/drawable/Icon.java index 7b4329a..85db6a1 100644 --- a/graphics/java/android/graphics/drawable/Icon.java +++ b/graphics/java/android/graphics/drawable/Icon.java @@ -29,6 +29,7 @@ import android.os.Handler; import android.os.Message; import android.os.Parcel; import android.os.Parcelable; +import android.text.TextUtils; import android.util.Log; import java.io.DataInputStream; @@ -258,16 +259,21 @@ public final class Icon implements Parcelable { return new BitmapDrawable(context.getResources(), getBitmap()); case TYPE_RESOURCE: if (getResources() == null) { - if (getResPackage() == null || "android".equals(getResPackage())) { + // figure out where to load resources from + String resPackage = getResPackage(); + if (TextUtils.isEmpty(resPackage)) { + // if none is specified, try the given context + resPackage = context.getPackageName(); + } + if ("android".equals(resPackage)) { mObj1 = Resources.getSystem(); } else { final PackageManager pm = context.getPackageManager(); try { - mObj1 = pm.getResourcesForApplication(getResPackage()); + mObj1 = pm.getResourcesForApplication(resPackage); } catch (PackageManager.NameNotFoundException e) { - Log.e(TAG, String.format("Unable to find pkg=%s", - getResPackage()), - e); + Log.e(TAG, String.format("Unable to find pkg=%s for icon %s", + resPackage, this), e); break; } } @@ -320,12 +326,15 @@ public final class Icon implements Parcelable { */ public Drawable loadDrawableAsUser(Context context, int userId) { if (mType == TYPE_RESOURCE) { - if (getResources() == null - && getResPackage() != null - && !(getResPackage().equals("android"))) { + String resPackage = getResPackage(); + if (TextUtils.isEmpty(resPackage)) { + resPackage = context.getPackageName(); + } + if (getResources() == null && !(getResPackage().equals("android"))) { final PackageManager pm = context.getPackageManager(); try { - mObj1 = pm.getResourcesForApplicationAsUser(getResPackage(), userId); + // assign getResources() as the correct user + mObj1 = pm.getResourcesForApplicationAsUser(resPackage, userId); } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, String.format("Unable to find pkg=%s user=%d", getResPackage(), @@ -410,6 +419,9 @@ public final class Icon implements Parcelable { * @param resId ID of the drawable resource */ public static Icon createWithResource(Context context, @DrawableRes int resId) { + if (context == null) { + throw new IllegalArgumentException("Context must not be null."); + } final Icon rep = new Icon(TYPE_RESOURCE); rep.mInt1 = resId; rep.mString1 = context.getPackageName(); diff --git a/graphics/java/android/graphics/drawable/LayerDrawable.java b/graphics/java/android/graphics/drawable/LayerDrawable.java index 5c00a23..90891f6 100644 --- a/graphics/java/android/graphics/drawable/LayerDrawable.java +++ b/graphics/java/android/graphics/drawable/LayerDrawable.java @@ -1248,12 +1248,12 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { } @Override - public boolean getDither() { + public boolean isDither() { final Drawable dr = getFirstNonNullDrawable(); if (dr != null) { - return dr.getDither(); + return dr.isDither(); } else { - return super.getDither(); + return super.isDither(); } } @@ -1537,8 +1537,23 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { continue; } + // Take the resolved layout direction into account. If start / end + // padding are defined, they will be resolved (hence overriding) to + // left / right or right / left depending on the resolved layout + // direction. If start / end padding are not defined, use the + // left / right ones. + final int insetL, insetR; + final int layoutDirection = getLayoutDirection(); + if (layoutDirection == LayoutDirection.RTL) { + insetL = r.mInsetE == UNDEFINED_INSET ? r.mInsetL : r.mInsetE; + insetR = r.mInsetS == UNDEFINED_INSET ? r.mInsetR : r.mInsetS; + } else { + insetL = r.mInsetS == UNDEFINED_INSET ? r.mInsetL : r.mInsetS; + insetR = r.mInsetE == UNDEFINED_INSET ? r.mInsetR : r.mInsetE; + } + final int minWidth = r.mWidth < 0 ? r.mDrawable.getIntrinsicWidth() : r.mWidth; - final int w = minWidth + r.mInsetL + r.mInsetR + padL + padR; + final int w = minWidth + insetL + insetR + padL + padR; if (w > width) { width = w; } diff --git a/graphics/java/android/graphics/drawable/NinePatchDrawable.java b/graphics/java/android/graphics/drawable/NinePatchDrawable.java index 0b7869b..adf53e3 100644 --- a/graphics/java/android/graphics/drawable/NinePatchDrawable.java +++ b/graphics/java/android/graphics/drawable/NinePatchDrawable.java @@ -374,7 +374,7 @@ public class NinePatchDrawable extends Drawable { } @Override - public boolean getDither() { + public boolean isDither() { return mPaint == null ? DEFAULT_DITHER : mPaint.isDither(); } diff --git a/graphics/java/android/graphics/drawable/ShapeDrawable.java b/graphics/java/android/graphics/drawable/ShapeDrawable.java index 334b3bd..a669d3c 100644 --- a/graphics/java/android/graphics/drawable/ShapeDrawable.java +++ b/graphics/java/android/graphics/drawable/ShapeDrawable.java @@ -328,7 +328,7 @@ public class ShapeDrawable extends Drawable { } @Override - public boolean getDither() { + public boolean isDither() { return mShapeState.mPaint.isDither(); } |
