Merge "Documentation & refinements around BubbleMetadata#setIcon API"

This commit is contained in:
Mady Mellor
2019-03-21 17:18:38 +00:00
committed by Android (Google) Code Review
3 changed files with 27 additions and 4 deletions

View File

@@ -16,6 +16,8 @@
package android.app;
import static android.graphics.drawable.Icon.TYPE_BITMAP;
import static com.android.internal.util.ContrastColorUtil.satisfiesTextContrast;
import android.annotation.ColorInt;
@@ -8707,12 +8709,25 @@ public class Notification implements Parcelable
* <p>An icon is required and should be representative of the content within the bubble.
* If your app produces multiple bubbles, the image should be unique for each of them.
* </p>
*
* <p>The shape of a bubble icon is adaptive and can match the device theme.
*
* If your icon is bitmap-based, you should create it using
* {@link Icon#createWithAdaptiveBitmap(Bitmap)}, otherwise this method will throw.
*
* If your icon is not bitmap-based, you should expect that the icon will be tinted.
* </p>
*/
@NonNull
public BubbleMetadata.Builder setIcon(@NonNull Icon icon) {
if (icon == null) {
throw new IllegalArgumentException("Bubbles require non-null icon");
}
if (icon.getType() == TYPE_BITMAP) {
throw new IllegalArgumentException("When using bitmap based icons, Bubbles "
+ "require TYPE_ADAPTIVE_BITMAP, please use"
+ " Icon#createWithAdaptiveBitmap instead");
}
mIcon = icon;
return this;
}