Skip to content

Commit

Permalink
[interactive_media_ads] Adds initial Android implementation (#6733)
Browse files Browse the repository at this point in the history
Android implementation for flutter/flutter#134228
  • Loading branch information
bparrishMines authored Jun 25, 2024
1 parent e9a3fcc commit f80cab4
Show file tree
Hide file tree
Showing 78 changed files with 16,725 additions and 71 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.0.2

* Adds Android implementation.

## 0.0.1+3

* Fixes the pub badge source.
Expand Down
6 changes: 6 additions & 0 deletions packages/interactive_media_ads/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,16 @@ android {

dependencies {
implementation 'androidx.annotation:annotation:1.8.0'
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.33.0'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation "org.mockito.kotlin:mockito-kotlin:4.1.0"
testImplementation 'org.mockito:mockito-inline:5.1.0'
testImplementation 'androidx.test:core:1.3.0'

// org.jetbrains.kotlin:kotlin-bom artifact purpose is to align kotlin stdlib and related code versions.
// See: https://youtrack.jetbrains.com/issue/KT-55297/kotlin-stdlib-should-declare-constraints-on-kotlin-stdlib-jdk8-and-kotlin-stdlib-jdk7
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.10"))
}

lintOptions {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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

/**
* ProxyApi implementation for [com.google.ads.interactivemedia.v3.api.AdDisplayContainer].
*
* <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 AdDisplayContainerProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
PigeonApiAdDisplayContainer(pigeonRegistrar)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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.AdError
import com.google.ads.interactivemedia.v3.api.AdErrorEvent

/**
* ProxyApi implementation for [AdErrorEvent].
*
* <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 AdErrorEventProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
PigeonApiAdErrorEvent(pigeonRegistrar) {
override fun error(pigeon_instance: AdErrorEvent): AdError {
return pigeon_instance.error
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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.AdErrorEvent

/**
* ProxyApi implementation for [AdErrorEvent.AdErrorListener].
*
* <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 AdErrorListenerProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
PigeonApiAdErrorListener(pigeonRegistrar) {
internal class AdErrorListenerImpl(val api: AdErrorListenerProxyApi) :
AdErrorEvent.AdErrorListener {
override fun onAdError(event: AdErrorEvent) {
api.pigeonRegistrar.runOnMainThread { api.onAdError(this, event) {} }
}
}

override fun pigeon_defaultConstructor(): AdErrorEvent.AdErrorListener {
return AdErrorListenerImpl(this)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// 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.AdError

/**
* ProxyApi implementation for [AdError].
*
* <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 AdErrorProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
PigeonApiAdError(pigeonRegistrar) {
override fun errorCode(pigeon_instance: AdError): AdErrorCode {
return when (pigeon_instance.errorCode) {
AdError.AdErrorCode.ADS_PLAYER_NOT_PROVIDED -> AdErrorCode.ADS_PLAYER_WAS_NOT_PROVIDED
AdError.AdErrorCode.INTERNAL_ERROR -> AdErrorCode.INTERNAL_ERROR
AdError.AdErrorCode.VAST_MALFORMED_RESPONSE -> AdErrorCode.VAST_MALFORMED_RESPONSE
AdError.AdErrorCode.UNKNOWN_AD_RESPONSE -> AdErrorCode.UNKNOWN_AD_RESPONSE
AdError.AdErrorCode.VAST_TRAFFICKING_ERROR -> AdErrorCode.VAST_TRAFFICKING_ERROR
AdError.AdErrorCode.VAST_LOAD_TIMEOUT -> AdErrorCode.VAST_LOAD_TIMEOUT
AdError.AdErrorCode.VAST_TOO_MANY_REDIRECTS -> AdErrorCode.VAST_TOO_MANY_REDIRECTS
AdError.AdErrorCode.VAST_NO_ADS_AFTER_WRAPPER -> AdErrorCode.VAST_NO_ADS_AFTER_WRAPPER
AdError.AdErrorCode.VIDEO_PLAY_ERROR -> AdErrorCode.VIDEO_PLAY_ERROR
AdError.AdErrorCode.VAST_MEDIA_LOAD_TIMEOUT -> AdErrorCode.VAST_MEDIA_LOAD_TIMEOUT
AdError.AdErrorCode.VAST_LINEAR_ASSET_MISMATCH -> AdErrorCode.VAST_LINEAR_ASSET_MISMATCH
AdError.AdErrorCode.OVERLAY_AD_PLAYING_FAILED -> AdErrorCode.OVERLAY_AD_PLAYING_FAILED
AdError.AdErrorCode.OVERLAY_AD_LOADING_FAILED -> AdErrorCode.OVERLAY_AD_LOADING_FAILED
AdError.AdErrorCode.VAST_NONLINEAR_ASSET_MISMATCH -> AdErrorCode.VAST_NONLINEAR_ASSET_MISMATCH
AdError.AdErrorCode.COMPANION_AD_LOADING_FAILED -> AdErrorCode.COMPANION_AD_LOADING_FAILED
AdError.AdErrorCode.UNKNOWN_ERROR -> AdErrorCode.UNKNOWN_ERROR
AdError.AdErrorCode.VAST_EMPTY_RESPONSE -> AdErrorCode.VAST_EMPTY_RESPONSE
AdError.AdErrorCode.FAILED_TO_REQUEST_ADS -> AdErrorCode.FAILED_TO_REQUEST_ADS
AdError.AdErrorCode.VAST_ASSET_NOT_FOUND -> AdErrorCode.VAST_ASSET_NOT_FOUND
AdError.AdErrorCode.ADS_REQUEST_NETWORK_ERROR -> AdErrorCode.ADS_REQUEST_NETWORK_ERROR
AdError.AdErrorCode.INVALID_ARGUMENTS -> AdErrorCode.INVALID_ARGUMENTS
AdError.AdErrorCode.PLAYLIST_NO_CONTENT_TRACKING -> AdErrorCode.PLAYLIST_NO_CONTENT_TRACKING
AdError.AdErrorCode.UNEXPECTED_ADS_LOADED_EVENT -> AdErrorCode.UNEXPECTED_ADS_LOADED_EVENT
else -> AdErrorCode.UNKNOWN
}
}

override fun errorCodeNumber(pigeon_instance: AdError): Long {
return pigeon_instance.errorCodeNumber.toLong()
}

override fun errorType(pigeon_instance: AdError): AdErrorType {
return when (pigeon_instance.errorType) {
AdError.AdErrorType.LOAD -> AdErrorType.LOAD
AdError.AdErrorType.PLAY -> AdErrorType.PLAY
else -> AdErrorType.UNKNOWN
}
}

override fun message(pigeon_instance: AdError): String {
return pigeon_instance.message
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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.AdEvent

/**
* ProxyApi implementation for [AdEvent.AdEventListener].
*
* <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 AdEventListenerProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
PigeonApiAdEventListener(pigeonRegistrar) {
internal class AdEventListenerImpl(val api: AdEventListenerProxyApi) : AdEvent.AdEventListener {
override fun onAdEvent(event: AdEvent) {
api.pigeonRegistrar.runOnMainThread { api.onAdEvent(this, event) {} }
}
}

override fun pigeon_defaultConstructor(): AdEvent.AdEventListener {
return AdEventListenerImpl(this)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// 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.AdEvent

/**
* ProxyApi implementation for [AdEvent].
*
* <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 AdEventProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
PigeonApiAdEvent(pigeonRegistrar) {
override fun type(pigeon_instance: AdEvent): AdEventType {
return when (pigeon_instance.type) {
AdEvent.AdEventType.ALL_ADS_COMPLETED -> AdEventType.ALL_ADS_COMPLETED
AdEvent.AdEventType.AD_BREAK_FETCH_ERROR -> AdEventType.AD_BREAK_FETCH_ERROR
AdEvent.AdEventType.CLICKED -> AdEventType.CLICKED
AdEvent.AdEventType.COMPLETED -> AdEventType.COMPLETED
AdEvent.AdEventType.CUEPOINTS_CHANGED -> AdEventType.CUEPOINTS_CHANGED
AdEvent.AdEventType.CONTENT_PAUSE_REQUESTED -> AdEventType.CONTENT_PAUSE_REQUESTED
AdEvent.AdEventType.CONTENT_RESUME_REQUESTED -> AdEventType.CONTENT_RESUME_REQUESTED
AdEvent.AdEventType.FIRST_QUARTILE -> AdEventType.FIRST_QUARTILE
AdEvent.AdEventType.LOG -> AdEventType.LOG
AdEvent.AdEventType.AD_BREAK_READY -> AdEventType.AD_BREAK_READY
AdEvent.AdEventType.MIDPOINT -> AdEventType.MIDPOINT
AdEvent.AdEventType.PAUSED -> AdEventType.PAUSED
AdEvent.AdEventType.RESUMED -> AdEventType.RESUMED
AdEvent.AdEventType.SKIPPABLE_STATE_CHANGED -> AdEventType.SKIPPABLE_STATE_CHANGED
AdEvent.AdEventType.SKIPPED -> AdEventType.SKIPPED
AdEvent.AdEventType.STARTED -> AdEventType.STARTED
AdEvent.AdEventType.TAPPED -> AdEventType.TAPPED
AdEvent.AdEventType.ICON_TAPPED -> AdEventType.ICON_TAPPED
AdEvent.AdEventType.ICON_FALLBACK_IMAGE_CLOSED -> AdEventType.ICON_FALLBACK_IMAGE_CLOSED
AdEvent.AdEventType.THIRD_QUARTILE -> AdEventType.THIRD_QUARTILE
AdEvent.AdEventType.LOADED -> AdEventType.LOADED
AdEvent.AdEventType.AD_PROGRESS -> AdEventType.AD_PROGRESS
AdEvent.AdEventType.AD_BUFFERING -> AdEventType.AD_BUFFERING
AdEvent.AdEventType.AD_BREAK_STARTED -> AdEventType.AD_BREAK_STARTED
AdEvent.AdEventType.AD_BREAK_ENDED -> AdEventType.AD_BREAK_ENDED
AdEvent.AdEventType.AD_PERIOD_STARTED -> AdEventType.AD_PERIOD_STARTED
AdEvent.AdEventType.AD_PERIOD_ENDED -> AdEventType.AD_PERIOD_ENDED
else -> AdEventType.UNKNOWN
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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.player.AdMediaInfo

/**
* ProxyApi implementation for [AdMediaInfo].
*
* <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 AdMediaInfoProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
PigeonApiAdMediaInfo(pigeonRegistrar) {
override fun url(pigeon_instance: AdMediaInfo): String {
return pigeon_instance.url
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// 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.AdPodInfo

/**
* ProxyApi implementation for [AdPodInfo].
*
* <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 AdPodInfoProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
PigeonApiAdPodInfo(pigeonRegistrar) {
override fun adPosition(pigeon_instance: AdPodInfo): Long {
return pigeon_instance.adPosition.toLong()
}

override fun maxDuration(pigeon_instance: AdPodInfo): Double {
return pigeon_instance.maxDuration
}

override fun podIndex(pigeon_instance: AdPodInfo): Long {
return pigeon_instance.podIndex.toLong()
}

override fun timeOffset(pigeon_instance: AdPodInfo): Double {
return pigeon_instance.timeOffset
}

override fun totalAds(pigeon_instance: AdPodInfo): Long {
return pigeon_instance.totalAds.toLong()
}

override fun isBumper(pigeon_instance: AdPodInfo): Boolean {
return pigeon_instance.isBumper
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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.AdsLoader
import com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent

/**
* ProxyApi implementation for [AdsLoader.AdsLoadedListener].
*
* <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 AdsLoadedListenerProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
PigeonApiAdsLoadedListener(pigeonRegistrar) {
internal class AdsLoadedListenerImpl(val api: AdsLoadedListenerProxyApi) :
AdsLoader.AdsLoadedListener {
override fun onAdsManagerLoaded(event: AdsManagerLoadedEvent) {
api.pigeonRegistrar.runOnMainThread { api.onAdsManagerLoaded(this, event) {} }
}
}

override fun pigeon_defaultConstructor(): AdsLoader.AdsLoadedListener {
return AdsLoadedListenerImpl(this)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 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.AdErrorEvent
import com.google.ads.interactivemedia.v3.api.AdsLoader
import com.google.ads.interactivemedia.v3.api.AdsRequest

/**
* ProxyApi implementation for [AdsLoader].
*
* <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 AdsLoaderProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
PigeonApiAdsLoader(pigeonRegistrar) {
override fun addAdErrorListener(
pigeon_instance: AdsLoader,
listener: AdErrorEvent.AdErrorListener
) {
pigeon_instance.addAdErrorListener(listener)
}

override fun addAdsLoadedListener(
pigeon_instance: AdsLoader,
listener: AdsLoader.AdsLoadedListener
) {
pigeon_instance.addAdsLoadedListener(listener)
}

override fun requestAds(pigeon_instance: AdsLoader, request: AdsRequest) {
pigeon_instance.requestAds(request)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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.AdsManager
import com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent

/**
* ProxyApi implementation for [AdsManagerLoadedEvent].
*
* <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 AdsManagerLoadedEventProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
PigeonApiAdsManagerLoadedEvent(pigeonRegistrar) {
override fun manager(pigeon_instance: AdsManagerLoadedEvent): AdsManager {
return pigeon_instance.adsManager
}
}
Loading

0 comments on commit f80cab4

Please sign in to comment.