[Architecture] split all feature modules to api/impl
This commit is contained in:
@@ -37,12 +37,12 @@ dependencies {
|
||||
kapt(libs.dagger.compiler)
|
||||
|
||||
implementation(projects.features.messages.api)
|
||||
implementation(projects.features.roomlist)
|
||||
implementation(projects.features.rageshake)
|
||||
implementation(projects.features.login)
|
||||
implementation(projects.features.preferences)
|
||||
implementation(projects.features.logout)
|
||||
implementation(projects.features.onboarding)
|
||||
implementation(projects.features.roomlist.api)
|
||||
implementation(projects.features.rageshake.api)
|
||||
implementation(projects.features.login.api)
|
||||
implementation(projects.features.preferences.api)
|
||||
implementation(projects.features.logout.api)
|
||||
implementation(projects.features.onboarding.api)
|
||||
|
||||
implementation(projects.libraries.core)
|
||||
implementation(projects.libraries.architecture)
|
||||
@@ -58,4 +58,6 @@ dependencies {
|
||||
testImplementation(libs.test.truth)
|
||||
testImplementation(libs.test.turbine)
|
||||
testImplementation(projects.libraries.matrix.test)
|
||||
testImplementation(projects.features.rageshake.test)
|
||||
testImplementation(projects.features.rageshake.impl)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package io.element.android.appnav
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.os.Parcelable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
@@ -42,13 +41,12 @@ import io.element.android.anvilannotations.ContributesNode
|
||||
import io.element.android.appnav.di.MatrixClientsHolder
|
||||
import io.element.android.appnav.root.RootPresenter
|
||||
import io.element.android.appnav.root.RootView
|
||||
import io.element.android.features.rageshake.bugreport.BugReportEntryPoint
|
||||
import io.element.android.features.rageshake.api.bugreport.BugReportEntryPoint
|
||||
import io.element.android.libraries.architecture.BackstackNode
|
||||
import io.element.android.libraries.architecture.animation.rememberDefaultTransitionHandler
|
||||
import io.element.android.libraries.architecture.createNode
|
||||
import io.element.android.libraries.designsystem.theme.components.CircularProgressIndicator
|
||||
import io.element.android.libraries.di.AppScope
|
||||
import io.element.android.libraries.di.ApplicationContext
|
||||
import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService
|
||||
import io.element.android.libraries.matrix.api.core.SessionId
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
@@ -63,7 +61,6 @@ import timber.log.Timber
|
||||
class RootFlowNode @AssistedInject constructor(
|
||||
@Assisted val buildContext: BuildContext,
|
||||
@Assisted plugins: List<Plugin>,
|
||||
@ApplicationContext private val appContext: Context,
|
||||
private val authenticationService: MatrixAuthenticationService,
|
||||
private val matrixClientsHolder: MatrixClientsHolder,
|
||||
private val presenter: RootPresenter,
|
||||
|
||||
@@ -19,8 +19,8 @@ package io.element.android.appnav.root
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import io.element.android.features.rageshake.crash.ui.CrashDetectionPresenter
|
||||
import io.element.android.features.rageshake.detection.RageshakeDetectionPresenter
|
||||
import io.element.android.features.rageshake.api.crash.CrashDetectionPresenter
|
||||
import io.element.android.features.rageshake.api.detection.RageshakeDetectionPresenter
|
||||
import io.element.android.libraries.architecture.Presenter
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
@@ -16,12 +16,11 @@
|
||||
|
||||
package io.element.android.appnav.root
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import io.element.android.appnav.root.RootEvents
|
||||
import io.element.android.features.rageshake.crash.ui.CrashDetectionState
|
||||
import io.element.android.features.rageshake.detection.RageshakeDetectionState
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.features.rageshake.api.crash.CrashDetectionState
|
||||
import io.element.android.features.rageshake.api.detection.RageshakeDetectionState
|
||||
|
||||
@Stable
|
||||
@Immutable
|
||||
data class RootState(
|
||||
val isShowkaseButtonVisible: Boolean,
|
||||
val rageshakeDetectionState: RageshakeDetectionState,
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package io.element.android.appnav.root
|
||||
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import io.element.android.features.rageshake.crash.ui.aCrashDetectionState
|
||||
import io.element.android.features.rageshake.detection.aRageshakeDetectionState
|
||||
import io.element.android.features.rageshake.api.crash.aCrashDetectionState
|
||||
import io.element.android.features.rageshake.api.detection.aRageshakeDetectionState
|
||||
|
||||
open class RootStateProvider : PreviewParameterProvider<RootState> {
|
||||
override val values: Sequence<RootState>
|
||||
|
||||
@@ -24,10 +24,10 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import io.element.android.features.rageshake.crash.ui.CrashDetectionEvents
|
||||
import io.element.android.features.rageshake.crash.ui.CrashDetectionView
|
||||
import io.element.android.features.rageshake.detection.RageshakeDetectionEvents
|
||||
import io.element.android.features.rageshake.detection.RageshakeDetectionView
|
||||
import io.element.android.features.rageshake.api.crash.CrashDetectionEvents
|
||||
import io.element.android.features.rageshake.api.crash.CrashDetectionView
|
||||
import io.element.android.features.rageshake.api.detection.RageshakeDetectionEvents
|
||||
import io.element.android.features.rageshake.api.detection.RageshakeDetectionView
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
|
||||
import io.element.android.libraries.designsystem.theme.components.Text
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* 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.appnav
|
||||
|
||||
import io.element.android.features.rageshake.reporter.BugReporter
|
||||
import io.element.android.features.rageshake.reporter.BugReporterListener
|
||||
import io.element.android.features.rageshake.reporter.ReportType
|
||||
import io.element.android.libraries.matrix.test.A_FAILURE_REASON
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
// TODO Remove this duplicated class when we will rework modules.
|
||||
class FakeBugReporter(val mode: FakeBugReporterMode = FakeBugReporterMode.Success) : BugReporter {
|
||||
override fun sendBugReport(
|
||||
coroutineScope: CoroutineScope,
|
||||
reportType: ReportType,
|
||||
withDevicesLogs: Boolean,
|
||||
withCrashLogs: Boolean,
|
||||
withKeyRequestHistory: Boolean,
|
||||
withScreenshot: Boolean,
|
||||
theBugDescription: String,
|
||||
serverVersion: String,
|
||||
canContact: Boolean,
|
||||
customFields: Map<String, String>?,
|
||||
listener: BugReporterListener?,
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
delay(100)
|
||||
listener?.onProgress(0)
|
||||
delay(100)
|
||||
listener?.onProgress(50)
|
||||
delay(100)
|
||||
when (mode) {
|
||||
FakeBugReporterMode.Success -> Unit
|
||||
FakeBugReporterMode.Failure -> {
|
||||
listener?.onUploadFailed(A_FAILURE_REASON)
|
||||
return@launch
|
||||
}
|
||||
FakeBugReporterMode.Cancel -> {
|
||||
listener?.onUploadCancelled()
|
||||
return@launch
|
||||
}
|
||||
}
|
||||
listener?.onProgress(100)
|
||||
delay(100)
|
||||
listener?.onUploadSucceed(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum class FakeBugReporterMode {
|
||||
Success,
|
||||
Failure,
|
||||
Cancel
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* 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.appnav
|
||||
|
||||
import io.element.android.features.rageshake.crash.CrashDataStore
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
||||
const val A_CRASH_DATA = "Some crash data"
|
||||
|
||||
// TODO Remove this duplicated class when we will rework modules.
|
||||
|
||||
class FakeCrashDataStore(
|
||||
crashData: String = "",
|
||||
appHasCrashed: Boolean = false,
|
||||
) : CrashDataStore {
|
||||
private val appHasCrashedFlow = MutableStateFlow(appHasCrashed)
|
||||
private val crashDataFlow = MutableStateFlow(crashData)
|
||||
|
||||
override fun setCrashData(crashData: String) {
|
||||
crashDataFlow.value = crashData
|
||||
}
|
||||
|
||||
override suspend fun resetAppHasCrashed() {
|
||||
appHasCrashedFlow.value = false
|
||||
}
|
||||
|
||||
override fun appHasCrashed(): Flow<Boolean> = appHasCrashedFlow
|
||||
|
||||
override fun crashInfo(): Flow<String> = crashDataFlow
|
||||
|
||||
override suspend fun reset() {
|
||||
appHasCrashedFlow.value = false
|
||||
crashDataFlow.value = ""
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* 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.appnav
|
||||
|
||||
import io.element.android.features.rageshake.rageshake.RageShake
|
||||
|
||||
// TODO Remove this duplicated class when we will rework modules.
|
||||
class FakeRageShake(
|
||||
private var isAvailableValue: Boolean = true
|
||||
) : RageShake {
|
||||
|
||||
private var interceptor: (() -> Unit)? = null
|
||||
|
||||
override fun isAvailable() = isAvailableValue
|
||||
|
||||
override fun start(sensitivity: Float) {
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
}
|
||||
|
||||
override fun setSensitivity(sensitivity: Float) {
|
||||
}
|
||||
|
||||
override fun setInterceptor(interceptor: (() -> Unit)?) {
|
||||
this.interceptor = interceptor
|
||||
}
|
||||
|
||||
fun triggerPhoneRageshake() = interceptor?.invoke()
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* 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.appnav
|
||||
|
||||
import io.element.android.features.rageshake.rageshake.RageshakeDataStore
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
||||
const val A_SENSITIVITY = 1f
|
||||
|
||||
// TODO Remove this duplicated class when we will rework modules.
|
||||
class FakeRageshakeDataStore(
|
||||
isEnabled: Boolean = true,
|
||||
sensitivity: Float = A_SENSITIVITY,
|
||||
) : RageshakeDataStore {
|
||||
|
||||
private val isEnabledFlow = MutableStateFlow(isEnabled)
|
||||
override fun isEnabled(): Flow<Boolean> = isEnabledFlow
|
||||
|
||||
override suspend fun setIsEnabled(isEnabled: Boolean) {
|
||||
isEnabledFlow.value = isEnabled
|
||||
}
|
||||
|
||||
private val sensitivityFlow = MutableStateFlow(sensitivity)
|
||||
override fun sensitivity(): Flow<Float> = sensitivityFlow
|
||||
|
||||
override suspend fun setSensitivity(sensitivity: Float) {
|
||||
sensitivityFlow.value = sensitivity
|
||||
}
|
||||
|
||||
override suspend fun reset() = Unit
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* 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.appnav
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import io.element.android.features.rageshake.screenshot.ScreenshotHolder
|
||||
|
||||
const val A_SCREENSHOT_URI = "file://content/uri"
|
||||
|
||||
// TODO Remove this duplicated class when we will rework modules.
|
||||
class FakeScreenshotHolder(private val screenshotUri: String? = null) : ScreenshotHolder {
|
||||
override fun writeBitmap(data: Bitmap) = Unit
|
||||
|
||||
override fun getFileUri() = screenshotUri
|
||||
|
||||
override fun reset() = Unit
|
||||
}
|
||||
@@ -24,9 +24,13 @@ import app.cash.turbine.test
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.appnav.root.RootEvents
|
||||
import io.element.android.appnav.root.RootPresenter
|
||||
import io.element.android.features.rageshake.crash.ui.CrashDetectionPresenter
|
||||
import io.element.android.features.rageshake.detection.RageshakeDetectionPresenter
|
||||
import io.element.android.features.rageshake.preferences.RageshakePreferencesPresenter
|
||||
import io.element.android.features.rageshake.impl.crash.DefaultCrashDetectionPresenter
|
||||
import io.element.android.features.rageshake.impl.detection.DefaultRageshakeDetectionPresenter
|
||||
import io.element.android.features.rageshake.impl.preferences.DefaultRageshakePreferencesPresenter
|
||||
import io.element.android.features.rageshake.test.crash.FakeCrashDataStore
|
||||
import io.element.android.features.rageshake.test.rageshake.FakeRageShake
|
||||
import io.element.android.features.rageshake.test.rageshake.FakeRageshakeDataStore
|
||||
import io.element.android.features.rageshake.test.screenshot.FakeScreenshotHolder
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
@@ -63,13 +67,13 @@ class RootPresenterTest {
|
||||
val rageshakeDataStore = FakeRageshakeDataStore()
|
||||
val rageshake = FakeRageShake()
|
||||
val screenshotHolder = FakeScreenshotHolder()
|
||||
val crashDetectionPresenter = CrashDetectionPresenter(
|
||||
val crashDetectionPresenter = DefaultCrashDetectionPresenter(
|
||||
crashDataStore = crashDataStore
|
||||
)
|
||||
val rageshakeDetectionPresenter = RageshakeDetectionPresenter(
|
||||
val rageshakeDetectionPresenter = DefaultRageshakeDetectionPresenter(
|
||||
screenshotHolder = screenshotHolder,
|
||||
rageShake = rageshake,
|
||||
preferencesPresenter = RageshakePreferencesPresenter(
|
||||
preferencesPresenter = DefaultRageshakePreferencesPresenter(
|
||||
rageshake = rageshake,
|
||||
rageshakeDataStore = rageshakeDataStore,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user