am 25931ade: Merge "Clean up drawable theming APIs" into lmp-preview-dev

* commit '25931adee5ba954220190f48901bb66c8c9dd462':
  Clean up drawable theming APIs
This commit is contained in:
Alan Viverette
2014-06-03 17:16:27 +00:00
committed by Android Git Automerger
17 changed files with 49 additions and 97 deletions

View File

@@ -702,12 +702,17 @@ public class Resources {
* Context.obtainStyledAttributes} with
* 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
* tool. This integer encodes the package, type, and resource
* entry. The value 0 is an invalid identifier.
* @return Drawable An object that can be used to draw this resource.
* @throws NotFoundException Throws NotFoundException if the given ID does
* not exist.
* @see #getDrawable(int, Theme)
*/
public Drawable getDrawable(int id) throws NotFoundException {
return getDrawable(id, null);
@@ -715,7 +720,9 @@ public class Resources {
/**
* 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
* 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
* 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.
* This integer encodes the package, type, and resource entry.
* The value 0 is an invalid identifier.
@@ -2340,12 +2352,12 @@ public class Resources {
if (file.endsWith(".xml")) {
final XmlResourceParser rp = loadXmlResourceParser(
file, id, value.assetCookie, "drawable");
dr = Drawable.createFromXmlThemed(this, rp, theme);
dr = Drawable.createFromXml(this, rp, theme);
rp.close();
} else {
final InputStream is = mAssets.openNonAsset(
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();
}
} catch (Exception e) {

View File

@@ -664,7 +664,7 @@ public class ImageView extends View {
InputStream stream = null;
try {
stream = mContext.getContentResolver().openInputStream(mUri);
d = Drawable.createFromStreamThemed(stream, null, mContext.getTheme());
d = Drawable.createFromStream(stream, null);
} catch (Exception e) {
Log.w("ImageView", "Unable to open content: " + mUri, e);
} finally {

View File

@@ -357,9 +357,8 @@ public class ProgressBar extends View {
Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
shapeDrawable.getPaint().setShader(bitmapShader);
// Ensure the color filter and tint are propagated.
shapeDrawable.setTint(bitmap.getTint());
shapeDrawable.setTintMode(bitmap.getTintMode());
// Ensure the tint and filter are propagated in the correct order.
shapeDrawable.setTint(bitmap.getTint(), bitmap.getTintMode());
shapeDrawable.setColorFilter(bitmap.getColorFilter());
return clip ? new ClipDrawable(

View File

@@ -574,7 +574,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter implements OnClickListene
throw new FileNotFoundException("Failed to open " + uri);
}
try {
return Drawable.createFromStreamThemed(stream, null, mContext.getTheme());
return Drawable.createFromStream(stream, null);
} finally {
try {
stream.close();