Skip to content

Commit

Permalink
Merge branch 'release/2.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
BytesZero committed Aug 22, 2023
2 parents 5808f97 + f4ba578 commit 40f8dc5
Show file tree
Hide file tree
Showing 33 changed files with 216 additions and 261 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
jobs:
build:
# This job will run on macos virtual machine
runs-on: macos-11
runs-on: macos-13
steps:

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

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

# Statically analyze the Dart code for any errors.
- run: flutter analyze .
- run: dart analyze .

# Run widget tests for our flutter project.
- run: flutter test
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v1
- name: Publish
uses: sakebook/actions-flutter-pub-publisher@v1.3.1
uses: sakebook/actions-flutter-pub-publisher@v1.4.1
with:
credential: ${{ secrets.PUB_OAUTH_ACCESS_TOKEN }}
flutter_package: true
skip_test: false
skip_test: true
dry_run: false
4 changes: 2 additions & 2 deletions .github/workflows/publish_apk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@v1
with:
#channel: 'stable' # 'dev', 'alpha', default to: 'stable'
flutter-version: '1.22.x'
channel: 'stable' # 'dev', 'alpha', default to: 'stable'
#flutter-version: '1.22.x'
# fix Permission denied
- name: Setup Permission
run: sudo chown -R $USER $PWD
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.6.0 [2023-08-22]
* [更新] Android SDK `v4.540.1410`
* [更新] iOS SDK `v4.14.40`
* [新增] 设置个性化广告接口 `setPersonalizedState`
* [优化] 去掉信息流中自动适配高度的功能,由开发者自行设置高度
* [优化] 去掉过时的方法调用
## 2.5.0 [2022-04-08]
* 更新 Android SDK `v4.460.1330`
* 以后将不在维护非 1x 版本,请及时升级
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<h3 align="center">一款优质的 Flutter 广告插件(腾讯广告、广点通、优量汇)</h3>

<p align="center">
<a href="https://github.com/FlutterAds/flutter_qq_ads"><img src=https://img.shields.io/badge/pub-v2.5.0-success></a>
<a href="https://github.com/FlutterAds/flutter_qq_ads"><img src=https://img.shields.io/badge/pub-v2.6.0-success></a>
<a href="https://github.com/FlutterAds/flutter_qq_ads"><img src=https://img.shields.io/badge/platform-iOS%20%7C%20Android-brightgreen></a>
<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>
<a href="https://github.com/FlutterAds/flutter_qq_ads"><img src=https://img.shields.io/github/stars/FlutterAds/flutter_qq_ads?color=brightgreen></a>
<a href="https://github.com/FlutterAds/flutter_qq_ads/blob/develop/LICENSE"><img src=https://img.shields.io/badge/license-MIT-brightgreen></a>
</p>

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

``` Dart
dependencies:
flutter_qq_ads: ^2.5.0
flutter_qq_ads: ^2.6.0
```

### 初始化广告
Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.4'
classpath 'com.android.tools.build:gradle:4.2.1'
}
}

Expand Down Expand Up @@ -38,5 +38,5 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
// 广告 SDK
implementation 'com.qq.e.union:union:4.460.1330'
implementation 'com.qq.e.union:union:4.540.1410'
}
13 changes: 13 additions & 0 deletions android/src/main/java/com/zero/flutter_qq_ads/PluginDelegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import androidx.annotation.NonNull;

