Explorar o código

【内容修改】

hubowen hai 1 ano
pai
achega
1729fdb275

+ 18 - 19
app/build.gradle

@@ -95,30 +95,27 @@ android {
 
 
 dependencies {
-
-    implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
-
 //    implementation 'com.google.android.gms:play-services-ads:21.3.0'
 //    implementation 'com.pangle.cn:ads-sdk-pro:4.8.0.8'
 //    implementation "com.gromore.cn:gromore-sdk:3.7.0.3"
 //    implementation "com.gromore.cn:pangle-adapter:4.8.0.8.2"
     //mintegral
-//    api("com.mbridge.msdk.support:videojs:16.2.27")
-//    api("com.mbridge.msdk.support:mbjscommon:16.2.27")
-//    api("com.mbridge.msdk.support:playercommon:16.2.27")
-//    api("com.mbridge.msdk.support:reward:16.2.27")
-//    api("com.mbridge.msdk.support:videocommon:16.2.27")
-//    api("com.mbridge.msdk.support:chinasame:16.2.27")
-//    api("com.mbridge.msdk.support:interstitialvideo:16.2.27")
-//    api("com.mbridge.msdk.support:mbnative:16.2.27")
-//    api("com.mbridge.msdk.support:nativeex:16.2.27")
-//    api("com.mbridge.msdk.support:mbnativeadvanced:16.2.27")
-//    api("com.mbridge.msdk.support:interstitial:16.2.27")
-//    api("com.mbridge.msdk.support:mbbanner:16.2.27")
-//    api("com.mbridge.msdk.support:mbsplash:16.2.27")
-//    api("com.mbridge.msdk.support:mbbid:16.2.27")
-//    api("com.mbridge.msdk.support:newinterstitial:16.2.27")
-
+    api("com.mbridge.msdk.support:videojs:16.2.27")
+    api("com.mbridge.msdk.support:mbjscommon:16.2.27")
+    api("com.mbridge.msdk.support:playercommon:16.2.27")
+    api("com.mbridge.msdk.support:reward:16.2.27")
+    api("com.mbridge.msdk.support:videocommon:16.2.27")
+    api("com.mbridge.msdk.support:chinasame:16.2.27")
+    api("com.mbridge.msdk.support:interstitialvideo:16.2.27")
+    api("com.mbridge.msdk.support:mbnative:16.2.27")
+    api("com.mbridge.msdk.support:nativeex:16.2.27")
+    api("com.mbridge.msdk.support:mbnativeadvanced:16.2.27")
+    api("com.mbridge.msdk.support:interstitial:16.2.27")
+    api("com.mbridge.msdk.support:mbbanner:16.2.27")
+    api("com.mbridge.msdk.support:mbsplash:16.2.27")
+    api("com.mbridge.msdk.support:mbbid:16.2.27")
+    api("com.mbridge.msdk.support:newinterstitial:16.2.27")
+    api fileTree(dir: "libs", include: ["*.jar", "*.aar"])
 
     implementation project(':lib_common')
     implementation project(':lib_ad_core')
@@ -134,6 +131,8 @@ dependencies {
     /*GroMore 优量汇*/
     implementation "by.gm_mediation.com:gdt-adapter:4.510.1380.0"
 
+    implementation 'com.pangle.cn:mediation-sdk:5.1.6.1'
+    implementation 'com.pangle.cn:mediation-test-tools:5.1.6.1'//测试工具
 
     //compose依赖
     implementation "androidx.compose.ui:ui:$compose_version"

+ 3 - 1
app/proguard-rules.pro

@@ -18,4 +18,6 @@
 
 # If you keep the line number information, uncomment this to
 # hide the original source file name.
-#-renamesourcefileattribute SourceFile
+#-renamesourcefileattribute SourceFile
+
+-keep class com.bytedance.mtesttools.api.** {*;}

+ 30 - 2
app/src/main/AndroidManifest.xml

@@ -3,9 +3,27 @@
     xmlns:tools="http://schemas.android.com/tools"
     package="com.convenient.android.lib">
 
+    <!-- 必要权限 -->
+    <uses-permission android:name="android.permission.INTERNET" /> <!-- 可选权限 -->
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
-    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
-    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
+    <uses-permission android:name="android.permission.VIBRATE" /> <!-- suppress DeprecatedClassUsageInspection -->
+    <uses-permission android:name="android.permission.GET_TASKS" />
+    <uses-permission
+        android:name="android.permission.WAKE_LOCK"
+        tools:node="remove" />
+    <!-- 可选,穿山甲提供“获取地理位置权限”和“不给予地理位置权限,开发者传入地理位置参数”两种方式上报用户位置,两种方式均可不选,添加位置权限或参数将帮助投放定位广告 -->
+    <!-- 请注意:无论通过何种方式提供给穿山甲用户地理位置,均需向用户声明地理位置权限将应用于穿山甲广告投放,穿山甲不强制获取地理位置信息 -->
+    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- demo场景用到的权限,不是必须的 -->
+    <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
+    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
+    <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" /> <!-- 建议添加“query_all_package”权限,穿山甲将通过此权限在Android R系统上判定广告对应的应用是否在用户的app上安装,避免投放错误的广告,以此提高用户的广告体验。若添加此权限,需要在您的用户隐私文档中声明! -->
+    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
+    <uses-permission android:name="android.permission.RECORD_AUDIO" />
 
     <application
         android:name=".LibApplication"
@@ -65,6 +83,16 @@
 
         <activity android:name=".ui.sample.read.ReaderViewActivity" />
 
+        <meta-data
+            android:name="test"
+            android:value="one" />
+        <meta-data
+            android:name="channel"
+            android:value="two" />
+        <meta-data
+            android:name="Channel_app"
+            android:value="three" />
+
         <meta-data
             android:name="com.google.android.gms.ads.APPLICATION_ID"
             android:value="ca-app-pub-3940256099942544~3347511713" />

+ 1 - 2
app/src/main/java/com/convenient/android/lib/ui/sample/ad/AdMainActivity.kt

@@ -24,8 +24,7 @@ class AdMainActivity : AppCompatActivity() {
         }
         initAd()
     }
-
-
+    
     private fun initAd() {
         AdManager.instance.init(applicationContext, true)
         AdManager.instance.initAdvertisersSDK(applicationContext, AdmobInitialize(), GroMoreInitialize("5089223"))

+ 1 - 1
app/src/main/java/com/convenient/android/lib/ui/sample/ad/model/Datas.kt

@@ -71,7 +71,7 @@ object Datas {
             AdUnitBean(INTERSTITIAL, Advertisers.GroMore.name, AdType.INTERSTITIAL.name, "948013677"),
             AdUnitBean(APP_OPEN, Advertisers.GroMore.name, AdType.APP_OPEN.name, "887622184"),
             AdUnitBean(REWARDED_VIDEO, Advertisers.GroMore.name, AdType.REWARDED_VIDEO.name, "102137844"),
-            AdUnitBean(NATIVE_TEMPLATE, Advertisers.GroMore.name, AdType.NATIVE_TEMPLATE.name, "948013677")
+            AdUnitBean(NATIVE_TEMPLATE, Advertisers.GroMore.name, AdType.NATIVE_TEMPLATE.name, "948013677"),
         )
 
 

+ 2 - 1
lib_ad_core/build.gradle

@@ -55,6 +55,7 @@ android {
 }
 
 dependencies {
+//    api fileTree(dir: "libs", include: ["*.jar", "*.aar"])
     /*Base*/
     api 'androidx.appcompat:appcompat:1.6.1'
     api 'com.google.android.material:material:1.8.0'
@@ -66,5 +67,5 @@ dependencies {
     api 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
     /*GroMore*/
     api 'com.pangle.cn:mediation-sdk:5.1.6.1'
-    api 'com.pangle.cn:mediation-test-tools:5.1.6.1'//测试工具
+//    api 'com.pangle.cn:mediation-test-tools:5.1.6.1'//测试工具
 }

+ 3 - 0
lib_ad_core/consumer-rules.pro

@@ -1,3 +1,6 @@
 
 -keep class com.composition.android.lib.ad.**{*;}
 -keep class com.composition.android.lib.ad.AdLoad
+
+-keep class com.bytedance.sdk.openadsdk.** {*;}
+-keep public interface com.bytedance.sdk.openadsdk.downloadnew.** {*;}

+ 44 - 0
lib_ad_gromore/consumer-rules.pro

@@ -0,0 +1,44 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /Users/sumirrowu/Library/Android/sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+-optimizationpasses 5
+
+#混淆时不会产生形形色色的类名
+-dontusemixedcaseclassnames
+
+#指定不去忽略非公共的库类
+-dontskipnonpubliclibraryclasses
+
+#不预校验
+#-dontpreverify
+
+#不优化输入的类文件
+-dontoptimize
+
+-ignorewarnings
+
+-verbose
+
+#优化
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+#保护内部类
+-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
+-keep class com.bytedance.sdk.openadsdk.** {*;}
+-keep public interface com.bytedance.sdk.openadsdk.downloadnew.** {*;}
+-keep class com.pgl.sys.ces.* {*;}

BIN=BIN
lib_ad_gromore/libs/beizi_ad_sdk_3.4.20.23.aar


BIN=BIN
lib_ad_gromore/libs/beizi_fusion_sdk_4.90.2.27.aar


+ 1 - 1
lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/impl/CSJAppDownloadListener.kt

@@ -11,7 +11,7 @@ import com.composition.android.lib.ad.basic.NativeAdViewHolder
  * @date: 2022/10/25
  * description:穿山甲广告下载监听
  */
-class CSJAppDownloadListener(var context: Context, var nativeAdViewHolder: NativeAdViewHolder?) : TTAppDownloadListener {
+class GMAppDownloadListener(var context: Context, var nativeAdViewHolder: NativeAdViewHolder?) : TTAppDownloadListener {
     override fun onIdle() {
         nativeAdViewHolder?.callActionButtonView?.text = context.getString(R.string.start_download)
     }

+ 20 - 0
lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/impl/GroMoreInitialize.kt

@@ -3,6 +3,9 @@ package com.composition.android.ad.gromore.impl
 import android.content.Context
 import com.bytedance.sdk.openadsdk.TTAdConfig
 import com.bytedance.sdk.openadsdk.TTAdSdk
+import com.bytedance.sdk.openadsdk.TTCustomController
+import com.bytedance.sdk.openadsdk.mediation.init.MediationConfig
+import com.bytedance.sdk.openadsdk.mediation.init.MediationConfigUserInfoForSegment
 import com.composition.android.lib.ad.AdManager
 import com.composition.android.lib.ad.interfaces.Initialize
 import com.composition.android.lib.ad.util.adLogE
@@ -16,6 +19,19 @@ import com.composition.android.lib.ad.util.adLogE
 class GroMoreInitialize(var appId: String) : Initialize {
 
     override fun init(context: Context) {
+        val userInfo = MediationConfigUserInfoForSegment()
+        userInfo.userId = "msdk-demo"
+        userInfo.gender = MediationConfigUserInfoForSegment.GENDER_MALE
+        userInfo.channel = "msdk-channel"
+        userInfo.subChannel = "msdk-sub-channel"
+        userInfo.age = 999
+        userInfo.userValueGroup = "msdk-demo-user-value-group"
+
+        val customInfos: MutableMap<String, String> = HashMap()
+        customInfos["aaaa"] = "test111"
+        customInfos["bbbb"] = "test222"
+        userInfo.customInfos = customInfos
+
         TTAdSdk.init(context, TTAdConfig.Builder()
             .appId(appId)
             .useTextureView(true)
@@ -23,6 +39,10 @@ class GroMoreInitialize(var appId: String) : Initialize {
             .supportMultiProcess(true)
             .debug(AdManager.instance.isDebug)
             .useMediation(true)
+            .customController(object : TTCustomController() {
+
+            })
+            .setMediationConfig(MediationConfig.Builder().setMediationConfigUserInfoForSegment(userInfo).build())
             .build(), object : TTAdSdk.InitCallback {
             override fun success() {
                 TTAdSdk.isInitSuccess()

+ 26 - 0
lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/impl/custom/BeiZiInitialize.kt

@@ -0,0 +1,26 @@
+package com.composition.android.ad.gromore.impl.custom
+
+import android.content.Context
+import com.beizi.fusion.BeiZis
+import com.bytedance.sdk.openadsdk.mediation.bridge.custom.MediationCustomInitLoader
+import com.bytedance.sdk.openadsdk.mediation.custom.MediationCustomInitConfig
+
+/**
+ * @author: HuBoWen
+ * @date: 2023/5/4
+ * @description:
+ */
+class BeiZiInitialize : MediationCustomInitLoader() {
+    override fun initializeADN(context: Context?, customInitConfig: MediationCustomInitConfig?, localExtra: MutableMap<String, Any>?) {
+        if(!isInit){
+            Thread{
+                BeiZis.init(context, customInitConfig?.appId)
+                callInitSuccess()
+            }.start()
+        }
+    }
+
+    override fun getNetworkSdkVersion(): String {
+        return BeiZis.getSdkVersion()
+    }
+}

+ 85 - 0
lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/request/custom/CustomBeiZiAppOpenRequestImpl.kt

@@ -0,0 +1,85 @@
+package com.composition.android.ad.gromore.load.request.custom
+
+import android.content.Context
+import android.view.ViewGroup
+import android.view.ViewParent
+import com.beizi.fusion.AdListener
+import com.beizi.fusion.SplashAd
+import com.bytedance.sdk.openadsdk.AdSlot
+import com.bytedance.sdk.openadsdk.mediation.MediationConstant
+import com.bytedance.sdk.openadsdk.mediation.bridge.custom.splash.MediationCustomSplashLoader
+import com.bytedance.sdk.openadsdk.mediation.custom.MediationCustomServiceConfig
+import com.composition.android.lib.ad.util.adLogWithFrame
+import com.composition.android.lib.ad.util.getScreenHeight
+import com.composition.android.lib.ad.util.getScreenHeightDp
+import com.composition.android.lib.ad.util.getScreenWidth
+import com.composition.android.lib.ad.util.getScreenWidthDp
+
+/**
+ * @author: HuBoWen
+ * @date: 2023/4/25
+ * @description:
+ */
+class CustomBeiZiAppOpenRequestImpl : MediationCustomSplashLoader() {
+
+    private var splash: SplashAd? = null
+
+    override fun load(context: Context?, adSlot: AdSlot?, serviceConfig: MediationCustomServiceConfig?) {
+
+        adLogWithFrame(msg = "scope onAdLoaded")
+        //step3:创建开屏广告请求参数AdSlot,具体参数含义参考文档
+        context?.apply {
+            val splashWidthDp: Float = getScreenWidthDp(context)
+            val splashWidthPx: Int = getScreenWidth(context)
+            val screenHeightPx: Int = getScreenHeight(context)
+            val screenHeightDp: Float = getScreenHeightDp(context)
+
+            // 开屏高度 = 屏幕高度 - 下方预留的高度,demo中是预留了屏幕高度的1/5,因此开屏高度传入 屏幕高度*4/5
+            val splashHeightDp: Float = screenHeightDp * 4 / 4f
+            val splashHeightPx: Int = (screenHeightPx * 4 / 4f).toInt()
+
+            splash = SplashAd(context, null, serviceConfig?.adnNetworkSlotId, object : AdListener {
+                override fun onAdLoaded() {
+                    adLogWithFrame(msg = "scope onAdLoaded")
+                    if (biddingType == MediationConstant.AD_TYPE_CLIENT_BIDING) {
+                        var epcm = splash?.ecpm?.toDouble()
+                        epcm?.apply {
+                            if (this < 0) {
+                                epcm = 0.0
+                            }
+                            callLoadSuccess(epcm!!)
+                        }
+                    } else {
+                        callLoadSuccess()
+                    }
+                }
+
+                override fun onAdShown() {
+                    adLogWithFrame(msg = "scope onAdShown")
+                }
+
+                override fun onAdFailedToLoad(p0: Int) {
+                    adLogWithFrame(msg = "scope onAdFailedToLoad")
+//                    callLoadFail(p0, s)
+                }
+
+                override fun onAdClosed() {
+                    adLogWithFrame(msg = "scope onAdClosed")
+                }
+
+                override fun onAdTick(p0: Long) {
+                    adLogWithFrame(msg = "scope onAdTick")
+                }
+
+                override fun onAdClicked() {
+                    adLogWithFrame(msg = "scope onAdClicked")
+                }
+            }, 5000)
+            splash?.loadAd(splashWidthPx, (screenHeightPx - 100))
+        }
+    }
+
+    override fun showAd(container: ViewGroup?) {
+        splash?.show(container)
+    }
+}

+ 2 - 2
lib_ad_gromore/src/main/java/com/composition/android/ad/gromore/load/view/CSJNativeAdView.kt

@@ -11,7 +11,7 @@ import com.bytedance.sdk.openadsdk.TTAdConstant
 import com.bytedance.sdk.openadsdk.TTAdDislike
 import com.bytedance.sdk.openadsdk.TTNativeAd
 import com.composition.android.ad.gromore.R
-import com.composition.android.ad.gromore.impl.CSJAppDownloadListener
+import com.composition.android.ad.gromore.impl.GMAppDownloadListener
 import com.composition.android.lib.ad.AdManager
 import com.composition.android.lib.ad.basic.AdResult
 import com.composition.android.lib.ad.basic.BasicAdView
@@ -119,7 +119,7 @@ class CSJNativeAdView(context: Context?) : BasicAdView<View>(context) {
                 TTAdConstant.INTERACTION_TYPE_DOWNLOAD -> {
                     ttNativeAd.setActivityForDownloadApp(viewHolder.activity)
                     viewHolder.callActionButtonView?.isVisible = true
-                    ttNativeAd.setDownloadListener(CSJAppDownloadListener(context, viewHolder))
+                    ttNativeAd.setDownloadListener(GMAppDownloadListener(context, viewHolder))
                 }
                 TTAdConstant.INTERACTION_TYPE_DIAL -> {
                     viewHolder.callActionButtonView?.also {