Merge pull request #1268 from vector-im/feature/bma/moreTrace
Add SDK trace item, set RUST_BACKTRACE and be able to configure trace before a session exists.
This commit is contained in:
commit
0a8e6ad073
15 changed files with 148 additions and 18 deletions
|
|
@ -33,5 +33,6 @@ interface OnBoardingEntryPoint : FeatureEntryPoint {
|
|||
interface Callback : Plugin {
|
||||
fun onSignUp()
|
||||
fun onSignIn()
|
||||
fun onOpenDeveloperSettings()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,10 @@ class OnBoardingNode @AssistedInject constructor(
|
|||
plugins<OnBoardingEntryPoint.Callback>().forEach { it.onSignUp() }
|
||||
}
|
||||
|
||||
private fun onOpenDeveloperSettings() {
|
||||
plugins<OnBoardingEntryPoint.Callback>().forEach { it.onOpenDeveloperSettings() }
|
||||
}
|
||||
|
||||
@Composable
|
||||
override fun View(modifier: Modifier) {
|
||||
val state = presenter.present()
|
||||
|
|
@ -54,6 +58,8 @@ class OnBoardingNode @AssistedInject constructor(
|
|||
modifier = modifier,
|
||||
onSignIn = ::onSignIn,
|
||||
onCreateAccount = ::onSignUp,
|
||||
onSignInWithQrCode = { /* Not supported yet */ },
|
||||
onOpenDeveloperSettings = ::onOpenDeveloperSettings,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ package io.element.android.features.onboarding.impl
|
|||
|
||||
import androidx.compose.runtime.Composable
|
||||
import io.element.android.libraries.architecture.Presenter
|
||||
import io.element.android.libraries.core.meta.BuildMeta
|
||||
import io.element.android.libraries.core.meta.BuildType
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
|
|
@ -25,10 +27,12 @@ import javax.inject.Inject
|
|||
* When this presenter get more code in it, please remove the ignore rule in the kover configuration.
|
||||
*/
|
||||
class OnBoardingPresenter @Inject constructor(
|
||||
private val buildMeta: BuildMeta,
|
||||
) : Presenter<OnBoardingState> {
|
||||
@Composable
|
||||
override fun present(): OnBoardingState {
|
||||
return OnBoardingState(
|
||||
isDebugBuild = buildMeta.buildType != BuildType.RELEASE,
|
||||
canLoginWithQrCode = OnBoardingConfig.canLoginWithQrCode,
|
||||
canCreateAccount = OnBoardingConfig.canCreateAccount,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package io.element.android.features.onboarding.impl
|
||||
|
||||
data class OnBoardingState(
|
||||
val isDebugBuild: Boolean,
|
||||
val canLoginWithQrCode: Boolean,
|
||||
val canCreateAccount: Boolean,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -25,13 +25,16 @@ open class OnBoardingStateProvider : PreviewParameterProvider<OnBoardingState> {
|
|||
anOnBoardingState(canLoginWithQrCode = true),
|
||||
anOnBoardingState(canCreateAccount = true),
|
||||
anOnBoardingState(canLoginWithQrCode = true, canCreateAccount = true),
|
||||
anOnBoardingState(isDebugBuild = true),
|
||||
)
|
||||
}
|
||||
|
||||
fun anOnBoardingState(
|
||||
isDebugBuild: Boolean = false,
|
||||
canLoginWithQrCode: Boolean = false,
|
||||
canCreateAccount: Boolean = false
|
||||
) = OnBoardingState(
|
||||
isDebugBuild = isDebugBuild,
|
||||
canLoginWithQrCode = canLoginWithQrCode,
|
||||
canCreateAccount = canCreateAccount
|
||||
)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ import androidx.compose.foundation.layout.height
|
|||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.QrCode
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Alignment.Companion.CenterHorizontally
|
||||
import androidx.compose.ui.BiasAlignment
|
||||
import androidx.compose.ui.Modifier
|
||||
|
|
@ -41,6 +43,8 @@ import io.element.android.libraries.designsystem.atomic.pages.OnBoardingPage
|
|||
import io.element.android.libraries.designsystem.preview.DayNightPreviews
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.theme.components.Button
|
||||
import io.element.android.libraries.designsystem.theme.components.Icon
|
||||
import io.element.android.libraries.designsystem.theme.components.IconButton
|
||||
import io.element.android.libraries.designsystem.theme.components.IconSource
|
||||
import io.element.android.libraries.designsystem.theme.components.OutlinedButton
|
||||
import io.element.android.libraries.designsystem.theme.components.Text
|
||||
|
|
@ -57,15 +61,19 @@ import io.element.android.libraries.ui.strings.CommonStrings
|
|||
@Composable
|
||||
fun OnBoardingView(
|
||||
state: OnBoardingState,
|
||||
onSignInWithQrCode: () -> Unit,
|
||||
onSignIn: () -> Unit,
|
||||
onCreateAccount: () -> Unit,
|
||||
onOpenDeveloperSettings: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
onSignInWithQrCode: () -> Unit = {},
|
||||
onSignIn: () -> Unit = {},
|
||||
onCreateAccount: () -> Unit = {},
|
||||
) {
|
||||
OnBoardingPage(
|
||||
modifier = modifier,
|
||||
content = {
|
||||
OnBoardingContent()
|
||||
OnBoardingContent(
|
||||
state = state,
|
||||
onOpenDeveloperSettings = onOpenDeveloperSettings
|
||||
)
|
||||
},
|
||||
footer = {
|
||||
OnBoardingButtons(
|
||||
|
|
@ -79,7 +87,11 @@ fun OnBoardingView(
|
|||
}
|
||||
|
||||
@Composable
|
||||
private fun OnBoardingContent(modifier: Modifier = Modifier) {
|
||||
private fun OnBoardingContent(
|
||||
state: OnBoardingState,
|
||||
onOpenDeveloperSettings: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Box(
|
||||
modifier = modifier.fillMaxSize(),
|
||||
) {
|
||||
|
|
@ -122,6 +134,17 @@ private fun OnBoardingContent(modifier: Modifier = Modifier) {
|
|||
)
|
||||
}
|
||||
}
|
||||
if (state.isDebugBuild) {
|
||||
IconButton(
|
||||
modifier = Modifier.align(Alignment.TopEnd),
|
||||
onClick = onOpenDeveloperSettings,
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.Settings,
|
||||
contentDescription = stringResource(CommonStrings.common_settings)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -172,5 +195,11 @@ private fun OnBoardingButtons(
|
|||
internal fun OnBoardingScreenPreview(
|
||||
@PreviewParameter(OnBoardingStateProvider::class) state: OnBoardingState
|
||||
) = ElementPreview {
|
||||
OnBoardingView(state)
|
||||
OnBoardingView(
|
||||
state = state,
|
||||
onSignInWithQrCode = {},
|
||||
onSignIn = {},
|
||||
onCreateAccount = {},
|
||||
onOpenDeveloperSettings = {}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ import app.cash.molecule.RecompositionMode
|
|||
import app.cash.molecule.moleculeFlow
|
||||
import app.cash.turbine.test
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.libraries.core.meta.BuildType
|
||||
import io.element.android.libraries.matrix.test.core.aBuildMeta
|
||||
import io.element.android.tests.testutils.WarmUpRule
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Rule
|
||||
|
|
@ -33,13 +35,25 @@ class OnBoardingPresenterTest {
|
|||
|
||||
@Test
|
||||
fun `present - initial state`() = runTest {
|
||||
val presenter = OnBoardingPresenter()
|
||||
val presenter = OnBoardingPresenter(aBuildMeta())
|
||||
moleculeFlow(RecompositionMode.Immediate) {
|
||||
presenter.present()
|
||||
}.test {
|
||||
val initialState = awaitItem()
|
||||
assertThat(initialState.isDebugBuild).isTrue()
|
||||
assertThat(initialState.canLoginWithQrCode).isFalse()
|
||||
assertThat(initialState.canCreateAccount).isFalse()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `present - initial state release`() = runTest {
|
||||
val presenter = OnBoardingPresenter(aBuildMeta(buildType = BuildType.RELEASE))
|
||||
moleculeFlow(RecompositionMode.Immediate) {
|
||||
presenter.present()
|
||||
}.test {
|
||||
val initialState = awaitItem()
|
||||
assertThat(initialState.isDebugBuild).isFalse()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (c) 2023 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.preferences.api
|
||||
|
||||
import io.element.android.libraries.architecture.SimpleFeatureEntryPoint
|
||||
|
||||
interface ConfigureTracingEntryPoint : SimpleFeatureEntryPoint
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2023 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.preferences.impl
|
||||
|
||||
import com.bumble.appyx.core.modality.BuildContext
|
||||
import com.bumble.appyx.core.node.Node
|
||||
import com.squareup.anvil.annotations.ContributesBinding
|
||||
import io.element.android.features.preferences.api.ConfigureTracingEntryPoint
|
||||
import io.element.android.features.preferences.impl.developer.tracing.ConfigureTracingNode
|
||||
import io.element.android.libraries.architecture.createNode
|
||||
import io.element.android.libraries.di.AppScope
|
||||
import javax.inject.Inject
|
||||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultConfigureTracingEntryPoint @Inject constructor() : ConfigureTracingEntryPoint {
|
||||
override fun createNode(parentNode: Node, buildContext: BuildContext): Node {
|
||||
return parentNode.createNode<ConfigureTracingNode>(buildContext)
|
||||
}
|
||||
}
|
||||
|
|
@ -29,7 +29,6 @@ class TargetLogLevelMapBuilder @Inject constructor(
|
|||
fun getDefaultMap(): Map<Target, LogLevel> {
|
||||
return Target.entries.associateWith { target ->
|
||||
defaultConfig.getLogLevel(target)
|
||||
?: LogLevel.INFO
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -37,7 +36,6 @@ class TargetLogLevelMapBuilder @Inject constructor(
|
|||
return Target.entries.associateWith { target ->
|
||||
tracingConfigurationStore.getLogLevel(target)
|
||||
?: defaultConfig.getLogLevel(target)
|
||||
?: LogLevel.INFO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue