Skip to content

Commit 4988524

Browse files
committed
Merge branch 'develop' into 2x
2 parents 066cc83 + 497eee2 commit 4988524

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1506
-412
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.4.0 [2021-11-30]
2+
* [新增] 信息流广告类型
3+
* 升级 Android SDK 到 Pro 版 `v4.0.2.2`
4+
15
## 2.3.1 [2021-10-28]
26
* 新增配置开屏广告点击热区样式
37
* 升级 Android SDK 到 Pro 版 `v4.0.1.1`
@@ -26,6 +30,14 @@
2630
* 2.x.x 是 Null Safety 版本
2731
* 现在阶段会同时维护这 2 个版本,再往后可能仅维护一个版本
2832

33+
## 1.4.0 [2021-11-30]
34+
* [新增] 信息流广告类型
35+
* 升级 Android SDK 到 Pro 版 `v4.0.2.2`
36+
37+
## 1.3.1 [2021-10-28]
38+
* 新增配置开屏广告点击热区样式
39+
* 升级 Android SDK 到 Pro 版 `v4.0.1.1`
40+
2941
## 1.2.0 [2021-09-04]
3042
* 增加 Banner 广告支持
3143
* 优化开屏广告支持超时时间设置 #3

README.md

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<h3 align="center">一款优质的 Flutter 广告插件(字节跳动、穿山甲)</h3>
55

66
<p align="center">
7-
<a href="https://pub.dev/packages/flutter_pangle_ads"><img src=https://img.shields.io/badge/version-v1.3.1-success></a>
8-
<a href="https://pub.dev/packages/flutter_pangle_ads"><img src=https://img.shields.io/badge/null_safety-v2.3.1-success></a>
7+
<a href="https://pub.dev/packages/flutter_pangle_ads"><img src=https://img.shields.io/badge/version-v1.4.1-success></a>
8+
<a href="https://pub.dev/packages/flutter_pangle_ads"><img src=https://img.shields.io/badge/null_safety-v2.4.1-success></a>
99
<a href="https://github.com/FlutterAds/flutter_pangle_ads"><img src=https://img.shields.io/badge/platform-iOS%20%7C%20Android-brightgreen></a>
1010
<a href="https://github.com/FlutterAds/flutter_pangle_ads/actions/workflows/flutter.yml"><img src="https://github.com/FlutterAds/flutter_pangle_ads/actions/workflows/flutter.yml/badge.svg?branch=2x"></a>
1111
<a href="https://github.com/FlutterAds/flutter_pangle_ads"><img src=https://img.shields.io/github/stars/FlutterAds/flutter_pangle_ads?color=brightgreen></a>
@@ -26,7 +26,8 @@
2626
- ✅ 激励视频
2727
- ✅ 全屏视频
2828
- ✅ Banner
29-
- 🔲 信息流
29+
- ✅ 信息流
30+
- 🔲 Draw 贴片视频
3031

3132
## 下载体验
3233
<a href="https://www.pgyer.com/app/qrcode/fads"><img src="https://www.pgyer.com/app/qrcode/fads" width='100' height='100'></a>
@@ -37,8 +38,8 @@
3738

3839
``` Dart
3940
dependencies:
40-
flutter_pangle_ads: ^1.3.1 # 非 Null Safety 版本
41-
flutter_pangle_ads: ^2.3.1 # Null Safety 版本
41+
flutter_pangle_ads: ^1.4.1 # 非 Null Safety 版本
42+
flutter_pangle_ads: ^2.4.1 # Null Safety 版本
4243
```
4344
### 初始化广告
4445

