Package-level declarations

Types

Link copied to clipboard
class AdLoadReporter(telemetryRepository: TelemetryRepository, buildInfoRepository: BuildInfoRepository)

The one place an ad that failed to load is written down.

Link copied to clipboard

Why an ad slot has nothing to show.

Link copied to clipboard
class AdSlotLoadException(slotName: String, adUnitId: String, errorCode: String, errorMessage: String) : Exception

Non-fatal marker for an ad failure other than no fill or a network error.

Link copied to clipboard
class AdSlotNotRequestedException(slotName: String, adUnitId: String) : Exception

Non-fatal marker for an ad request that was never made.

Link copied to clipboard
class AspectRatioFrameLayout(context: Context, widthToHeightRatio: Float) : FrameLayout

A frame that always measures widthToHeightRatio, whatever its child reports.

Link copied to clipboard

Default implementation of NativeAdViewFactory providing the toolkit's standard presentations.

Link copied to clipboard
class NativeAdBadgeShape(val path: Path, val sizePx: Float)

A Compose Shape, flattened to the path an ad's icon badge is filled with.

Link copied to clipboard

Keeps the native ads of one screen alive while their slots scroll in and out of view.

Link copied to clipboard

How an ad's call to action is drawn.

Link copied to clipboard

The single seam between rememberNativeAd and the Google Mobile Ads SDK.

Link copied to clipboard
data class NativeAdPalette(val surface: Int, val surfaceContainer: Int, val onSurface: Int, val onSurfaceVariant: Int, val primary: Int, val secondaryContainer: Int, val onSecondaryContainer: Int, val surfaceContainerHighest: Int, val surfaceVariant: Int, val surfaceContainerHigh: Int = surfaceContainer, val tertiary: Int = primary, val tertiaryContainer: Int = secondaryContainer, val onTertiaryContainer: Int = onSecondaryContainer)

An ARGB snapshot of the Compose theme, for the Android views that render an ad.

Link copied to clipboard

The shape a native ad takes on screen.

Link copied to clipboard
data class NativeAdSlotState(val ad: NativeAd? = null, val failure: AdSlotFailure? = null, val detail: String? = null)

What a slot has: an ad, or the reason it has none.

Link copied to clipboard
data class NativeAdStyle(val badgeShape: NativeAdBadgeShape? = null, val badgeCornerRadiusDp: Int? = null, val badgeColor: Color = Color.Unspecified, val headlineTextSizeSp: Float? = null, val headlineBold: Boolean? = null, val headlineColor: Color = Color.Unspecified, val bodyTextSizeSp: Float? = null, val bodyMaxLines: Int? = null, val bodyColor: Color = Color.Unspecified, val callToAction: NativeAdCallToActionStyle = NativeAdCallToActionStyle.Filled, val iconInsetDp: Int? = null)

Per-screen look for a native ad.

Link copied to clipboard

Interface for creating the view hierarchy for different native ad presentations.

Link copied to clipboard
class NativeAdViewHolder(val presentation: NativeAdPresentation, val root: NativeAdView, val content: LinearLayout, val label: TextView, val media: MediaView?, val mediaFrame: View?, val icon: ImageView?, val iconFrame: View?, val headline: TextView, val body: TextView?, val advertiser: TextView, val callToAction: TextView?, decorate: NativeAdViewHolder.(palette: NativeAdPalette, style: NativeAdStyle) -> Unit? = null)

Strong references to the views a native ad binds to, so binding never needs findViewById.

Properties

Link copied to clipboard
const val ADVERTISER_TEXT_SIZE_SP: Float = 12.0f
Link copied to clipboard
Link copied to clipboard
const val BAR_ICON_SIZE_DP: Int = 32
Link copied to clipboard
Link copied to clipboard
const val BODY_TEXT_SIZE_SP: Float = 14.0f
Link copied to clipboard
const val CARD_PADDING_DP: Int = 8
Link copied to clipboard
const val COMPACT_ICON_SIZE_DP: Int = 48
Link copied to clipboard
const val CTA_CORNER_RADIUS_DP: Int = 20
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
const val CTA_TEXT_SIZE_SP: Float = 14.0f
Link copied to clipboard
Link copied to clipboard
const val FONT_WEIGHT_BOLD: Int = 700
Link copied to clipboard
const val FONT_WEIGHT_MEDIUM: Int = 500
Link copied to clipboard
const val FONT_WEIGHT_REGULAR: Int = 400
Link copied to clipboard
const val FONT_WEIGHT_SEMI_BOLD: Int = 600
Link copied to clipboard
const val GRID_ICON_SIZE_DP: Int = 56
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
const val HEADLINE_TEXT_SIZE_SP: Float = 16.0f
Link copied to clipboard
const val ICON_CORNER_RADIUS_DP: Int = 12
Link copied to clipboard
const val ICON_PADDING_DP: Int = 4
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
const val LABEL_TEXT_SIZE_SP: Float = 11.0f
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Aspect ratio of media in the Featured presentation.

