[WebAPK] Improve splash icon logic.
pkotwicz@ pointed out that res/mipmap is actually an alias for res/mipmap-mdpi. This resulted in all icons being way too large and appear with some fidelity issues. In testing I believed these larger icons to be correct but in reality they should have been smaller. To fix this we could move the icons into the mipmap-nodpi folder. However, this prevents them from scaling even when aliased. i.e. if on an xxhdpi device all we have is an mdpi icon the following scenario occurs; drawable-*dpi/ has no valid splash_icon.xml so we fall back to the mipmap-*dpi/app_icon.xml here we find that only the mdpi icon is available. One would think this then scales up to an appropriate size on drawable-xxhdpi but instead Android refuses to scale it as it is in the mipmap-nodpi as the double lookup does not change the fact it is nodpi. pkotwicz@ then suggested we use Scale XML resources, these solve the problem but require the minting server to manually compute the scaling at mint time. Instead I propose the following solution: - Restore the state for app_icon.png files prior to CL https://chromium-review.googlesource.com/1128256 - Introduce a single splash_icon.xml in drawable-xxxhpdi. This will reference mipmap/app_icon and essentially be identical to the current behavior of just using the app_icon (this is just a placeholder). - Add a boolean to the metadata of the AndroidManifest.xml indicating whether we were able to package larger images on the server. (This is so xxhpdi can use these images rather than only using the slightly larger xxxhdpi icon). - Use ApiCompatibilityUtils#getDrawableForDensity(). This gives us the image for a specific density or scales the nearest available one if there isn't one available. This allows us to control which size of image we show. We can then impose the following lookup scheme based on the current device density. Tested on xhdpi, hdpi and xxhdpi running N, O, P | Current Density | App Icon Density for Splash Icon | | mdpi | xhdpi | | hdpi | xxhdpi | | xhdpi | xxxhdpi | | xxhdpi | xxxhdpi or larger if provided | | xxxhdpi | xxxhdpi or larger if provided | Bug: 819755 Change-Id: I40fe68375782b29d082193aae0ab1c1af0ae49f2 Reviewed-on: https://chromium-review.googlesource.com/1150297 Commit-Queue: Calder Kitagawa <ckitagawa@chromium.org> Reviewed-by:Dominick Ng <dominickn@chromium.org> Reviewed-by:
Xi Han <hanxi@chromium.org> Cr-Commit-Position: refs/heads/master@{#581549}
Showing
File moved
File moved
File moved
File moved
File moved
Please register or sign in to comment