Skip to content

Commit 40f8dc5

Browse files
committed
Merge branch 'release/2.6.0'
2 parents 5808f97 + f4ba578 commit 40f8dc5

33 files changed

+216
-261
lines changed

.github/workflows/flutter.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
jobs:
1616
build:
1717
# This job will run on macos virtual machine
18-
runs-on: macos-11
18+
runs-on: macos-13
1919
steps:
2020

2121
# Setup Java environment in order to build the Android app.
@@ -33,10 +33,10 @@ jobs:
3333
- run: flutter pub get
3434

3535
# Check for any formatting issues in the code.
36-
- run: flutter format --set-exit-if-changed .
36+
- run: dart format --set-exit-if-changed .
3737

3838
# Statically analyze the Dart code for any errors.
39-
- run: flutter analyze .
39+
- run: dart analyze .
4040

4141
# Run widget tests for our flutter project.
4242
- run: flutter test

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
- name: Checkout
1616
uses: actions/checkout@v1
1717
- name: Publish
18-
uses: sakebook/actions-flutter-pub-publisher@v1.3.1
18+
uses: sakebook/actions-flutter-pub-publisher@v1.4.1
1919
with:
2020
credential: ${{ secrets.PUB_OAUTH_ACCESS_TOKEN }}
2121
flutter_package: true
22-
skip_test: false
22+
skip_test: true
2323
dry_run: false

.github/workflows/publish_apk.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
- name: Setup Flutter
2424
uses: subosito/flutter-action@v1
2525
with:
26-
#channel: 'stable' # 'dev', 'alpha', default to: 'stable'
27-
flutter-version: '1.22.x'
26+
channel: 'stable' # 'dev', 'alpha', default to: 'stable'
27+
#flutter-version: '1.22.x'
2828
# fix Permission denied
2929
- name: Setup Permission
3030
run: sudo chown -R $USER $PWD

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 2.6.0 [2023-08-22]
2+
* [更新] Android SDK `v4.540.1410`
3+
* [更新] iOS SDK `v4.14.40`
4+
* [新增] 设置个性化广告接口 `setPersonalizedState`
5+
* [优化] 去掉信息流中自动适配高度的功能,由开发者自行设置高度
6+
* [优化] 去掉过时的方法调用
17
## 2.5.0 [2022-04-08]
28
* 更新 Android SDK `v4.460.1330`
39
* 以后将不在维护非 1x 版本,请及时升级

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
<h3 align="center">一款优质的 Flutter 广告插件(腾讯广告、广点通、优量汇)</h3>
55

66
<p align="center">
7-
<a href="https://github.com/FlutterAds/flutter_qq_ads"><img src=https://img.shields.io/badge/pub-v2.5.0-success></a>
7+
<a href="https://github.com/FlutterAds/flutter_qq_ads"><img src=https://img.shields.io/badge/pub-v2.6.0-success></a>
88
<a href="https://github.com/FlutterAds/flutter_qq_ads"><img src=https://img.shields.io/badge/platform-iOS%20%7C%20Android-brightgreen></a>
99
<a href="https://github.com/FlutterAds/flutter_qq_ads/actions/workflows/flutter.yml"><img src="https://github.com/FlutterAds/flutter_qq_ads/actions/workflows/flutter.yml/badge.svg"></a>
1010
<a href="https://github.com/FlutterAds/flutter_qq_ads"><img src=https://img.shields.io/github/stars/FlutterAds/flutter_qq_ads?color=brightgreen></a>
1111
<a href="https://github.com/FlutterAds/flutter_qq_ads/blob/develop/LICENSE"><img src=https://img.shields.io/badge/license-MIT-brightgreen></a>
1212
</p>
1313

1414
## 插件特点
15-
- 🔨 接入简单快速(封装原生端配置,仅需引入即可开始
15+
- 🔨 接入简单快速(封装原生端配置,仅需引入即可
1616
- 📡 事件统一返回(将原生端各种重要回调事件统一返回,方便业务处理和埋点统计等需求)
1717
- 🎁 注重优化体验(无闪烁 Logo 开屏、权限申请、隐私跟踪申请等、信息流自动适配宽高)
1818
- 🏆 极客代码封装(原生端代码不凑合,两端统一基础框架、广告事件封装抽象、易扩展新广告形式、方便开发个性化需求)
@@ -36,7 +36,7 @@
3636

3737
``` Dart
3838
dependencies:
39-
flutter_qq_ads: ^2.5.0
39+
flutter_qq_ads: ^2.6.0
4040
```
4141

4242
### 初始化广告

android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
}
99

1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:3.5.4'
11+
classpath 'com.android.tools.build:gradle:4.2.1'
1212
}
1313
}
1414