Link copied to clipboard
const val MEDIA_CORNER_RADIUS_DP: Int = 20
Link copied to clipboard
const val SMALL_SPACING_DP: Int = 8
Link copied to clipboard
const val SPACING_DP: Int = 16

Functions

Link copied to clipboard
fun AdBanner(modifier: Modifier = Modifier, adsConfig: AdsConfig)

A Composable function that displays a banner ad from Google AdMob.

Link copied to clipboard
fun AdSlotDebugPlaceholder(slotName: String, reason: AdSlotFailure, modifier: Modifier = Modifier, detail: String? = null)

What an empty ad slot looks like on a debug build.

Link copied to clipboard
Link copied to clipboard
fun bodyView(context: Context, maxLines: Int): TextView
Link copied to clipboard
fun BottomAppBarNativeAdBanner(modifier: Modifier = Modifier, adUnitId: String, enabled: Boolean = false, onAdLoaded: (Boolean) -> Unit = {})

Native ad strip for a bottom app bar, using NativeAdSlot without a card container.

Link copied to clipboard

The call to action.

Link copied to clipboard
Link copied to clipboard
fun Context.dp(value: Int): Int
Link copied to clipboard
fun headlineView(context: Context, maxLines: Int): TextView

The ad's headline, bold by default.

Link copied to clipboard
fun iconFrameView(context: Context, sizeDp: Int, radiusDp: Int = ICON_CORNER_RADIUS_DP, paddingDp: Int = 0): LinearLayout

Icon container. The icon itself is the registered iconView; the frame carries the rounded background so the icon can keep its own padding without clipping the tint.

Link copied to clipboard
Link copied to clipboard
fun nativeAdRoot(context: Context, height: Int = ViewGroup.LayoutParams.WRAP_CONTENT): NativeAdView
Link copied to clipboard
fun NativeAdSlot(adUnitId: String, presentation: NativeAdPresentation, modifier: Modifier = Modifier, position: GroupedItemPosition = GroupedItemPosition.SINGLE, showContainer: Boolean = true, cornerRadius: Dp = SizeConstants.ExtraLargeSize, containerColor: Color = Color.Unspecified, style: NativeAdStyle = NativeAdStyle(), label: String? = null, cache: NativeAdCache? = null, cacheKey: Any? = null, onAdLoaded: (Boolean) -> Unit = {})

The single entry point for rendering a native ad anywhere in the toolkit.

Link copied to clipboard
fun NoDataNativeAdCard(modifier: Modifier = Modifier, adUnitId: String, containerColor: Color = Color.Unspecified, onAdLoaded: (Boolean) -> Unit = {})

Media-led NativeAdSlot for empty and error states.

Link copied to clipboard
fun pathDrawable(color: Int, path: Path, sourceSize: Float): ShapeDrawable

Fills path with color, rescaled from the size it was measured at to whatever bounds the view ends up with.

Link copied to clipboard

Reads the ads preference provided by LocalAdsEnabled. Reuses the theme's observation and host-configured default instead of creating a collector for each ad slot.

Link copied to clipboard
fun rememberNativeAd(adUnitId: String, enabled: Boolean = true, cache: NativeAdCache? = null, cacheKey: Any? = null): NativeAd?

Loads a NativeAd for adUnitId and keeps it alive for as long as it is composed.

Link copied to clipboard

Flattens shape at size into the badge an ad row can fill.

Link copied to clipboard
fun rememberNativeAdCache(maxAdAge: Duration = NativeAdCache.DefaultMaxAdAge): NativeAdCache

Remembers a NativeAdCache for the current screen and destroys its ads when the screen leaves.

Link copied to clipboard
fun rememberNativeAdState(adUnitId: String, enabled: Boolean = true, slotName: String = adUnitId, cache: NativeAdCache? = null, cacheKey: Any? = null): NativeAdSlotState

rememberNativeAd with the reason an empty slot is empty.

Link copied to clipboard
fun roundedDrawable(color: Int, radiusPx: Int): GradientDrawable
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun TextView.useAppFont(weight: Int = FONT_WEIGHT_REGULAR)

Sets the app's typeface (Google Sans Flex) at weight, so an ad's text matches the Compose text around it instead of falling back to the system font.

Link copied to clipboard
fun verticalContent(context: Context, padding: Int): LinearLayout
Link copied to clipboard
fun <T : View> T.withTopMargin(margin: Int): T