Skip to content
Snippets Groups Projects
Commit 0f9a00f5 authored by Sebastian's avatar Sebastian Committed by Mikolai Gütschow
Browse files

Add DesktopFeatureFlags to disable certain features in code base

parent baafe604
No related branches found
No related tags found
1 merge request!82Add DesktopFeatureFlags to disable certain features in code base
Pipeline #8975 passed
package org.briarproject.briar.desktop
interface DesktopFeatureFlags {
fun shouldEnablePrivateGroups(): Boolean
fun shouldEnableForums(): Boolean
fun shouldEnableBlogs(): Boolean
fun shouldEnableTransportSettings(): Boolean
}
......@@ -130,6 +130,17 @@ internal class DesktopModule(
override fun shouldEnableDisappearingMessages() = false
}
@Provides
@Singleton
internal fun provideDesktopFeatureFlags() = object : DesktopFeatureFlags {
// TODO: once we have shouldEnableBlogsInCore() in briar core, wire them up with these here
// so that the value for shouldEnableBlogs() is always the same the respective core flag.
override fun shouldEnablePrivateGroups() = false
override fun shouldEnableForums() = false
override fun shouldEnableBlogs() = false
override fun shouldEnableTransportSettings() = false
}
@Provides
@Singleton
internal fun provideImageCompressor(imageCompressor: ImageCompressorImpl): ImageCompressor {
......
......@@ -27,6 +27,7 @@ import org.briarproject.bramble.api.identity.LocalAuthor
import org.briarproject.briar.desktop.contact.ProfileCircle
import org.briarproject.briar.desktop.theme.sidebarSurface
import org.briarproject.briar.desktop.ui.UiMode
import org.briarproject.briar.desktop.utils.getDesktopFeatureFlags
val SIDEBAR_WIDTH = 56.dp
......@@ -54,26 +55,27 @@ fun BriarSidebar(
) {
account?.let { ProfileCircle(size = 45.dp, it.id.bytes) }
}
for (
(mode, icon) in listOf(
Pair(UiMode.CONTACTS, Icons.Filled.Contacts),
Pair(UiMode.GROUPS, Icons.Filled.Group),
Pair(UiMode.FORUMS, Icons.Filled.Forum),
Pair(UiMode.BLOGS, Icons.Filled.ChromeReaderMode),
)
) {
val items = buildList {
add(Pair(UiMode.CONTACTS, Icons.Filled.Contacts))
val featureFlags = getDesktopFeatureFlags()
if (featureFlags.shouldEnablePrivateGroups()) add(Pair(UiMode.GROUPS, Icons.Filled.Group))
if (featureFlags.shouldEnableForums()) add(Pair(UiMode.FORUMS, Icons.Filled.Forum))
if (featureFlags.shouldEnableBlogs()) add(Pair(UiMode.BLOGS, Icons.Filled.ChromeReaderMode))
}
for ((mode, icon) in items) {
displayButton(uiMode, mode, icon)
}
}
Column(verticalArrangement = Arrangement.Bottom) {
for (
(mode, icon) in listOf(
Pair(UiMode.TRANSPORTS, Icons.Filled.WifiTethering),
Pair(UiMode.SETTINGS, Icons.Filled.Settings),
Pair(UiMode.SIGNOUT, Icons.Filled.Logout),
val items = buildList {
val featureFlags = getDesktopFeatureFlags()
if (featureFlags.shouldEnableTransportSettings()) add(
Pair(UiMode.TRANSPORTS, Icons.Filled.WifiTethering)
)
) {
add(Pair(UiMode.SETTINGS, Icons.Filled.Settings))
add(Pair(UiMode.SIGNOUT, Icons.Filled.Logout))
}
for ((mode, icon) in items) {
displayButton(uiMode, mode, icon)
}
}
......
......@@ -12,6 +12,7 @@ import androidx.compose.ui.window.Window
import org.briarproject.bramble.api.account.AccountManager
import org.briarproject.bramble.api.lifecycle.LifecycleManager
import org.briarproject.bramble.api.lifecycle.LifecycleManager.LifecycleState.RUNNING
import org.briarproject.briar.desktop.DesktopFeatureFlags
import org.briarproject.briar.desktop.login.LoginScreen
import org.briarproject.briar.desktop.login.RegistrationScreen
import org.briarproject.briar.desktop.theme.BriarTheme
......@@ -37,6 +38,7 @@ interface BriarUi {
}
val LocalViewModelProvider = staticCompositionLocalOf<ViewModelProvider?> { null }
val LocalDesktopFeatureFlags = staticCompositionLocalOf<DesktopFeatureFlags?> { null }
@Immutable
@Singleton
......@@ -46,6 +48,7 @@ constructor(
private val accountManager: AccountManager,
private val lifecycleManager: LifecycleManager,
private val viewModelProvider: ViewModelProvider,
private val desktopFeatureFlags: DesktopFeatureFlags,
) : BriarUi {
override fun stop() {
......@@ -79,7 +82,10 @@ constructor(
icon = painterResource("images/logo_circle.svg")
) {
window.minimumSize = Dimension(800, 600)
CompositionLocalProvider(LocalViewModelProvider provides viewModelProvider) {
CompositionLocalProvider(
LocalViewModelProvider provides viewModelProvider,
LocalDesktopFeatureFlags provides desktopFeatureFlags
) {
BriarTheme(isDarkTheme = isDark) {
when (screenState) {
Screen.REGISTRATION ->
......
......@@ -23,7 +23,7 @@ fun MainScreen(
BriarSidebar(
viewModel.account.value,
viewModel.uiMode.value,
viewModel::setUiMode
viewModel::setUiMode,
)
VerticalDivider()
when (viewModel.uiMode.value) {
......
package org.briarproject.briar.desktop.utils
import androidx.compose.runtime.Composable
import org.briarproject.briar.desktop.ui.LocalDesktopFeatureFlags
@Composable
fun getDesktopFeatureFlags() = checkNotNull(LocalDesktopFeatureFlags.current) {
"No DesktopFeatureFlags was provided via LocalDesktopFeatureFlags"
}
......@@ -136,6 +136,17 @@ internal class DesktopTestModule(
override fun shouldEnableDisappearingMessages() = false
}
@Provides
@Singleton
internal fun provideDesktopFeatureFlags() = object : DesktopFeatureFlags {
// TODO: once we have shouldEnableBlogsInCore() in briar core, wire them up with these here
// so that the value for shouldEnableBlogs() is always the same the respective core flag.
override fun shouldEnablePrivateGroups() = false
override fun shouldEnableForums() = false
override fun shouldEnableBlogs() = false
override fun shouldEnableTransportSettings() = false
}
@Provides
@Singleton
internal fun provideImageCompressor(imageCompressor: ImageCompressorImpl): ImageCompressor {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment