Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phase 1 development released to master #85

Merged
merged 44 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5d6d21f
Create ads module
cugur24 Jul 11, 2023
316e69e
Rewarded factory development
cugur24 Jul 20, 2023
5d3b4e8
Fix class control condition flow
cugur24 Jul 24, 2023
abea534
Update README.md
cugur24 Jul 27, 2023
09c43d9
Upgrade cms sdk version
cugur24 Jul 27, 2023
4fc4924
Add license headers
cugur24 Jul 28, 2023
38b36fa
Create common callback
Sep 11, 2023
722b795
Create factory classes
Sep 11, 2023
5fbf6c5
Create implementation classes
Sep 11, 2023
a34c9f4
Create static load func
Sep 11, 2023
f305450
Create common ad load callback
Oct 26, 2023
c42d2f8
Create banner ad factory classes
Oct 26, 2023
c12639d
Create banner ad implementation classes
Oct 26, 2023
b3d052c
Add required internet permission to manifest file
Oct 26, 2023
e2d9122
Create static banner ad load func
Oct 26, 2023
d40a9cd
Create common splash ad load callback
Dec 10, 2023
cefee88
Create splash ad factory classes
Dec 10, 2023
7ca9d36
Create splash ad implementation classes
Dec 10, 2023
00f3049
Create static splash ad load func
Dec 10, 2023
c32a1ca
Merge pull request #73 from Explore-In-HMS/Explore-In-HMS/ads/rewarded
htk007 Dec 12, 2023
8d35840
Merge remote-tracking branch 'origin/dev' into Explore-In-HMS/ads/int…
Dec 12, 2023
3b9c595
Merge pull request #75 from Explore-In-HMS/Explore-In-HMS/ads/interst…
htk007 Dec 12, 2023
eb5060d
Merge remote-tracking branch 'origin/dev' into Explore-In-HMS/ads/banner
Dec 12, 2023
6bd6f7d
Merge pull request #76 from Explore-In-HMS/Explore-In-HMS/ads/banner
htk007 Dec 12, 2023
915dfdc
Merge remote-tracking branch 'origin/dev' into Explore-In-HMS/ads/splash
Dec 12, 2023
3a0da41
Merge pull request #77 from Explore-In-HMS/Explore-In-HMS/ads/splash
htk007 Dec 12, 2023
e03c981
Update README.md
Feyzarkt Jan 30, 2024
a28091d
Update README.md
Feyzarkt Jan 30, 2024
691d7f9
Merge pull request #78 from Explore-In-HMS/Explore-In-HMS/readme/inst…
htk007 Feb 12, 2024
15f61ec
CMS-81 # Update gms and hms version
emineinan Feb 13, 2024
675390a
CMS-81 # Update compileSdkVersion and targetSdkVersion
emineinan Feb 13, 2024
354b68d
CMS-80 # Update version of push kit dependencies
Feb 14, 2024
393d1db
CMS-80 # Upgrade version of sdk
Feb 14, 2024
00a097c
Merge pull request #83 from Explore-In-HMS/chore/CMS-80-version-updat…
htk007 Feb 15, 2024
f3a0626
Merge remote-tracking branch 'origin/dev' into chore/CMS-81-version-u…
emineinan Feb 15, 2024
0d400e3
Merge pull request #82 from Explore-In-HMS/chore/CMS-81-version-updat…
htk007 Feb 15, 2024
6d0ae99
[REFACTOR][UPDATE] debug_deploy.yml
Mar 14, 2024
643d992
[REFACTOR][UPDATE] core build gradle hms base version
Mar 14, 2024
b474e62
[REFACTOR][UNDO] push module runtime version
Mar 14, 2024
7acf0ec
Merge pull request #89 from Explore-In-HMS/CMS-88_cms_gradle_configur…
htk007 Mar 15, 2024
0593df2
[REFACTOR] debug_deploy.yml version Github Distrubution version
Mar 19, 2024
b13418f
[REFACTOR] debug_deploy.yml version Setup Google Cloud
Mar 20, 2024
e5f500c
[REFACTOR] debug_deploy.yml version undo
Mar 20, 2024
a0be314
[REFACTOR] debug_deploy.yml version removed firebase deploy phase
Mar 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 9 additions & 28 deletions .github/workflows/debug_deploy.yml
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
116 changes: 101 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,67 @@ 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.
```gradle
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`
Expand Down Expand Up @@ -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:<versionName>'
```
### Ads
```gradle
implementation 'com.github.Explore-In-HMS.common-mobile-services:ads:<versionName>'
implementation 'com.google.android.gms:play-services-ads:22.2.0'
implementation 'com.huawei.hms:ads-prime:3.4.62.302'
```
### Face Detection
```gradle
Expand Down Expand Up @@ -893,6 +930,55 @@ The `textRecognition()` function takes a callback lambda function as a parameter
fun textRecognition(bitmap: Bitmap, callback: (recognizedValue: RecognitionResult<Any>) -> 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
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-YOUR-CA_APP_PUB_HERE" />
```

## 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.

Expand Down
1 change: 1 addition & 0 deletions ads/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
7 changes: 7 additions & 0 deletions ads/build.gradle
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 added ads/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions ads/proguard-rules.pro
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
6 changes: 6 additions & 0 deletions ads/src/main/AndroidManifest.xml
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>
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()
}
}
}
}
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)
}
Loading
Loading