Skip to content

Commit

Permalink
UPGRADE flutter-hms-ml to 13.4.35.300
Browse files Browse the repository at this point in the history
  • Loading branch information
cagdasmer committed Dec 31, 2020
1 parent 0a17e8c commit c265fd7
Show file tree
Hide file tree
Showing 119 changed files with 6,674 additions and 1,021 deletions.
Binary file added flutter-hms-ads/.docs/demo-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flutter-hms-ads/.docs/demo-pages.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions flutter-hms-ads/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 13.4.35+300

* Banner Ad - Platform View implementation
* Instream Ad - implementation
* HMSLogger - implementation
* New function implementations comes with 'HMS Ads Kit: 13.4.35.300'
* General bug fixes and improvements

## 13.4.32

* Initial release.
2 changes: 1 addition & 1 deletion flutter-hms-ads/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ You may add Your own copyright statement to Your modifications and may provide a

9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
3,638 changes: 3,209 additions & 429 deletions flutter-hms-ads/README.md

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions flutter-hms-ads/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
/gradle/checkstyle
/gradle/findbugs
10 changes: 6 additions & 4 deletions flutter-hms-ads/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ android {
}

dependencies {
implementation 'com.huawei.hms:ads-lite:13.4.32.300'
implementation 'com.huawei.hms:ads-consent:3.4.32.300'
implementation 'com.huawei.hms:ads-identifier:3.4.32.300'
implementation 'com.huawei.hms:ads-installreferrer:3.4.32.300'
implementation 'com.huawei.hms:ads-lite:13.4.35.300'
implementation 'com.huawei.hms:ads-consent:3.4.35.300'
implementation 'com.huawei.hms:ads-identifier:3.4.35.300'
implementation 'com.huawei.hms:ads-installreferrer:3.4.35.300'
implementation 'com.huawei.hms:stats:5.0.5.300'
implementation 'com.huawei.agconnect:agconnect-core:1.4.2.301'
}
1 change: 1 addition & 0 deletions flutter-hms-ads/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.huawei.hms.flutter.ads">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:usesCleartextTraffic="true">
<service
android:name="com.huawei.hms.flutter.ads.installreferrer.PpsChannelInfoService"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
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
http://www.apache.org/licenses/LICENSE-2.0
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,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
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
http://www.apache.org/licenses/LICENSE-2.0
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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
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
http://www.apache.org/licenses/LICENSE-2.0
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,
Expand All @@ -16,11 +16,13 @@
package com.huawei.hms.flutter.ads.adslite.banner;

import android.app.Activity;
import android.content.Context;

import androidx.annotation.NonNull;

