Remove dependencies to other presenters to FullScreenIntentPermissionsPresenter.

Also do some renaming since FullScreenIntentPermissionsPresenter interface can be removed.
This commit is contained in:
Benoit Marty
2024-10-07 09:29:31 +02:00
committed by Benoit Marty
parent cf05a9680f
commit 724c183639
17 changed files with 66 additions and 106 deletions

View File

@@ -1,12 +0,0 @@
/*
* Copyright 2024 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only
* Please see LICENSE in the repository root for full details.
*/
package io.element.android.libraries.fullscreenintent.api
import io.element.android.libraries.architecture.Presenter
interface FullScreenIntentPermissionsPresenter : Presenter<FullScreenIntentPermissionsState>

View File

@@ -0,0 +1,20 @@
/*
* Copyright 2024 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only
* Please see LICENSE in the repository root for full details.
*/
package io.element.android.libraries.fullscreenintent.api
fun aFullScreenIntentPermissionsState(
permissionGranted: Boolean = true,
shouldDisplay: Boolean = false,
openFullScreenIntentSettings: () -> Unit = {},
dismissFullScreenIntentBanner: () -> Unit = {},
) = FullScreenIntentPermissionsState(
permissionGranted = permissionGranted,
shouldDisplayBanner = shouldDisplay,
openFullScreenIntentSettings = openFullScreenIntentSettings,
dismissFullScreenIntentBanner = dismissFullScreenIntentBanner,
)

View File

@@ -27,7 +27,6 @@ dependencies {
implementation(projects.services.toolbox.api)
implementation(libs.androidx.datastore.preferences)
testImplementation(projects.libraries.fullscreenintent.test)
testImplementation(libs.test.junit)
testImplementation(libs.coroutines.test)
testImplementation(libs.molecule.runtime)

View File

@@ -19,11 +19,10 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.core.app.NotificationManagerCompat
import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.edit
import com.squareup.anvil.annotations.ContributesBinding
import io.element.android.libraries.architecture.Presenter
import io.element.android.libraries.core.meta.BuildMeta
import io.element.android.libraries.di.AppScope
import io.element.android.libraries.di.SingleIn
import io.element.android.libraries.fullscreenintent.api.FullScreenIntentPermissionsPresenter
import io.element.android.libraries.fullscreenintent.api.FullScreenIntentPermissionsState
import io.element.android.libraries.preferences.api.store.PreferenceDataStoreFactory
import io.element.android.services.toolbox.api.intent.ExternalIntentLauncher
@@ -33,14 +32,13 @@ import kotlinx.coroutines.launch
import javax.inject.Inject
@SingleIn(AppScope::class)
@ContributesBinding(AppScope::class)
class DefaultFullScreenIntentPermissionsPresenter @Inject constructor(
class FullScreenIntentPermissionsPresenter @Inject constructor(
private val buildVersionSdkIntProvider: BuildVersionSdkIntProvider,
private val externalIntentLauncher: ExternalIntentLauncher,
private val buildMeta: BuildMeta,
private val notificationManagerCompat: NotificationManagerCompat,
preferencesDataStoreFactory: PreferenceDataStoreFactory,
) : FullScreenIntentPermissionsPresenter {
) : Presenter<FullScreenIntentPermissionsState> {
companion object {
private const val PREF_KEY_FULL_SCREEN_INTENT_BANNER_DISMISSED = "PREF_KEY_FULL_SCREEN_INTENT_BANNER_DISMISSED"
}

View File

@@ -0,0 +1,23 @@
/*
* Copyright 2024 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only
* Please see LICENSE in the repository root for full details.
*/
package io.element.android.libraries.fullscreenintent.impl.di
import com.squareup.anvil.annotations.ContributesTo
import dagger.Binds
import dagger.Module
import io.element.android.libraries.architecture.Presenter
import io.element.android.libraries.di.AppScope
import io.element.android.libraries.fullscreenintent.api.FullScreenIntentPermissionsState
import io.element.android.libraries.fullscreenintent.impl.FullScreenIntentPermissionsPresenter
@ContributesTo(AppScope::class)
@Module
interface FullScreenIntentModule {
@Binds
fun bindFullScreenIntentPermissionsPresenter(presenter: FullScreenIntentPermissionsPresenter): Presenter<FullScreenIntentPermissionsState>
}

View File

@@ -15,7 +15,7 @@ import app.cash.molecule.moleculeFlow
import app.cash.turbine.test
import com.google.common.truth.Truth.assertThat
import io.element.android.libraries.core.meta.BuildMeta
import io.element.android.libraries.fullscreenintent.impl.DefaultFullScreenIntentPermissionsPresenter
import io.element.android.libraries.fullscreenintent.impl.FullScreenIntentPermissionsPresenter
import io.element.android.libraries.matrix.test.core.aBuildMeta
import io.element.android.libraries.preferences.test.FakePreferenceDataStoreFactory
import io.element.android.services.toolbox.api.intent.ExternalIntentLauncher
@@ -32,7 +32,7 @@ import org.junit.Rule
import org.junit.Test
@OptIn(ExperimentalCoroutinesApi::class)
class DefaultFullScreenIntentPermissionsPresenterTest {
class FullScreenIntentPermissionsPresenterTest {
@get:Rule
val warmUpRule = WarmUpRule()
@@ -129,7 +129,7 @@ class DefaultFullScreenIntentPermissionsPresenterTest {
externalIntentLauncher: ExternalIntentLauncher = FakeExternalIntentLauncher(),
buildMeta: BuildMeta = aBuildMeta(),
notificationManagerCompat: NotificationManagerCompat = mockk(relaxed = true)
) = DefaultFullScreenIntentPermissionsPresenter(
) = FullScreenIntentPermissionsPresenter(
buildVersionSdkIntProvider = buildVersionSdkIntProvider,
externalIntentLauncher = externalIntentLauncher,
buildMeta = buildMeta,

View File

@@ -1,19 +0,0 @@
/*
* Copyright 2024 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only
* Please see LICENSE in the repository root for full details.
*/
plugins {
id("io.element.android-compose-library")
}
android {
namespace = "io.element.android.libraries.fullscreenintent.test"
}
dependencies {
api(projects.libraries.fullscreenintent.api)
implementation(projects.libraries.architecture)
}

View File

@@ -1,25 +0,0 @@
/*
* Copyright 2024 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only
* Please see LICENSE in the repository root for full details.
*/
package io.element.android.libraries.fullscreenintent.test
import androidx.compose.runtime.Composable
import io.element.android.libraries.fullscreenintent.api.FullScreenIntentPermissionsPresenter
import io.element.android.libraries.fullscreenintent.api.FullScreenIntentPermissionsState
class FakeFullScreenIntentPermissionsPresenter : FullScreenIntentPermissionsPresenter {
var state = FullScreenIntentPermissionsState(
permissionGranted = true,
shouldDisplayBanner = false,
dismissFullScreenIntentBanner = {},
openFullScreenIntentSettings = {},
)
@Composable
override fun present(): FullScreenIntentPermissionsState {
return state
}
}