-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support the native ad options API.
- Loading branch information
Showing
27 changed files
with
1,041 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
..._ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterNativeAdOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright 2021 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License.c language governing permissions and | ||
// limitations under the License. | ||
|
||
package io.flutter.plugins.googlemobileads; | ||
|
||
import androidx.annotation.Nullable; | ||
import com.google.android.gms.ads.nativead.NativeAdOptions; | ||
|
||
/** A wrapper for {@link com.google.android.gms.ads.nativead.NativeAdOptions}. */ | ||
class FlutterNativeAdOptions { | ||
|
||
@Nullable final Integer adChoicesPlacement; | ||
@Nullable final Integer mediaAspectRatio; | ||
@Nullable final FlutterVideoOptions videoOptions; | ||
@Nullable final Boolean requestCustomMuteThisAd; | ||
@Nullable final Boolean shouldRequestMultipleImages; | ||
@Nullable final Boolean shouldReturnUrlsForImageAssets; | ||
|
||
FlutterNativeAdOptions( | ||
@Nullable Integer adChoicesPlacement, | ||
@Nullable Integer mediaAspectRatio, | ||
@Nullable FlutterVideoOptions videoOptions, | ||
@Nullable Boolean requestCustomMuteThisAd, | ||
@Nullable Boolean shouldRequestMultipleImages, | ||
@Nullable Boolean shouldReturnUrlsForImageAssets) { | ||
this.adChoicesPlacement = adChoicesPlacement; | ||
this.mediaAspectRatio = mediaAspectRatio; | ||
this.videoOptions = videoOptions; | ||
this.requestCustomMuteThisAd = requestCustomMuteThisAd; | ||
this.shouldRequestMultipleImages = shouldRequestMultipleImages; | ||
this.shouldReturnUrlsForImageAssets = shouldReturnUrlsForImageAssets; | ||
} | ||
|
||
NativeAdOptions asNativeAdOptions() { | ||
NativeAdOptions.Builder builder = new NativeAdOptions.Builder(); | ||
if (adChoicesPlacement != null) { | ||
builder.setAdChoicesPlacement(adChoicesPlacement); | ||
} | ||
if (mediaAspectRatio != null) { | ||
builder.setMediaAspectRatio(mediaAspectRatio); | ||
} | ||
if (videoOptions != null) { | ||
builder.setVideoOptions(videoOptions.asVideoOptions()); | ||
} | ||
if (requestCustomMuteThisAd != null) { | ||
builder.setRequestCustomMuteThisAd(requestCustomMuteThisAd); | ||
} | ||
if (shouldRequestMultipleImages != null) { | ||
builder.setRequestMultipleImages(shouldRequestMultipleImages); | ||
} | ||
if (shouldReturnUrlsForImageAssets != null) { | ||
builder.setReturnUrlsForImageAssets(shouldReturnUrlsForImageAssets); | ||
} | ||
return builder.build(); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...ile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterVideoOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2021 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License.c language governing permissions and | ||
// limitations under the License. | ||
|
||
package io.flutter.plugins.googlemobileads; | ||
|
||
import androidx.annotation.Nullable; | ||
import com.google.android.gms.ads.VideoOptions; | ||
|
||
/** A wrapper for {@link com.google.android.gms.ads.VideoOptions}. */ | ||
class FlutterVideoOptions { | ||
@Nullable final Boolean clickToExpandRequested; | ||
@Nullable final Boolean customControlsRequested; | ||
@Nullable final Boolean startMuted; | ||
|
||
FlutterVideoOptions( | ||
@Nullable Boolean clickToExpandRequested, | ||
@Nullable Boolean customControlsRequested, | ||
@Nullable Boolean startMuted) { | ||
this.clickToExpandRequested = clickToExpandRequested; | ||
this.customControlsRequested = customControlsRequested; | ||
this.startMuted = startMuted; | ||
} | ||
|
||
VideoOptions asVideoOptions() { | ||
VideoOptions.Builder builder = new VideoOptions.Builder(); | ||
if (clickToExpandRequested != null) { | ||
builder.setClickToExpandRequested(clickToExpandRequested); | ||
} | ||
if (customControlsRequested != null) { | ||
builder.setCustomControlsRequested(customControlsRequested); | ||
} | ||
if (startMuted != null) { | ||
builder.setStartMuted(startMuted); | ||
} | ||
return builder.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.