import com.huawei.hms.ads.BannerAdSize;
import com.huawei.hms.flutter.ads.factory.EventChannelFactory;
import com.huawei.hms.flutter.ads.logger.HMSLogger;
import com.huawei.hms.flutter.ads.utils.FromMap;
import com.huawei.hms.flutter.ads.utils.ToMap;
import com.huawei.hms.flutter.ads.utils.constants.AdGravity;
Expand All @@ -37,10 +39,12 @@
public class BannerMethodHandler implements MethodChannel.MethodCallHandler {
private final BinaryMessenger messenger;
private final Activity activity;
private final Context context;

public BannerMethodHandler(final BinaryMessenger messenger, final Activity activity) {
public BannerMethodHandler(final BinaryMessenger messenger, final Activity activity, final Context context) {
this.messenger = messenger;
this.activity = activity;
this.context = context;
}

@Override
Expand Down Expand Up @@ -73,23 +77,26 @@ public void onMethodCall(@NonNull final MethodCall call, @NonNull final Result r
}

private void initBannerAd(Activity activity, MethodCall call, Result result) {
HMSLogger.getInstance(context).startMethodExecutionTimer("initBannerAd");
Integer id = FromMap.toInteger("id", call.argument("id"));
final Integer width = FromMap.toInteger("width", call.argument("width"));
final Integer height = FromMap.toInteger("height", call.argument("height"));
final Long bannerRefresh = FromMap.toLong("refreshTime", call.argument("refreshTime"));

if (id == null) {
result.error(ErrorCodes.NULL_PARAM, "Ad id is null. Init failed.", "");
HMSLogger.getInstance(context).sendSingleEvent("initBannerAd", ErrorCodes.NULL_PARAM);
return;
}

if ((width == null || height == null) || (width == 0 || height == 0)) {
result.error(ErrorCodes.INVALID_PARAM, "BannerAdSize is invalid. Init failed. | Ad id : " + id, "");
HMSLogger.getInstance(context).sendSingleEvent("initBannerAd", ErrorCodes.INVALID_PARAM);
return;
}

EventChannelFactory.create(id, Channels.BANNER_EVENT_CHANNEL, messenger);
EventChannelFactory.setup(id, new BannerStreamHandler());
EventChannelFactory.setup(id, new BannerStreamHandler(context));

BannerAdSize adSize;
if (width == BannerAdSize.BANNER_SIZE_SMART.getWidth() &&
Expand All @@ -104,41 +111,50 @@ private void initBannerAd(Activity activity, MethodCall call, Result result) {

new Banner(id, adSize, bannerRefresh, activity);
result.success(true);
HMSLogger.getInstance(context).sendSingleEvent("initBannerAd");
}

private void loadBannerAd(MethodCall call, Result result) {
HMSLogger.getInstance(context).startMethodExecutionTimer("loadBannerAd");
Integer id = FromMap.toInteger("id", call.argument("id"));
String adSlotId = call.argument("adSlotId");
if (adSlotId == null || adSlotId.isEmpty()) {
result.error(ErrorCodes.NULL_PARAM, "adSlotId is either null or empty. Load failed. | Ad id : " + id, "");
HMSLogger.getInstance(context).sendSingleEvent("loadBannerAd", ErrorCodes.NULL_PARAM);
return;
}

Banner banner = Banner.get(id);
if (banner == null) {
result.error(ErrorCodes.NOT_FOUND, "No ad for given id. Load failed. | Ad id : " + id, "");
HMSLogger.getInstance(context).sendSingleEvent("loadBannerAd", ErrorCodes.NOT_FOUND);
return;
}

if (!banner.isCreated()) {
if (banner.isFailed()) {
result.error(ErrorCodes.LOAD_FAILED, "Failed ad. Load failed. | Ad id : " + id, "");
HMSLogger.getInstance(context).sendSingleEvent("loadBannerAd", ErrorCodes.LOAD_FAILED);
} else {
result.success(true);
HMSLogger.getInstance(context).sendSingleEvent("loadBannerAd");
}
return;
}

Map<String, Object> adParam = ToMap.fromObject(call.argument("adParam"));
banner.loadAd(adSlotId, adParam);
result.success(true);
HMSLogger.getInstance(context).sendSingleEvent("loadBannerAd");
}

private void showBannerAd(MethodCall call, Result result) {
HMSLogger.getInstance(context).startMethodExecutionTimer("showBannerAd");
Integer id = FromMap.toInteger("id", call.argument("id"));
Banner bannerAd = Banner.get(id);
if (bannerAd == null) {
result.error(ErrorCodes.NOT_FOUND, "No ad for given id. Show failed. | Ad id: " + id, null);
HMSLogger.getInstance(context).sendSingleEvent("showBannerAd", ErrorCodes.NOT_FOUND);
return;
}
String offset = FromMap.toString("offset", call.argument("offset"));
Expand All @@ -151,68 +167,84 @@ private void showBannerAd(MethodCall call, Result result) {
}
bannerAd.show();
result.success(true);
HMSLogger.getInstance(context).sendSingleEvent("showBannerAd");
}

private void destroyAd(MethodCall call, Result result) {
HMSLogger.getInstance(context).startMethodExecutionTimer("destroyBannerAd");
Integer id = FromMap.toInteger("id", call.argument("id"));
Banner banner = Banner.get(id);
if (id == null || banner == null) {
result.error(ErrorCodes.NOT_FOUND, "No ad for given id. Destroy failed. | Ad id : " + id, null);
HMSLogger.getInstance(context).sendSingleEvent("destroyBannerAd", ErrorCodes.NOT_FOUND);
return;
}
EventChannelFactory.dispose(id);
banner.destroy();
result.success(true);
HMSLogger.getInstance(context).sendSingleEvent("destroyBannerAd");
}

private void isAdLoading(MethodCall call, Result result) {
HMSLogger.getInstance(context).startMethodExecutionTimer("isBannerAdLoading");
Integer id = FromMap.toInteger("id", call.argument("id"));
String adType = FromMap.toString("adType", call.argument("adType"));
Banner banner = Banner.get(id);
if (id == null || banner == null) {
result.error(ErrorCodes.NULL_PARAM, "Null parameter provided for the method. isAdLoading failed. | Ad id : " + id, "");
HMSLogger.getInstance(context).sendSingleEvent("isBannerAdLoading", ErrorCodes.NULL_PARAM);
return;
}

if (adType != null && adType.equals("Banner")) {
result.success(banner.isLoading());
HMSLogger.getInstance(context).sendSingleEvent("isBannerAdLoading");
} else {
result.error(ErrorCodes.INVALID_PARAM, "Ad type parameter is invalid. isAdLoading failed. | Ad id : " + id, "");
HMSLogger.getInstance(context).sendSingleEvent("isBannerAdLoading", ErrorCodes.INVALID_PARAM);
}
}

private void pauseAd(MethodCall call, Result result) {
HMSLogger.getInstance(context).startMethodExecutionTimer("pauseBannerAd");
Integer id = FromMap.toInteger("id", call.argument("id"));
String adType = FromMap.toString("adType", call.argument("adType"));
Banner banner = Banner.get(id);
if (id == null || banner == null) {
result.error(ErrorCodes.NOT_FOUND, "No ad for given id. Pause failed. | Ad id : " + id, "");
HMSLogger.getInstance(context).sendSingleEvent("pauseBannerAd", ErrorCodes.NULL_PARAM);
return;
}

if (adType != null && adType.equals("Banner")) {
banner.getBannerView().pause();
result.success(true);
HMSLogger.getInstance(context).sendSingleEvent("pauseBannerAd");
} else {
result.error(ErrorCodes.INVALID_PARAM, "Ad type parameter is invalid. Pause failed. | Ad id : " + id, "");
HMSLogger.getInstance(context).sendSingleEvent("pauseBannerAd", ErrorCodes.INVALID_PARAM);
}
}

private void resumeAd(MethodCall call, Result result) {
HMSLogger.getInstance(context).startMethodExecutionTimer("resumeBannerAd");
Integer id = FromMap.toInteger("id", call.argument("id"));
String adType = FromMap.toString("adType", call.argument("adType"));
Banner banner = Banner.get(id);

if (id == null || banner == null) {
result.error(ErrorCodes.NOT_FOUND, "No ad for given id. Resume failed. | Ad id : " + id, "");
HMSLogger.getInstance(context).sendSingleEvent("resumeBannerAd", ErrorCodes.NULL_PARAM);
return;
}

if (adType != null && adType.equals("Banner")) {
banner.getBannerView().resume();
result.success(true);
HMSLogger.getInstance(context).sendSingleEvent("resumeBannerAd");
} else {
result.error(ErrorCodes.INVALID_PARAM, "Ad type parameter is invalid. Pause failed. | Ad id : " + id, "");
HMSLogger.getInstance(context).sendSingleEvent("resumeBannerAd", ErrorCodes.INVALID_PARAM);
}
}
}
Loading

0 comments on commit c265fd7

Please sign in to comment.