-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop'
- Loading branch information
Showing
81 changed files
with
963 additions
and
508 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
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
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,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) | ||
} | ||
} |
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,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> |
8 changes: 8 additions & 0 deletions
8
analytics/src/main/java/com/mustafaozhan/github/analytics/Analytics.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,8 @@ | ||
package com.mustafaozhan.github.analytics | ||
|
||
import android.content.Context | ||
import com.google.firebase.analytics.FirebaseAnalytics | ||
|
||
fun initAnalytics(context: Context) { | ||
FirebaseAnalytics.getInstance(context) | ||
} |
13 changes: 13 additions & 0 deletions
13
analytics/src/main/java/com/mustafaozhan/github/analytics/AnalyticsManager.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,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) | ||
} |
46 changes: 46 additions & 0 deletions
46
analytics/src/main/java/com/mustafaozhan/github/analytics/AnalyticsManagerImpl.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,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)) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
analytics/src/main/java/com/mustafaozhan/github/analytics/model/EventParam.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,5 @@ | ||
package com.mustafaozhan.github.analytics.model | ||
|
||
enum class EventParam(val key: String) { | ||
BASE("base") | ||
} |
7 changes: 7 additions & 0 deletions
7
analytics/src/main/java/com/mustafaozhan/github/analytics/model/FirebaseEvent.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,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") | ||
} |
11 changes: 11 additions & 0 deletions
11
analytics/src/main/java/com/mustafaozhan/github/analytics/model/UserProperty.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,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") | ||
} |
32 changes: 32 additions & 0 deletions
32
analytics/src/main/java/com/mustafaozhan/github/analytics/util/AnalyticsUtil.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,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() | ||
} |
Oops, something went wrong.