-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add QR code login. * Add FF to disable it in release mode. * Force portrait orientation on the login flow. * Create `NumberedList` UI components. * Improve camera permission dialog. * Make nodes in qrcode feature use `QrCodeLoginScope` instead of `AppScope` * Bump SDK version. * Fix maestro tests --------- Co-authored-by: Benoit Marty <benoit@matrix.org> Co-authored-by: ElementBot <benoitm+elementbot@element.io>
- Loading branch information
1 parent
e29f919
commit c8bd04c
Showing
253 changed files
with
4,421 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
*/ | ||
plugins { | ||
id("io.element.android-library") | ||
id("kotlin-parcelize") | ||
} | ||
|
||
android { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...gin/impl/src/main/kotlin/io/element/android/features/login/impl/di/QrCodeLoginBindings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2024 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 io.element.android.features.login.impl.di | ||
|
||
import com.squareup.anvil.annotations.ContributesTo | ||
import io.element.android.features.login.impl.qrcode.QrCodeLoginManager | ||
|
||
@ContributesTo(QrCodeLoginScope::class) | ||
interface QrCodeLoginBindings { | ||
fun qrCodeLoginManager(): QrCodeLoginManager | ||
} |
38 changes: 38 additions & 0 deletions
38
...in/impl/src/main/kotlin/io/element/android/features/login/impl/di/QrCodeLoginComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2024 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 io.element.android.features.login.impl.di | ||
|
||
import com.squareup.anvil.annotations.ContributesTo | ||
import com.squareup.anvil.annotations.MergeSubcomponent | ||
import dagger.Subcomponent | ||
import io.element.android.libraries.architecture.NodeFactoriesBindings | ||
import io.element.android.libraries.di.AppScope | ||
import io.element.android.libraries.di.SingleIn | ||
|
||
@SingleIn(QrCodeLoginScope::class) | ||
@MergeSubcomponent(QrCodeLoginScope::class) | ||
interface QrCodeLoginComponent : NodeFactoriesBindings { | ||
@Subcomponent.Builder | ||
interface Builder { | ||
fun build(): QrCodeLoginComponent | ||
} | ||
|
||
@ContributesTo(AppScope::class) | ||
interface ParentBindings { | ||
fun qrCodeLoginComponentBuilder(): Builder | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../login/impl/src/main/kotlin/io/element/android/features/login/impl/di/QrCodeLoginScope.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright (c) 2024 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 io.element.android.features.login.impl.di | ||
|
||
abstract class QrCodeLoginScope private constructor() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...rc/main/kotlin/io/element/android/features/login/impl/qrcode/DefaultQrCodeLoginManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (c) 2024 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 io.element.android.features.login.impl.qrcode | ||
|
||
import com.squareup.anvil.annotations.ContributesBinding | ||
import io.element.android.features.login.impl.di.QrCodeLoginScope | ||
import io.element.android.libraries.di.SingleIn | ||
import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService | ||
import io.element.android.libraries.matrix.api.auth.qrlogin.MatrixQrCodeLoginData | ||
import io.element.android.libraries.matrix.api.auth.qrlogin.QrCodeLoginStep | ||
import io.element.android.libraries.matrix.api.auth.qrlogin.QrLoginException | ||
import io.element.android.libraries.matrix.api.core.SessionId | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import javax.inject.Inject | ||
|
||
@SingleIn(QrCodeLoginScope::class) | ||
@ContributesBinding(QrCodeLoginScope::class) | ||
class DefaultQrCodeLoginManager @Inject constructor( | ||
private val authenticationService: MatrixAuthenticationService, | ||
) : QrCodeLoginManager { | ||
private val _currentLoginStep = MutableStateFlow<QrCodeLoginStep>(QrCodeLoginStep.Uninitialized) | ||
override val currentLoginStep: StateFlow<QrCodeLoginStep> = _currentLoginStep | ||
|
||
override suspend fun authenticate(qrCodeLoginData: MatrixQrCodeLoginData): Result<SessionId> { | ||
reset() | ||
|
||
return authenticationService.loginWithQrCode(qrCodeLoginData) { step -> | ||
_currentLoginStep.value = step | ||
}.onFailure { throwable -> | ||
if (throwable is QrLoginException) { | ||
_currentLoginStep.value = QrCodeLoginStep.Failed(throwable) | ||
} | ||
} | ||
} | ||
|
||
override fun reset() { | ||
_currentLoginStep.value = QrCodeLoginStep.Uninitialized | ||
} | ||
} |
Oops, something went wrong.