@@ -141,6 +142,43 @@ SizedBox(
141142
)
142143
```
143144

145+
### 信息流
146+
- 获取信息流广告列表
147+
``` Dart
148+
/// [posId] 广告位 id
149+
/// [width] 宽度
150+
/// [height] 高度
151+
/// [count] 获取广告数量,建议 1~3 个
152+
List<int> feedAdList = await FlutterPangleAds.loadFeedAd(
153+
AdsConfig.feedId,
154+
width: 375,
155+
height: 128,
156+
count: 3,
157+
);
158+
```
159+
- 清除信息流广告列表
160+
161+
> 当你的广告不再需要时,请一定执行清除操作
162+
``` Dart
163+
/// [list] 信息流广告 id 列表
164+
bool result = await FlutterPangleAds.clearFeedAd(feedAdList);
165+
```
166+
- 页面中展示信息流广告
167+
``` Dart
168+
/// Feed 信息流广告组件
169+
/// [posId]返回的广告 id,这里不是广告位id
170+
/// [width]组件的宽度
171+
/// [height]组件的高度
172+
/// [show]是否显示
173+
AdFeedWidget(
174+
posId: '${feedAdList[0]}',
175+
width: 375,
176+
height: 128,
177+
show: true,
178+
)
179+
```
180+
> `width``height` 需要根据你新建广告位的模板来设置
181+
144182
### 设置广告事件监听
145183

146184
``` Dart

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ dependencies {
3939
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
4040
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
4141
// 广告 SDK
42-
implementation 'com.pangle.cn:ads-sdk-pro:4.0.1.1'
42+
implementation 'com.pangle.cn:ads-sdk-pro:4.0.2.2'
4343
}

android/src/main/java/com/zero/flutter_pangle_ads/FlutterPangleAdsPlugin.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
77
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
88
import io.flutter.plugin.common.EventChannel;
9-
import io.flutter.plugin.common.MethodCall;
109
import io.flutter.plugin.common.MethodChannel;
11-
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
12-
import io.flutter.plugin.common.MethodChannel.Result;
13-
import io.flutter.plugin.common.PluginRegistry.Registrar;
1410

1511
/**
1612
* FlutterPangleAdsPlugin
@@ -49,6 +45,7 @@ public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) {
4945
methodChannel.setMethodCallHandler(delegate);
5046
eventChannel.setStreamHandler(delegate);
5147
this.delegate.registerBannerView();
48+
this.delegate.registerFeedView();
5249
}
5350

5451
@Override

android/src/main/java/com/zero/flutter_pangle_ads/PluginDelegate.java

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
import androidx.annotation.NonNull;
88

99
import com.bytedance.sdk.openadsdk.TTAdConfig;
10-
import com.bytedance.sdk.openadsdk.TTAdConstant;
1110
import com.bytedance.sdk.openadsdk.TTAdSdk;
11+
import com.zero.flutter_pangle_ads.load.FeedAdLoad;
12+
import com.zero.flutter_pangle_ads.load.FeedAdManager;
1213
import com.zero.flutter_pangle_ads.page.AdSplashActivity;
1314
import com.zero.flutter_pangle_ads.page.FullScreenVideoPage;
1415
import com.zero.flutter_pangle_ads.page.InterstitialPage;
@@ -42,8 +43,11 @@ public class PluginDelegate implements MethodChannel.MethodCallHandler, EventCha
4243
public static PluginDelegate getInstance() {
4344
return _instance;
4445
}
46+
4547
// Banner View
4648
public static final String KEY_BANNER_VIEW = "flutter_pangle_ads_banner";
49+
// Feed View
50+
public static final String KEY_FEED_VIEW = "flutter_pangle_ads_feed";
4751
// 广告参数
4852
public static final String KEY_POSID = "posId";
4953
// logo 参数
@@ -87,6 +91,10 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
8791
showRewardVideoAd(call, result);
8892
} else if ("showFullScreenVideoAd".equals(method)) {
8993
showFullScreenVideoAd(call, result);
94+
} else if ("loadFeedAd".equals(method)) {
95+
loadFeedAd(call, result);
96+
} else if ("clearFeedAd".equals(method)) {
97+
clearFeedAd(call, result);
9098
} else {
9199
result.notImplemented();
92100
}
@@ -132,7 +140,15 @@ public void addEvent(Object event) {
132140
*/
133141
public void registerBannerView() {
134142
bind.getPlatformViewRegistry()
135-
.registerViewFactory(KEY_BANNER_VIEW, new NativeViewFactory(KEY_BANNER_VIEW,this));
143+
.registerViewFactory(KEY_BANNER_VIEW, new NativeViewFactory(KEY_BANNER_VIEW, this));
144+
}
145+
146+
/**
147+
* 展示 Feed 信息流广告
148+
*/
149+
public void registerFeedView() {
150+
bind.getPlatformViewRegistry()
151+
.registerViewFactory(KEY_FEED_VIEW, new NativeViewFactory(KEY_FEED_VIEW, this));
136152
}
137153

