Skip to content

Commit

Permalink
[interactive_media_ads] Adds internal wrapper for Android native `Ads…
Browse files Browse the repository at this point in the history
…RenderingSettings` (flutter#7660)
  • Loading branch information
bparrishMines authored Sep 18, 2024
1 parent fef7ffb commit e9253e6
Show file tree
Hide file tree
Showing 10 changed files with 1,385 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/interactive_media_ads/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.2+2

* Adds internal wrapper for Android native `AdsRenderingSettings`.

## 0.2.2+1

* Bumps Android dependency `com.google.ads.interactivemedia.v3:interactivemedia` from `3.34.0` to
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package dev.flutter.packages.interactive_media_ads

import com.google.ads.interactivemedia.v3.api.AdsRenderingSettings
import com.google.ads.interactivemedia.v3.api.UiElement

/**
* ProxyApi implementation for [AdsRenderingSettings].
*
* <p>This class may handle instantiating native object instances that are attached to a Dart
* instance or handle method calls on the associated native class or an instance of that class.
*/
class AdsRenderingSettingsProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
PigeonApiAdsRenderingSettings(pigeonRegistrar) {
override fun getBitrateKbps(pigeon_instance: AdsRenderingSettings): Long {
return pigeon_instance.bitrateKbps.toLong()
}

override fun getEnableCustomTabs(pigeon_instance: AdsRenderingSettings): Boolean {
return pigeon_instance.enableCustomTabs
}

override fun getEnablePreloading(pigeon_instance: AdsRenderingSettings): Boolean {
return pigeon_instance.enablePreloading
}

override fun getFocusSkipButtonWhenAvailable(pigeon_instance: AdsRenderingSettings): Boolean {
return pigeon_instance.focusSkipButtonWhenAvailable
}

override fun getMimeTypes(pigeon_instance: AdsRenderingSettings): List<String> {
return pigeon_instance.mimeTypes
}

override fun setBitrateKbps(pigeon_instance: AdsRenderingSettings, bitrate: Long) {
pigeon_instance.bitrateKbps = bitrate.toInt()
}

override fun setEnableCustomTabs(
pigeon_instance: AdsRenderingSettings,
enableCustomTabs: Boolean
) {
pigeon_instance.enableCustomTabs = enableCustomTabs
}

override fun setEnablePreloading(
pigeon_instance: AdsRenderingSettings,
enablePreloading: Boolean
) {
pigeon_instance.enablePreloading = enablePreloading
}

override fun setFocusSkipButtonWhenAvailable(
pigeon_instance: AdsRenderingSettings,
enableFocusSkipButton: Boolean
) {
pigeon_instance.focusSkipButtonWhenAvailable = enableFocusSkipButton
}

override fun setLoadVideoTimeout(pigeon_instance: AdsRenderingSettings, loadVideoTimeout: Long) {
pigeon_instance.setLoadVideoTimeout(loadVideoTimeout.toInt())
}

override fun setMimeTypes(pigeon_instance: AdsRenderingSettings, mimeTypes: List<String>) {
pigeon_instance.mimeTypes = mimeTypes
}

override fun setPlayAdsAfterTime(pigeon_instance: AdsRenderingSettings, time: Double) {
pigeon_instance.setPlayAdsAfterTime(time)
}

override fun setUiElements(
pigeon_instance: AdsRenderingSettings,
uiElements: List<dev.flutter.packages.interactive_media_ads.UiElement>
) {
val nativeUiElements =
uiElements.map {
when (it) {
dev.flutter.packages.interactive_media_ads.UiElement.AD_ATTRIBUTION ->
UiElement.AD_ATTRIBUTION
dev.flutter.packages.interactive_media_ads.UiElement.COUNTDOWN -> UiElement.COUNTDOWN
dev.flutter.packages.interactive_media_ads.UiElement.UNKNOWN ->
throw UnsupportedOperationException("$it is not supported.")
}
}
pigeon_instance.setUiElements(nativeUiElements.toSet())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AdsRequestProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
*
* This must match the version in pubspec.yaml.
*/
const val pluginVersion = "0.2.2+1"
const val pluginVersion = "0.2.2+2"
}

override fun setAdTagUrl(pigeon_instance: AdsRequest, adTagUrl: String) {
Expand Down
Loading

0 comments on commit e9253e6

Please sign in to comment.