-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from Explore-In-HMS/dev
Phase 1 development released to master
- Loading branch information
Showing
47 changed files
with
1,424 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
path: app/build/outputs/apk/debug/app-debug.apk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.hms.lib.commonmobileservices.ads"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
</manifest> |
97 changes: 97 additions & 0 deletions
97
ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/BannerAd.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<GoogleBannerAd, AdView>(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<HuaweiBannerAd, BannerView>( | ||
hms_BannerView | ||
) | ||
huaweiBannerAd.create().let(callback::onBannerAdLoaded) | ||
} | ||
|
||
override fun onAdFailed(errorCode: Int) { | ||
callback.onAdLoadFailed(errorCode.toString()) | ||
} | ||
} | ||
loadAd(adRequestParams) | ||
} | ||
|
||
} | ||
MobileServiceType.NON -> throw IllegalArgumentException() | ||
} | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
ads/src/main/java/com/hms/lib/commonmobileservices/ads/banner/common/BannerAdLoadCallback.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
Oops, something went wrong.