mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-01 11:46:57 +01:00
providing a features abstraction for the login
- aims to have a centralised place for all feature login, overrideable by forks and debug flavours
This commit is contained in:
parent
a2a89c1ee8
commit
9e367a8535
@ -31,6 +31,8 @@ import im.vector.app.core.error.DefaultErrorFormatter
|
|||||||
import im.vector.app.core.error.ErrorFormatter
|
import im.vector.app.core.error.ErrorFormatter
|
||||||
import im.vector.app.core.time.Clock
|
import im.vector.app.core.time.Clock
|
||||||
import im.vector.app.core.time.DefaultClock
|
import im.vector.app.core.time.DefaultClock
|
||||||
|
import im.vector.app.features.DefaultVectorFeatures
|
||||||
|
import im.vector.app.features.VectorFeatures
|
||||||
import im.vector.app.features.invite.AutoAcceptInvites
|
import im.vector.app.features.invite.AutoAcceptInvites
|
||||||
import im.vector.app.features.invite.CompileTimeAutoAcceptInvites
|
import im.vector.app.features.invite.CompileTimeAutoAcceptInvites
|
||||||
import im.vector.app.features.navigation.DefaultNavigator
|
import im.vector.app.features.navigation.DefaultNavigator
|
||||||
@ -133,4 +135,9 @@ object VectorStaticModule {
|
|||||||
fun providesCoroutineDispatchers(): CoroutineDispatchers {
|
fun providesCoroutineDispatchers(): CoroutineDispatchers {
|
||||||
return CoroutineDispatchers(io = Dispatchers.IO, computation = Dispatchers.Default)
|
return CoroutineDispatchers(io = Dispatchers.IO, computation = Dispatchers.Default)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
fun providesFeatures(context: Context): VectorFeatures {
|
||||||
|
return DefaultVectorFeatures(context)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021 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.features
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import im.vector.app.R
|
||||||
|
import im.vector.app.features.VectorFeatures.LoginType
|
||||||
|
|
||||||
|
interface VectorFeatures {
|
||||||
|
|
||||||
|
fun loginType(): LoginType
|
||||||
|
|
||||||
|
enum class LoginType {
|
||||||
|
V1,
|
||||||
|
V2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DefaultVectorFeatures(private val context: Context) : VectorFeatures {
|
||||||
|
override fun loginType(): LoginType {
|
||||||
|
val v2LoginIsEnabled = context.resources.getBoolean(R.bool.useLoginV2)
|
||||||
|
return if (v2LoginIsEnabled) {
|
||||||
|
LoginType.V2
|
||||||
|
} else {
|
||||||
|
LoginType.V1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -36,6 +36,7 @@ import im.vector.app.core.di.ActiveSessionHolder
|
|||||||
import im.vector.app.core.error.fatalError
|
import im.vector.app.core.error.fatalError
|
||||||
import im.vector.app.core.platform.VectorBaseActivity
|
import im.vector.app.core.platform.VectorBaseActivity
|
||||||
import im.vector.app.core.utils.toast
|
import im.vector.app.core.utils.toast
|
||||||
|
import im.vector.app.features.VectorFeatures
|
||||||
import im.vector.app.features.call.conference.JitsiCallViewModel
|
import im.vector.app.features.call.conference.JitsiCallViewModel
|
||||||
import im.vector.app.features.call.conference.VectorJitsiActivity
|
import im.vector.app.features.call.conference.VectorJitsiActivity
|
||||||
import im.vector.app.features.call.transfer.CallTransferActivity
|
import im.vector.app.features.call.transfer.CallTransferActivity
|
||||||
@ -104,24 +105,23 @@ class DefaultNavigator @Inject constructor(
|
|||||||
private val vectorPreferences: VectorPreferences,
|
private val vectorPreferences: VectorPreferences,
|
||||||
private val widgetArgsBuilder: WidgetArgsBuilder,
|
private val widgetArgsBuilder: WidgetArgsBuilder,
|
||||||
private val appStateHandler: AppStateHandler,
|
private val appStateHandler: AppStateHandler,
|
||||||
private val supportedVerificationMethodsProvider: SupportedVerificationMethodsProvider
|
private val supportedVerificationMethodsProvider: SupportedVerificationMethodsProvider,
|
||||||
|
private val features: VectorFeatures
|
||||||
) : Navigator {
|
) : Navigator {
|
||||||
|
|
||||||
override fun openLogin(context: Context, loginConfig: LoginConfig?, flags: Int) {
|
override fun openLogin(context: Context, loginConfig: LoginConfig?, flags: Int) {
|
||||||
val intent = if (context.resources.getBoolean(R.bool.useLoginV2)) {
|
val intent = when (features.loginType()) {
|
||||||
LoginActivity2.newIntent(context, loginConfig)
|
VectorFeatures.LoginType.V1 -> LoginActivity.newIntent(context, loginConfig)
|
||||||
} else {
|
VectorFeatures.LoginType.V2 -> LoginActivity2.newIntent(context, loginConfig)
|
||||||
LoginActivity.newIntent(context, loginConfig)
|
|
||||||
}
|
}
|
||||||
intent.addFlags(flags)
|
intent.addFlags(flags)
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun softLogout(context: Context) {
|
override fun softLogout(context: Context) {
|
||||||
val intent = if (context.resources.getBoolean(R.bool.useLoginV2)) {
|
val intent = when (features.loginType()) {
|
||||||
SoftLogoutActivity2.newIntent(context)
|
VectorFeatures.LoginType.V1 -> SoftLogoutActivity.newIntent(context)
|
||||||
} else {
|
VectorFeatures.LoginType.V2 -> SoftLogoutActivity2.newIntent(context)
|
||||||
SoftLogoutActivity.newIntent(context)
|
|
||||||
}
|
}
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user