diff --git a/.github/workflows/debug_deploy.yml b/.github/workflows/debug_deploy.yml index 004c90a7..df7b5750 100644 --- a/.github/workflows/debug_deploy.yml +++ b/.github/workflows/debug_deploy.yml @@ -1,48 +1,29 @@ -## 1 name: Build Debug Apk and Deploy - ## Actions that will be executed when pull request is created on: pull_request: branches: - master - jobs: ## Debug build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3 - name: set up JDK 11 - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: java-version: 11 - # 3 + distribution: 'adopt' + # 3.1 + - name: Clean Project + run: ./gradlew clean + # 3.2 - name: Generate Debug APK run: ./gradlew assembleDebug --stacktrace - # 4 - name: Upload APK to artifacts - uses: actions/upload-artifact@master + uses: actions/upload-artifact@v3 with: name: app-debug.apk - path: app/build/outputs/apk/debug/app-debug.apk - - # deploy_To_Firebase - deploy-firebase: - # 1 - needs: [ build ] - runs-on: ubuntu-latest - steps: - # 2 - - uses: actions/download-artifact@master - with: - name: app-debug.apk - #3 - - name: upload artifact to Firebase App Distribution - uses: wzieba/Firebase-Distribution-Github-Action@v1 - with: - appId: ${{secrets.FIREBASE_APP_ID}} - token: ${{secrets.FIREBASE_TOKEN}} - groups: debug-test - file: app-debug.apk \ No newline at end of file + path: app/build/outputs/apk/debug/app-debug.apk \ No newline at end of file diff --git a/README.md b/README.md index 6bacfedc..e565ce71 100644 --- a/README.md +++ b/README.md @@ -12,28 +12,33 @@ If you want to contribute don't hesitate to create PR's :) Currently added services: `MapKit`, `Location`, `Analytics`, `CreditCardScanner`, `Awareness`, `Scan`, `Translate`, `Speech To Text`, `Text To Speech`, `Object Detection`, `Text Recognition`, `Face Detection`, `Language Detection`, `Image Classification`, `Account`, `Auth`, `Safety`, `Crash`, `Push`, `Site`, `Identity` and `Remote Config`. -## How to install +## How to install -### Step 1. Add the JitPack repository, Huawei repo and classpaths to your build file +### Step 1. Add the dependency of Huawei AGC and Google Play Services to your build file ```gradle buildscript { - repositories { - ... - maven {url 'https://developer.huawei.com/repo/'} + ext { + toolsBuildGradleVersion = '7.1.1' } dependencies { - ... - classpath 'com.huawei.agconnect:agcp:1.7.1.300' - classpath 'com.google.gms:google-services:4.3.14' + + classpath "com.android.tools.build:gradle:$toolsBuildGradleVersion" + classpath 'com.huawei.agconnect:agcp:1.9.1.301' + classpath "io.realm:realm-gradle-plugin:10.13.3-transformer-api" + classpath 'com.google.gms:google-services:4.3.15' + classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.5' } } -allprojects { - repositories { - ... - maven { url 'https://jitpack.io' } - maven { url "https://developer.huawei.com/repo/" } - } +plugins { + id 'com.android.application' version '8.0.2' apply false + id 'com.android.library' version '8.0.2' apply false + id 'org.jetbrains.kotlin.android' version '1.8.20' apply false + id 'com.google.gms.google-services' version '4.4.0' apply false +} + +task clean(type: Delete) { + delete rootProject.buildDir } ``` ### Step 2. Get the agconnect-services.json file from the AGC Console and google-services.json file from Firebase Console. Then, place it under the app module. And, add plugins to app level gradle file header. @@ -41,7 +46,33 @@ allprojects { apply plugin: 'com.huawei.agconnect' apply plugin: 'com.google.gms.google-services' ``` -### Step 3. Add the dependency for module(s): +### Step 3. Add the dependency to app level gradle file: +```gradle +dependencies { + implementation(platform("com.google.firebase:firebase-bom:32.5.0")) + implementation 'com.huawei.agconnect:agconnect-core:1.9.1.300' + implementation 'com.huawei.hms:hmscoreinstaller:6.11.0.301' +} +``` +### Step 4. Add the JitPack and Huawei developer repository to settings.gradle: +```gradle +pluginManagement { + repositories { + maven { url 'https://developer.huawei.com/repo/' } + } +} +dependencyResolutionManagement { + repositories { + maven { url 'https://developer.huawei.com/repo/' } + maven { url "https://jitpack.io" } + } +} +``` +### Step 5. Add the this configuration setting that disables the instrumentation of the application performance management system: +```gradle +apmsInstrumentationEnabled=false +``` +### Step 6. Add the dependency for module(s): com.github.Explore-In-HMS.common-mobile-services `latest version 2.2.2` @@ -88,6 +119,12 @@ implementation 'com.github.Explore-In-HMS.common-mobile-services:objectdetection ### Text Recognition ```gradle implementation 'com.github.Explore-In-HMS.common-mobile-services:textrecognition:' +``` + ### Ads +```gradle +implementation 'com.github.Explore-In-HMS.common-mobile-services:ads:' +implementation 'com.google.android.gms:play-services-ads:22.2.0' +implementation 'com.huawei.hms:ads-prime:3.4.62.302' ``` ### Face Detection ```gradle @@ -893,6 +930,55 @@ The `textRecognition()` function takes a callback lambda function as a parameter fun textRecognition(bitmap: Bitmap, callback: (recognizedValue: RecognitionResult) -> Unit) ``` +## Ads +Allows you to show ads in your app. + +### Rewarded Ad +Rewarded ads are shown to users in exchange for a reward, such as an extra life or in-app currency. +You can specify the reward values associated with the ad units in your app and set different rewards for different ad units. Users will receive the reward for interacting with the ad without needing to install anything. + +#### How to use +Create an IRewardedAd variable in order to get instance when ads showing is ready. +```kt + private lateinit var rewardedAd: IRewardedAd +``` +First, you need to call static 'load()' function to get rewarded ad instance. +By passing 'context', 'hmsAd_ID', 'gmsAd_ID' and 'RewardedAdLoadCallback' you will get IRewardedAd instance in order to show ad. +```kt + RewardedAd.load( + this, + "testx9dtjwj8hp", + "ca-app-pub-3940256099942544/5224354917", + object : RewardedAdLoadCallback { + override fun onAdLoadFailed(adError: String) { + Log.e("main", adError) + } + override fun onRewardedAdLoaded(rewardedAd: IRewardedAd) { + rewardedAd = rewardedAd + } + } + ) +``` +Call `show()` function whenever you want to show ad. +You need to pass 'context' and 'UserRewardEarnedListener' params in order to get reward after user watched the ad. +You can get reward value by calling 'getAmount()' function. +```kt + rewardedAd.show( + this, + object : UserRewardEarnedListener { + override fun onUserEarnedReward(item: IRewardItem) { + Log.d("main", "${item.getAmount()} ${item.getTypeOrName()}") + } + } + ) +``` +In Addition you need add your ca-app-pub value in androidmanifest.xml +```xml + +``` + ## Face Detection With ML Kit's face detection API, you can detect faces in an image, identify key facial features, and get the contours of detected faces. Note that the API detects faces, it does not recognize people. With face detection, you can get the information you need to perform tasks like embellishing selfies and portraits, or generating avatars from a user's photo. Because ML Kit can perform face detection in real time, you can use it in applications like video chat or games that respond to the player's expressions. diff --git a/ads/.gitignore b/ads/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/ads/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/ads/build.gradle b/ads/build.gradle new file mode 100644 index 00000000..5f34ad4b --- /dev/null +++ b/ads/build.gradle @@ -0,0 +1,7 @@ +apply from: "$project.rootDir/base_sdk.gradle" + +dependencies { + implementation 'com.google.android.gms:play-services-ads:22.2.0' + implementation 'com.huawei.hms:ads-prime:3.4.62.302' + api project(':core') +} \ No newline at end of file diff --git a/ads/consumer-rules.pro b/ads/consumer-rules.pro new file mode 100644 index 00000000..e69de29b diff --git a/ads/proguard-rules.pro b/ads/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/ads/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# 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 *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/ads/src/main/AndroidManifest.xml b/ads/src/main/AndroidManifest.xml new file mode 100644 index 00000000..3b805f52 --- /dev/null +++ b/ads/src/main/AndroidManifest.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/BannerAd.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/BannerAd.kt new file mode 100644 index 00000000..9347e327 --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/BannerAd.kt @@ -0,0 +1,97 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.banner + +import android.content.Context +import com.google.android.gms.ads.AdRequest +import com.google.android.gms.ads.AdView +import com.google.android.gms.ads.LoadAdError +import com.hms.lib.commonmobileservices.ads.banner.common.BannerAdLoadCallback +import com.hms.lib.commonmobileservices.ads.banner.factory.BannerAdFactory +import com.hms.lib.commonmobileservices.ads.banner.implementation.GoogleBannerAd +import com.hms.lib.commonmobileservices.ads.banner.implementation.HuaweiBannerAd +import com.hms.lib.commonmobileservices.core.Device +import com.hms.lib.commonmobileservices.core.MobileServiceType +import com.huawei.hms.ads.AdListener +import com.huawei.hms.ads.AdParam +import com.huawei.hms.ads.banner.BannerView + +class BannerAd { + + companion object { + /** + * Loads a banner ad based on the mobile service type. + * + * @param context The context of the application. + * @param gms_AdView The Google Mobile Services AdView. + * @param hms_BannerView The Huawei Mobile Services BannerView. + * @param gmsAdRequestParams The Google Mobile Services AdRequest parameters. Default is null. + * @param hmsAdRequestParams The Huawei Mobile Services AdParam parameters. Default is null. + * @param callback The callback for banner ad loading events. + * @throws IllegalArgumentException if the mobile service type is not supported. + */ + fun load( + context: Context, + gms_AdView: AdView?, + hms_BannerView: BannerView?, + gmsAdRequestParams: AdRequest? = null, + hmsAdRequestParams: AdParam? = null, + callback: BannerAdLoadCallback + ) { + when (Device.getMobileServiceType(context)) { + MobileServiceType.GMS -> { + val adRequestParams = gmsAdRequestParams ?: AdRequest.Builder().build() + gms_AdView?.apply { + adListener = object : com.google.android.gms.ads.AdListener() { + override fun onAdLoaded() { + super.onAdLoaded() + val googleBannerAdFactory = + BannerAdFactory.createFactory(gms_AdView) + googleBannerAdFactory.create().let(callback::onBannerAdLoaded) + } + + override fun onAdFailedToLoad(p0: LoadAdError) { + callback.onAdLoadFailed(p0.toString()) + } + } + loadAd(adRequestParams) + } + } + MobileServiceType.HMS -> { + val adRequestParams = hmsAdRequestParams ?: AdParam.Builder().build() + hms_BannerView?.apply { + adListener = object : AdListener() { + override fun onAdLoaded() { + super.onAdLoaded() + val huaweiBannerAd = + BannerAdFactory.createFactory( + hms_BannerView + ) + huaweiBannerAd.create().let(callback::onBannerAdLoaded) + } + + override fun onAdFailed(errorCode: Int) { + callback.onAdLoadFailed(errorCode.toString()) + } + } + loadAd(adRequestParams) + } + + } + MobileServiceType.NON -> throw IllegalArgumentException() + } + } + } +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/common/BannerAdLoadCallback.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/common/BannerAdLoadCallback.kt new file mode 100644 index 00000000..a3f45aa0 --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/common/BannerAdLoadCallback.kt @@ -0,0 +1,22 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.banner.common + +import com.hms.lib.commonmobileservices.ads.banner.implementation.IBannerAd + +interface BannerAdLoadCallback { + fun onAdLoadFailed(adError: String) + fun onBannerAdLoaded(bannerAd: IBannerAd) +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/factory/BannerAdFactory.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/factory/BannerAdFactory.kt new file mode 100644 index 00000000..1cb41ccd --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/factory/BannerAdFactory.kt @@ -0,0 +1,55 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.banner.factory + +import com.google.android.gms.ads.AdView +import com.hms.lib.commonmobileservices.ads.banner.implementation.GoogleBannerAd +import com.hms.lib.commonmobileservices.ads.banner.implementation.HuaweiBannerAd +import com.hms.lib.commonmobileservices.ads.banner.implementation.IBannerAd +import com.huawei.hms.ads.banner.BannerView + +abstract class BannerAdFactory { + abstract fun create(): IBannerAd + + companion object { + inline fun createFactory(bannerAd: K): BannerAdFactory { + when (T::class) { + HuaweiBannerAd::class -> { + return when (K::class) { + BannerView::class -> { + HuaweiBannerAdFactory(bannerAd as BannerView) + } + AdView::class -> { + throw IllegalArgumentException("${HuaweiBannerAd::class.java.name} expected but ${AdView::class.java.name} found") + } + else -> throw IllegalArgumentException() + } + } + GoogleBannerAd::class -> { + return when (K::class) { + AdView::class -> { + GoogleBannerAdFactory(bannerAd as AdView) + } + BannerView::class -> { + throw IllegalArgumentException("${GoogleBannerAd::class.java.name} expected but ${BannerView::class.java.name} found") + } + else -> throw IllegalArgumentException() + } + } + else -> throw IllegalArgumentException() + } + } + } +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/factory/GoogleBannerAdFactory.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/factory/GoogleBannerAdFactory.kt new file mode 100644 index 00000000..69d7ac27 --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/factory/GoogleBannerAdFactory.kt @@ -0,0 +1,23 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.banner.factory + +import com.google.android.gms.ads.AdView +import com.hms.lib.commonmobileservices.ads.banner.implementation.GoogleBannerAd +import com.hms.lib.commonmobileservices.ads.banner.implementation.IBannerAd + +class GoogleBannerAdFactory(private val bannerAd: AdView) : BannerAdFactory() { + override fun create(): IBannerAd = GoogleBannerAd(bannerAd) +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/factory/HuaweiBannerAdFactory.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/factory/HuaweiBannerAdFactory.kt new file mode 100644 index 00000000..1246c694 --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/factory/HuaweiBannerAdFactory.kt @@ -0,0 +1,23 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.banner.factory + +import com.hms.lib.commonmobileservices.ads.banner.implementation.HuaweiBannerAd +import com.hms.lib.commonmobileservices.ads.banner.implementation.IBannerAd +import com.huawei.hms.ads.banner.BannerView + +class HuaweiBannerAdFactory(private val bannerAd: BannerView): BannerAdFactory() { + override fun create(): IBannerAd = HuaweiBannerAd(bannerAd) +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/implementation/GoogleBannerAd.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/implementation/GoogleBannerAd.kt new file mode 100644 index 00000000..b27a7a44 --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/implementation/GoogleBannerAd.kt @@ -0,0 +1,28 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.banner.implementation + +import com.google.android.gms.ads.AdView + +class GoogleBannerAd(private var _banner: AdView) : IBannerAd { + override fun destroy() { + _banner.destroy() + } + + override fun isLoading(): Boolean { + return _banner.isLoading + } + +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/implementation/HuaweiBannerAd.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/implementation/HuaweiBannerAd.kt new file mode 100644 index 00000000..db772d2d --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/implementation/HuaweiBannerAd.kt @@ -0,0 +1,28 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.banner.implementation + +import com.huawei.hms.ads.banner.BannerView + +class HuaweiBannerAd(private var _banner: BannerView) : IBannerAd { + override fun destroy() { + _banner.destroy() + } + + override fun isLoading(): Boolean { + return _banner.isLoading + } + +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/implementation/IBannerAd.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/implementation/IBannerAd.kt new file mode 100644 index 00000000..ea28163b --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/implementation/IBannerAd.kt @@ -0,0 +1,20 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.banner.implementation + +interface IBannerAd { + fun destroy() + fun isLoading(): Boolean +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/InterstitialAd.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/InterstitialAd.kt new file mode 100644 index 00000000..0efa4cf2 --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/InterstitialAd.kt @@ -0,0 +1,95 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.interstitial + +import android.content.Context +import com.google.android.gms.ads.AdRequest +import com.google.android.gms.ads.LoadAdError +import com.google.android.gms.ads.admanager.AdManagerAdRequest +import com.google.android.gms.ads.interstitial.InterstitialAd +import com.hms.lib.commonmobileservices.ads.interstitial.common.InterstitialAdLoadCallback +import com.hms.lib.commonmobileservices.ads.interstitial.factory.InterstitialAdFactory +import com.hms.lib.commonmobileservices.ads.interstitial.implementation.GoogleInterstitialAd +import com.hms.lib.commonmobileservices.ads.interstitial.implementation.HuaweiInterstitialAd +import com.hms.lib.commonmobileservices.core.Device +import com.hms.lib.commonmobileservices.core.MobileServiceType +import com.huawei.hms.ads.AdListener +import com.huawei.hms.ads.AdParam + +class InterstitialAd { + + companion object { + /** + * TODO:Explain AdRequestParams in Readme document + * TODO:Initialize Ad_ID param with test ad_ID + */ + fun load( + context: Context, + hmsAd_ID: String, + gmsAd_ID: String, + gmsAdRequestParams: AdRequest? = null, + hmsAdRequestParams: AdParam? = null, + callback: InterstitialAdLoadCallback + ) { + when (Device.getMobileServiceType(context)) { + MobileServiceType.GMS -> { + val adRequestParams = gmsAdRequestParams ?: AdManagerAdRequest.Builder().build() + InterstitialAd.load( + context, + gmsAd_ID, + adRequestParams, + object : + com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback() { + override fun onAdLoaded(interstitialAd: InterstitialAd) { + val googleRewardedAdFactory = + InterstitialAdFactory.createFactory( + interstitialAd + ) + googleRewardedAdFactory.create() + .let(callback::onInterstitialAdLoaded) + } + + override fun onAdFailedToLoad(adError: LoadAdError) { + callback.onAdLoadFailed(adError.toString()) + } + }) + } + MobileServiceType.HMS -> { + val interstitialAd = com.huawei.hms.ads.InterstitialAd(context) + val adRequestParams = hmsAdRequestParams ?: AdParam.Builder().build() + interstitialAd.apply { + adId = hmsAd_ID + adListener = object : AdListener() { + override fun onAdLoaded() { + super.onAdLoaded() + val huaweiInterstitialAd = + InterstitialAdFactory.createFactory( + interstitialAd + ) + huaweiInterstitialAd.create().let(callback::onInterstitialAdLoaded) + } + + override fun onAdFailed(errorCode: Int) { + callback.onAdLoadFailed(errorCode.toString()) + } + } + loadAd(adRequestParams) + } + } + MobileServiceType.NON -> throw IllegalArgumentException() + } + } + } +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/common/InterstitialAdLoadCallback.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/common/InterstitialAdLoadCallback.kt new file mode 100644 index 00000000..7543210b --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/common/InterstitialAdLoadCallback.kt @@ -0,0 +1,22 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.interstitial.common + +import com.hms.lib.commonmobileservices.ads.interstitial.implementation.IInterstitialAd + +interface InterstitialAdLoadCallback { + fun onAdLoadFailed(adError: String) + fun onInterstitialAdLoaded(interstitialAd: IInterstitialAd) +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/factory/GoogleInterstitialAdFactory.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/factory/GoogleInterstitialAdFactory.kt new file mode 100644 index 00000000..6de1de0c --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/factory/GoogleInterstitialAdFactory.kt @@ -0,0 +1,24 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.interstitial.factory + +import com.google.android.gms.ads.interstitial.InterstitialAd +import com.hms.lib.commonmobileservices.ads.interstitial.implementation.GoogleInterstitialAd +import com.hms.lib.commonmobileservices.ads.interstitial.implementation.IInterstitialAd + +class GoogleInterstitialAdFactory(private val interstitialAd: InterstitialAd) : + InterstitialAdFactory() { + override fun create(): IInterstitialAd = GoogleInterstitialAd(interstitialAd) +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/factory/HuaweiInterstitialAdFactory.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/factory/HuaweiInterstitialAdFactory.kt new file mode 100644 index 00000000..b7b1bb5b --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/factory/HuaweiInterstitialAdFactory.kt @@ -0,0 +1,23 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.interstitial.factory + +import com.hms.lib.commonmobileservices.ads.interstitial.implementation.HuaweiInterstitialAd +import com.hms.lib.commonmobileservices.ads.interstitial.implementation.IInterstitialAd +import com.huawei.hms.ads.InterstitialAd + +class HuaweiInterstitialAdFactory(private val interstitialAd: InterstitialAd): InterstitialAdFactory() { + override fun create(): IInterstitialAd = HuaweiInterstitialAd(interstitialAd) +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/factory/InterstitialAdFactory.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/factory/InterstitialAdFactory.kt new file mode 100644 index 00000000..b25b306d --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/factory/InterstitialAdFactory.kt @@ -0,0 +1,54 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.interstitial.factory + +import com.hms.lib.commonmobileservices.ads.interstitial.implementation.GoogleInterstitialAd +import com.hms.lib.commonmobileservices.ads.interstitial.implementation.HuaweiInterstitialAd +import com.hms.lib.commonmobileservices.ads.interstitial.implementation.IInterstitialAd +import com.huawei.hms.ads.InterstitialAd + +abstract class InterstitialAdFactory { + abstract fun create(): IInterstitialAd + + companion object { + inline fun createFactory(interstitialAd: K): InterstitialAdFactory { + when (T::class) { + HuaweiInterstitialAd::class -> { + return when (K::class) { + InterstitialAd::class -> { + HuaweiInterstitialAdFactory(interstitialAd as InterstitialAd) + } + com.google.android.gms.ads.interstitial.InterstitialAd::class -> { + throw IllegalArgumentException("${HuaweiInterstitialAd::class.java.name} expected but ${com.google.android.gms.ads.interstitial.InterstitialAd::class.java.name} found") + } + else -> throw IllegalArgumentException() + } + } + GoogleInterstitialAd::class -> { + return when (K::class) { + com.google.android.gms.ads.interstitial.InterstitialAd::class -> { + GoogleInterstitialAdFactory(interstitialAd as com.google.android.gms.ads.interstitial.InterstitialAd) + } + InterstitialAd::class -> { + throw IllegalArgumentException("${GoogleInterstitialAd::class.java.name} expected but ${InterstitialAd::class.java.name} found") + } + else -> throw IllegalArgumentException() + } + } + else -> throw IllegalArgumentException() + } + } + } +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/implementation/GoogleInterstitialAd.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/implementation/GoogleInterstitialAd.kt new file mode 100644 index 00000000..ce7bbaef --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/implementation/GoogleInterstitialAd.kt @@ -0,0 +1,25 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.interstitial.implementation + +import android.app.Activity +import com.google.android.gms.ads.interstitial.InterstitialAd + +class GoogleInterstitialAd(private var _interstitial: InterstitialAd) : IInterstitialAd { + + override fun show(activity: Activity) { + _interstitial.show(activity) + } +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/implementation/HuaweiInterstitialAd.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/implementation/HuaweiInterstitialAd.kt new file mode 100644 index 00000000..c48f78a5 --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/implementation/HuaweiInterstitialAd.kt @@ -0,0 +1,27 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.interstitial.implementation + +import android.app.Activity +import com.huawei.hms.ads.InterstitialAd + + +class HuaweiInterstitialAd(private var _interstitial: InterstitialAd) : IInterstitialAd { + + override fun show(activity: Activity) { + _interstitial.show(activity) + } + +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/implementation/IInterstitialAd.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/implementation/IInterstitialAd.kt new file mode 100644 index 00000000..cb4ba584 --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/interstitial/implementation/IInterstitialAd.kt @@ -0,0 +1,21 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.interstitial.implementation + +import android.app.Activity + +interface IInterstitialAd { + fun show(activity: Activity) +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/RewardedAd.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/RewardedAd.kt new file mode 100644 index 00000000..e40c6d0f --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/RewardedAd.kt @@ -0,0 +1,82 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.rewarded + +import android.content.Context +import com.google.android.gms.ads.LoadAdError +import com.google.android.gms.ads.admanager.AdManagerAdRequest +import com.google.android.gms.ads.rewarded.RewardedAd +import com.hms.lib.commonmobileservices.ads.rewarded.common.RewardedAdLoadCallback +import com.hms.lib.commonmobileservices.ads.rewarded.factory.RewardedAdFactory +import com.hms.lib.commonmobileservices.ads.rewarded.implementation.GoogleRewardedAd +import com.hms.lib.commonmobileservices.ads.rewarded.implementation.HuaweiRewardedAd +import com.hms.lib.commonmobileservices.core.Device +import com.hms.lib.commonmobileservices.core.MobileServiceType +import com.huawei.hms.ads.AdParam +import com.huawei.hms.ads.reward.RewardAd +import com.huawei.hms.ads.reward.RewardAdLoadListener + +class RewardedAd { + + companion object { + /** + * TODO:Explain AdRequestParams in Readme document + * TODO:Initialize Ad_ID param with test ad_ID + */ + fun load( + context: Context, + hmsAd_ID: String, + gmsAd_ID: String, + callback: RewardedAdLoadCallback, + gmsAdRequestParams: AdManagerAdRequest? = null, + hmsAdRequestParams: AdParam? = null + ) { + when (Device.getMobileServiceType(context)) { + MobileServiceType.GMS -> { + val adRequestParams = gmsAdRequestParams ?: AdManagerAdRequest.Builder().build() + RewardedAd.load( + context, + gmsAd_ID, + adRequestParams, + object : com.google.android.gms.ads.rewarded.RewardedAdLoadCallback() { + override fun onAdLoaded(p0: RewardedAd) { + val huaweiRewardedAdFactory = RewardedAdFactory.createFactory(p0) + huaweiRewardedAdFactory.create().let(callback::onRewardedAdLoaded) + } + + override fun onAdFailedToLoad(p0: LoadAdError) { + callback.onAdLoadFailed(p0.toString()) + } + }) + } + MobileServiceType.HMS -> { + val rewardAd = RewardAd(context, hmsAd_ID) + val adRequestParams = hmsAdRequestParams ?: AdParam.Builder().build() + rewardAd.loadAd(adRequestParams, object : RewardAdLoadListener() { + override fun onRewardedLoaded() { + val googleRewardedAdFactory = RewardedAdFactory.createFactory(rewardAd) + googleRewardedAdFactory.create().let(callback::onRewardedAdLoaded) + } + + override fun onRewardAdFailedToLoad(errorCode: Int) { + callback.onAdLoadFailed("HMS Reward Ad Failed To Load. Error code: $errorCode") + } + }) + } + MobileServiceType.NON -> throw IllegalArgumentException() + } + } + } +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/common/IRewardItem.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/common/IRewardItem.kt new file mode 100644 index 00000000..b57a58bf --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/common/IRewardItem.kt @@ -0,0 +1,24 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.rewarded.common + +interface IRewardItem { + fun getAmount(): Int? + + /** + * This function return name for hms instance type for gms instance + */ + fun getTypeOrName(): String? +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/common/MetaDataChangedListener.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/common/MetaDataChangedListener.kt new file mode 100644 index 00000000..96d841a0 --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/common/MetaDataChangedListener.kt @@ -0,0 +1,19 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.rewarded.common + +interface MetaDataChangedListener { + fun onMetaDataChanged() +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/common/RewardedAdLoadCallback.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/common/RewardedAdLoadCallback.kt new file mode 100644 index 00000000..259e23fb --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/common/RewardedAdLoadCallback.kt @@ -0,0 +1,23 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.rewarded.common + +import com.hms.lib.commonmobileservices.ads.rewarded.implementation.IRewardedAd + + +interface RewardedAdLoadCallback { + fun onAdLoadFailed(adError: String) + fun onRewardedAdLoaded(rewardedAd: IRewardedAd) +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/common/UserRewardEarnedListener.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/common/UserRewardEarnedListener.kt new file mode 100644 index 00000000..37b0b2c1 --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/common/UserRewardEarnedListener.kt @@ -0,0 +1,20 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.rewarded.common + +interface UserRewardEarnedListener { + + fun onUserEarnedReward(item: IRewardItem) +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/factory/GoogleRewardedAdFactory.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/factory/GoogleRewardedAdFactory.kt new file mode 100644 index 00000000..acb3e4d7 --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/factory/GoogleRewardedAdFactory.kt @@ -0,0 +1,23 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.rewarded.factory + +import com.google.android.gms.ads.rewarded.RewardedAd +import com.hms.lib.commonmobileservices.ads.rewarded.implementation.GoogleRewardedAd +import com.hms.lib.commonmobileservices.ads.rewarded.implementation.IRewardedAd + +class GoogleRewardedAdFactory(private val rewardedAd: RewardedAd) : RewardedAdFactory() { + override fun create(): IRewardedAd = GoogleRewardedAd(rewardedAd) +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/factory/HuaweiRewardedAdFactory.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/factory/HuaweiRewardedAdFactory.kt new file mode 100644 index 00000000..d342a935 --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/factory/HuaweiRewardedAdFactory.kt @@ -0,0 +1,23 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.rewarded.factory + +import com.hms.lib.commonmobileservices.ads.rewarded.implementation.HuaweiRewardedAd +import com.hms.lib.commonmobileservices.ads.rewarded.implementation.IRewardedAd +import com.huawei.hms.ads.reward.RewardAd + +class HuaweiRewardedAdFactory(private val rewardedAd: RewardAd): RewardedAdFactory() { + override fun create(): IRewardedAd = HuaweiRewardedAd(rewardedAd) +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/factory/RewardedAdFactory.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/factory/RewardedAdFactory.kt new file mode 100644 index 00000000..ffa8cc73 --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/factory/RewardedAdFactory.kt @@ -0,0 +1,55 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.rewarded.factory + +import com.google.android.gms.ads.rewarded.RewardedAd +import com.hms.lib.commonmobileservices.ads.rewarded.implementation.GoogleRewardedAd +import com.hms.lib.commonmobileservices.ads.rewarded.implementation.HuaweiRewardedAd +import com.hms.lib.commonmobileservices.ads.rewarded.implementation.IRewardedAd +import com.huawei.hms.ads.reward.RewardAd + +abstract class RewardedAdFactory { + abstract fun create(): IRewardedAd + + companion object { + inline fun createFactory(rewardedAd: K): RewardedAdFactory { + when (T::class) { + HuaweiRewardedAd::class -> { + return when (K::class) { + com.huawei.hms.ads.reward.RewardAd::class -> { + HuaweiRewardedAdFactory(rewardedAd as RewardAd) + } + com.google.android.gms.ads.rewarded.RewardedAd::class -> { + throw IllegalArgumentException("${HuaweiRewardedAd::class.java.name} expected but ${RewardedAd::class.java.name} found") + } + else -> throw IllegalArgumentException() + } + } + GoogleRewardedAd::class -> { + return when (K::class) { + com.google.android.gms.ads.rewarded.RewardedAd::class -> { + GoogleRewardedAdFactory(rewardedAd as RewardedAd) + } + com.huawei.hms.ads.reward.RewardAd::class -> { + throw IllegalArgumentException("${GoogleRewardedAd::class.java.name} expected but ${RewardAd::class.java.name} found") + } + else -> throw IllegalArgumentException() + } + } + else -> throw IllegalArgumentException() + } + } + } +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/implementation/GoogleRewardedAd.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/implementation/GoogleRewardedAd.kt new file mode 100644 index 00000000..2c15e44f --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/implementation/GoogleRewardedAd.kt @@ -0,0 +1,58 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.rewarded.implementation + +import android.app.Activity +import android.os.Bundle +import com.google.android.gms.ads.OnUserEarnedRewardListener +import com.google.android.gms.ads.rewarded.OnAdMetadataChangedListener +import com.google.android.gms.ads.rewarded.RewardItem +import com.google.android.gms.ads.rewarded.RewardedAd +import com.hms.lib.commonmobileservices.ads.rewarded.common.IRewardItem +import com.hms.lib.commonmobileservices.ads.rewarded.common.UserRewardEarnedListener +import com.hms.lib.commonmobileservices.ads.rewarded.common.MetaDataChangedListener + +class GoogleRewardedAd(private var _rewarded: RewardedAd) : IRewardedAd { + override fun getMetaData(): Bundle = _rewarded.adMetadata + + override fun setOnMetadataChangedListener(callback: MetaDataChangedListener) { + val listener = OnAdMetadataChangedListener { callback.onMetaDataChanged() } + _rewarded.onAdMetadataChangedListener = listener + } + + override fun setImmersive(value: Boolean) { + _rewarded.setImmersiveMode(value) + } + + override fun show(activity: Activity, callback: UserRewardEarnedListener) { + val listener = object : OnUserEarnedRewardListener { + override fun onUserEarnedReward(p0: RewardItem) { + val rewardItem = object : IRewardItem { + override fun getAmount(): Int { + return p0.amount + } + + override fun getTypeOrName(): String { + return p0.type + } + + } + callback.onUserEarnedReward(rewardItem) + } + } + _rewarded.show(activity, listener) + } + +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/implementation/HuaweiRewardedAd.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/implementation/HuaweiRewardedAd.kt new file mode 100644 index 00000000..f4c53898 --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/implementation/HuaweiRewardedAd.kt @@ -0,0 +1,59 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.rewarded.implementation + +import android.app.Activity +import android.os.Bundle +import com.hms.lib.commonmobileservices.ads.rewarded.common.IRewardItem +import com.hms.lib.commonmobileservices.ads.rewarded.common.UserRewardEarnedListener +import com.hms.lib.commonmobileservices.ads.rewarded.common.MetaDataChangedListener +import com.huawei.hms.ads.reward.OnMetadataChangedListener +import com.huawei.hms.ads.reward.Reward +import com.huawei.hms.ads.reward.RewardAd +import com.huawei.hms.ads.reward.RewardAdStatusListener + +class HuaweiRewardedAd(private var _rewarded: RewardAd) : IRewardedAd { + override fun getMetaData(): Bundle = _rewarded.metadata + override fun setOnMetadataChangedListener(callback: MetaDataChangedListener) { + val listener = object : OnMetadataChangedListener() { + override fun onMetadataChanged() { + callback.onMetaDataChanged() + } + } + _rewarded.setOnMetadataChangedListener(listener) + } + + override fun setImmersive(value: Boolean) { + _rewarded.setImmersive(value) + } + + override fun show(activity: Activity, callback: UserRewardEarnedListener) { + val listener = object : RewardAdStatusListener() { + override fun onRewarded(p0: Reward?) { + val rewardItem = object : IRewardItem { + override fun getAmount(): Int? { + return p0?.amount + } + + override fun getTypeOrName(): String? { + return p0?.name + } + } + callback.onUserEarnedReward(rewardItem) + } + } + _rewarded.show(activity, listener) + } +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/implementation/IRewardedAd.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/implementation/IRewardedAd.kt new file mode 100644 index 00000000..49ad1efc --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/rewarded/implementation/IRewardedAd.kt @@ -0,0 +1,27 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.rewarded.implementation + +import android.app.Activity +import android.os.Bundle +import com.hms.lib.commonmobileservices.ads.rewarded.common.UserRewardEarnedListener +import com.hms.lib.commonmobileservices.ads.rewarded.common.MetaDataChangedListener + +interface IRewardedAd { + fun getMetaData(): Bundle + fun setOnMetadataChangedListener(callback: MetaDataChangedListener) + fun setImmersive(value: Boolean) + fun show(activity: Activity, callback: UserRewardEarnedListener) +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/SplashAd.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/SplashAd.kt new file mode 100644 index 00000000..b413252e --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/SplashAd.kt @@ -0,0 +1,90 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.splash + +import android.content.Context +import com.google.android.gms.ads.AdRequest +import com.google.android.gms.ads.LoadAdError +import com.google.android.gms.ads.appopen.AppOpenAd +import com.hms.lib.commonmobileservices.ads.splash.common.SplashAdLoadCallback +import com.hms.lib.commonmobileservices.ads.splash.factory.SplashAdFactory +import com.hms.lib.commonmobileservices.ads.splash.implementation.GoogleAppOpenAd +import com.hms.lib.commonmobileservices.ads.splash.implementation.HuaweiSplashAd +import com.hms.lib.commonmobileservices.core.Device +import com.hms.lib.commonmobileservices.core.MobileServiceType +import com.huawei.hms.ads.AdParam +import com.huawei.hms.ads.splash.SplashView +import com.huawei.hms.ads.splash.SplashView.SplashAdLoadListener + +class SplashAd { + + + companion object { + /** + * TODO:Explain AdRequestParams in Readme document + * TODO:Initialize Ad_ID param with test ad_ID + */ + fun load( + context: Context, + hmsAd_ID: String, + gmsAd_ID: String, + splashView: SplashView, + screenOrientation: Int, + callback: SplashAdLoadCallback, + hmsAdRequestParams: AdParam? = null + ) { + when (Device.getMobileServiceType(context)) { + MobileServiceType.GMS -> { + AppOpenAd.load( + context, + gmsAd_ID, + AdRequest.Builder().build(), + object : AppOpenAd.AppOpenAdLoadCallback() { + override fun onAdLoaded(appOpenAd: AppOpenAd) { + val googleAppOpenAdFactory = + SplashAdFactory.createFactory(appOpenAd) + googleAppOpenAdFactory.create().let(callback::onSplashAdLoaded) + } + + override fun onAdFailedToLoad(loadAdError: LoadAdError) { + callback.onAdLoadFailed(loadAdError.toString()) + } + } + ) + } + MobileServiceType.HMS -> { + val splashAd = SplashAd() + val adRequestParams = hmsAdRequestParams ?: AdParam.Builder().build() + splashView.load( + hmsAd_ID, + screenOrientation, + adRequestParams, + object : SplashAdLoadListener() { + override fun onAdLoaded() { + val huaweiSplashAdFactory = + SplashAdFactory.createFactory(splashAd) + huaweiSplashAdFactory.create().let(callback::onSplashAdLoaded) + } + + override fun onAdFailedToLoad(errorCode: Int) { + callback.onAdLoadFailed("HMS Splash Ad Failed To Load. Error code: $errorCode") + } + }) + } + MobileServiceType.NON -> throw IllegalArgumentException() + } + } + } +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/common/SplashAdLoadCallback.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/common/SplashAdLoadCallback.kt new file mode 100644 index 00000000..be364051 --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/common/SplashAdLoadCallback.kt @@ -0,0 +1,8 @@ +package com.hms.lib.commonmobileservices.ads.splash.common + +import com.hms.lib.commonmobileservices.ads.splash.implementation.ISplashAd + +interface SplashAdLoadCallback { + fun onAdLoadFailed(adError: String) + fun onSplashAdLoaded(splashAd: ISplashAd) +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/factory/GoogleAppOpenAdFactory.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/factory/GoogleAppOpenAdFactory.kt new file mode 100644 index 00000000..51848e9f --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/factory/GoogleAppOpenAdFactory.kt @@ -0,0 +1,23 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.splash.factory + +import com.google.android.gms.ads.appopen.AppOpenAd +import com.hms.lib.commonmobileservices.ads.splash.implementation.GoogleAppOpenAd +import com.hms.lib.commonmobileservices.ads.splash.implementation.ISplashAd + +class GoogleAppOpenAdFactory(private val appOpenAd: AppOpenAd): SplashAdFactory() { + override fun create(): ISplashAd = GoogleAppOpenAd(appOpenAd) +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/factory/HuaweiSplashAdFactory.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/factory/HuaweiSplashAdFactory.kt new file mode 100644 index 00000000..eae1646d --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/factory/HuaweiSplashAdFactory.kt @@ -0,0 +1,23 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.splash.factory + +import com.hms.lib.commonmobileservices.ads.splash.implementation.HuaweiSplashAd +import com.hms.lib.commonmobileservices.ads.splash.implementation.ISplashAd +import com.huawei.hms.ads.splash.SplashAd + +class HuaweiSplashAdFactory(private val splashAd: SplashAd): SplashAdFactory() { + override fun create(): ISplashAd = HuaweiSplashAd(splashAd) +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/factory/SplashAdFactory.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/factory/SplashAdFactory.kt new file mode 100644 index 00000000..e1d74dd5 --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/factory/SplashAdFactory.kt @@ -0,0 +1,55 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.splash.factory + +import com.google.android.gms.ads.appopen.AppOpenAd +import com.hms.lib.commonmobileservices.ads.splash.implementation.GoogleAppOpenAd +import com.hms.lib.commonmobileservices.ads.splash.implementation.HuaweiSplashAd +import com.hms.lib.commonmobileservices.ads.splash.implementation.ISplashAd +import com.huawei.hms.ads.splash.SplashAd + +abstract class SplashAdFactory { + abstract fun create(): ISplashAd + + companion object { + inline fun createFactory(splashAd: K): SplashAdFactory { + when (T::class) { + HuaweiSplashAd::class -> { + return when (K::class) { + com.huawei.hms.ads.splash.SplashAd::class -> { + HuaweiSplashAdFactory(splashAd as SplashAd) + } + com.google.android.gms.ads.appopen.AppOpenAd::class -> { + throw IllegalArgumentException("${SplashAd::class.java.name} expected but ${AppOpenAd::class.java.name} found") + } + else -> throw IllegalArgumentException() + } + } + GoogleAppOpenAd::class -> { + return when (K::class) { + com.google.android.gms.ads.appopen.AppOpenAd::class -> { + GoogleAppOpenAdFactory(splashAd as AppOpenAd) + } + com.huawei.hms.ads.splash.SplashAd::class -> { + throw IllegalArgumentException("${AppOpenAd::class.java.name} expected but ${SplashAd::class.java.name} found") + } + else -> throw IllegalArgumentException() + } + } + else -> throw IllegalArgumentException() + } + } + } +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/implementation/GoogleAppOpenAd.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/implementation/GoogleAppOpenAd.kt new file mode 100644 index 00000000..a6d67ce7 --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/implementation/GoogleAppOpenAd.kt @@ -0,0 +1,24 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.splash.implementation + +import android.app.Activity +import com.google.android.gms.ads.appopen.AppOpenAd + +class GoogleAppOpenAd(private var _appOpenAd: AppOpenAd) : ISplashAd { + override fun show(activity: Activity) { + _appOpenAd.show(activity) + } +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/implementation/HuaweiSplashAd.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/implementation/HuaweiSplashAd.kt new file mode 100644 index 00000000..0e12f2fd --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/implementation/HuaweiSplashAd.kt @@ -0,0 +1,24 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.splash.implementation + +import android.app.Activity +import com.huawei.hms.ads.splash.SplashAd + +class HuaweiSplashAd(private var _splash: SplashAd) : ISplashAd { + override fun show(activity: Activity) { + TODO("Not yet implemented") + } +} \ No newline at end of file diff --git a/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/implementation/ISplashAd.kt b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/implementation/ISplashAd.kt new file mode 100644 index 00000000..6dae8202 --- /dev/null +++ b/ads/src/main/java/com/hms/lib/commonmobileservices/ads/splash/implementation/ISplashAd.kt @@ -0,0 +1,21 @@ +// Copyright 2020. Explore in HMS. All rights reserved. +// +// 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 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hms.lib.commonmobileservices.ads.splash.implementation + +import android.app.Activity + +interface ISplashAd { + fun show(activity: Activity) +} \ No newline at end of file diff --git a/base_sdk.gradle b/base_sdk.gradle index 5e725818..8ca4f55c 100644 --- a/base_sdk.gradle +++ b/base_sdk.gradle @@ -7,14 +7,14 @@ apply from: "$project.rootDir/sonarqube.gradle" group = 'com.hms.lib.commonmobileservices' android { - compileSdkVersion 30 + compileSdkVersion 31 buildToolsVersion "30.0.3" defaultConfig { minSdkVersion 21 - targetSdkVersion 30 - versionCode 6 - versionName "2.2.2" + targetSdkVersion 31 + versionCode 7 + versionName "2.3.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" } diff --git a/core/build.gradle b/core/build.gradle index 86266fbd..51c9a872 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,7 +1,7 @@ apply from: "$project.rootDir/base_sdk.gradle" dependencies { - implementation 'com.huawei.hms:base:5.2.0.300' + implementation 'com.huawei.hms:base:6.6.0.300' implementation 'com.google.android.gms:play-services-base:17.6.0' api 'com.google.code.gson:gson:2.8.6' diff --git a/mapkit/build.gradle b/mapkit/build.gradle index 7e9502a0..28e8da87 100644 --- a/mapkit/build.gradle +++ b/mapkit/build.gradle @@ -2,9 +2,9 @@ apply from: "$project.rootDir/base_sdk.gradle" dependencies { //Huawei Services - api 'com.huawei.hms:maps:6.6.1.301' + api 'com.huawei.hms:maps:6.11.2.301' //Google Services - api 'com.google.android.gms:play-services-maps:18.1.0' + api 'com.google.android.gms:play-services-maps:18.2.0' api 'com.google.maps.android:android-maps-utils:0.6.2' api project(':core') } diff --git a/push/build.gradle b/push/build.gradle index 110fe5ea..aad96d67 100644 --- a/push/build.gradle +++ b/push/build.gradle @@ -1,8 +1,8 @@ apply from: "$project.rootDir/base_sdk.gradle" dependencies { - implementation 'com.huawei.hms:push:6.5.0.300' - implementation 'com.google.firebase:firebase-messaging-ktx:23.0.1' + implementation 'com.huawei.hms:push:6.11.0.300' + implementation 'com.google.firebase:firebase-messaging-ktx:23.4.0' implementation "androidx.work:work-runtime-ktx:2.7.1" api project(":core") implementation 'com.squareup.picasso:picasso:2.71828' diff --git a/settings.gradle b/settings.gradle index e8d20f5a..3ec4b50f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -24,3 +24,5 @@ include ':remoteconfig' include ':texttospeech' rootProject.name = "Common Mobile Services" +include ':ads' +include ':rewarded'