mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-26 02:48:24 +01:00
parent
3bf70b230f
commit
15e3f28aa3
@ -1,9 +0,0 @@
|
||||
package mihon.core.firebase
|
||||
|
||||
import android.content.Context
|
||||
import eu.kanade.tachiyomi.core.security.PrivacyPreferences
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
||||
object Firebase {
|
||||
fun setup(context: Context, preference: PrivacyPreferences, scope: CoroutineScope) = Unit
|
||||
}
|
11
app/src/dev/java/mihon/core/firebase/FirebaseConfig.kt
Normal file
11
app/src/dev/java/mihon/core/firebase/FirebaseConfig.kt
Normal file
@ -0,0 +1,11 @@
|
||||
package mihon.core.firebase
|
||||
|
||||
import android.content.Context
|
||||
|
||||
object FirebaseConfig {
|
||||
fun init(context: Context) = Unit
|
||||
|
||||
fun setAnalyticsEnabled(enabled: Boolean) = Unit
|
||||
|
||||
fun setCrashlyticsEnabled(enabled: Boolean) = Unit
|
||||
}
|
@ -51,7 +51,7 @@ import kotlinx.coroutines.flow.onEach
|
||||
import logcat.AndroidLogcatLogger
|
||||
import logcat.LogPriority
|
||||
import logcat.LogcatLogger
|
||||
import mihon.core.firebase.Firebase
|
||||
import mihon.core.firebase.FirebaseConfig
|
||||
import mihon.core.migration.Migrator
|
||||
import mihon.core.migration.migrations.migrations
|
||||
import org.conscrypt.Conscrypt
|
||||
@ -78,6 +78,7 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
|
||||
override fun onCreate() {
|
||||
super<Application>.onCreate()
|
||||
patchInjekt()
|
||||
FirebaseConfig.init(applicationContext)
|
||||
|
||||
GlobalExceptionHandler.initialize(applicationContext, CrashActivity::class.java)
|
||||
|
||||
@ -96,12 +97,12 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
|
||||
Injekt.importModule(AppModule(this))
|
||||
Injekt.importModule(DomainModule())
|
||||
|
||||
Firebase.setup(applicationContext, privacyPreferences, ProcessLifecycleOwner.get().lifecycleScope)
|
||||
|
||||
setupNotificationChannels()
|
||||
|
||||
ProcessLifecycleOwner.get().lifecycle.addObserver(this)
|
||||
|
||||
val scope = ProcessLifecycleOwner.get().lifecycleScope
|
||||
|
||||
// Show notification to disable Incognito Mode when it's enabled
|
||||
basePreferences.incognitoMode().changes()
|
||||
.onEach { enabled ->
|
||||
@ -129,14 +130,22 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
|
||||
cancelNotification(Notifications.ID_INCOGNITO_MODE)
|
||||
}
|
||||
}
|
||||
.launchIn(ProcessLifecycleOwner.get().lifecycleScope)
|
||||
.launchIn(scope)
|
||||
|
||||
privacyPreferences.analytics()
|
||||
.changes()
|
||||
.onEach(FirebaseConfig::setAnalyticsEnabled)
|
||||
.launchIn(scope)
|
||||
|
||||
privacyPreferences.crashlytics()
|
||||
.changes()
|
||||
.onEach(FirebaseConfig::setCrashlyticsEnabled)
|
||||
.launchIn(scope)
|
||||
|
||||
setAppCompatDelegateThemeMode(Injekt.get<UiPreferences>().themeMode().get())
|
||||
|
||||
// Updates widget update
|
||||
with(WidgetManager(Injekt.get(), Injekt.get())) {
|
||||
init(ProcessLifecycleOwner.get().lifecycleScope)
|
||||
}
|
||||
WidgetManager(Injekt.get(), Injekt.get()).apply { init(scope) }
|
||||
|
||||
if (!LogcatLogger.isInstalled && networkPreferences.verboseLogging().get()) {
|
||||
LogcatLogger.install(AndroidLogcatLogger(LogPriority.VERBOSE))
|
||||
|
@ -1,20 +0,0 @@
|
||||
package mihon.core.firebase
|
||||
|
||||
import android.content.Context
|
||||
import com.google.firebase.analytics.FirebaseAnalytics
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import eu.kanade.tachiyomi.core.security.PrivacyPreferences
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
||||
object Firebase {
|
||||
fun setup(context: Context, preference: PrivacyPreferences, scope: CoroutineScope) {
|
||||
preference.analytics().changes().onEach { enabled ->
|
||||
FirebaseAnalytics.getInstance(context).setAnalyticsCollectionEnabled(enabled)
|
||||
}.launchIn(scope)
|
||||
preference.crashlytics().changes().onEach { enabled ->
|
||||
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(enabled)
|
||||
}.launchIn(scope)
|
||||
}
|
||||
}
|
25
app/src/standard/java/mihon/core/firebase/FirebaseConfig.kt
Normal file
25
app/src/standard/java/mihon/core/firebase/FirebaseConfig.kt
Normal file
@ -0,0 +1,25 @@
|
||||
package mihon.core.firebase
|
||||
|
||||
import android.content.Context
|
||||
import com.google.firebase.FirebaseApp
|
||||
import com.google.firebase.analytics.FirebaseAnalytics
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
|
||||
object FirebaseConfig {
|
||||
private lateinit var analytics: FirebaseAnalytics
|
||||
private lateinit var crashlytics: FirebaseCrashlytics
|
||||
|
||||
fun init(context: Context) {
|
||||
analytics = FirebaseAnalytics.getInstance(context)
|
||||
FirebaseApp.initializeApp(context)
|
||||
crashlytics = FirebaseCrashlytics.getInstance()
|
||||
}
|
||||
|
||||
fun setAnalyticsEnabled(enabled: Boolean) {
|
||||
analytics.setAnalyticsCollectionEnabled(enabled)
|
||||
}
|
||||
|
||||
fun setCrashlyticsEnabled(enabled: Boolean) {
|
||||
crashlytics.isCrashlyticsCollectionEnabled = enabled
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user