import com.qq.e.comm.managers.GDTAdSdk;
import com.qq.e.comm.managers.setting.GlobalSetting;
import com.zero.flutter_qq_ads.load.FeedAdLoad;
import com.zero.flutter_qq_ads.load.FeedAdManager;
import com.zero.flutter_qq_ads.page.AdSplashActivity;
Expand Down Expand Up @@ -75,6 +76,8 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
getPlatformVersion(call, result);
} else if ("initAd".equals(method)) {
initAd(call, result);
} else if("setPersonalizedState".equals(method)){
setPersonalizedState(call, result);
} else if ("showSplashAd".equals(method)) {
showSplashAd(call, result);
} else if ("showInterstitialAd".equals(method)) {
Expand Down Expand Up @@ -164,6 +167,16 @@ public void initAd(MethodCall call, MethodChannel.Result result) {
result.success(true);
}

/**
* 设置广告个性化
* @param call MethodCall
* @param result Result
*/
public void setPersonalizedState(MethodCall call, MethodChannel.Result result) {
int state = call.argument("state");
GlobalSetting.setPersonalizedState(state);
result.success(true);
}
/**
* 显示开屏广告
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void loadAd(@NonNull MethodCall call) {
int width = call.argument("width");
int height = call.argument("height");
int count = call.argument("count");
NativeExpressAD ad = new NativeExpressAD(activity, new ADSize(width, height == 0 ? ADSize.AUTO_HEIGHT : height), this.posId, this);
NativeExpressAD ad = new NativeExpressAD(activity, new ADSize(width, height), this.posId, this);
ad.loadAD(count);
}

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

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.zero.flutter_qq_ads.page;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.View;
Expand Down
67 changes: 4 additions & 63 deletions android/src/main/java/com/zero/flutter_qq_ads/page/AdFeedView.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
Expand All @@ -17,9 +15,7 @@
import com.zero.flutter_qq_ads.PluginDelegate;
import com.zero.flutter_qq_ads.event.AdEventAction;
import com.zero.flutter_qq_ads.load.FeedAdManager;
import com.zero.flutter_qq_ads.utils.UIUtils;

import java.util.HashMap;
import java.util.Map;

import io.flutter.plugin.common.MethodCall;
Expand All @@ -29,25 +25,20 @@
/**
* Feed 信息流广告 View
*/
class AdFeedView extends BaseAdPage implements PlatformView, View.OnLayoutChangeListener {
class AdFeedView extends BaseAdPage implements PlatformView {
private final String TAG = AdFeedView.class.getSimpleName();
@NonNull
private final FrameLayout frameLayout;
private final PluginDelegate pluginDelegate;
private int id;
private NativeExpressADView fad;
private MethodChannel methodChannel;
private BroadcastReceiver receiver;


AdFeedView(@NonNull Context context, int id, @Nullable Map<String, Object> creationParams, PluginDelegate pluginDelegate) {
this.id = id;
this.pluginDelegate = pluginDelegate;
methodChannel = new MethodChannel(this.pluginDelegate.bind.getBinaryMessenger(), PluginDelegate.KEY_FEED_VIEW + "/" + id);
frameLayout = new FrameLayout(context);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
frameLayout.setLayoutParams(params);
frameLayout.addOnLayoutChangeListener(this);
MethodCall call = new MethodCall("AdFeedView", creationParams);
showAd(this.pluginDelegate.activity, call);
}
Expand All @@ -69,12 +60,11 @@ public void loadAd(@NonNull MethodCall call) {
regReceiver(key);
fad = FeedAdManager.getInstance().getAd(key);
if (fad != null) {
View adView = fad.getRootView();
if (adView.getParent() != null) {
((ViewGroup) adView.getParent()).removeAllViews();
if (frameLayout.getChildCount() > 0) {
frameLayout.removeAllViews();
}
frameLayout.addView(adView);
fad.render();
frameLayout.addView(fad);
}
}

Expand All @@ -91,29 +81,13 @@ public void onReceive(Context context, Intent intent) {
String event = intent.getStringExtra("event");
if (AdEventAction.onAdClosed.equals(event) || AdEventAction.onAdError.equals(event)) {
AdFeedView.this.disposeAd();
} else if (AdEventAction.onAdPresent.equals(event)) {
AdFeedView.this.resizeAdView();
}
}
};
IntentFilter intentFilter = new IntentFilter(PluginDelegate.KEY_FEED_VIEW + "_" + key);
LocalBroadcastManager.getInstance(activity).registerReceiver(receiver, intentFilter);
}

/**
* 重新计算真实的广告 View 的宽高
*/
private void resizeAdView() {
this.fad.measure(100, 100);
int mw = this.fad.getMeasuredWidth();
int mh = this.fad.getMeasuredHeight();
Log.d(TAG, "resizeAdView mw:" + mw + " mh:" + mh);
FrameLayout.LayoutParams params=new FrameLayout.LayoutParams(mw,mh);
frameLayout.setLayoutParams(params);
frameLayout.requestLayout();
setFlutterViewSize(mw,mh);
}

/**
* 移除广告
*/
Expand All @@ -134,39 +108,6 @@ private void disposeAd() {
if (fad != null) {
fad.destroy();
}
// 更新宽高
setFlutterViewSize(0f, 0f);
}

/**
* 设置 FlutterAds 视图宽高
*
* @param width 宽度
* @param height 高度
*/
private void setFlutterViewSize(float width, float height) {
int widthPd = UIUtils.px2dip(activity, width);
int heightPd = UIUtils.px2dip(activity, height);
Log.i(TAG, "onLayoutChange widthPd:" + widthPd + " heightPd:" + heightPd);
// 更新宽高
Map<String, Double> sizeMap = new HashMap<>();
sizeMap.put("width", (double) widthPd);
sizeMap.put("height", (double) heightPd);
if (methodChannel != null) {
methodChannel.invokeMethod("setSize", sizeMap);
}
}

@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
Log.i(TAG, "onLayoutChange left:" + left + " top:" + top + " right:" + right + " bottom:" + bottom);

if (right > 0 && bottom > 0) {
int width = right - left;
int height = bottom - top;
Log.i(TAG, "onLayoutChange width:" + width + " height:" + height);
// setFlutterViewSize(width, height);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public void showAd(Activity activity, MethodCall call) {
/**
* 加载广告
*
* @param activity 上下文
* @param call 方法调用
*/
public abstract void loadAd(MethodCall call);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private void show() {
*/
private void showAsPopup() {
if (iad != null && iad.isValid()) {
iad.showAsPopupWindow();
iad.show();
} else {
Log.d(TAG, "请加载广告并渲染成功后再进行展示 ! ");
}
Expand Down
7 changes: 4 additions & 3 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 29
ndkVersion "21.4.7075529"
compileSdkVersion 31
// ndkVersion "25.1.8937393"
lintOptions {
disable 'InvalidPackage'
}
Expand All @@ -36,9 +36,10 @@ android {
// applicationId "com.zero.flutter_qq_ads_example"
applicationId "com.banjixiaoguanjia.app"
minSdkVersion 19
targetSdkVersion 29
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}

//签名信息
Expand Down
1 change: 1 addition & 0 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:exported="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
// Generated file.
//
// If you wish to remove Flutter's multidex support, delete this entire file.
//
// Modifications to this file should be done in a copy under a different name
// as this file may be regenerated.

package io.flutter.app;

import android.app.Application;
import android.content.Context;
import androidx.annotation.CallSuper;
import androidx.multidex.MultiDex;

/**
* Extension of {@link io.flutter.app.FlutterApplication}, adding multidex support.
* Extension of {@link android.app.Application}, adding multidex support.
*/
public class FlutterMultiDexApplication extends FlutterApplication {
public class FlutterMultiDexApplication extends Application {
@Override
@CallSuper
protected void attachBaseContext(Context base) {
Expand Down
4 changes: 2 additions & 2 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.4'
classpath 'com.android.tools.build:gradle:4.2.1'
}
}

Expand All @@ -24,6 +24,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
1 change: 1 addition & 0 deletions example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
android.injected.testOnly=false
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>
Loading

0 comments on commit 40f8dc5

Please sign in to comment.