@@ -38,5 +38,5 @@ dependencies {
3838
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
3939
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
4040
// 广告 SDK
41-
implementation 'com.qq.e.union:union:4.460.1330'
41+
implementation 'com.qq.e.union:union:4.540.1410'
4242
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import androidx.annotation.NonNull;
88

99
import com.qq.e.comm.managers.GDTAdSdk;
10+
import com.qq.e.comm.managers.setting.GlobalSetting;
1011
import com.zero.flutter_qq_ads.load.FeedAdLoad;
1112
import com.zero.flutter_qq_ads.load.FeedAdManager;
1213
import com.zero.flutter_qq_ads.page.AdSplashActivity;
@@ -75,6 +76,8 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
7576
getPlatformVersion(call, result);
7677
} else if ("initAd".equals(method)) {
7778
initAd(call, result);
79+
} else if("setPersonalizedState".equals(method)){
80+
setPersonalizedState(call, result);
7881
} else if ("showSplashAd".equals(method)) {
7982
showSplashAd(call, result);
8083
} else if ("showInterstitialAd".equals(method)) {
@@ -164,6 +167,16 @@ public void initAd(MethodCall call, MethodChannel.Result result) {
164167
result.success(true);
165168
}
166169

170+
/**
171+
* 设置广告个性化
172+
* @param call MethodCall
173+
* @param result Result
174+
*/
175+
public void setPersonalizedState(MethodCall call, MethodChannel.Result result) {
176+
int state = call.argument("state");
177+
GlobalSetting.setPersonalizedState(state);
178+
result.success(true);
179+
}
167180
/**
168181
* 显示开屏广告
169182
*

android/src/main/java/com/zero/flutter_qq_ads/load/FeedAdLoad.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void loadAd(@NonNull MethodCall call) {
4646
int width = call.argument("width");
4747
int height = call.argument("height");
4848
int count = call.argument("count");
49-
NativeExpressAD ad = new NativeExpressAD(activity, new ADSize(width, height == 0 ? ADSize.AUTO_HEIGHT : height), this.posId, this);
49+
NativeExpressAD ad = new NativeExpressAD(activity, new ADSize(width, height), this.posId, this);
5050
ad.loadAD(count);
5151
}
5252

@@ -106,7 +106,6 @@ private void sendBroadcastEvent(NativeExpressADView adView, String event) {
106106
intent.setAction(PluginDelegate.KEY_FEED_VIEW + "_" + adView.hashCode());
107107
intent.putExtra("event", event);
108108
boolean result = LocalBroadcastManager.getInstance(activity).sendBroadcast(intent);
109-
// Log.i(TAG, "sendBroadcastEvent sendBroadcast:" + result);
110109
}
111110

112111
@Override

android/src/main/java/com/zero/flutter_qq_ads/page/AdBannerView.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.zero.flutter_qq_ads.page;
22

3-
import android.app.Activity;
43
import android.content.Context;
54
import android.util.Log;
65
import android.view.View;

android/src/main/java/com/zero/flutter_qq_ads/page/AdFeedView.java

Lines changed: 4 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
import android.content.Context;
55
import android.content.Intent;
66
import android.content.IntentFilter;
7-
import android.util.Log;
87
import android.view.View;
9-
import android.view.ViewGroup;
108
import android.widget.FrameLayout;
119

1210
import androidx.annotation.NonNull;
@@ -17,9 +15,7 @@
1715
import com.zero.flutter_qq_ads.PluginDelegate;
1816
import com.zero.flutter_qq_ads.event.AdEventAction;
1917
import com.zero.flutter_qq_ads.load.FeedAdManager;
20-
import com.zero.flutter_qq_ads.utils.UIUtils;
2118

22-
import java.util.HashMap;
2319
import java.util.Map;
2420

2521
import io.flutter.plugin.common.MethodCall;
@@ -29,25 +25,20 @@
2925
/**
3026
* Feed 信息流广告 View
3127
*/
32-
class AdFeedView extends BaseAdPage implements PlatformView, View.OnLayoutChangeListener {
28+
class AdFeedView extends BaseAdPage implements PlatformView {
3329
private final String TAG = AdFeedView.class.getSimpleName();
3430
@NonNull
3531
private final FrameLayout frameLayout;
3632
private final PluginDelegate pluginDelegate;
3733
private int id;
3834
private NativeExpressADView fad;
39-
private MethodChannel methodChannel;
4035
private BroadcastReceiver receiver;
4136

4237

4338
AdFeedView(@NonNull Context context, int id, @Nullable Map<String, Object> creationParams, PluginDelegate pluginDelegate) {
4439
this.id = id;
4540
this.pluginDelegate = pluginDelegate;
46-
methodChannel = new MethodChannel(this.pluginDelegate.bind.getBinaryMessenger(), PluginDelegate.KEY_FEED_VIEW + "/" + id);
4741
frameLayout = new FrameLayout(context);
48-
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
49-
frameLayout.setLayoutParams(params);
50-
frameLayout.addOnLayoutChangeListener(this);
5142
MethodCall call = new MethodCall("AdFeedView", creationParams);
5243
showAd(this.pluginDelegate.activity, call);
5344
}
@@ -69,12 +60,11 @@ public void loadAd(@NonNull MethodCall call) {
6960
regReceiver(key);
7061
fad = FeedAdManager.getInstance().getAd(key);
7162
if (fad != null) {
72-
View adView = fad.getRootView();
73-
if (adView.getParent() != null) {
74-
((ViewGroup) adView.getParent()).removeAllViews();
63+
if (frameLayout.getChildCount() > 0) {
64+
frameLayout.removeAllViews();
7565
}
76-
frameLayout.addView(adView);
7766
fad.render();
67+
frameLayout.addView(fad);
7868
}
7969
}
8070

@@ -91,29 +81,13 @@ public void onReceive(Context context, Intent intent) {
9181
String event = intent.getStringExtra("event");
9282
if (AdEventAction.onAdClosed.equals(event) || AdEventAction.onAdError.equals(event)) {
9383
AdFeedView.this.disposeAd();
94-
} else if (AdEventAction.onAdPresent.equals(event)) {
95-
AdFeedView.this.resizeAdView();
9684
}
9785
}
9886
};
9987
IntentFilter intentFilter = new IntentFilter(PluginDelegate.KEY_FEED_VIEW + "_" + key);
10088
LocalBroadcastManager.getInstance(activity).registerReceiver(receiver, intentFilter);
10189
}
10290

103-
/**
104-
* 重新计算真实的广告 View 的宽高
105-
*/
106-
private void resizeAdView() {
107-
this.fad.measure(100, 100);
108-
int mw = this.fad.getMeasuredWidth();
109-
int mh = this.fad.getMeasuredHeight();
110-
Log.d(TAG, "resizeAdView mw:" + mw + " mh:" + mh);
111-
FrameLayout.LayoutParams params=new FrameLayout.LayoutParams(mw,mh);
112-
frameLayout.setLayoutParams(params);
113-
frameLayout.requestLayout();
114-
setFlutterViewSize(mw,mh);
115-
}
116-
11791
/**
11892
* 移除广告
11993
*/
@@ -134,39 +108,6 @@ private void disposeAd() {
134108
if (fad != null) {
135109
fad.destroy();
136110
}
137-
// 更新宽高
138-
setFlutterViewSize(0f, 0f);
139-
}
140-
141-
/**
142-
* 设置 FlutterAds 视图宽高
143-
*
144-
* @param width 宽度
145-
* @param height 高度
146-
*/
147-
private void setFlutterViewSize(float width, float height) {
148-
int widthPd = UIUtils.px2dip(activity, width);
149-
int heightPd = UIUtils.px2dip(activity, height);
150-
Log.i(TAG, "onLayoutChange widthPd:" + widthPd + " heightPd:" + heightPd);
151-
// 更新宽高
152-
Map<String, Double> sizeMap = new HashMap<>();
153-
sizeMap.put("width", (double) widthPd);
154-
sizeMap.put("height", (double) heightPd);
155-
if (methodChannel != null) {
156-
methodChannel.invokeMethod("setSize", sizeMap);
157-
}
158-
}
159-
160-
@Override
161-
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
162-
Log.i(TAG, "onLayoutChange left:" + left + " top:" + top + " right:" + right + " bottom:" + bottom);
163-
164-
if (right > 0 && bottom > 0) {
165-
int width = right - left;
166-
int height = bottom - top;
167-
Log.i(TAG, "onLayoutChange width:" + width + " height:" + height);
168-
// setFlutterViewSize(width, height);
169-
}
170111
}
171112

172113
}

0 commit comments

Comments
 (0)