mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 02:15:35 +03:00
Add flag for qr code login.
This commit is contained in:
parent
f272e566b0
commit
d8ea9c8215
5 changed files with 40 additions and 9 deletions
|
@ -90,6 +90,11 @@ class DebugFeaturesStateFactory @Inject constructor(
|
||||||
key = DebugFeatureKeys.newDeviceManagementEnabled,
|
key = DebugFeatureKeys.newDeviceManagementEnabled,
|
||||||
factory = VectorFeatures::isNewDeviceManagementEnabled
|
factory = VectorFeatures::isNewDeviceManagementEnabled
|
||||||
),
|
),
|
||||||
|
createBooleanFeature(
|
||||||
|
label = "Enable QR Code Login",
|
||||||
|
key = DebugFeatureKeys.qrCodeLoginEnabled,
|
||||||
|
factory = VectorFeatures::isQrCodeLoginEnabled
|
||||||
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,9 @@ class DebugVectorFeatures(
|
||||||
override fun isNewDeviceManagementEnabled(): Boolean = read(DebugFeatureKeys.newDeviceManagementEnabled)
|
override fun isNewDeviceManagementEnabled(): Boolean = read(DebugFeatureKeys.newDeviceManagementEnabled)
|
||||||
?: vectorFeatures.isNewDeviceManagementEnabled()
|
?: vectorFeatures.isNewDeviceManagementEnabled()
|
||||||
|
|
||||||
|
override fun isQrCodeLoginEnabled() = read(DebugFeatureKeys.qrCodeLoginEnabled)
|
||||||
|
?: vectorFeatures.isQrCodeLoginEnabled()
|
||||||
|
|
||||||
fun <T> override(value: T?, key: Preferences.Key<T>) = updatePreferences {
|
fun <T> override(value: T?, key: Preferences.Key<T>) = updatePreferences {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
it.remove(key)
|
it.remove(key)
|
||||||
|
@ -140,4 +143,5 @@ object DebugFeatureKeys {
|
||||||
val startDmOnFirstMsg = booleanPreferencesKey("start-dm-on-first-msg")
|
val startDmOnFirstMsg = booleanPreferencesKey("start-dm-on-first-msg")
|
||||||
val newAppLayoutEnabled = booleanPreferencesKey("new-app-layout-enabled")
|
val newAppLayoutEnabled = booleanPreferencesKey("new-app-layout-enabled")
|
||||||
val newDeviceManagementEnabled = booleanPreferencesKey("new-device-management-enabled")
|
val newDeviceManagementEnabled = booleanPreferencesKey("new-device-management-enabled")
|
||||||
|
val qrCodeLoginEnabled = booleanPreferencesKey("qr-code-login-enabled")
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ interface VectorFeatures {
|
||||||
*/
|
*/
|
||||||
fun isNewAppLayoutFeatureEnabled(): Boolean
|
fun isNewAppLayoutFeatureEnabled(): Boolean
|
||||||
fun isNewDeviceManagementEnabled(): Boolean
|
fun isNewDeviceManagementEnabled(): Boolean
|
||||||
|
fun isQrCodeLoginEnabled(): Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
class DefaultVectorFeatures : VectorFeatures {
|
class DefaultVectorFeatures : VectorFeatures {
|
||||||
|
@ -57,4 +58,5 @@ class DefaultVectorFeatures : VectorFeatures {
|
||||||
override fun forceUsageOfOpusEncoder(): Boolean = false
|
override fun forceUsageOfOpusEncoder(): Boolean = false
|
||||||
override fun isNewAppLayoutFeatureEnabled(): Boolean = true
|
override fun isNewAppLayoutFeatureEnabled(): Boolean = true
|
||||||
override fun isNewDeviceManagementEnabled(): Boolean = false
|
override fun isNewDeviceManagementEnabled(): Boolean = false
|
||||||
|
override fun isQrCodeLoginEnabled(): Boolean = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import im.vector.app.core.extensions.setOnFocusLostListener
|
||||||
import im.vector.app.core.extensions.setOnImeDoneListener
|
import im.vector.app.core.extensions.setOnImeDoneListener
|
||||||
import im.vector.app.core.extensions.toReducedUrl
|
import im.vector.app.core.extensions.toReducedUrl
|
||||||
import im.vector.app.databinding.FragmentFtueCombinedLoginBinding
|
import im.vector.app.databinding.FragmentFtueCombinedLoginBinding
|
||||||
|
import im.vector.app.features.VectorFeatures
|
||||||
import im.vector.app.features.login.LoginMode
|
import im.vector.app.features.login.LoginMode
|
||||||
import im.vector.app.features.login.SSORedirectRouterActivity
|
import im.vector.app.features.login.SSORedirectRouterActivity
|
||||||
import im.vector.app.features.login.SocialLoginButtonsView
|
import im.vector.app.features.login.SocialLoginButtonsView
|
||||||
|
@ -57,6 +58,7 @@ class FtueAuthCombinedLoginFragment :
|
||||||
|
|
||||||
@Inject lateinit var loginFieldsValidation: LoginFieldsValidation
|
@Inject lateinit var loginFieldsValidation: LoginFieldsValidation
|
||||||
@Inject lateinit var loginErrorParser: LoginErrorParser
|
@Inject lateinit var loginErrorParser: LoginErrorParser
|
||||||
|
@Inject lateinit var vectorFeatures: VectorFeatures
|
||||||
|
|
||||||
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentFtueCombinedLoginBinding {
|
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentFtueCombinedLoginBinding {
|
||||||
return FragmentFtueCombinedLoginBinding.inflate(inflater, container, false)
|
return FragmentFtueCombinedLoginBinding.inflate(inflater, container, false)
|
||||||
|
@ -72,15 +74,19 @@ class FtueAuthCombinedLoginFragment :
|
||||||
viewModel.handle(OnboardingAction.UserNameEnteredAction.Login(views.loginInput.content()))
|
viewModel.handle(OnboardingAction.UserNameEnteredAction.Login(views.loginInput.content()))
|
||||||
}
|
}
|
||||||
views.loginForgotPassword.debouncedClicks { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnForgetPasswordClicked)) }
|
views.loginForgotPassword.debouncedClicks { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnForgetPasswordClicked)) }
|
||||||
views.loginWithQrCode.debouncedClicks {
|
if (vectorFeatures.isQrCodeLoginEnabled()) {
|
||||||
navigator
|
views.loginWithQrCode.debouncedClicks {
|
||||||
.openLoginWithQrCode(
|
navigator
|
||||||
requireActivity(),
|
.openLoginWithQrCode(
|
||||||
QrCodeLoginArgs(
|
requireActivity(),
|
||||||
loginType = QrCodeLoginType.LOGIN,
|
QrCodeLoginArgs(
|
||||||
showQrCodeByDefault = false,
|
loginType = QrCodeLoginType.LOGIN,
|
||||||
)
|
showQrCodeByDefault = false,
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
views.loginWithQrCode.isVisible = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ import im.vector.app.core.platform.VectorBaseFragment
|
||||||
import im.vector.app.core.resources.ColorProvider
|
import im.vector.app.core.resources.ColorProvider
|
||||||
import im.vector.app.core.resources.DrawableProvider
|
import im.vector.app.core.resources.DrawableProvider
|
||||||
import im.vector.app.databinding.FragmentSettingsDevicesBinding
|
import im.vector.app.databinding.FragmentSettingsDevicesBinding
|
||||||
|
import im.vector.app.features.VectorFeatures
|
||||||
import im.vector.app.features.crypto.recover.SetupMode
|
import im.vector.app.features.crypto.recover.SetupMode
|
||||||
import im.vector.app.features.crypto.verification.VerificationBottomSheet
|
import im.vector.app.features.crypto.verification.VerificationBottomSheet
|
||||||
import im.vector.app.features.login.qr.QrCodeLoginArgs
|
import im.vector.app.features.login.qr.QrCodeLoginArgs
|
||||||
|
@ -64,6 +65,8 @@ class VectorSettingsDevicesFragment :
|
||||||
|
|
||||||
@Inject lateinit var colorProvider: ColorProvider
|
@Inject lateinit var colorProvider: ColorProvider
|
||||||
|
|
||||||
|
@Inject lateinit var vectorFeatures: VectorFeatures
|
||||||
|
|
||||||
private val viewModel: DevicesViewModel by fragmentViewModel()
|
private val viewModel: DevicesViewModel by fragmentViewModel()
|
||||||
|
|
||||||
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentSettingsDevicesBinding {
|
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentSettingsDevicesBinding {
|
||||||
|
@ -154,6 +157,17 @@ class VectorSettingsDevicesFragment :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initQrLoginView() {
|
private fun initQrLoginView() {
|
||||||
|
if (!vectorFeatures.isQrCodeLoginEnabled()) {
|
||||||
|
views.deviceListHeaderSignInWithQrCode.isVisible = false
|
||||||
|
views.deviceListHeaderScanQrCodeButton.isVisible = false
|
||||||
|
views.deviceListHeaderShowQrCodeButton.isVisible = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
views.deviceListHeaderSignInWithQrCode.isVisible = true
|
||||||
|
views.deviceListHeaderScanQrCodeButton.isVisible = true
|
||||||
|
views.deviceListHeaderShowQrCodeButton.isVisible = true
|
||||||
|
|
||||||
views.deviceListHeaderScanQrCodeButton.debouncedClicks {
|
views.deviceListHeaderScanQrCodeButton.debouncedClicks {
|
||||||
navigator
|
navigator
|
||||||
.openLoginWithQrCode(
|
.openLoginWithQrCode(
|
||||||
|
|
Loading…
Reference in a new issue