Loading app-common/build.gradle.kts +5 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,11 @@ dependencies { implementation(projects.legacy.core) implementation(projects.core.android.account) implementation(projects.core.logging.api) implementation(projects.core.logging.implComposite) implementation(projects.core.logging.implConsole) implementation(projects.core.logging.implLegacy) implementation(projects.core.featureflag) implementation(projects.core.ui.legacy.theme2.common) Loading app-common/src/main/kotlin/net/thunderbird/app/common/AppCommonModule.kt +2 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import com.fsck.k9.legacyCommonAppModules import com.fsck.k9.legacyCoreModules import com.fsck.k9.legacyUiModules import net.thunderbird.app.common.account.appCommonAccountModule import net.thunderbird.app.common.core.appCommonCoreModule import net.thunderbird.app.common.feature.appCommonFeatureModule import org.koin.core.module.Module import org.koin.dsl.module Loading @@ -15,6 +16,7 @@ val appCommonModule: Module = module { includes( appCommonAccountModule, appCommonCoreModule, appCommonFeatureModule, ) } app-common/src/main/kotlin/net/thunderbird/app/common/BaseApplication.kt +6 −3 Original line number Diff line number Diff line Loading @@ -11,7 +11,6 @@ import com.fsck.k9.K9 import com.fsck.k9.MessagingListenerProvider import com.fsck.k9.controller.MessagingController import com.fsck.k9.job.WorkManagerConfigurationProvider import com.fsck.k9.logging.Timber import com.fsck.k9.notification.NotificationChannelManager import com.fsck.k9.ui.base.AppLanguageManager import com.fsck.k9.ui.base.extensions.currentLocale Loading @@ -22,6 +21,8 @@ import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.drop import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import net.thunderbird.core.logging.Logger import net.thunderbird.core.logging.legacy.Log import net.thunderbird.core.ui.theme.manager.ThemeManager import org.koin.android.ext.android.inject import org.koin.core.module.Module Loading @@ -36,6 +37,7 @@ abstract class BaseApplication : Application(), WorkManagerConfiguration.Provide private val notificationChannelManager: NotificationChannelManager by inject() private val messageListWidgetManager: MessageListWidgetManager by inject() private val workManagerConfigurationProvider: WorkManagerConfigurationProvider by inject() private val logger: Logger by inject() private val appCoroutineScope: CoroutineScope = MainScope() private var appLanguageManagerInitialized = false Loading @@ -52,6 +54,7 @@ abstract class BaseApplication : Application(), WorkManagerConfiguration.Provide override fun onCreate() { super.onCreate() Log.logger = logger K9.init(this) Core.init(this) initializeAppLanguage() Loading Loading @@ -95,7 +98,7 @@ abstract class BaseApplication : Application(), WorkManagerConfiguration.Provide } private fun updateConfigurationWithLocale(configuration: Configuration, locale: Locale) { Timber.d("Updating application configuration with locale '$locale'") Log.d("Updating application configuration with locale '$locale'") val newConfiguration = Configuration(configuration).apply { currentLocale = locale Loading @@ -119,7 +122,7 @@ abstract class BaseApplication : Application(), WorkManagerConfiguration.Provide if (appLanguageManagerInitialized) { appLanguageManager.getOverrideLocale()?.let { overrideLocale -> if (resources.configuration.currentLocale != overrideLocale) { Timber.w("Resources configuration was reset. Re-applying locale override.") Log.w("Resources configuration was reset. Re-applying locale override.") appLanguageManager.applyOverrideLocale() applyOverrideLocaleToConfiguration() } Loading app-common/src/main/kotlin/net/thunderbird/app/common/account/AccountCreator.kt +2 −2 Original line number Diff line number Diff line Loading @@ -10,7 +10,6 @@ import com.fsck.k9.Core import com.fsck.k9.Preferences import com.fsck.k9.account.DeletePolicyProvider import com.fsck.k9.controller.MessagingController import com.fsck.k9.logging.Timber import com.fsck.k9.mail.ServerSettings import com.fsck.k9.mail.store.imap.ImapStoreSettings.autoDetectNamespace import com.fsck.k9.mail.store.imap.ImapStoreSettings.createExtra Loading @@ -24,6 +23,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import net.thunderbird.core.android.account.LegacyAccount import net.thunderbird.core.common.mail.Protocols import net.thunderbird.core.logging.legacy.Log import net.thunderbird.feature.mail.folder.api.SpecialFolderSelection // TODO Move to feature/account/setup Loading @@ -43,7 +43,7 @@ internal class AccountCreator( return try { withContext(coroutineDispatcher) { AccountCreatorResult.Success(create(account)) } } catch (e: Exception) { Timber.e(e, "Error while creating new account") Log.e(e, "Error while creating new account") AccountCreatorResult.Error(e.message ?: "Unknown create account error") } Loading app-common/src/main/kotlin/net/thunderbird/app/common/core/AppCommonCoreModule.kt 0 → 100644 +37 −0 Original line number Diff line number Diff line package net.thunderbird.app.common.core import net.thunderbird.core.logging.DefaultLogger import net.thunderbird.core.logging.LogLevel import net.thunderbird.core.logging.LogSink import net.thunderbird.core.logging.Logger import net.thunderbird.core.logging.composite.CompositeLogSink import net.thunderbird.core.logging.console.ConsoleLogSink import org.koin.core.module.Module import org.koin.dsl.module val appCommonCoreModule: Module = module { single<LogLevel> { LogLevel.INFO } single<List<LogSink>> { listOf( ConsoleLogSink( level = get(), ), ) } single<LogSink> { CompositeLogSink( level = get(), sinks = get(), ) } single<Logger> { DefaultLogger( sink = get(), ) } } Loading
app-common/build.gradle.kts +5 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,11 @@ dependencies { implementation(projects.legacy.core) implementation(projects.core.android.account) implementation(projects.core.logging.api) implementation(projects.core.logging.implComposite) implementation(projects.core.logging.implConsole) implementation(projects.core.logging.implLegacy) implementation(projects.core.featureflag) implementation(projects.core.ui.legacy.theme2.common) Loading
app-common/src/main/kotlin/net/thunderbird/app/common/AppCommonModule.kt +2 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import com.fsck.k9.legacyCommonAppModules import com.fsck.k9.legacyCoreModules import com.fsck.k9.legacyUiModules import net.thunderbird.app.common.account.appCommonAccountModule import net.thunderbird.app.common.core.appCommonCoreModule import net.thunderbird.app.common.feature.appCommonFeatureModule import org.koin.core.module.Module import org.koin.dsl.module Loading @@ -15,6 +16,7 @@ val appCommonModule: Module = module { includes( appCommonAccountModule, appCommonCoreModule, appCommonFeatureModule, ) }
app-common/src/main/kotlin/net/thunderbird/app/common/BaseApplication.kt +6 −3 Original line number Diff line number Diff line Loading @@ -11,7 +11,6 @@ import com.fsck.k9.K9 import com.fsck.k9.MessagingListenerProvider import com.fsck.k9.controller.MessagingController import com.fsck.k9.job.WorkManagerConfigurationProvider import com.fsck.k9.logging.Timber import com.fsck.k9.notification.NotificationChannelManager import com.fsck.k9.ui.base.AppLanguageManager import com.fsck.k9.ui.base.extensions.currentLocale Loading @@ -22,6 +21,8 @@ import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.drop import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import net.thunderbird.core.logging.Logger import net.thunderbird.core.logging.legacy.Log import net.thunderbird.core.ui.theme.manager.ThemeManager import org.koin.android.ext.android.inject import org.koin.core.module.Module Loading @@ -36,6 +37,7 @@ abstract class BaseApplication : Application(), WorkManagerConfiguration.Provide private val notificationChannelManager: NotificationChannelManager by inject() private val messageListWidgetManager: MessageListWidgetManager by inject() private val workManagerConfigurationProvider: WorkManagerConfigurationProvider by inject() private val logger: Logger by inject() private val appCoroutineScope: CoroutineScope = MainScope() private var appLanguageManagerInitialized = false Loading @@ -52,6 +54,7 @@ abstract class BaseApplication : Application(), WorkManagerConfiguration.Provide override fun onCreate() { super.onCreate() Log.logger = logger K9.init(this) Core.init(this) initializeAppLanguage() Loading Loading @@ -95,7 +98,7 @@ abstract class BaseApplication : Application(), WorkManagerConfiguration.Provide } private fun updateConfigurationWithLocale(configuration: Configuration, locale: Locale) { Timber.d("Updating application configuration with locale '$locale'") Log.d("Updating application configuration with locale '$locale'") val newConfiguration = Configuration(configuration).apply { currentLocale = locale Loading @@ -119,7 +122,7 @@ abstract class BaseApplication : Application(), WorkManagerConfiguration.Provide if (appLanguageManagerInitialized) { appLanguageManager.getOverrideLocale()?.let { overrideLocale -> if (resources.configuration.currentLocale != overrideLocale) { Timber.w("Resources configuration was reset. Re-applying locale override.") Log.w("Resources configuration was reset. Re-applying locale override.") appLanguageManager.applyOverrideLocale() applyOverrideLocaleToConfiguration() } Loading
app-common/src/main/kotlin/net/thunderbird/app/common/account/AccountCreator.kt +2 −2 Original line number Diff line number Diff line Loading @@ -10,7 +10,6 @@ import com.fsck.k9.Core import com.fsck.k9.Preferences import com.fsck.k9.account.DeletePolicyProvider import com.fsck.k9.controller.MessagingController import com.fsck.k9.logging.Timber import com.fsck.k9.mail.ServerSettings import com.fsck.k9.mail.store.imap.ImapStoreSettings.autoDetectNamespace import com.fsck.k9.mail.store.imap.ImapStoreSettings.createExtra Loading @@ -24,6 +23,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import net.thunderbird.core.android.account.LegacyAccount import net.thunderbird.core.common.mail.Protocols import net.thunderbird.core.logging.legacy.Log import net.thunderbird.feature.mail.folder.api.SpecialFolderSelection // TODO Move to feature/account/setup Loading @@ -43,7 +43,7 @@ internal class AccountCreator( return try { withContext(coroutineDispatcher) { AccountCreatorResult.Success(create(account)) } } catch (e: Exception) { Timber.e(e, "Error while creating new account") Log.e(e, "Error while creating new account") AccountCreatorResult.Error(e.message ?: "Unknown create account error") } Loading
app-common/src/main/kotlin/net/thunderbird/app/common/core/AppCommonCoreModule.kt 0 → 100644 +37 −0 Original line number Diff line number Diff line package net.thunderbird.app.common.core import net.thunderbird.core.logging.DefaultLogger import net.thunderbird.core.logging.LogLevel import net.thunderbird.core.logging.LogSink import net.thunderbird.core.logging.Logger import net.thunderbird.core.logging.composite.CompositeLogSink import net.thunderbird.core.logging.console.ConsoleLogSink import org.koin.core.module.Module import org.koin.dsl.module val appCommonCoreModule: Module = module { single<LogLevel> { LogLevel.INFO } single<List<LogSink>> { listOf( ConsoleLogSink( level = get(), ), ) } single<LogSink> { CompositeLogSink( level = get(), sinks = get(), ) } single<Logger> { DefaultLogger( sink = get(), ) } }