Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaozhan committed Apr 21, 2024
2 parents d2b1df8 + 6f9745d commit b530e2d
Show file tree
Hide file tree
Showing 39 changed files with 307 additions and 155 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @Oztechan/core-team
* @Oztechan/core-team @mustafaozhan
35 changes: 22 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
cancel-in-progress: ${{ !contains(github.ref, 'develop')}}

env:
BASE_URL_BACKEND: ${{ secrets.BASE_URL_BACKEND }}
Expand Down Expand Up @@ -90,9 +90,12 @@ jobs:
distribution: 'temurin'

- name: Assemble
uses: gradle/gradle-build-action@v3.1.0
uses: gradle/actions/setup-gradle@v3.3.0
with:
arguments: assemble
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use"
build-scan-terms-of-use-agree: "yes"

- name: Upload Android Artifacts
uses: actions/[email protected]
Expand All @@ -112,7 +115,7 @@ jobs:
run: echo "status=success" >> $GITHUB_OUTPUT

DistributeAndroid:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: [ GradleBuild ]
if: github.event_name == 'push'
outputs:
Expand All @@ -123,7 +126,7 @@ jobs:
uses: actions/[email protected]

- name: Download Android Artifacts
uses: actions/[email protected].4
uses: actions/[email protected].5
with:
name: androidArtifacts

Expand Down Expand Up @@ -212,7 +215,7 @@ jobs:
run: echo "status=success" >> $GITHUB_OUTPUT

DistributeIOS:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: [ XCodeBuild ]
if: github.event_name == 'push'
outputs:
Expand All @@ -222,7 +225,7 @@ jobs:
uses: actions/[email protected]

- name: Download iOS IPA
uses: actions/[email protected].4
uses: actions/[email protected].5
with:
name: iOSArtifacts
path: ios
Expand Down Expand Up @@ -262,9 +265,12 @@ jobs:
distribution: 'temurin'

- name: Run Quality Jobs
uses: gradle/gradle-build-action@v3.1.0
uses: gradle/actions/setup-gradle@v3.3.0
with:
arguments: check koverMergedXmlReport --parallel
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use"
build-scan-terms-of-use-agree: "yes"

- name: Upload Coverage Report
uses: actions/[email protected]
Expand All @@ -281,7 +287,7 @@ jobs:
run: echo "status=success" >> $GITHUB_OUTPUT

UploadQualityReports:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: [ Quality ]
outputs:
status: ${{ steps.status.outputs.status }}
Expand All @@ -290,13 +296,13 @@ jobs:
uses: actions/[email protected]

- name: Download Coverage Report
uses: actions/[email protected].4
uses: actions/[email protected].5
with:
name: coverageReport
path: build

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.1.0
uses: codecov/codecov-action@v4.3.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: build/report.xml
Expand Down Expand Up @@ -329,7 +335,7 @@ jobs:
run: echo "status=success" >> $GITHUB_OUTPUT

CodeAnalysis:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
outputs:
status: ${{ steps.status.outputs.status }}
steps:
Expand All @@ -346,9 +352,12 @@ jobs:
distribution: 'temurin'

- name: Detekt
uses: gradle/gradle-build-action@v3.1.0
uses: gradle/actions/setup-gradle@v3.3.0
with:
arguments: detektAll
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use"
build-scan-terms-of-use-agree: "yes"

- name: SwiftLint
uses: norio-nomura/[email protected]
Expand All @@ -366,7 +375,7 @@ jobs:
run: echo "status=success" >> $GITHUB_OUTPUT

Notify:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: [ GradleBuild, XCodeBuild, Quality, CodeAnalysis, DistributeAndroid, DistributeIOS, UploadQualityReports ]
if: always()
steps:
Expand Down
21 changes: 12 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ env:
jobs:

GenerateGradleArtifacts:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
outputs:
status: ${{ steps.status.outputs.status }}
steps:
Expand Down Expand Up @@ -85,9 +85,12 @@ jobs:
distribution: 'temurin'

- name: Generate Artifacts
uses: gradle/gradle-build-action@v3.1.0
uses: gradle/actions/setup-gradle@v3.3.0
with:
arguments: :android:app:bundleRelease :backend:app:jar --parallel
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use"
build-scan-terms-of-use-agree: "yes"

- name: Upload Google App Bundle
uses: actions/[email protected]
Expand All @@ -112,14 +115,14 @@ jobs:
run: echo "status=success" >> $GITHUB_OUTPUT

UploadToGooglePlay:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: [ GenerateGradleArtifacts ]
outputs:
status: ${{ steps.status.outputs.status }}
steps:

- name: Download App Bundle
uses: actions/[email protected].4
uses: actions/[email protected].5
with:
name: googleBundle

Expand Down Expand Up @@ -148,14 +151,14 @@ jobs:
run: echo "status=success" >> $GITHUB_OUTPUT

UploadToHuaweiAppGallery:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: [ GenerateGradleArtifacts ]
outputs:
status: ${{ steps.status.outputs.status }}
steps:

- name: Download App Bundle
uses: actions/[email protected].4
uses: actions/[email protected].5
with:
name: huaweiBundle

Expand All @@ -180,14 +183,14 @@ jobs:
run: echo "status=success" >> $GITHUB_OUTPUT

DeployToServer:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: [ GenerateGradleArtifacts ]
outputs:
status: ${{ steps.status.outputs.status }}
steps:

