Use Resources to load search icons with android.resource URIs
Before, all icon URIs were opened with ContentResolver.openInputStream(Uri), but that does not include the density information from the source application. Now, if the URI uses the android.resource scheme, we resolve the URI to a Resources and a resource ID, and load it with Resources.getDrawable(int). This requires making OpenResourceIdResult and getResourceId() in ContentResolver public (but hidden). This change also caches icons that were specified using just a resource ID. Since loading a Drawable from a URI is a generally useful operation, it would be good to make it easy for apps to do it in the proper density-independent way. We could add a getDrawable(Uri) method to the framework. The question is where. It would be easiest to add it to ContentResolver, but that may be a bit odd since there is no other code for dealing with Drawables in ContentResolver. Another alternative is in Resources, since getDrawable(int) is there, but that class deals with the resources for a single app, whereas getDrawable(Uri) can open a drawable from any app. Putting it in Context may be the best choice, since that's in android.content, and can thus access package private members in ContentResolver, and since it's already a dumping place for random useful high-level methods. Opinions? Fixes http://b/issue?id=2034526 "Icons on search do not scale for wide VGA" Change-Id: I44de0b74826e5560141a3174bcbba991ba6264ac
Loading
Please register or sign in to comment