Skip to content

Commit

Permalink
Progress?
Browse files Browse the repository at this point in the history
  • Loading branch information
Animeboynz committed Sep 21, 2024
1 parent de7e394 commit 0a33026
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/src/dev/java/mihon/core/firebase/Firebase.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import android.content.Context
import eu.kanade.domain.base.BasePreferences
import eu.kanade.tachiyomi.core.security.SecurityPreferences

object Firebase {
fun setup(context: Context, preference: BasePreferences) = Unit
fun setup(context: Context, preference: SecurityPreferences) = Unit
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,19 @@ internal class PermissionStep : OnboardingStep {
subtitle = stringResource(MR.strings.onboarding_permission_crashlytics_description),
granted = allowCrashLogs,
onButtonClick = {
// Toggle the granted state
allowCrashLogs = !allowCrashLogs
securityPreferences.crashlytics().set(allowCrashLogs)
}
},
)

PermissionItem(
title = stringResource(MR.strings.onboarding_permission_analytics),
subtitle = stringResource(MR.strings.onboarding_permission_analytics_description),
granted = allowAnalytics,
onButtonClick = {
// Toggle the granted state
allowAnalytics = !allowAnalytics
securityPreferences.analytics().set(allowAnalytics)
}
},
)
}
}
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/eu/kanade/tachiyomi/App.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package eu.kanade.tachiyomi

import Firebase
import android.annotation.SuppressLint
import android.app.Application
import android.app.PendingIntent
Expand All @@ -27,6 +26,7 @@ import eu.kanade.domain.DomainModule
import eu.kanade.domain.base.BasePreferences
import eu.kanade.domain.ui.UiPreferences
import eu.kanade.domain.ui.model.setAppCompatDelegateThemeMode
import eu.kanade.tachiyomi.core.security.SecurityPreferences
import eu.kanade.tachiyomi.crash.CrashActivity
import eu.kanade.tachiyomi.crash.GlobalExceptionHandler
import eu.kanade.tachiyomi.data.coil.BufferedSourceFetcher
Expand All @@ -51,6 +51,7 @@ import kotlinx.coroutines.flow.onEach
import logcat.AndroidLogcatLogger
import logcat.LogPriority
import logcat.LogcatLogger
import mihon.core.firebase.Firebase
import mihon.core.migration.Migrator
import mihon.core.migration.migrations.migrations
import org.conscrypt.Conscrypt
Expand All @@ -68,6 +69,7 @@ import java.security.Security
class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factory {

private val basePreferences: BasePreferences by injectLazy()
private val securityPreferences: SecurityPreferences by injectLazy()
private val networkPreferences: NetworkPreferences by injectLazy()

private val disableIncognitoReceiver = DisableIncognitoReceiver()
Expand All @@ -76,7 +78,7 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
override fun onCreate() {
super<Application>.onCreate()
patchInjekt()
Firebase.setup(applicationContext, basePreferences)
Firebase.setup(applicationContext, securityPreferences)

GlobalExceptionHandler.initialize(applicationContext, CrashActivity::class.java)

Expand Down
11 changes: 8 additions & 3 deletions app/src/standard/java/mihon/core/firebase/Firebase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ package mihon.core.firebase

import android.content.Context
import com.google.firebase.analytics.FirebaseAnalytics
import eu.kanade.domain.base.BasePreferences
import com.google.firebase.crashlytics.FirebaseCrashlytics
import eu.kanade.tachiyomi.core.security.SecurityPreferences
import kotlinx.coroutines.flow.onEach

object Firebase {
fun setup(context: Context, preference: BasePreferences) {
preference.incognitoMode().changes().onEach { enabled ->
fun setup(context: Context, preference: SecurityPreferences) {
preference.analytics().changes().onEach { enabled ->
FirebaseAnalytics.getInstance(context).setAnalyticsCollectionEnabled(enabled)
}
preference.crashlytics().changes().onEach { enabled ->
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(enabled)
}
}
}

0 comments on commit 0a33026

Please sign in to comment.