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 Dec 5, 2021
2 parents 323976d + a922838 commit 9047cf1
Show file tree
Hide file tree
Showing 81 changed files with 963 additions and 508 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ env:
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
BASE_URL_BACKEND: ${{ secrets.BASE_URL_BACKEND }}
BASE_URL_API: ${{ secrets.BASE_URL_API }}
BASE_URL_API_POPULAR: ${{ secrets.BASE_URL_API_POPULAR }}
API_KEY_POPULAR: ${{ secrets.API_KEY_POPULAR }}
BASE_URL_API_PREMIUM: ${{ secrets.BASE_URL_API_PREMIUM }}
API_KEY_PREMIUM: ${{ secrets.API_KEY_PREMIUM }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

jobs:
Expand Down Expand Up @@ -142,14 +142,19 @@ jobs:
java-version: 11

- name: Run Kover
run: |
./gradlew koverCollectReports --parallel
run: ./gradlew koverXmlReport koverCollectReports

- name: Upload to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: client/build/reports/kover/report.xml, common/build/reports/kover/report.xml, scopemob/build/reports/kover/report.xml, parsermob/build/reports/kover/report.xml
files: build/kover/ad.xml,build/kover/analytics.xml,build/kover/android.xml,build/kover/backend.xml,build/kover/basemob.xml,build/kover/billing.xml,build/kover/client.xml,build/kover/common.xml,build/kover/logmob.xml,build/kover/parsermob.xml,build/kover/scopemob.xml

- name: Upload to Codacy
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: build/kover/ad.xml,build/kover/analytics.xml,build/kover/android.xml,build/kover/backend.xml,build/kover/basemob.xml,build/kover/billing.xml,build/kover/client.xml,build/kover/common.xml,build/kover/logmob.xml,build/kover/parsermob.xml,build/kover/scopemob.xml

- name: Set Job Status
id: status
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ env:
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
BASE_URL_BACKEND: ${{ secrets.BASE_URL_BACKEND }}
BASE_URL_API: ${{ secrets.BASE_URL_API }}
BASE_URL_API_POPULAR: ${{ secrets.BASE_URL_API_POPULAR }}
API_KEY_POPULAR: ${{ secrets.API_KEY_POPULAR }}
BASE_URL_API_PREMIUM: ${{ secrets.BASE_URL_API_PREMIUM }}
API_KEY_PREMIUM: ${{ secrets.API_KEY_PREMIUM }}

jobs:

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ env:
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
BASE_URL_BACKEND: ${{ secrets.BASE_URL_BACKEND }}
BASE_URL_API: ${{ secrets.BASE_URL_API }}
BASE_URL_API_POPULAR: ${{ secrets.BASE_URL_API_POPULAR }}
API_KEY_POPULAR: ${{ secrets.API_KEY_POPULAR }}
BASE_URL_API_PREMIUM: ${{ secrets.BASE_URL_API_PREMIUM }}
API_KEY_PREMIUM: ${{ secrets.API_KEY_PREMIUM }}

jobs:
Distribute:
Expand Down
16 changes: 9 additions & 7 deletions ad/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import config.DeviceFlavour

plugins {
with(Dependencies.Plugins) {
id(ANDROID_LIB)
Expand All @@ -15,23 +17,23 @@ android {
}
}

with(Build.Flavor) {
flavorDimensions.addAll(listOf(getFlavorName()))
with(DeviceFlavour) {
flavorDimensions.addAll(listOf(flavorDimension))

productFlavors {
create(GOOGLE) {
dimension = getFlavorName()
create(google) {
dimension = flavorDimension
}

create(HUAWEI) {
dimension = getFlavorName()
create(huawei) {
dimension = flavorDimension
}
}
}
}

dependencies {
with(Build.Flavor.Implementation) {
with(DeviceFlavour) {
googleImplementation(Dependencies.Android.GOOGLE.ADMOB)
}

Expand Down
1 change: 1 addition & 0 deletions analytics/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
25 changes: 25 additions & 0 deletions analytics/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
plugins {
with(Dependencies.Plugins) {
id(ANDROID_LIB)
kotlin(ANDROID)
}
}

android {
with(ProjectSettings) {
compileSdk = COMPILE_SDK_VERSION

defaultConfig {
minSdk = MIN_SDK_VERSION
targetSdk = TARGET_SDK_VERSION
}
}
}

dependencies {
with(Dependencies.Android) {
implementation(FIREBASE_ANALYTICS)
implementation(HUAWEI_HSM_BASE)
implementation(ROOT_BEER)
}
}
8 changes: 8 additions & 0 deletions analytics/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mustafaozhan.github">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.mustafaozhan.github.analytics

import android.content.Context
import com.google.firebase.analytics.FirebaseAnalytics

fun initAnalytics(context: Context) {
FirebaseAnalytics.getInstance(context)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.mustafaozhan.github.analytics

import com.mustafaozhan.github.analytics.model.EventParam
import com.mustafaozhan.github.analytics.model.FirebaseEvent
import com.mustafaozhan.github.analytics.model.UserProperty

interface AnalyticsManager {
fun trackScreen(screenName: String)

fun setUserProperty(userProperty: UserProperty, value: String)

fun trackEvent(event: FirebaseEvent, params: Map<EventParam, String>? = null)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.mustafaozhan.github.analytics

import android.content.Context
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.analytics.ktx.logEvent
import com.google.firebase.ktx.Firebase
import com.mustafaozhan.github.analytics.model.EventParam
import com.mustafaozhan.github.analytics.model.FirebaseEvent
import com.mustafaozhan.github.analytics.model.UserProperty
import com.mustafaozhan.github.analytics.util.getAvailableServices
import com.mustafaozhan.github.analytics.util.isDeviceRooted

class AnalyticsManagerImpl(
context: Context
) : AnalyticsManager {
private val firebaseAnalytics by lazy { Firebase.analytics }

init {
setDefaultUserProperties(context)
}

override fun trackScreen(screenName: String) {
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SCREEN_VIEW) {
param(FirebaseAnalytics.Param.SCREEN_NAME, screenName)
param(FirebaseAnalytics.Param.SCREEN_CLASS, screenName)
}
}

override fun setUserProperty(userProperty: UserProperty, value: String) {
firebaseAnalytics.setUserProperty(userProperty.key, value)
}

override fun trackEvent(event: FirebaseEvent, params: Map<EventParam, String>?) {
firebaseAnalytics.logEvent(event.key) {
params?.forEach {
param(it.key.key, it.value)
}
}
}

private fun setDefaultUserProperties(context: Context) {
setUserProperty(UserProperty.MOBILE_SERVICES, getAvailableServices(context))
setUserProperty(UserProperty.IS_ROOTED, isDeviceRooted(context))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.mustafaozhan.github.analytics.model

enum class EventParam(val key: String) {
BASE("base")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.mustafaozhan.github.analytics.model

enum class FirebaseEvent(val key: String) {
BASE_CHANGE("base_change"),
SHOW_CONVERSION("show_conversion"),
OFFLINE_SYNC("offline_sync")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.mustafaozhan.github.analytics.model

enum class UserProperty(val key: String) {
BASE_CURRENCY("base_currency"),
MOBILE_SERVICES("mobile_services"),
ACTIVE_CURRENCIES("active_currencies"),
CURRENCY_COUNT("currency_count"),
IS_ROOTED("is_rooted"),
APP_THEME("app_theme"),
IS_AD_FREE("is_ad_free")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.mustafaozhan.github.analytics.util

import android.content.Context
import com.google.android.gms.common.GoogleApiAvailabilityLight
import com.huawei.hms.api.HuaweiApiAvailability
import com.scottyab.rootbeer.RootBeer
import com.google.android.gms.common.ConnectionResult as GoogleConnectionResult
import com.huawei.hms.api.ConnectionResult as HuaweiConnectionResult

private const val GOOGLE_MOBILE_SERVICES = "gms"
private const val HUAWEI_MOBILE_SERVICES = "hms"

fun getAvailableServices(context: Context): String {
val playServiceAvailable = GoogleApiAvailabilityLight.getInstance()
.isGooglePlayServicesAvailable(context) == GoogleConnectionResult.SUCCESS

val huaweiServiceAvailable = HuaweiApiAvailability.getInstance()
.isHuaweiMobileServicesAvailable(context) == HuaweiConnectionResult.SUCCESS

return when {
playServiceAvailable && huaweiServiceAvailable -> "$GOOGLE_MOBILE_SERVICES,$HUAWEI_MOBILE_SERVICES"
playServiceAvailable -> GOOGLE_MOBILE_SERVICES
huaweiServiceAvailable -> HUAWEI_MOBILE_SERVICES
else -> ""
}
}

fun isDeviceRooted(context: Context) = if (RootBeer(context).isRooted) {
true.toString()
} else {
false.toString()
}
Loading

0 comments on commit 9047cf1

Please sign in to comment.