mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-28 14:08:44 +03:00
extracting the config models to their own files
This commit is contained in:
parent
cc4aae0f4a
commit
9fe3fc69dd
6 changed files with 112 additions and 83 deletions
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.app.config
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The types of analytics Element currently supports.
|
||||||
|
*/
|
||||||
|
sealed interface Analytics {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables the analytics integrations.
|
||||||
|
*/
|
||||||
|
object Disabled : Analytics
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Analytics integration via PostHog.
|
||||||
|
*/
|
||||||
|
data class PostHog(
|
||||||
|
/**
|
||||||
|
* The PostHog instance url.
|
||||||
|
*/
|
||||||
|
val postHogHost: String,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The PostHog instance API key.
|
||||||
|
*/
|
||||||
|
val postHogApiKey: String,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A URL to more information about the analytics collection.
|
||||||
|
*/
|
||||||
|
val policyLink: String,
|
||||||
|
) : Analytics
|
||||||
|
}
|
|
@ -87,58 +87,3 @@ object Config {
|
||||||
*/
|
*/
|
||||||
val NIGHTLY_ANALYTICS_CONFIG = RELEASE_ANALYTICS_CONFIG
|
val NIGHTLY_ANALYTICS_CONFIG = RELEASE_ANALYTICS_CONFIG
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The types of analytics Element currently supports.
|
|
||||||
*/
|
|
||||||
sealed interface Analytics {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disables the analytics integrations.
|
|
||||||
*/
|
|
||||||
object Disabled : Analytics
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Analytics integration via PostHog.
|
|
||||||
*/
|
|
||||||
data class PostHog(
|
|
||||||
/**
|
|
||||||
* The PostHog instance url.
|
|
||||||
*/
|
|
||||||
val postHogHost: String,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The PostHog instance API key.
|
|
||||||
*/
|
|
||||||
val postHogApiKey: String,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A URL to more information about the analytics collection.
|
|
||||||
*/
|
|
||||||
val policyLink: String,
|
|
||||||
) : Analytics
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class OnboardingVariant {
|
|
||||||
LEGACY,
|
|
||||||
LOGIN_2,
|
|
||||||
FTUE_AUTH
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class KeySharingStrategy {
|
|
||||||
/**
|
|
||||||
* Keys will be sent for the first time when the first message is sent.
|
|
||||||
* This is handled by the Matrix SDK so there's no need to do it in Vector.
|
|
||||||
*/
|
|
||||||
WhenSendingEvent,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Keys will be sent for the first time when the timeline displayed.
|
|
||||||
*/
|
|
||||||
WhenEnteringRoom,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Keys will be sent for the first time when a typing started.
|
|
||||||
*/
|
|
||||||
WhenTyping
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.app.config
|
||||||
|
|
||||||
|
enum class KeySharingStrategy {
|
||||||
|
/**
|
||||||
|
* Keys will be sent for the first time when the first message is sent.
|
||||||
|
* This is handled by the Matrix SDK so there's no need to do it in Vector.
|
||||||
|
*/
|
||||||
|
WhenSendingEvent,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keys will be sent for the first time when the timeline displayed.
|
||||||
|
*/
|
||||||
|
WhenEnteringRoom,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keys will be sent for the first time when a typing started.
|
||||||
|
*/
|
||||||
|
WhenTyping
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.app.config
|
||||||
|
|
||||||
|
enum class OnboardingVariant {
|
||||||
|
LEGACY,
|
||||||
|
LOGIN_2,
|
||||||
|
FTUE_AUTH
|
||||||
|
}
|
|
@ -37,10 +37,12 @@ import im.vector.app.features.raw.wellknown.CryptoConfig
|
||||||
object ConfigurationModule {
|
object ConfigurationModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
fun providesAnalyticsConfig(buildMeta: BuildMeta): AnalyticsConfig {
|
fun providesAnalyticsConfig(): AnalyticsConfig {
|
||||||
val config: Analytics = when (buildMeta.isDebug) {
|
val config: Analytics = when (BuildConfig.BUILD_TYPE) {
|
||||||
true -> Config.DEBUG_ANALYTICS_CONFIG
|
"debug" -> Config.DEBUG_ANALYTICS_CONFIG
|
||||||
false -> Config.RELEASE_ANALYTICS_CONFIG
|
"nightly" -> Config.NIGHTLY_ANALYTICS_CONFIG
|
||||||
|
"release" -> Config.RELEASE_ANALYTICS_CONFIG
|
||||||
|
else -> throw IllegalStateException("Unhandled build type: ${BuildConfig.BUILD_TYPE}")
|
||||||
}
|
}
|
||||||
return when (config) {
|
return when (config) {
|
||||||
Analytics.Disabled -> AnalyticsConfig(isEnabled = false, "", "", "")
|
Analytics.Disabled -> AnalyticsConfig(isEnabled = false, "", "", "")
|
||||||
|
|
|
@ -211,30 +211,6 @@ object VectorStaticModule {
|
||||||
@Provides
|
@Provides
|
||||||
fun providesPhoneNumberUtil(): PhoneNumberUtil = PhoneNumberUtil.getInstance()
|
fun providesPhoneNumberUtil(): PhoneNumberUtil = PhoneNumberUtil.getInstance()
|
||||||
|
|
||||||
@Provides
|
|
||||||
fun providesAnalyticsConfig(): AnalyticsConfig {
|
|
||||||
val config: Analytics = when (BuildConfig.BUILD_TYPE) {
|
|
||||||
"debug" -> Config.DEBUG_ANALYTICS_CONFIG
|
|
||||||
"nightly" -> Config.NIGHTLY_ANALYTICS_CONFIG
|
|
||||||
"release" -> Config.RELEASE_ANALYTICS_CONFIG
|
|
||||||
else -> throw IllegalStateException("Unhandled build type: ${BuildConfig.BUILD_TYPE}")
|
|
||||||
}
|
|
||||||
return when (config) {
|
|
||||||
Analytics.Disabled -> AnalyticsConfig(isEnabled = false, "", "", "")
|
|
||||||
is Analytics.PostHog -> AnalyticsConfig(
|
|
||||||
isEnabled = true,
|
|
||||||
postHogHost = config.postHogHost,
|
|
||||||
postHogApiKey = config.postHogApiKey,
|
|
||||||
policyLink = config.policyLink
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
fun providesVoiceMessageConfig() = VoiceMessageConfig(
|
|
||||||
lengthLimitMs = Config.VOICE_MESSAGE_LIMIT_MS
|
|
||||||
)
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun providesBuildMeta() = BuildMeta(
|
fun providesBuildMeta() = BuildMeta(
|
||||||
|
|
Loading…
Reference in a new issue