Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fc00df8
ad android method and add platform class
bparrishMines Nov 12, 2024
efc63c0
update platform class
bparrishMines Nov 12, 2024
ca5c47d
add app facing portion
bparrishMines Nov 12, 2024
70be676
android implementation
bparrishMines Nov 12, 2024
d0e0de9
ios implementation
bparrishMines Nov 12, 2024
c10c14f
fix android test
bparrishMines Nov 12, 2024
7f9a563
update app facing test
bparrishMines Nov 12, 2024
5b3e3ae
ios test
bparrishMines Nov 12, 2024
bae565f
version bump
bparrishMines Nov 12, 2024
e5abb39
Merge branch 'main' of github.com:flutter/packages into ima_adsrendering
bparrishMines Nov 12, 2024
3071bf5
fix up changelog
bparrishMines Nov 12, 2024
bf2a118
Merge branch 'main' of github.com:flutter/packages into ima_adsrendering
bparrishMines Nov 12, 2024
aa443bc
create new android and ios implementations
bparrishMines Nov 13, 2024
832d86e
Merge branch 'main' of github.com:flutter/packages into ima_adsrendering
bparrishMines Nov 13, 2024
efa6b2d
fix tests
bparrishMines Nov 13, 2024
63eabc3
fix lint and add comment
bparrishMines Nov 13, 2024
b69a9bd
add enable preloading to example
bparrishMines Nov 13, 2024
e7aaf61
update excerpts
bparrishMines Nov 13, 2024
4c8bc86
Merge branch 'main' of github.com:flutter/packages into ima_adsrendering
bparrishMines Nov 13, 2024
300a608
obey contract
bparrishMines Nov 14, 2024
b2abcd1
Merge branch 'main' of github.com:flutter/packages into ima_adsrendering
bparrishMines Nov 14, 2024
3b79dd0
use duration
bparrishMines Nov 14, 2024
e80a923
review comments
bparrishMines Nov 14, 2024
1e58518
Merge branch 'main' of github.com:flutter/packages into ima_adsrendering
bparrishMines Nov 14, 2024
9d85bf8
Merge branch 'main' of github.com:flutter/packages into ima_adsrendering
bparrishMines Nov 16, 2024
d9b81e6
fix lints
bparrishMines Nov 16, 2024
35e05c5
fix excerpts
bparrishMines Nov 16, 2024
aea49fe
add null clarification and doc fix
bparrishMines Nov 19, 2024
4b4bf9c
Merge branch 'main' of github.com:flutter/packages into ima_adsrendering
bparrishMines Nov 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
ad android method and add platform class
  • Loading branch information
bparrishMines committed Nov 12, 2024
commit fc00df8f04d30a43b34d9949c48dab07b7345611
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package dev.flutter.packages.interactive_media_ads
import android.view.ViewGroup
import com.google.ads.interactivemedia.v3.api.AdDisplayContainer
import com.google.ads.interactivemedia.v3.api.AdsLoader
import com.google.ads.interactivemedia.v3.api.AdsRenderingSettings
import com.google.ads.interactivemedia.v3.api.AdsRequest
import com.google.ads.interactivemedia.v3.api.ImaSdkFactory
import com.google.ads.interactivemedia.v3.api.ImaSdkSettings
Expand Down Expand Up @@ -46,4 +47,8 @@ class ImaSdkFactoryProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
override fun createAdsRequest(pigeon_instance: ImaSdkFactory): AdsRequest {
return pigeon_instance.createAdsRequest()
}

