From cd54a6f913a77ee6a8f477926e679256d585bd92 Mon Sep 17 00:00:00 2001 From: Sachin Dehury <51115041+sachin2dehury@users.noreply.github.com> Date: Tue, 27 Jun 2023 19:31:50 +0530 Subject: [PATCH] Reduce start up time (#89) --- app/build.gradle | 1 + app/src/main/AndroidManifest.xml | 18 ++++++++++++++++-- .../kotlin/github/owlmail/app/OwlMailApp.kt | 10 ---------- .../app/initializer/FirebaseInitializer.kt | 16 ++++++++++++++++ .../app/initializer/StethoInitializer.kt | 18 ++++++++++++++++++ buildSrc/src/main/kotlin/Dependencies.kt | 2 ++ buildSrc/src/main/kotlin/DependencyVersion.kt | 2 ++ 7 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 app/src/main/kotlin/github/owlmail/app/initializer/FirebaseInitializer.kt create mode 100644 app/src/main/kotlin/github/owlmail/app/initializer/StethoInitializer.kt diff --git a/app/build.gradle b/app/build.gradle index 4c8f8e9..bcc1166 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -131,6 +131,7 @@ dependencies { kapt Dependencies.RoomCompiler implementation Dependencies.BaselineProfileInstaller + implementation Dependencies.StartUp implementation(project(Modules.Auth)) implementation(project(Modules.Mail)) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 35023a6..53fb306 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -25,10 +25,24 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/kotlin/github/owlmail/app/OwlMailApp.kt b/app/src/main/kotlin/github/owlmail/app/OwlMailApp.kt index 79c789c..bdffb53 100644 --- a/app/src/main/kotlin/github/owlmail/app/OwlMailApp.kt +++ b/app/src/main/kotlin/github/owlmail/app/OwlMailApp.kt @@ -3,8 +3,6 @@ package github.owlmail.app import android.app.Application import androidx.hilt.work.HiltWorkerFactory import androidx.work.Configuration -import com.facebook.stetho.Stetho -import com.google.firebase.FirebaseApp import dagger.hilt.android.HiltAndroidApp import javax.inject.Inject @@ -17,12 +15,4 @@ class OwlMailApp : Application(), Configuration.Provider { Configuration.Builder() .setWorkerFactory(workerFactory) .build() - - override fun onCreate() { - super.onCreate() - FirebaseApp.initializeApp(this) - if (BuildConfig.DEBUG) { - Stetho.initializeWithDefaults(this) - } - } } diff --git a/app/src/main/kotlin/github/owlmail/app/initializer/FirebaseInitializer.kt b/app/src/main/kotlin/github/owlmail/app/initializer/FirebaseInitializer.kt new file mode 100644 index 0000000..79c9ce0 --- /dev/null +++ b/app/src/main/kotlin/github/owlmail/app/initializer/FirebaseInitializer.kt @@ -0,0 +1,16 @@ +package github.owlmail.app.initializer + +import android.content.Context +import androidx.startup.Initializer +import com.google.firebase.FirebaseApp + +class FirebaseInitializer : Initializer { + + override fun create(context: Context) { + FirebaseApp.initializeApp(context) + } + + override fun dependencies(): List>> { + return emptyList() + } +} \ No newline at end of file diff --git a/app/src/main/kotlin/github/owlmail/app/initializer/StethoInitializer.kt b/app/src/main/kotlin/github/owlmail/app/initializer/StethoInitializer.kt new file mode 100644 index 0000000..c3db008 --- /dev/null +++ b/app/src/main/kotlin/github/owlmail/app/initializer/StethoInitializer.kt @@ -0,0 +1,18 @@ +package github.owlmail.app.initializer + +import android.content.Context +import androidx.startup.Initializer +import com.facebook.stetho.Stetho +import github.owlmail.app.BuildConfig + +class StethoInitializer : Initializer { + override fun create(context: Context) { + if (BuildConfig.DEBUG) { + Stetho.initializeWithDefaults(context) + } + } + + override fun dependencies(): List>> { + return emptyList() + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index e493fc7..0f379cd 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -83,4 +83,6 @@ object Dependencies { // Baseline Profile installer const val BaselineProfileInstaller = "androidx.profileinstaller:profileinstaller:${DependencyVersion.BaselineProfileInstaller}" + + const val StartUp = "androidx.startup:startup-runtime:${DependencyVersion.StartUp}" } diff --git a/buildSrc/src/main/kotlin/DependencyVersion.kt b/buildSrc/src/main/kotlin/DependencyVersion.kt index c16b0c2..ebef4e1 100644 --- a/buildSrc/src/main/kotlin/DependencyVersion.kt +++ b/buildSrc/src/main/kotlin/DependencyVersion.kt @@ -64,4 +64,6 @@ object DependencyVersion { // Baseline Profile installer const val BaselineProfileInstaller = "1.2.2" + + const val StartUp = "1.1.1" }