From 0c99a457e46675d0ce84b26d42e4ae856f2bff2e Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 19 Dec 2023 15:09:39 +0100 Subject: [PATCH] Add RoomListConfig to be able to hide menu items. And hide them #2062. --- .../android/appconfig/RoomListConfig.kt | 25 ++++++ changelog.d/2062.misc | 1 + features/roomlist/impl/build.gradle.kts | 1 + .../impl/components/RoomListTopBar.kt | 82 ++++++++++--------- 4 files changed, 71 insertions(+), 38 deletions(-) create mode 100644 appconfig/src/main/kotlin/io/element/android/appconfig/RoomListConfig.kt create mode 100644 changelog.d/2062.misc diff --git a/appconfig/src/main/kotlin/io/element/android/appconfig/RoomListConfig.kt b/appconfig/src/main/kotlin/io/element/android/appconfig/RoomListConfig.kt new file mode 100644 index 0000000000..92dee4174d --- /dev/null +++ b/appconfig/src/main/kotlin/io/element/android/appconfig/RoomListConfig.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.appconfig + +object RoomListConfig { + const val showInviteMenuItem = false + const val showReportProblemMenuItem = false + + const val hasDropdownMenu = showInviteMenuItem || showReportProblemMenuItem +} + diff --git a/changelog.d/2062.misc b/changelog.d/2062.misc new file mode 100644 index 0000000000..dea482098b --- /dev/null +++ b/changelog.d/2062.misc @@ -0,0 +1 @@ +Hide room list dropdown menu. diff --git a/features/roomlist/impl/build.gradle.kts b/features/roomlist/impl/build.gradle.kts index cb70d9078a..4e415fd2a2 100644 --- a/features/roomlist/impl/build.gradle.kts +++ b/features/roomlist/impl/build.gradle.kts @@ -38,6 +38,7 @@ anvil { dependencies { implementation(projects.anvilannotations) anvil(projects.anvilcodegen) + implementation(projects.appconfig) implementation(projects.libraries.core) implementation(projects.libraries.androidutils) implementation(projects.libraries.architecture) diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListTopBar.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListTopBar.kt index 4746464716..60ab360428 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListTopBar.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListTopBar.kt @@ -46,6 +46,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.DpOffset import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp +import io.element.android.appconfig.RoomListConfig import io.element.android.compound.theme.ElementTheme import io.element.android.compound.tokens.generated.CompoundIcons import io.element.android.features.roomlist.impl.R @@ -128,8 +129,6 @@ private fun DefaultRoomListTopBar( onMenuActionClicked: (RoomListMenuAction) -> Unit, modifier: Modifier = Modifier, ) { - var showMenu by remember { mutableStateOf(false) } - // We need this to manually clip the top app bar in preview mode val previewAppBarHeight = if (LocalInspectionMode.current) { 112.dp.roundToPx() @@ -222,46 +221,53 @@ private fun DefaultRoomListTopBar( contentDescription = stringResource(CommonStrings.action_search), ) } - IconButton( - onClick = { showMenu = !showMenu } - ) { - Icon( - imageVector = CompoundIcons.OverflowVertical, - contentDescription = null, - ) - } - DropdownMenu( - expanded = showMenu, - onDismissRequest = { showMenu = false } - ) { - DropdownMenuItem( - onClick = { - showMenu = false - onMenuActionClicked(RoomListMenuAction.InviteFriends) - }, - text = { Text(stringResource(id = CommonStrings.action_invite)) }, - leadingIcon = { - Icon( - imageVector = CompoundIcons.ShareAndroid, - tint = ElementTheme.materialColors.secondary, - contentDescription = null, + if (RoomListConfig.hasDropdownMenu) { + var showMenu by remember { mutableStateOf(false) } + IconButton( + onClick = { showMenu = !showMenu } + ) { + Icon( + imageVector = CompoundIcons.OverflowVertical, + contentDescription = null, + ) + } + DropdownMenu( + expanded = showMenu, + onDismissRequest = { showMenu = false } + ) { + if (RoomListConfig.showInviteMenuItem) { + DropdownMenuItem( + onClick = { + showMenu = false + onMenuActionClicked(RoomListMenuAction.InviteFriends) + }, + text = { Text(stringResource(id = CommonStrings.action_invite)) }, + leadingIcon = { + Icon( + imageVector = CompoundIcons.ShareAndroid, + tint = ElementTheme.materialColors.secondary, + contentDescription = null, + ) + } ) } - ) - DropdownMenuItem( - onClick = { - showMenu = false - onMenuActionClicked(RoomListMenuAction.ReportBug) - }, - text = { Text(stringResource(id = CommonStrings.common_report_a_problem)) }, - leadingIcon = { - Icon( - imageVector = CompoundIcons.ChatProblem, - tint = ElementTheme.materialColors.secondary, - contentDescription = null, + if (RoomListConfig.showReportProblemMenuItem) { + DropdownMenuItem( + onClick = { + showMenu = false + onMenuActionClicked(RoomListMenuAction.ReportBug) + }, + text = { Text(stringResource(id = CommonStrings.common_report_a_problem)) }, + leadingIcon = { + Icon( + imageVector = CompoundIcons.ChatProblem, + tint = ElementTheme.materialColors.secondary, + contentDescription = null, + ) + } ) } - ) + } } }, scrollBehavior = scrollBehavior,