override fun createAdsRenderingSettings(pigeon_instance: ImaSdkFactory): AdsRenderingSettings {
return pigeon_instance.createAdsRenderingSettings()
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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.
// Autogenerated from Pigeon (v22.5.0), do not edit directly.
// Autogenerated from Pigeon (v22.6.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon
@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass", "SyntheticAccessor")

Expand Down Expand Up @@ -2236,6 +2236,14 @@ abstract class PigeonApiImaSdkFactory(
pigeon_instance: com.google.ads.interactivemedia.v3.api.ImaSdkFactory
): com.google.ads.interactivemedia.v3.api.AdsRequest

/**
* Creates an `AdsRenderingSettings` object to give the AdsManager parameters that control the
* rendering of ads.
*/
abstract fun createAdsRenderingSettings(
pigeon_instance: com.google.ads.interactivemedia.v3.api.ImaSdkFactory
): com.google.ads.interactivemedia.v3.api.AdsRenderingSettings

companion object {
@Suppress("LocalVariableName")
fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiImaSdkFactory?) {
Expand Down Expand Up @@ -2355,6 +2363,28 @@ abstract class PigeonApiImaSdkFactory(
channel.setMessageHandler(null)
}
}
run {
val channel =
BasicMessageChannel<Any?>(
binaryMessenger,
"dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.createAdsRenderingSettings",
codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.ImaSdkFactory
val wrapped: List<Any?> =
try {
listOf(api.createAdsRenderingSettings(pigeon_instanceArg))
} catch (exception: Throwable) {
wrapError(exception)
}
reply.reply(wrapped)
}
} else {
channel.setMessageHandler(null)
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package dev.flutter.packages.interactive_media_ads

import com.google.ads.interactivemedia.v3.api.AdDisplayContainer
import com.google.ads.interactivemedia.v3.api.AdsLoader
import com.google.ads.interactivemedia.v3.api.AdsRenderingSettings
import com.google.ads.interactivemedia.v3.api.AdsRequest
import com.google.ads.interactivemedia.v3.api.ImaSdkFactory
import com.google.ads.interactivemedia.v3.api.ImaSdkSettings
Expand Down Expand Up @@ -51,4 +52,15 @@ class ImaSdkFactoryProxyApiTest {

assertEquals(mockRequest, api.createAdsRequest(instance))
}

@Test
fun createAdsRenderingSettings() {
val api = TestProxyApiRegistrar().getPigeonApiImaSdkFactory()

val instance = mock<ImaSdkFactory>()
val mockSettings = mock<AdsRenderingSettings>()
whenever(instance.createAdsRenderingSettings()).thenReturn(mockSettings)

assertEquals(mockSettings, api.createAdsRenderingSettings(instance))
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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.
// Autogenerated from Pigeon (v22.5.0), do not edit directly.
// Autogenerated from Pigeon (v22.6.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers

Expand Down Expand Up @@ -2482,6 +2482,40 @@ class ImaSdkFactory extends PigeonInternalProxyApiBaseClass {
}
}

/// Creates an `AdsRenderingSettings` object to give the AdsManager parameters
/// that control the rendering of ads.
Future<AdsRenderingSettings> createAdsRenderingSettings() async {
final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec =
_pigeonVar_codecImaSdkFactory;
final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger;
const String pigeonVar_channelName =
'dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.createAdsRenderingSettings';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final List<Object?>? pigeonVar_replyList =
await pigeonVar_channel.send(<Object?>[this]) as List<Object?>?;
if (pigeonVar_replyList == null) {
throw _createConnectionError(pigeonVar_channelName);
} else if (pigeonVar_replyList.length > 1) {
throw PlatformException(
code: pigeonVar_replyList[0]! as String,
message: pigeonVar_replyList[1] as String?,
details: pigeonVar_replyList[2],
);
} else if (pigeonVar_replyList[0] == null) {
throw PlatformException(
code: 'null-error',
message: 'Host platform returned null value for non-null return value.',
);
} else {
return (pigeonVar_replyList[0] as AdsRenderingSettings?)!;
}
}

@override
ImaSdkFactory pigeon_copy() {
return ImaSdkFactory.pigeon_detached(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// 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.

import 'ui_element.dart';

/// Defines parameters that control the rendering of ads.
class PlatformAdsRenderingSettings {
/// Constructs an [PlatformAdsRenderingSettings].
PlatformAdsRenderingSettings({
this.bitrate,
this.enablePreloading,
this.loadVideoTimeout,
this.mimeTypes,
this.playAdsAfterTime,
this.uiElements,
});

/// Maximum recommended bitrate.
///
/// The value is in kbit/s.
///
/// The SDK will select media which has a bitrate below the specified max or
/// the closest bitrate if there is no media with a lower bitrate found.
///
/// If null, the bitrate will be selected by the SDK, using the currently
/// detected network speed (cellular or Wi-Fi).
final int? bitrate;

/// If set, the SDK will instruct the player to load the creative in response
/// initializing the ads manager.
///
/// This allows the player to preload the ad at any point before starting the
/// ads manager.
///
/// If null, the platform will decide the default value.
final bool? enablePreloading;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This value defaults to false on Android and true on iOS. To prevent a breaking change, I made the value nullable to indicate the platform will handle the default. Same is true for the other fields.


/// Specifies a non-default amount of time to wait for media to load before
/// timing out, in milliseconds.
///
/// This only applies to the IMA client-side SDK. Default time is 8000 ms.
final int? loadVideoTimeout;

/// The SDK will prioritize the media with MIME type on the list.
///
/// If empty, the SDK will pick the media based on player capabilities. This
/// only refers to the mime types of videos to be selected for linear ads.
final List<String>? mimeTypes;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-nullable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the documentation for iOS actually states what happens if it is empty. Android doesn't actually mention it:

If specified, the SDK will prioritize the media with MIME type on the list. If not specified,
the SDK will pick the media based on player capabilities. This only refers to the mime
types of videos to be selected for linear ads.

This is related to having a "don't set" option for optional native parameters.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an implementation detail though; if we want empty to mean "the SDK decides" as the docs currently say, then we should map an empty list to not setting on platforms that treat null as not setting.

If we actually want to treat [] and null differently, then we need to explain what the difference is in the comments, ideally in a cross-platform way.


/// For VMAP and ad rules playlists, only play ad breaks scheduled after this
/// time (in seconds).
///
/// This setting is strictly after the specified time. For example, setting
/// `playAdsAfterTime` to 15 will ignore an ad break scheduled to play at 15s.
final double? playAdsAfterTime;

/// Sets the ad UI elements to be rendered by the IMA SDK.
///
/// Some modifications to the uiElements list may have no effect for specific
/// ads.
final Set<UIElement>? uiElements;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-nullable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Not sure if there is a difference between setting to empty or not setting it all.

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ export 'platform_ad_display_container.dart';
export 'platform_ads_loader.dart';
export 'platform_ads_manager.dart';
export 'platform_ads_manager_delegate.dart';
export 'platform_ads_rendering_settings.dart';
export 'platform_ads_request.dart';
export 'platform_content_progress_provider.dart';
export 'ui_element.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 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.

/// Describes an element of the ad UI, to be requested or rendered by the SDK.
enum UIElement {
/// The ad attribution UI element, for example, "Ad".
adAttribution,

/// Ad attribution is required for a countdown timer to be displayed.
countdown,
}
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ abstract class ImaSdkFactory {

/// Creates an AdsRequest object to contain the data used to request ads.
AdsRequest createAdsRequest();

/// Creates an `AdsRenderingSettings` object to give the AdsManager parameters
/// that control the rendering of ads.
AdsRenderingSettings createAdsRenderingSettings();
}

/// Defines general SDK settings that are used when creating an `AdsLoader`.
Expand Down
2 changes: 1 addition & 1 deletion packages/interactive_media_ads/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dev_dependencies:
flutter_test:
sdk: flutter
mockito: ^5.4.4
pigeon: ^22.5.0
pigeon: ^22.6.0

topics:
- ads