- name: Download Backend Jar
uses: actions/[email protected].4
uses: actions/[email protected].5
with:
name: backendJar
path: artifact
Expand Down Expand Up @@ -246,7 +249,7 @@ jobs:
run: echo "status=success" >> $GITHUB_OUTPUT

Notify:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: [ GenerateGradleArtifacts, UploadToGooglePlay, UploadToHuaweiAppGallery, DeployToServer, UploadToAppStore ]
if: always()
steps:
Expand Down
4 changes: 4 additions & 0 deletions android/app/src/googleDebug/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">CCC_G</string>
</resources>
4 changes: 4 additions & 0 deletions android/app/src/huaweiDebug/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">CCC_H</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import android.os.StrictMode.ThreadPolicy
import android.os.StrictMode.VmPolicy
import co.touchlab.kermit.Logger
import com.github.submob.logmob.ANRWatchDogHandler
import com.github.submob.logmob.initCrashlytics
import com.github.submob.logmob.initLogger
import com.github.submob.logmob.setCrashlyticsCollection
import com.oztechan.ccc.android.app.di.initKoin
import com.oztechan.ccc.android.core.ad.initAds
import com.oztechan.ccc.client.core.analytics.initAnalytics

class Application : Application() {

override fun onCreate() {
super.onCreate()

setCrashlyticsCollection(!BuildConfig.DEBUG)

if (!BuildConfig.DEBUG) {
initCrashlytics()
initAnalytics(this)
}

Expand All @@ -38,8 +38,6 @@ class Application : Application() {
Thread.setDefaultUncaughtExceptionHandler(ANRWatchDogHandler())
}

initAds(this)

initKoin(this)
}

Expand Down
1 change: 1 addition & 0 deletions android/core/ad/android-core-ad.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ dependencies {
libs.android.apply {
google.apply {
DeviceFlavour.GOOGLE.implementation(googleAds)
DeviceFlavour.GOOGLE.implementation(ump)
}
huawei.apply {
DeviceFlavour.HUAWEI.implementation(huaweiAds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,64 @@ import com.google.android.gms.ads.interstitial.InterstitialAd
import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback
import com.google.android.gms.ads.rewarded.RewardedAd
import com.google.android.gms.ads.rewarded.RewardedAdLoadCallback
import com.google.android.ump.ConsentInformation
import com.google.android.ump.ConsentRequestParameters
import com.google.android.ump.UserMessagingPlatform
import java.util.concurrent.atomic.AtomicBoolean

internal class AdManagerImpl : AdManager {
internal class AdManagerImpl(context: Context) : AdManager {
// Use an atomic boolean to initialize the Google Mobile Ads SDK and load ads once.
private val isMobileAdsInitializeCalled = AtomicBoolean(false)

private val consentInformation: ConsentInformation =
UserMessagingPlatform.getConsentInformation(context)

private val adRequest: AdRequest by lazy {
AdRequest.Builder().build()
}

init {
Logger.v { "AdManagerImpl init" }
MobileAds.setAppVolume(0.0f)
MobileAds.setAppMuted(true)
}

override fun initAds(activity: Activity) {
Logger.v { "AdManagerImpl initAds" }
consentInformation.requestConsentInfoUpdate(
activity,
ConsentRequestParameters.Builder().build(),
{
UserMessagingPlatform.loadAndShowConsentFormIfRequired(activity) {
if (it != null) {
Logger.e { "Consent gathering failed: ${it.errorCode}: ${it.message}" }
}

// Consent has been gathered.
if (consentInformation.canRequestAds()) {
activity.initializeMobileAdsSdk()
}
}
},
{ Logger.e { "Consent gathering failed: ${it.errorCode}: ${it.message}" } }
)

// Check if you can initialize the Google Mobile Ads SDK in parallel
// while checking for new consent information. Consent obtained in
// the previous session can be used to request ads.
if (consentInformation.canRequestAds()) {
activity.initializeMobileAdsSdk()
}
}

override fun isPrivacyOptionsRequired() =
consentInformation.privacyOptionsRequirementStatus ==
ConsentInformation.PrivacyOptionsRequirementStatus.REQUIRED

override fun showConsentForm(activity: Activity) {
UserMessagingPlatform.showPrivacyOptionsForm(activity) {
if (it != null) {
Logger.e { "Showing consent form failed: ${it.errorCode}: ${it.message}" }
}
}
}

override fun getBannerAd(
Expand Down Expand Up @@ -115,4 +162,17 @@ internal class AdManagerImpl : AdManager {
}
)
}

private fun Activity.initializeMobileAdsSdk() {
Logger.v { "AdManagerImpl initializeMobileAdsSdk" }

if (isMobileAdsInitializeCalled.getAndSet(true)) {
Logger.v { "AdManagerImpl initializeMobileAdsSdk is not called, already called" }
return
}

MobileAds.initialize(this)
MobileAds.setAppVolume(0.0f)
MobileAds.setAppMuted(true)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,19 @@ internal class AdManagerImpl : AdManager {

init {
Logger.v { "AdManagerImpl init" }
}

override fun initAds(activity: Activity) {
Logger.v { "Ads initAds" }
HwAds.init(activity)
HwAds.setVideoVolume(0f)
HwAds.setVideoMuted(true)
}

override fun isPrivacyOptionsRequired() = false

override fun showConsentForm(activity: Activity) = Unit

override fun getBannerAd(
context: Context,
width: Int,
Expand Down

This file was deleted.

Loading

0 comments on commit b530e2d

Please sign in to comment.