-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ANDDEP-230 Начало создания общего примера для аналитики и пушей
- Loading branch information
1 parent
ebeac34
commit 2727ba4
Showing
55 changed files
with
1,343 additions
and
11 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
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,40 @@ | ||
apply from: '../androidSample.gradle' | ||
apply plugin: 'io.fabric' | ||
|
||
android { | ||
ext.enableCrashlytics = false | ||
|
||
defaultConfig { | ||
applicationId "ru.surfstudio.android.firebase.sample" | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation project(':core-app') | ||
implementation project(':core-ui') | ||
implementation project(':core-mvp') | ||
implementation project(':dagger-scope') | ||
implementation project(':analytics') | ||
implementation project(':firebase-analytics') | ||
implementation project(':push') | ||
implementation project(':network') | ||
implementation project(':filestorage') | ||
implementation project(':logger:') | ||
implementation project(':connection') | ||
implementation project(':rx-extension') | ||
implementation project(':util-ktx') | ||
implementation project(':shared-pref') | ||
implementation project(':message-controller') | ||
|
||
kapt "com.google.dagger:dagger-compiler:$daggerVersion" | ||
implementation "com.google.dagger:dagger:$daggerVersion" | ||
|
||
api "com.google.firebase:firebase-core:$firebaseCoreVersion" | ||
implementation "com.google.firebase:firebase-messaging:$firebaseMessagingVersion" | ||
|
||
implementation("com.crashlytics.sdk.android:crashlytics:${crashlyticsVersion}@aar") { | ||
transitive = true | ||
} | ||
} | ||
|
||
apply plugin: 'com.google.gms.google-services' |
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,73 @@ | ||
{ | ||
"project_info": { | ||
"project_number": "372763265468", | ||
"firebase_url": "https://androidstandard-sample.firebaseio.com", | ||
"project_id": "androidstandard-sample", | ||
"storage_bucket": "androidstandard-sample.appspot.com" | ||
}, | ||
"client": [ | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:372763265468:android:3424eee7df0a7a3e", | ||
"android_client_info": { | ||
"package_name": "ru.surfstudio.android.firebase.sample" | ||
} | ||
}, | ||
"oauth_client": [ | ||
{ | ||
"client_id": "372763265468-b4eobqmimi8dpr4jbd3c70l28g1ers2b.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyDV8cZCPLI1UAY3kl0fCejOnkiI6AWy0VU" | ||
} | ||
], | ||
"services": { | ||
"analytics_service": { | ||
"status": 1 | ||
}, | ||
"appinvite_service": { | ||
"status": 1, | ||
"other_platform_oauth_client": [] | ||
}, | ||
"ads_service": { | ||
"status": 2 | ||
} | ||
} | ||
}, | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:372763265468:android:802fab935976bab8", | ||
"android_client_info": { | ||
"package_name": "ru.surfstudio.android.template" | ||
} | ||
}, | ||
"oauth_client": [ | ||
{ | ||
"client_id": "372763265468-b4eobqmimi8dpr4jbd3c70l28g1ers2b.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyDV8cZCPLI1UAY3kl0fCejOnkiI6AWy0VU" | ||
} | ||
], | ||
"services": { | ||
"analytics_service": { | ||
"status": 1 | ||
}, | ||
"appinvite_service": { | ||
"status": 1, | ||
"other_platform_oauth_client": [] | ||
}, | ||
"ads_service": { | ||
"status": 2 | ||
} | ||
} | ||
} | ||
], | ||
"configuration_version": "1" | ||
} |
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,32 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="ru.surfstudio.android.firebase.sample"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
|
||
<application | ||
android:name=".app.App" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".ui.screen.main.MainActivityView"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<!-- | ||
<service android:name=".ui.common.notification.FirebaseMessagingService"> | ||
<intent-filter> | ||
<action android:name="com.google.firebase.MESSAGING_EVENT" /> | ||
</intent-filter> | ||
</service>--> | ||
|
||
<service android:name=".ui.common.notification.FirebaseInstanceIDService" /> | ||
</application> | ||
</manifest> |
57 changes: 57 additions & 0 deletions
57
firebase-sample/src/main/java/ru/surfstudio/android/firebase/sample/app/App.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,57 @@ | ||
package ru.surfstudio.android.firebase.sample.app | ||
|
||
import android.app.Activity | ||
import com.crashlytics.android.Crashlytics | ||
import com.crashlytics.android.core.CrashlyticsCore | ||
import io.fabric.sdk.android.Fabric | ||
import io.fabric.sdk.android.Kit | ||
import ru.surfstudio.android.core.app.CoreApp | ||
import ru.surfstudio.android.core.app.DefaultActivityLifecycleCallbacks | ||
import ru.surfstudio.android.firebase.sample.app.dagger.AppComponent | ||
import ru.surfstudio.android.firebase.sample.app.dagger.AppModule | ||
import ru.surfstudio.android.firebase.sample.app.dagger.DaggerAppComponent | ||
import ru.surfstudio.android.firebase.sample.ui.common.notification.PushHandleStrategyFactory | ||
import ru.surfstudio.android.notification.NotificationCenter | ||
|
||
/** | ||
* Класс приложения | ||
*/ | ||
class App : CoreApp() { | ||
|
||
var appComponent: AppComponent? = null | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
initFabric() | ||
initInjector() | ||
initNotificationCenter() | ||
} | ||
|
||
private fun initFabric() { | ||
val kits = arrayOf<Kit<*>>( | ||
Crashlytics.Builder().core( | ||
CrashlyticsCore.Builder() | ||
.build()) | ||
.build()) | ||
Fabric.with(this, *kits) | ||
} | ||
|
||
private fun initInjector() { | ||
appComponent = DaggerAppComponent.builder() | ||
.appModule(AppModule(this)) | ||
.build() | ||
} | ||
|
||
private fun initNotificationCenter() { | ||
NotificationCenter.configure { | ||
setActiveActivityHolder(activeActivityHolder) | ||
setPushHandleStrategyFactory(PushHandleStrategyFactory) | ||
} | ||
|
||
registerActivityLifecycleCallbacks(object : DefaultActivityLifecycleCallbacks() { | ||
override fun onActivityResumed(activity: Activity) { | ||
NotificationCenter.onActivityStarted(activity) | ||
} | ||
}) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ase-sample/src/main/java/ru/surfstudio/android/firebase/sample/app/dagger/AppComponent.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,25 @@ | ||
package ru.surfstudio.android.firebase.sample.app.dagger | ||
|
||
import android.content.Context | ||
import dagger.Component | ||
import ru.surfstudio.android.connection.ConnectionProvider | ||
import ru.surfstudio.android.core.app.ActiveActivityHolder | ||
import ru.surfstudio.android.core.app.StringsProvider | ||
import ru.surfstudio.android.dagger.scope.PerApplication | ||
import ru.surfstudio.android.firebase.sample.interactor.analytics.AnalyticsModule | ||
import ru.surfstudio.android.firebase.sample.interactor.analytics.AnalyticsService | ||
import ru.surfstudio.android.rx.extension.scheduler.SchedulersProvider | ||
|
||
@PerApplication | ||
@Component(modules = [ | ||
AppModule::class, | ||
SharedPrefModule::class, | ||
AnalyticsModule::class]) | ||
interface AppComponent { | ||
fun context(): Context | ||
fun activeActivityHolder(): ActiveActivityHolder | ||
fun connectionProvider(): ConnectionProvider | ||
fun schedulerProvider(): SchedulersProvider | ||
fun stringsProvider(): StringsProvider | ||
fun analyticsService(): AnalyticsService | ||
} |
48 changes: 48 additions & 0 deletions
48
firebase-sample/src/main/java/ru/surfstudio/android/firebase/sample/app/dagger/AppModule.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,48 @@ | ||
package ru.surfstudio.android.firebase.sample.app.dagger | ||
|
||
import android.content.Context | ||
|
||
import dagger.Module | ||
import dagger.Provides | ||
import ru.surfstudio.android.core.app.ActiveActivityHolder | ||
import ru.surfstudio.android.core.app.CoreApp | ||
import ru.surfstudio.android.core.app.StringsProvider | ||
import ru.surfstudio.android.core.ui.navigation.activity.navigator.GlobalNavigator | ||
import ru.surfstudio.android.dagger.scope.PerApplication | ||
import ru.surfstudio.android.rx.extension.scheduler.SchedulersProvider | ||
import ru.surfstudio.android.rx.extension.scheduler.SchedulersProviderImpl | ||
|
||
@Module | ||
class AppModule(private val coreApp: CoreApp) { | ||
|
||
@PerApplication | ||
@Provides | ||
internal fun provideActiveActivityHolder(): ActiveActivityHolder { | ||
return coreApp.activeActivityHolder | ||
} | ||
|
||
@PerApplication | ||
@Provides | ||
internal fun provideContext(): Context { | ||
return coreApp | ||
} | ||
|
||
@PerApplication | ||
@Provides | ||
internal fun provideStringsProvider(context: Context): StringsProvider { | ||
return StringsProvider(context) | ||
} | ||
|
||
@PerApplication | ||
@Provides | ||
internal fun provideGlobalNavigator(context: Context, | ||
activityHolder: ActiveActivityHolder): GlobalNavigator { | ||
return GlobalNavigator(context, activityHolder) | ||
} | ||
|
||
@Provides | ||
@PerApplication | ||
fun provideSchedulerProvider(): SchedulersProvider { | ||
return SchedulersProviderImpl() | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...mple/src/main/java/ru/surfstudio/android/firebase/sample/app/dagger/SharedPrefModule.java
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,31 @@ | ||
package ru.surfstudio.android.firebase.sample.app.dagger; | ||
|
||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
|
||
import javax.inject.Named; | ||
|
||
import dagger.Module; | ||
import dagger.Provides; | ||
import ru.surfstudio.android.dagger.scope.PerApplication; | ||
|
||
import static ru.surfstudio.android.shared.pref.SettingsUtilKt.BACKUP_SHARED_PREF; | ||
import static ru.surfstudio.android.shared.pref.SettingsUtilKt.NO_BACKUP_SHARED_PREF; | ||
|
||
@Module | ||
public class SharedPrefModule { | ||
|
||
@Provides | ||
@PerApplication | ||
@Named(NO_BACKUP_SHARED_PREF) | ||
public SharedPreferences provideNoBackupSharedPref(Context context) { | ||
return context.getSharedPreferences(NO_BACKUP_SHARED_PREF, Context.MODE_PRIVATE); | ||
} | ||
|
||
@Provides | ||
@PerApplication | ||
@Named(BACKUP_SHARED_PREF) | ||
public SharedPreferences provideBackupSharedPref(Context context) { | ||
return context.getSharedPreferences(BACKUP_SHARED_PREF, Context.MODE_PRIVATE); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...c/main/java/ru/surfstudio/android/firebase/sample/interactor/analytics/AnalyticsModule.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 ru.surfstudio.android.firebase.sample.interactor.analytics | ||
|
||
import android.content.Context | ||
import com.google.firebase.analytics.FirebaseAnalytics | ||
import dagger.Module | ||
import dagger.Provides | ||
import ru.surfstudio.android.analytics.Analytics | ||
import ru.surfstudio.android.analytics.store.AnalyticsStore | ||
import ru.surfstudio.android.dagger.scope.PerApplication | ||
import ru.surfstudio.android.firebaseanalytics.api.FirebaseApi | ||
|
||
@Module | ||
class AnalyticsModule { | ||
|
||
@Provides | ||
@PerApplication | ||
internal fun provideFirebaseAnalytics(context: Context): FirebaseAnalytics { | ||
return FirebaseAnalytics.getInstance(context) | ||
} | ||
|
||
@Provides | ||
@PerApplication | ||
internal fun provideFirebaseApi(firebaseAnalytics: FirebaseAnalytics): FirebaseApi { | ||
return FirebaseApi(firebaseAnalytics) | ||
} | ||
|
||
@Provides | ||
@PerApplication | ||
internal fun provideAnalyticsStorage(firebaseApi: FirebaseApi): Analytics { | ||
return AnalyticsStore(listOf(firebaseApi)) | ||
} | ||
} |
Oops, something went wrong.