138154
/**
@@ -158,7 +174,7 @@ public void initAd(MethodCall call, final MethodChannel.Result result) {
158174
boolean supportMultiProcess = call.argument("supportMultiProcess");
159175
boolean allowShowNotify = call.argument("allowShowNotify");
160176
ArrayList directDownloadNetworkType = call.argument("directDownloadNetworkType");
161-
int[] directDownloadNetworkTypeList= DataUtils.convertIntegers(directDownloadNetworkType);
177+
int[] directDownloadNetworkTypeList = DataUtils.convertIntegers(directDownloadNetworkType);
162178
// 构建配置
163179
TTAdConfig config = new TTAdConfig.Builder()
164180
.appId(appId)
@@ -183,7 +199,7 @@ public void run() {
183199

184200
@Override
185201
public void fail(int code, String msg) {
186-
Log.i(TAG, "fail: code = " + code + " msg = " + msg);
202+
Log.e(TAG, "fail: code = " + code + " msg = " + msg);
187203
activity.runOnUiThread(new Runnable() {
188204
@Override
189205
public void run() {
@@ -252,4 +268,32 @@ public void showFullScreenVideoAd(MethodCall call, MethodChannel.Result result)
252268
adPage.showAd(activity, call);
253269
result.success(true);
254270
}
271+
272+
/**
273+
* 加载信息流广告列表
274+
*
275+
* @param call MethodCall
276+
* @param result Result
277+
*/
278+
public void loadFeedAd(MethodCall call, MethodChannel.Result result) {
279+
FeedAdLoad feedAd = new FeedAdLoad();
280+
feedAd.loadFeedAdList(activity, call, result);
281+
}
282+
283+
/**
284+
* 删除信息流广告列表
285+
*
286+
* @param call MethodCall
287+
* @param result Result
288+
*/
289+
public void clearFeedAd(MethodCall call, MethodChannel.Result result) {
290+
List<Integer> adList = call.argument("list");
291+
if (adList != null) {
292+
for (int ad : adList) {
293+
FeedAdManager.getInstance().removeAd(ad);
294+
}
295+
}
296+
result.success(true);
297+
298+
}
255299
}

android/src/main/java/com/zero/flutter_pangle_ads/event/AdErrorEvent.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
import java.util.HashMap;
44

