From 6699462e063f3851d337558ac3bed230ebda6948 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 30 Jun 2023 15:40:49 +0200 Subject: [PATCH] Change hierarchy of settings. --- .../preferences/AnalyticsPreferencesView.kt | 7 ++- .../logout/api/LogoutPreferenceScreen.kt | 2 +- .../preferences/impl/PreferencesFlowNode.kt | 22 +++++++ .../preferences/impl/about/AboutEvents.kt | 21 +++++++ .../preferences/impl/about/AboutNode.kt | 45 +++++++++++++ .../preferences/impl/about/AboutPresenter.kt | 38 +++++++++++ .../preferences/impl/about/AboutState.kt | 23 +++++++ .../impl/about/AboutStateProvider.kt | 30 +++++++++ .../preferences/impl/about/AboutView.kt | 63 +++++++++++++++++++ .../impl/analytics/AnalyticsSettingsEvents.kt | 21 +++++++ .../impl/analytics/AnalyticsSettingsNode.kt | 45 +++++++++++++ .../analytics/AnalyticsSettingsPresenter.kt | 43 +++++++++++++ .../impl/analytics/AnalyticsSettingsState.kt | 25 ++++++++ .../AnalyticsSettingsStateProvider.kt | 32 ++++++++++ .../impl/analytics/AnalyticsSettingsView.kt | 63 +++++++++++++++++++ .../developer/DeveloperSettingsPresenter.kt | 4 ++ .../impl/developer/DeveloperSettingsState.kt | 2 + .../DeveloperSettingsStateProvider.kt | 2 + .../impl/developer/DeveloperSettingsView.kt | 4 ++ .../impl/root/PreferencesRootNode.kt | 13 +++- .../impl/root/PreferencesRootPresenter.kt | 8 --- .../impl/root/PreferencesRootState.kt | 4 -- .../impl/root/PreferencesRootStateProvider.kt | 4 -- .../impl/root/PreferencesRootView.kt | 62 +++++++++++------- ...AnalyticsAnalyticsSettingsPresenterTest.kt | 43 +++++++++++++ .../DeveloperSettingsPresenterTest.kt | 15 +++++ .../impl/root/PreferencesRootPresenterTest.kt | 8 --- .../preferences/RageshakePreferencesView.kt | 10 --- 28 files changed, 598 insertions(+), 61 deletions(-) create mode 100644 features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutEvents.kt create mode 100644 features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutNode.kt create mode 100644 features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutPresenter.kt create mode 100644 features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutState.kt create mode 100644 features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutStateProvider.kt create mode 100644 features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutView.kt create mode 100644 features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsEvents.kt create mode 100644 features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsNode.kt create mode 100644 features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsPresenter.kt create mode 100644 features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsState.kt create mode 100644 features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsStateProvider.kt create mode 100644 features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsView.kt create mode 100644 features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsAnalyticsSettingsPresenterTest.kt diff --git a/features/analytics/api/src/main/kotlin/io/element/android/features/analytics/api/preferences/AnalyticsPreferencesView.kt b/features/analytics/api/src/main/kotlin/io/element/android/features/analytics/api/preferences/AnalyticsPreferencesView.kt index 8186119132..b04848a999 100644 --- a/features/analytics/api/src/main/kotlin/io/element/android/features/analytics/api/preferences/AnalyticsPreferencesView.kt +++ b/features/analytics/api/src/main/kotlin/io/element/android/features/analytics/api/preferences/AnalyticsPreferencesView.kt @@ -43,13 +43,16 @@ fun AnalyticsPreferencesView( state.eventSink(AnalyticsOptInEvents.EnableAnalytics(isEnabled = isEnabled)) } - PreferenceCategory(title = stringResource(id = CommonStrings.screen_analytics_settings_share_data)) { + PreferenceCategory( + modifier = modifier, + title = stringResource(id = CommonStrings.screen_analytics_settings_share_data) + ) { val firstPart = stringResource(id = CommonStrings.screen_analytics_settings_help_us_improve, state.applicationName) val secondPart = buildAnnotatedStringWithColoredPart( CommonStrings.screen_analytics_settings_read_terms, CommonStrings.screen_analytics_settings_read_terms_content_link ) - val title = "$firstPart\n\n$secondPart" + val title = "$firstPart\n\n$secondPart" PreferenceSwitch( title = title, diff --git a/features/logout/api/src/main/kotlin/io/element/android/features/logout/api/LogoutPreferenceScreen.kt b/features/logout/api/src/main/kotlin/io/element/android/features/logout/api/LogoutPreferenceScreen.kt index 0ad6eab4eb..60844f4477 100644 --- a/features/logout/api/src/main/kotlin/io/element/android/features/logout/api/LogoutPreferenceScreen.kt +++ b/features/logout/api/src/main/kotlin/io/element/android/features/logout/api/LogoutPreferenceScreen.kt @@ -81,7 +81,7 @@ fun LogoutPreferenceContent( ) { PreferenceText( title = stringResource(id = R.string.screen_signout_preference_item), - icon = Icons.Default.Logout, + icon = Icons.Filled.Logout, onClick = onClick ) } diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/PreferencesFlowNode.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/PreferencesFlowNode.kt index cded5d4bf6..35fe4e77bb 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/PreferencesFlowNode.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/PreferencesFlowNode.kt @@ -30,6 +30,8 @@ import dagger.assisted.Assisted import dagger.assisted.AssistedInject import io.element.android.anvilannotations.ContributesNode import io.element.android.features.preferences.api.PreferencesEntryPoint +import io.element.android.features.preferences.impl.about.AboutNode +import io.element.android.features.preferences.impl.analytics.AnalyticsSettingsNode import io.element.android.features.preferences.impl.developer.DeveloperSettingsNode import io.element.android.features.preferences.impl.root.PreferencesRootNode import io.element.android.libraries.architecture.BackstackNode @@ -57,6 +59,12 @@ class PreferencesFlowNode @AssistedInject constructor( @Parcelize object DeveloperSettings : NavTarget + + @Parcelize + object AnalyticsSettings : NavTarget + + @Parcelize + object About : NavTarget } override fun resolve(navTarget: NavTarget, buildContext: BuildContext): Node { @@ -67,6 +75,14 @@ class PreferencesFlowNode @AssistedInject constructor( plugins().forEach { it.onOpenBugReport() } } + override fun onOpenAnalytics() { + backstack.push(NavTarget.AnalyticsSettings) + } + + override fun onOpenAbout() { + backstack.push(NavTarget.About) + } + override fun onOpenDeveloperSettings() { backstack.push(NavTarget.DeveloperSettings) } @@ -76,6 +92,12 @@ class PreferencesFlowNode @AssistedInject constructor( NavTarget.DeveloperSettings -> { createNode(buildContext) } + NavTarget.About -> { + createNode(buildContext) + } + NavTarget.AnalyticsSettings -> { + createNode(buildContext) + } } } diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutEvents.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutEvents.kt new file mode 100644 index 0000000000..fd27e3f682 --- /dev/null +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutEvents.kt @@ -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.impl.about + +sealed interface AboutEvents { + object MyEvent : AboutEvents +} diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutNode.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutNode.kt new file mode 100644 index 0000000000..0cd19d8e14 --- /dev/null +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutNode.kt @@ -0,0 +1,45 @@ +/* + * 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.about + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import com.bumble.appyx.core.modality.BuildContext +import com.bumble.appyx.core.node.Node +import com.bumble.appyx.core.plugin.Plugin +import dagger.assisted.Assisted +import dagger.assisted.AssistedInject +import io.element.android.anvilannotations.ContributesNode +import io.element.android.libraries.di.SessionScope + +@ContributesNode(SessionScope::class) +class AboutNode @AssistedInject constructor( + @Assisted buildContext: BuildContext, + @Assisted plugins: List, + private val presenter: AboutPresenter, +) : Node(buildContext, plugins = plugins) { + + @Composable + override fun View(modifier: Modifier) { + val state = presenter.present() + AboutView( + state = state, + onBackPressed = ::navigateUp, + modifier = modifier + ) + } +} diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutPresenter.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutPresenter.kt new file mode 100644 index 0000000000..708e7c9abc --- /dev/null +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutPresenter.kt @@ -0,0 +1,38 @@ +/* + * 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.about + +import androidx.compose.runtime.Composable +import io.element.android.libraries.architecture.Presenter +import javax.inject.Inject + +class AboutPresenter @Inject constructor() : Presenter { + + @Composable + override fun present(): AboutState { + + fun handleEvents(event: AboutEvents) { + when (event) { + AboutEvents.MyEvent -> Unit + } + } + + return AboutState( + eventSink = ::handleEvents + ) + } +} diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutState.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutState.kt new file mode 100644 index 0000000000..0af95e5502 --- /dev/null +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutState.kt @@ -0,0 +1,23 @@ +/* + * 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.about + +// TODO add your ui models. Remove the eventSink if you don't have events. +// Do not use default value, so no member get forgotten in the presenters. +data class AboutState( + val eventSink: (AboutEvents) -> Unit +) diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutStateProvider.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutStateProvider.kt new file mode 100644 index 0000000000..aeb8dd9aa3 --- /dev/null +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutStateProvider.kt @@ -0,0 +1,30 @@ +/* + * 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.about + +import androidx.compose.ui.tooling.preview.PreviewParameterProvider + +open class AboutStateProvider : PreviewParameterProvider { + override val values: Sequence + get() = sequenceOf( + aAboutState(), + ) +} + +fun aAboutState() = AboutState( + eventSink = {} +) diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutView.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutView.kt new file mode 100644 index 0000000000..3736c33bfa --- /dev/null +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutView.kt @@ -0,0 +1,63 @@ +/* + * 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.about + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.tooling.preview.PreviewParameter +import io.element.android.libraries.designsystem.components.preferences.PreferenceText +import io.element.android.libraries.designsystem.components.preferences.PreferenceView +import io.element.android.libraries.designsystem.preview.ElementPreviewDark +import io.element.android.libraries.designsystem.preview.ElementPreviewLight +import io.element.android.libraries.ui.strings.CommonStrings + +@Composable +fun AboutView( + state: AboutState, + onBackPressed: () -> Unit, + modifier: Modifier = Modifier, +) { + PreferenceView( + modifier = modifier, + onBackPressed = onBackPressed, + title = stringResource(id = CommonStrings.common_about) + ) { + PreferenceText(title = stringResource(id = CommonStrings.common_copyright)) + PreferenceText(title = stringResource(id = CommonStrings.common_acceptable_use_policy)) + PreferenceText(title = stringResource(id = CommonStrings.common_privacy_policy)) + } +} + +@Preview +@Composable +fun AboutViewLightPreview(@PreviewParameter(AboutStateProvider::class) state: AboutState) = + ElementPreviewLight { ContentToPreview(state) } + +@Preview +@Composable +fun AboutViewDarkPreview(@PreviewParameter(AboutStateProvider::class) state: AboutState) = + ElementPreviewDark { ContentToPreview(state) } + +@Composable +private fun ContentToPreview(state: AboutState) { + AboutView( + state = state, + onBackPressed = {}, + ) +} diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsEvents.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsEvents.kt new file mode 100644 index 0000000000..86b2db16d9 --- /dev/null +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsEvents.kt @@ -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.impl.analytics + +sealed interface AnalyticsSettingsEvents { + object MyEvent : AnalyticsSettingsEvents +} diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsNode.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsNode.kt new file mode 100644 index 0000000000..adc917b7e6 --- /dev/null +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsNode.kt @@ -0,0 +1,45 @@ +/* + * 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.analytics + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import com.bumble.appyx.core.modality.BuildContext +import com.bumble.appyx.core.node.Node +import com.bumble.appyx.core.plugin.Plugin +import dagger.assisted.Assisted +import dagger.assisted.AssistedInject +import io.element.android.anvilannotations.ContributesNode +import io.element.android.libraries.di.SessionScope + +@ContributesNode(SessionScope::class) +class AnalyticsSettingsNode @AssistedInject constructor( + @Assisted buildContext: BuildContext, + @Assisted plugins: List, + private val presenter: AnalyticsSettingsPresenter, +) : Node(buildContext, plugins = plugins) { + + @Composable + override fun View(modifier: Modifier) { + val state = presenter.present() + AnalyticsSettingsView( + state = state, + onBackPressed = ::navigateUp, + modifier = modifier + ) + } +} diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsPresenter.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsPresenter.kt new file mode 100644 index 0000000000..976193db74 --- /dev/null +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsPresenter.kt @@ -0,0 +1,43 @@ +/* + * 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.analytics + +import androidx.compose.runtime.Composable +import io.element.android.features.analytics.api.preferences.AnalyticsPreferencesPresenter +import io.element.android.libraries.architecture.Presenter +import javax.inject.Inject + +class AnalyticsSettingsPresenter @Inject constructor( + private val analyticsPresenter: AnalyticsPreferencesPresenter, +) : Presenter { + + @Composable + override fun present(): AnalyticsSettingsState { + val analyticsState = analyticsPresenter.present() + + fun handleEvents(event: AnalyticsSettingsEvents) { + when (event) { + AnalyticsSettingsEvents.MyEvent -> Unit + } + } + + return AnalyticsSettingsState( + analyticsState = analyticsState, + eventSink = ::handleEvents + ) + } +} diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsState.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsState.kt new file mode 100644 index 0000000000..b5a38fb23c --- /dev/null +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsState.kt @@ -0,0 +1,25 @@ +/* + * 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.analytics + +import io.element.android.features.analytics.api.preferences.AnalyticsPreferencesState + +// Do not use default value, so no member get forgotten in the presenters. +data class AnalyticsSettingsState( + val analyticsState: AnalyticsPreferencesState, + val eventSink: (AnalyticsSettingsEvents) -> Unit +) diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsStateProvider.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsStateProvider.kt new file mode 100644 index 0000000000..f1eb2b6c0f --- /dev/null +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsStateProvider.kt @@ -0,0 +1,32 @@ +/* + * 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.analytics + +import androidx.compose.ui.tooling.preview.PreviewParameterProvider +import io.element.android.features.analytics.api.preferences.aAnalyticsPreferencesState + +open class AnalyticsSettingsStateProvider : PreviewParameterProvider { + override val values: Sequence + get() = sequenceOf( + aAnalyticsSettingsState(), + ) +} + +fun aAnalyticsSettingsState() = AnalyticsSettingsState( + analyticsState = aAnalyticsPreferencesState(), + eventSink = {} +) diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsView.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsView.kt new file mode 100644 index 0000000000..165406c6f5 --- /dev/null +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsSettingsView.kt @@ -0,0 +1,63 @@ +/* + * 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.analytics + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.tooling.preview.PreviewParameter +import io.element.android.features.analytics.api.preferences.AnalyticsPreferencesView +import io.element.android.libraries.designsystem.components.preferences.PreferenceView +import io.element.android.libraries.designsystem.preview.ElementPreviewDark +import io.element.android.libraries.designsystem.preview.ElementPreviewLight +import io.element.android.libraries.ui.strings.CommonStrings + +@Composable +fun AnalyticsSettingsView( + state: AnalyticsSettingsState, + onBackPressed: () -> Unit, + modifier: Modifier = Modifier, +) { + PreferenceView( + modifier = modifier, + onBackPressed = onBackPressed, + title = stringResource(id = CommonStrings.common_analytics) + ) { + AnalyticsPreferencesView( + state = state.analyticsState, + ) + } +} + +@Preview +@Composable +fun AnalyticsSettingsViewLightPreview(@PreviewParameter(AnalyticsSettingsStateProvider::class) state: AnalyticsSettingsState) = + ElementPreviewLight { ContentToPreview(state) } + +@Preview +@Composable +fun AnalyticsSettingsViewDarkPreview(@PreviewParameter(AnalyticsSettingsStateProvider::class) state: AnalyticsSettingsState) = + ElementPreviewDark { ContentToPreview(state) } + +@Composable +private fun ContentToPreview(state: AnalyticsSettingsState) { + AnalyticsSettingsView( + state = state, + onBackPressed = {}, + ) +} diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsPresenter.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsPresenter.kt index 2e10622c7a..1a8216ff1b 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsPresenter.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsPresenter.kt @@ -27,6 +27,7 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.snapshots.SnapshotStateMap import io.element.android.features.preferences.impl.tasks.ClearCacheUseCase import io.element.android.features.preferences.impl.tasks.ComputeCacheSizeUseCase +import io.element.android.features.rageshake.api.preferences.RageshakePreferencesPresenter import io.element.android.libraries.architecture.Async import io.element.android.libraries.architecture.Presenter import io.element.android.libraries.architecture.runCatchingUpdatingState @@ -44,10 +45,12 @@ class DeveloperSettingsPresenter @Inject constructor( private val featureFlagService: FeatureFlagService, private val computeCacheSizeUseCase: ComputeCacheSizeUseCase, private val clearCacheUseCase: ClearCacheUseCase, + private val rageshakePresenter: RageshakePreferencesPresenter, ) : Presenter { @Composable override fun present(): DeveloperSettingsState { + val rageshakeState = rageshakePresenter.present() val features = remember { mutableStateMapOf() @@ -90,6 +93,7 @@ class DeveloperSettingsPresenter @Inject constructor( features = featureUiModels.toImmutableList(), cacheSize = cacheSize.value, clearCacheAction = clearCacheAction.value, + rageshakeState = rageshakeState, eventSink = ::handleEvents ) } diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsState.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsState.kt index 61205e7f7d..8d79c9241d 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsState.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsState.kt @@ -16,6 +16,7 @@ package io.element.android.features.preferences.impl.developer +import io.element.android.features.rageshake.api.preferences.RageshakePreferencesState import io.element.android.libraries.architecture.Async import io.element.android.libraries.featureflag.ui.model.FeatureUiModel import kotlinx.collections.immutable.ImmutableList @@ -23,6 +24,7 @@ import kotlinx.collections.immutable.ImmutableList data class DeveloperSettingsState constructor( val features: ImmutableList, val cacheSize: Async, + val rageshakeState: RageshakePreferencesState, val clearCacheAction: Async, val eventSink: (DeveloperSettingsEvents) -> Unit ) diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsStateProvider.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsStateProvider.kt index de94bd6664..ee5c897987 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsStateProvider.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsStateProvider.kt @@ -17,6 +17,7 @@ package io.element.android.features.preferences.impl.developer import androidx.compose.ui.tooling.preview.PreviewParameterProvider +import io.element.android.features.rageshake.api.preferences.aRageshakePreferencesState import io.element.android.libraries.architecture.Async import io.element.android.libraries.featureflag.ui.model.aFeatureUiModelList @@ -30,6 +31,7 @@ open class DeveloperSettingsStateProvider : PreviewParameterProvider().forEach { it.onOpenDeveloperSettings() } } + private fun onOpenAnalytics() { + plugins().forEach { it.onOpenAnalytics() } + } + + private fun onOpenAbout() { + plugins().forEach { it.onOpenAbout() } + } + @Composable override fun View(modifier: Modifier) { val state = presenter.present() @@ -55,8 +65,9 @@ class PreferencesRootNode @AssistedInject constructor( modifier = modifier, onBackPressed = this::navigateUp, onOpenRageShake = this::onOpenBugReport, + onOpenAnalytics = this::onOpenAnalytics, + onOpenAbout = this::onOpenAbout, onOpenDeveloperSettings = this::onOpenDeveloperSettings ) } - } diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootPresenter.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootPresenter.kt index bb8b656ee6..2fe22161a8 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootPresenter.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootPresenter.kt @@ -21,9 +21,7 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MutableState import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable -import io.element.android.features.analytics.api.preferences.AnalyticsPreferencesPresenter import io.element.android.features.logout.api.LogoutPreferencePresenter -import io.element.android.features.rageshake.api.preferences.RageshakePreferencesPresenter import io.element.android.libraries.architecture.Presenter import io.element.android.libraries.core.meta.BuildType import io.element.android.libraries.matrix.api.user.CurrentUserProvider @@ -34,8 +32,6 @@ import javax.inject.Inject class PreferencesRootPresenter @Inject constructor( private val logoutPresenter: LogoutPreferencePresenter, - private val rageshakePresenter: RageshakePreferencesPresenter, - private val analyticsPresenter: AnalyticsPreferencesPresenter, private val currentUserProvider: CurrentUserProvider, private val buildType: BuildType, ) : Presenter { @@ -50,13 +46,9 @@ class PreferencesRootPresenter @Inject constructor( } val logoutState = logoutPresenter.present() - val rageshakeState = rageshakePresenter.present() - val analyticsState = analyticsPresenter.present() val showDeveloperSettings = buildType != BuildType.RELEASE return PreferencesRootState( logoutState = logoutState, - rageshakeState = rageshakeState, - analyticsState = analyticsState, myUser = matrixUser.value, showDeveloperSettings = showDeveloperSettings ) diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootState.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootState.kt index d427d01ab9..d1e3a0535c 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootState.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootState.kt @@ -16,15 +16,11 @@ package io.element.android.features.preferences.impl.root -import io.element.android.features.analytics.api.preferences.AnalyticsPreferencesState import io.element.android.features.logout.api.LogoutPreferenceState -import io.element.android.features.rageshake.api.preferences.RageshakePreferencesState import io.element.android.libraries.matrix.api.user.MatrixUser data class PreferencesRootState( val logoutState: LogoutPreferenceState, - val rageshakeState: RageshakePreferencesState, - val analyticsState: AnalyticsPreferencesState, val myUser: MatrixUser?, val showDeveloperSettings: Boolean ) diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootStateProvider.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootStateProvider.kt index db8e7e1f8a..c438687278 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootStateProvider.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootStateProvider.kt @@ -16,14 +16,10 @@ package io.element.android.features.preferences.impl.root -import io.element.android.features.analytics.api.preferences.aAnalyticsPreferencesState import io.element.android.features.logout.api.aLogoutPreferenceState -import io.element.android.features.rageshake.api.preferences.aRageshakePreferencesState fun aPreferencesRootState() = PreferencesRootState( logoutState = aLogoutPreferenceState(), - rageshakeState = aRageshakePreferencesState(), - analyticsState = aAnalyticsPreferencesState(), myUser = null, showDeveloperSettings = true ) diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootView.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootView.kt index 8ea02883ac..a652b866ad 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootView.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootView.kt @@ -18,21 +18,21 @@ package io.element.android.features.preferences.impl.root import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.DeveloperMode +import androidx.compose.material.icons.filled.Help +import androidx.compose.material.icons.outlined.BugReport +import androidx.compose.material.icons.outlined.InsertChart import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.PreviewParameter import io.element.android.features.logout.api.LogoutPreferenceView import io.element.android.features.preferences.impl.user.UserPreferences -import io.element.android.features.analytics.api.preferences.AnalyticsPreferencesView -import io.element.android.features.rageshake.api.preferences.RageshakePreferencesView -import io.element.android.libraries.architecture.Async -import io.element.android.libraries.designsystem.components.preferences.PreferenceCategory import io.element.android.libraries.designsystem.components.preferences.PreferenceText import io.element.android.libraries.designsystem.components.preferences.PreferenceView import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight import io.element.android.libraries.designsystem.preview.LargeHeightPreview +import io.element.android.libraries.designsystem.theme.components.Divider import io.element.android.libraries.matrix.api.user.MatrixUser import io.element.android.libraries.matrix.ui.components.MatrixUserProvider import io.element.android.libraries.ui.strings.CommonStrings @@ -41,11 +41,12 @@ import io.element.android.libraries.ui.strings.CommonStrings fun PreferencesRootView( state: PreferencesRootState, modifier: Modifier = Modifier, - onBackPressed: () -> Unit = {}, - onOpenRageShake: () -> Unit = {}, - onOpenDeveloperSettings: () -> Unit = {}, + onBackPressed: () -> Unit, + onOpenAnalytics: () -> Unit, + onOpenRageShake: () -> Unit, + onOpenAbout: () -> Unit, + onOpenDeveloperSettings: () -> Unit, ) { - // TODO Hierarchy! // Include pref from other modules PreferenceView( modifier = modifier, @@ -53,31 +54,39 @@ fun PreferencesRootView( title = stringResource(id = CommonStrings.common_settings) ) { UserPreferences(state.myUser) - AnalyticsPreferencesView( - state = state.analyticsState, + // TODO Verification and eventually divider + PreferenceText( + title = stringResource(id = CommonStrings.common_analytics), + icon = Icons.Outlined.InsertChart, + onClick = onOpenAnalytics, ) - RageshakePreferencesView( - state = state.rageshakeState, - onOpenRageshake = onOpenRageShake, + PreferenceText( + title = stringResource(id = CommonStrings.action_report_bug), + icon = Icons.Outlined.BugReport, + onClick = onOpenRageShake ) - LogoutPreferenceView( - state = state.logoutState, + PreferenceText( + title = stringResource(id = CommonStrings.common_about), + icon = Icons.Filled.Help, + onClick = onOpenAbout, ) if (state.showDeveloperSettings) { DeveloperPreferencesView(onOpenDeveloperSettings) } + Divider() + LogoutPreferenceView( + state = state.logoutState, + ) } } @Composable fun DeveloperPreferencesView(onOpenDeveloperSettings: () -> Unit) { - PreferenceCategory(title = stringResource(id = CommonStrings.common_developer_options)) { - PreferenceText( - title = stringResource(id = CommonStrings.common_developer_options), - icon = Icons.Default.DeveloperMode, - onClick = onOpenDeveloperSettings - ) - } + PreferenceText( + title = stringResource(id = CommonStrings.common_developer_options), + icon = Icons.Default.DeveloperMode, + onClick = onOpenDeveloperSettings + ) } @LargeHeightPreview @@ -92,5 +101,12 @@ fun PreferencesRootViewDarkPreview(@PreviewParameter(MatrixUserProvider::class) @Composable private fun ContentToPreview(matrixUser: MatrixUser) { - PreferencesRootView(aPreferencesRootState().copy(myUser = matrixUser)) + PreferencesRootView( + state = aPreferencesRootState().copy(myUser = matrixUser), + onBackPressed = {}, + onOpenAnalytics = {}, + onOpenRageShake = {}, + onOpenDeveloperSettings = {}, + onOpenAbout = {}, + ) } diff --git a/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsAnalyticsSettingsPresenterTest.kt b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsAnalyticsSettingsPresenterTest.kt new file mode 100644 index 0000000000..a383bcf71b --- /dev/null +++ b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/analytics/AnalyticsAnalyticsSettingsPresenterTest.kt @@ -0,0 +1,43 @@ +/* + * 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.analytics + +import app.cash.molecule.RecompositionClock +import app.cash.molecule.moleculeFlow +import app.cash.turbine.test +import com.google.common.truth.Truth.assertThat +import io.element.android.features.analytics.impl.preferences.DefaultAnalyticsPreferencesPresenter +import io.element.android.features.analytics.test.A_BUILD_META +import io.element.android.features.analytics.test.FakeAnalyticsService +import kotlinx.coroutines.test.runTest +import org.junit.Test + +class AnalyticsAnalyticsSettingsPresenterTest { + @Test + fun `present - initial state`() = runTest { + val analyticsPresenter = DefaultAnalyticsPreferencesPresenter(FakeAnalyticsService(), A_BUILD_META) + val presenter = AnalyticsSettingsPresenter( + analyticsPresenter, + ) + moleculeFlow(RecompositionClock.Immediate) { + presenter.present() + }.test { + val initialState = awaitItem() + assertThat(initialState.analyticsState.isEnabled).isFalse() + } + } +} diff --git a/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsPresenterTest.kt b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsPresenterTest.kt index 226140647d..8fee4df488 100644 --- a/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsPresenterTest.kt +++ b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsPresenterTest.kt @@ -22,6 +22,9 @@ import app.cash.turbine.test import com.google.common.truth.Truth.assertThat import io.element.android.features.preferences.impl.tasks.FakeClearCacheUseCase import io.element.android.features.preferences.impl.tasks.FakeComputeCacheSizeUseCase +import io.element.android.features.rageshake.impl.preferences.DefaultRageshakePreferencesPresenter +import io.element.android.features.rageshake.test.rageshake.FakeRageShake +import io.element.android.features.rageshake.test.rageshake.FakeRageshakeDataStore import io.element.android.libraries.architecture.Async import io.element.android.libraries.featureflag.api.FeatureFlags import io.element.android.libraries.featureflag.test.FakeFeatureFlagService @@ -31,10 +34,12 @@ import org.junit.Test class DeveloperSettingsPresenterTest { @Test fun `present - ensures initial state is correct`() = runTest { + val rageshakePresenter = DefaultRageshakePreferencesPresenter(FakeRageShake(), FakeRageshakeDataStore()) val presenter = DeveloperSettingsPresenter( FakeFeatureFlagService(), FakeComputeCacheSizeUseCase(), FakeClearCacheUseCase(), + rageshakePresenter ) moleculeFlow(RecompositionClock.Immediate) { presenter.present() @@ -43,16 +48,22 @@ class DeveloperSettingsPresenterTest { assertThat(initialState.features).isEmpty() assertThat(initialState.clearCacheAction).isEqualTo(Async.Uninitialized) assertThat(initialState.cacheSize).isEqualTo(Async.Uninitialized) + val loadedState = awaitItem() + assertThat(loadedState.rageshakeState.isEnabled).isTrue() + assertThat(loadedState.rageshakeState.isSupported).isTrue() + assertThat(loadedState.rageshakeState.sensitivity).isEqualTo(1.0f) cancelAndIgnoreRemainingEvents() } } @Test fun `present - ensures feature list is loaded`() = runTest { + val rageshakePresenter = DefaultRageshakePreferencesPresenter(FakeRageShake(), FakeRageshakeDataStore()) val presenter = DeveloperSettingsPresenter( FakeFeatureFlagService(), FakeComputeCacheSizeUseCase(), FakeClearCacheUseCase(), + rageshakePresenter, ) moleculeFlow(RecompositionClock.Immediate) { presenter.present() @@ -66,10 +77,12 @@ class DeveloperSettingsPresenterTest { @Test fun `present - ensures state is updated when enabled feature event is triggered`() = runTest { + val rageshakePresenter = DefaultRageshakePreferencesPresenter(FakeRageShake(), FakeRageshakeDataStore()) val presenter = DeveloperSettingsPresenter( FakeFeatureFlagService(), FakeComputeCacheSizeUseCase(), FakeClearCacheUseCase(), + rageshakePresenter, ) moleculeFlow(RecompositionClock.Immediate) { presenter.present() @@ -88,11 +101,13 @@ class DeveloperSettingsPresenterTest { @Test fun `present - clear cache`() = runTest { + val rageshakePresenter = DefaultRageshakePreferencesPresenter(FakeRageShake(), FakeRageshakeDataStore()) val clearCacheUseCase = FakeClearCacheUseCase() val presenter = DeveloperSettingsPresenter( FakeFeatureFlagService(), FakeComputeCacheSizeUseCase(), clearCacheUseCase, + rageshakePresenter, ) moleculeFlow(RecompositionClock.Immediate) { presenter.present() diff --git a/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootPresenterTest.kt b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootPresenterTest.kt index 6600656803..4254668583 100644 --- a/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootPresenterTest.kt +++ b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootPresenterTest.kt @@ -41,12 +41,8 @@ class PreferencesRootPresenterTest { fun `present - initial state`() = runTest { val matrixClient = FakeMatrixClient() val logoutPresenter = DefaultLogoutPreferencePresenter(matrixClient) - val rageshakePresenter = DefaultRageshakePreferencesPresenter(FakeRageShake(), FakeRageshakeDataStore()) - val analyticsPresenter = DefaultAnalyticsPreferencesPresenter(FakeAnalyticsService(), A_BUILD_META) val presenter = PreferencesRootPresenter( logoutPresenter, - rageshakePresenter, - analyticsPresenter, CurrentUserProvider(matrixClient), A_BUILD_META.buildType ) @@ -57,10 +53,6 @@ class PreferencesRootPresenterTest { assertThat(initialState.myUser).isNull() val loadedState = awaitItem() assertThat(loadedState.logoutState.logoutAction).isEqualTo(Async.Uninitialized) - assertThat(loadedState.analyticsState.isEnabled).isFalse() - assertThat(loadedState.rageshakeState.isEnabled).isTrue() - assertThat(loadedState.rageshakeState.isSupported).isTrue() - assertThat(loadedState.rageshakeState.sensitivity).isEqualTo(1.0f) assertThat(loadedState.myUser).isEqualTo( MatrixUser( userId = matrixClient.sessionId, diff --git a/features/rageshake/api/src/main/kotlin/io/element/android/features/rageshake/api/preferences/RageshakePreferencesView.kt b/features/rageshake/api/src/main/kotlin/io/element/android/features/rageshake/api/preferences/RageshakePreferencesView.kt index d775bce275..73e04fb5d4 100644 --- a/features/rageshake/api/src/main/kotlin/io/element/android/features/rageshake/api/preferences/RageshakePreferencesView.kt +++ b/features/rageshake/api/src/main/kotlin/io/element/android/features/rageshake/api/preferences/RageshakePreferencesView.kt @@ -17,8 +17,6 @@ package io.element.android.features.rageshake.api.preferences import androidx.compose.foundation.layout.Column -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.BugReport import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource @@ -36,7 +34,6 @@ import io.element.android.libraries.ui.strings.CommonStrings fun RageshakePreferencesView( state: RageshakePreferencesState, modifier: Modifier = Modifier, - onOpenRageshake: () -> Unit = {}, ) { fun onSensitivityChanged(sensitivity: Float) { state.eventSink(RageshakePreferencesEvents.SetSensitivity(sensitivity = sensitivity)) @@ -47,13 +44,6 @@ fun RageshakePreferencesView( } Column(modifier = modifier) { - PreferenceCategory(title = stringResource(id = CommonStrings.action_report_bug)) { - PreferenceText( - title = stringResource(id = CommonStrings.action_report_bug), - icon = Icons.Default.BugReport, - onClick = onOpenRageshake - ) - } PreferenceCategory(title = stringResource(id = CommonStrings.settings_rageshake)) { if (state.isSupported) { PreferenceSwitch(