mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 11:59:12 +03:00
Merge branch 'feature/ons/qr_code_login_ui' into feature/hughns/qr_code_login
This commit is contained in:
commit
dc9b41d19a
11 changed files with 30 additions and 28 deletions
|
@ -3331,7 +3331,7 @@
|
||||||
<string name="device_manager_session_rename_edit_hint">Session name</string>
|
<string name="device_manager_session_rename_edit_hint">Session name</string>
|
||||||
<string name="device_manager_session_rename_description">Custom session names can help you recognize your devices more easily.</string>
|
<string name="device_manager_session_rename_description">Custom session names can help you recognize your devices more easily.</string>
|
||||||
<string name="device_manager_session_rename_warning">Please be aware that session names are also visible to people you communicate with.</string>
|
<string name="device_manager_session_rename_warning">Please be aware that session names are also visible to people you communicate with.</string>
|
||||||
<string name="device_manager_sessions_sign_in_with_qr_code_title">SIGN IN WITH QR CODE</string>
|
<string name="device_manager_sessions_sign_in_with_qr_code_title">Sign in with QR Code</string>
|
||||||
<string name="device_manager_sessions_sign_in_with_qr_code_description">You can use this device to sign in a mobile or web device with a QR code. There are two ways to do this:</string>
|
<string name="device_manager_sessions_sign_in_with_qr_code_description">You can use this device to sign in a mobile or web device with a QR code. There are two ways to do this:</string>
|
||||||
|
|
||||||
<string name="device_manager_learn_more_sessions_inactive_title">Inactive sessions</string>
|
<string name="device_manager_learn_more_sessions_inactive_title">Inactive sessions</string>
|
||||||
|
|
|
@ -55,6 +55,7 @@ import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo035
|
||||||
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo036
|
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo036
|
||||||
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo037
|
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo037
|
||||||
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo038
|
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo038
|
||||||
|
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo039
|
||||||
import org.matrix.android.sdk.internal.util.Normalizer
|
import org.matrix.android.sdk.internal.util.Normalizer
|
||||||
import org.matrix.android.sdk.internal.util.database.MatrixRealmMigration
|
import org.matrix.android.sdk.internal.util.database.MatrixRealmMigration
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -63,7 +64,7 @@ internal class RealmSessionStoreMigration @Inject constructor(
|
||||||
private val normalizer: Normalizer
|
private val normalizer: Normalizer
|
||||||
) : MatrixRealmMigration(
|
) : MatrixRealmMigration(
|
||||||
dbName = "Session",
|
dbName = "Session",
|
||||||
schemaVersion = 38L,
|
schemaVersion = 39L,
|
||||||
) {
|
) {
|
||||||
/**
|
/**
|
||||||
* Forces all RealmSessionStoreMigration instances to be equal.
|
* Forces all RealmSessionStoreMigration instances to be equal.
|
||||||
|
@ -111,5 +112,6 @@ internal class RealmSessionStoreMigration @Inject constructor(
|
||||||
if (oldVersion < 36) MigrateSessionTo036(realm).perform()
|
if (oldVersion < 36) MigrateSessionTo036(realm).perform()
|
||||||
if (oldVersion < 37) MigrateSessionTo037(realm).perform()
|
if (oldVersion < 37) MigrateSessionTo037(realm).perform()
|
||||||
if (oldVersion < 38) MigrateSessionTo038(realm).perform()
|
if (oldVersion < 38) MigrateSessionTo038(realm).perform()
|
||||||
|
if (oldVersion < 39) MigrateSessionTo039(realm).perform()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,9 +133,6 @@ internal class DefaultGetHomeServerCapabilitiesTask @Inject constructor(
|
||||||
homeServerCapabilitiesEntity.roomVersionsJson = capabilities?.roomVersions?.let {
|
homeServerCapabilitiesEntity.roomVersionsJson = capabilities?.roomVersions?.let {
|
||||||
MoshiProvider.providesMoshi().adapter(RoomVersions::class.java).toJson(it)
|
MoshiProvider.providesMoshi().adapter(RoomVersions::class.java).toJson(it)
|
||||||
}
|
}
|
||||||
homeServerCapabilitiesEntity.canUseThreading = /* capabilities?.threads?.enabled.orFalse() || */
|
|
||||||
getVersionResult?.doesServerSupportThreads().orFalse()
|
|
||||||
homeServerCapabilitiesEntity.canLoginWithQrCode = getVersionResult?.doesServerSupportQrCodeLogin().orFalse()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getMediaConfigResult != null) {
|
if (getMediaConfigResult != null) {
|
||||||
|
@ -146,6 +143,9 @@ internal class DefaultGetHomeServerCapabilitiesTask @Inject constructor(
|
||||||
if (getVersionResult != null) {
|
if (getVersionResult != null) {
|
||||||
homeServerCapabilitiesEntity.lastVersionIdentityServerSupported = getVersionResult.isLoginAndRegistrationSupportedBySdk()
|
homeServerCapabilitiesEntity.lastVersionIdentityServerSupported = getVersionResult.isLoginAndRegistrationSupportedBySdk()
|
||||||
homeServerCapabilitiesEntity.canControlLogoutDevices = getVersionResult.doesServerSupportLogoutDevices()
|
homeServerCapabilitiesEntity.canControlLogoutDevices = getVersionResult.doesServerSupportLogoutDevices()
|
||||||
|
homeServerCapabilitiesEntity.canUseThreading = /* capabilities?.threads?.enabled.orFalse() || */
|
||||||
|
getVersionResult.doesServerSupportThreads().orFalse()
|
||||||
|
homeServerCapabilitiesEntity.canLoginWithQrCode = getVersionResult.doesServerSupportQrCodeLogin().orFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getWellknownResult != null && getWellknownResult is WellknownResult.Prompt) {
|
if (getWellknownResult != null && getWellknownResult is WellknownResult.Prompt) {
|
||||||
|
|
|
@ -92,13 +92,13 @@ class DebugFeaturesStateFactory @Inject constructor(
|
||||||
),
|
),
|
||||||
createBooleanFeature(
|
createBooleanFeature(
|
||||||
label = "Allow QR Code Login for all servers",
|
label = "Allow QR Code Login for all servers",
|
||||||
key = DebugFeatureKeys.allowQrCodeLoginForAllServers,
|
key = DebugFeatureKeys.qrCodeLoginForAllServers,
|
||||||
factory = VectorFeatures::allowQrCodeLoginForAllServers
|
factory = VectorFeatures::isQrCodeLoginForAllServers
|
||||||
),
|
),
|
||||||
createBooleanFeature(
|
createBooleanFeature(
|
||||||
label = "Show QR Code Login in Device Manager",
|
label = "Show QR Code Login in Device Manager",
|
||||||
key = DebugFeatureKeys.allowReciprocateQrCodeLogin,
|
key = DebugFeatureKeys.reciprocateQrCodeLogin,
|
||||||
factory = VectorFeatures::allowReciprocateQrCodeLogin
|
factory = VectorFeatures::isReciprocateQrCodeLogin
|
||||||
),
|
),
|
||||||
createBooleanFeature(
|
createBooleanFeature(
|
||||||
label = "Enable Voice Broadcast",
|
label = "Enable Voice Broadcast",
|
||||||
|
|
|
@ -79,11 +79,11 @@ class DebugVectorFeatures(
|
||||||
override fun isQrCodeLoginEnabled() = read(DebugFeatureKeys.qrCodeLoginEnabled)
|
override fun isQrCodeLoginEnabled() = read(DebugFeatureKeys.qrCodeLoginEnabled)
|
||||||
?: vectorFeatures.isQrCodeLoginEnabled()
|
?: vectorFeatures.isQrCodeLoginEnabled()
|
||||||
|
|
||||||
override fun allowQrCodeLoginForAllServers() = read(DebugFeatureKeys.allowQrCodeLoginForAllServers)
|
override fun isQrCodeLoginForAllServers() = read(DebugFeatureKeys.qrCodeLoginForAllServers)
|
||||||
?: vectorFeatures.allowQrCodeLoginForAllServers()
|
?: vectorFeatures.isQrCodeLoginForAllServers()
|
||||||
|
|
||||||
override fun allowReciprocateQrCodeLogin() = read(DebugFeatureKeys.allowReciprocateQrCodeLogin)
|
override fun isReciprocateQrCodeLogin() = read(DebugFeatureKeys.reciprocateQrCodeLogin)
|
||||||
?: vectorFeatures.allowReciprocateQrCodeLogin()
|
?: vectorFeatures.isReciprocateQrCodeLogin()
|
||||||
|
|
||||||
override fun isVoiceBroadcastEnabled(): Boolean = read(DebugFeatureKeys.voiceBroadcastEnabled)
|
override fun isVoiceBroadcastEnabled(): Boolean = read(DebugFeatureKeys.voiceBroadcastEnabled)
|
||||||
?: vectorFeatures.isVoiceBroadcastEnabled()
|
?: vectorFeatures.isVoiceBroadcastEnabled()
|
||||||
|
@ -148,7 +148,7 @@ object DebugFeatureKeys {
|
||||||
val forceUsageOfOpusEncoder = booleanPreferencesKey("force-usage-of-opus-encoder")
|
val forceUsageOfOpusEncoder = booleanPreferencesKey("force-usage-of-opus-encoder")
|
||||||
val newAppLayoutEnabled = booleanPreferencesKey("new-app-layout-enabled")
|
val newAppLayoutEnabled = booleanPreferencesKey("new-app-layout-enabled")
|
||||||
val qrCodeLoginEnabled = booleanPreferencesKey("qr-code-login-enabled")
|
val qrCodeLoginEnabled = booleanPreferencesKey("qr-code-login-enabled")
|
||||||
val allowQrCodeLoginForAllServers = booleanPreferencesKey("allow-qr-code-login-for-all-servers")
|
val qrCodeLoginForAllServers = booleanPreferencesKey("qr-code-login-for-all-servers")
|
||||||
val allowReciprocateQrCodeLogin = booleanPreferencesKey("allow-reciprocate-qr-code-login")
|
val reciprocateQrCodeLogin = booleanPreferencesKey("reciprocate-qr-code-login")
|
||||||
val voiceBroadcastEnabled = booleanPreferencesKey("voice-broadcast-enabled")
|
val voiceBroadcastEnabled = booleanPreferencesKey("voice-broadcast-enabled")
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,8 @@ interface VectorFeatures {
|
||||||
*/
|
*/
|
||||||
fun isNewAppLayoutFeatureEnabled(): Boolean
|
fun isNewAppLayoutFeatureEnabled(): Boolean
|
||||||
fun isQrCodeLoginEnabled(): Boolean
|
fun isQrCodeLoginEnabled(): Boolean
|
||||||
fun allowQrCodeLoginForAllServers(): Boolean
|
fun isQrCodeLoginForAllServers(): Boolean
|
||||||
fun allowReciprocateQrCodeLogin(): Boolean
|
fun isReciprocateQrCodeLogin(): Boolean
|
||||||
fun isVoiceBroadcastEnabled(): Boolean
|
fun isVoiceBroadcastEnabled(): Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ 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 isQrCodeLoginEnabled(): Boolean = false
|
override fun isQrCodeLoginEnabled(): Boolean = false
|
||||||
override fun allowQrCodeLoginForAllServers(): Boolean = false
|
override fun isQrCodeLoginForAllServers(): Boolean = false
|
||||||
override fun allowReciprocateQrCodeLogin(): Boolean = false
|
override fun isReciprocateQrCodeLogin(): Boolean = false
|
||||||
override fun isVoiceBroadcastEnabled(): Boolean = false
|
override fun isVoiceBroadcastEnabled(): Boolean = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import dagger.hilt.android.AndroidEntryPoint
|
||||||
import im.vector.app.core.extensions.addFragment
|
import im.vector.app.core.extensions.addFragment
|
||||||
import im.vector.app.core.platform.SimpleFragmentActivity
|
import im.vector.app.core.platform.SimpleFragmentActivity
|
||||||
import im.vector.app.features.home.HomeActivity
|
import im.vector.app.features.home.HomeActivity
|
||||||
|
import im.vector.lib.core.utils.compat.getParcelableCompat
|
||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ class QrCodeLoginActivity : SimpleFragmentActivity() {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
views.toolbar.visibility = View.GONE
|
views.toolbar.visibility = View.GONE
|
||||||
|
|
||||||
val qrCodeLoginArgs: QrCodeLoginArgs? = intent?.extras?.getParcelable(Mavericks.KEY_ARG)
|
val qrCodeLoginArgs: QrCodeLoginArgs? = intent?.extras?.getParcelableCompat(Mavericks.KEY_ARG)
|
||||||
if (isFirstCreation()) {
|
if (isFirstCreation()) {
|
||||||
when (qrCodeLoginArgs?.loginType) {
|
when (qrCodeLoginArgs?.loginType) {
|
||||||
QrCodeLoginType.LOGIN -> {
|
QrCodeLoginType.LOGIN -> {
|
||||||
|
|
|
@ -44,7 +44,7 @@ class QrCodeLoginShowQrCodeFragment : VectorBaseFragment<FragmentQrCodeLoginShow
|
||||||
|
|
||||||
private fun initCancelButton() {
|
private fun initCancelButton() {
|
||||||
views.qrCodeLoginShowQrCodeCancelButton.debouncedClicks {
|
views.qrCodeLoginShowQrCodeCancelButton.debouncedClicks {
|
||||||
activity?.onBackPressed()
|
activity?.onBackPressedDispatcher?.onBackPressed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ class QrCodeLoginStatusFragment : VectorBaseFragment<FragmentQrCodeLoginStatusBi
|
||||||
|
|
||||||
private fun initCancelButton() {
|
private fun initCancelButton() {
|
||||||
views.qrCodeLoginStatusCancelButton.debouncedClicks {
|
views.qrCodeLoginStatusCancelButton.debouncedClicks {
|
||||||
activity?.onBackPressed()
|
activity?.onBackPressedDispatcher?.onBackPressed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,14 +118,14 @@ class OnboardingViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeQrCodeLoginCapability() = viewModelScope.launch {
|
private fun observeQrCodeLoginCapability(homeServerUrl: String) = viewModelScope.launch {
|
||||||
if (!vectorFeatures.isQrCodeLoginEnabled()) {
|
if (!vectorFeatures.isQrCodeLoginEnabled()) {
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
canLoginWithQrCode = false
|
canLoginWithQrCode = false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else if (vectorFeatures.allowQrCodeLoginForAllServers()) {
|
} else if (vectorFeatures.isQrCodeLoginForAllServers()) {
|
||||||
// allow for all servers
|
// allow for all servers
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
|
@ -134,8 +134,7 @@ class OnboardingViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// check if selected server supports MSC3882 first
|
// check if selected server supports MSC3882 first
|
||||||
// FIXME: this should be checking the selected homeserver not defaultHomeserverUrl
|
homeServerConnectionConfigFactory.create(homeServerUrl)?.let {
|
||||||
homeServerConnectionConfigFactory.create(defaultHomeserverUrl)?.let {
|
|
||||||
val canLoginWithQrCode = authenticationService.isQrLoginSupported(it)
|
val canLoginWithQrCode = authenticationService.isQrLoginSupported(it)
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
|
@ -263,7 +262,6 @@ class OnboardingViewModel @AssistedInject constructor(
|
||||||
private fun handleSplashAction(action: OnboardingAction.SplashAction) {
|
private fun handleSplashAction(action: OnboardingAction.SplashAction) {
|
||||||
setState { copy(onboardingFlow = action.onboardingFlow) }
|
setState { copy(onboardingFlow = action.onboardingFlow) }
|
||||||
continueToPageAfterSplash(action.onboardingFlow)
|
continueToPageAfterSplash(action.onboardingFlow)
|
||||||
observeQrCodeLoginCapability()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun continueToPageAfterSplash(onboardingFlow: OnboardingFlow) {
|
private fun continueToPageAfterSplash(onboardingFlow: OnboardingFlow) {
|
||||||
|
@ -709,6 +707,7 @@ class OnboardingViewModel @AssistedInject constructor(
|
||||||
_viewEvents.post(OnboardingViewEvents.Failure(Throwable("Unable to create a HomeServerConnectionConfig")))
|
_viewEvents.post(OnboardingViewEvents.Failure(Throwable("Unable to create a HomeServerConnectionConfig")))
|
||||||
} else {
|
} else {
|
||||||
startAuthenticationFlow(action, homeServerConnectionConfig, serverTypeOverride, postAction)
|
startAuthenticationFlow(action, homeServerConnectionConfig, serverTypeOverride, postAction)
|
||||||
|
observeQrCodeLoginCapability(homeServerConnectionConfig.homeServerUri.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,7 @@ class VectorSettingsDevicesFragment :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initQrLoginView() {
|
private fun initQrLoginView() {
|
||||||
if (!vectorFeatures.allowReciprocateQrCodeLogin()) {
|
if (!vectorFeatures.isReciprocateQrCodeLogin()) {
|
||||||
views.deviceListHeaderSignInWithQrCode.isVisible = false
|
views.deviceListHeaderSignInWithQrCode.isVisible = false
|
||||||
views.deviceListHeaderScanQrCodeButton.isVisible = false
|
views.deviceListHeaderScanQrCodeButton.isVisible = false
|
||||||
views.deviceListHeaderShowQrCodeButton.isVisible = false
|
views.deviceListHeaderShowQrCodeButton.isVisible = false
|
||||||
|
|
Loading…
Reference in a new issue