55
/**
6-
* 广告错误事件
6+
* 广告错误事件
77
*/
88
public class AdErrorEvent extends AdEvent {
99
// 错误码
1010
private final int errCode;
1111
// 错误信息
1212
private final String errMsg;
13+
1314
// 错误事件实体
1415
public AdErrorEvent(String adId, int errCode, String errMsg) {
1516
super(adId, AdEventAction.onAdError);
@@ -19,13 +20,14 @@ public AdErrorEvent(String adId, int errCode, String errMsg) {
1920

2021
/**
2122
* 重写 toMap 方法
23+
*
2224
* @return 返回错误事件的map
2325
*/
2426
@Override
2527
public HashMap<String, Object> toMap() {
26-
HashMap<String, Object> newMap= super.toMap();
27-
newMap.put("errCode",errCode);
28-
newMap.put("errMsg",errMsg);
28+
HashMap<String, Object> newMap = super.toMap();
29+
newMap.put("errCode", errCode);
30+
newMap.put("errMsg", errMsg);
2931
return newMap;
3032
}
3133
}

android/src/main/java/com/zero/flutter_pangle_ads/event/AdEvent.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ public AdEvent(String adId, String action) {
1818

1919
/**
2020
* 转换为 Map 方面传输
21+
*
2122
* @return 转换后的 Map 对象
2223
*/
23-
public HashMap<String,Object> toMap() {
24-
HashMap<String,Object> map=new HashMap<String,Object>();
25-
map.put("adId",adId);
26-
map.put("action",action);
24+
public HashMap<String, Object> toMap() {
25+
HashMap<String, Object> map = new HashMap<String, Object>();
26+
map.put("adId", adId);
27+
map.put("action", action);
2728
return map;
2829
}
2930
}

android/src/main/java/com/zero/flutter_pangle_ads/event/AdEventAction.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
*/
66
public class AdEventAction {
77
// 广告错误
8-
public static final String onAdError="onAdError";
8+
public static final String onAdError = "onAdError";
99
// 广告加载成功
10-
public static final String onAdLoaded="onAdLoaded";
10+
public static final String onAdLoaded = "onAdLoaded";
1111
// 广告填充
12-
public static final String onAdPresent="onAdPresent";
12+
public static final String onAdPresent = "onAdPresent";
1313
// 广告曝光
14-
public static final String onAdExposure="onAdExposure";
14+
public static final String onAdExposure = "onAdExposure";
1515
// 广告关闭(计时结束或者用户点击关闭)
16-
public static final String onAdClosed="onAdClosed";
16+
public static final String onAdClosed = "onAdClosed";
1717
// 广告点击
18-
public static final String onAdClicked="onAdClicked";
18+
public static final String onAdClicked = "onAdClicked";
1919
// 广告跳过
20-
public static final String onAdSkip="onAdSkip";
20+
public static final String onAdSkip = "onAdSkip";
2121
// 广告播放或计时完毕
22-
public static final String onAdComplete="onAdComplete";
22+
public static final String onAdComplete = "onAdComplete";
2323
// 获得广告激励
24-
public static final String onAdReward="onAdReward";
24+
public static final String onAdReward = "onAdReward";
2525
}

android/src/main/java/com/zero/flutter_pangle_ads/event/AdRewardEvent.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* 广告激励事件
77
*/
8-
public class AdRewardEvent extends AdEvent{
8+
public class AdRewardEvent extends AdEvent {
99
// 奖励是否有效
1010
private final boolean rewardVerify;
1111
// 奖励数量
@@ -21,27 +21,27 @@ public class AdRewardEvent extends AdEvent{
2121
// 用户信息
2222
private final String userId;
2323

24-
public AdRewardEvent(String adId,boolean rewardVerify, int rewardAmount,String rewardName,int errCode,String errMsg,String customData,String userId) {
24+
public AdRewardEvent(String adId, boolean rewardVerify, int rewardAmount, String rewardName, int errCode, String errMsg, String customData, String userId) {
2525
super(adId, AdEventAction.onAdReward);
26-
this.rewardVerify=rewardVerify;
27-
this.rewardAmount=rewardAmount;
28-
this.rewardName=rewardName;
29-
this.errCode=errCode;
30-
this.errMsg=errMsg;
31-
this.customData=customData;
32-
this.userId=userId;
26+
this.rewardVerify = rewardVerify;
27+
this.rewardAmount = rewardAmount;
28+
this.rewardName = rewardName;
29+
this.errCode = errCode;
30+
this.errMsg = errMsg;
31+
this.customData = customData;
32+
this.userId = userId;
3333
}
3434

3535
@Override
3636
public HashMap<String, Object> toMap() {
37-
HashMap<String, Object> newMap= super.toMap();
38-
newMap.put("rewardVerify",rewardVerify);
39-
newMap.put("rewardAmount",rewardAmount);
40-
newMap.put("rewardName",rewardName);
41-
newMap.put("errCode",errCode);
42-
newMap.put("errMsg",errMsg);
43-
newMap.put("customData",customData);
44-
newMap.put("userId",userId);
37+
HashMap<String, Object> newMap = super.toMap();
38+
newMap.put("rewardVerify", rewardVerify);
39+
newMap.put("rewardAmount", rewardAmount);
40+
newMap.put("rewardName", rewardName);
41+
newMap.put("errCode", errCode);
42+
newMap.put("errMsg", errMsg);
43+
newMap.put("customData", customData);
44+
newMap.put("userId", userId);
4545
return newMap;
4646
}
4747
}

0 commit comments

Comments
 (0)