Merge pull request #2063 from element-hq/feature/bma/hideRoomListMenu

Hide room list menu
This commit is contained in:
Benoit Marty 2023-12-19 21:26:56 +01:00 committed by GitHub
commit ea2647cb8a
30 changed files with 120 additions and 88 deletions

View file

@ -14,9 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
package io.element.android.features.analytics.api package io.element.android.appconfig
object Config { object AnalyticsConfig {
const val POLICY_LINK = "https://element.io/cookie-policy" const val POLICY_LINK = "https://element.io/cookie-policy"
} }

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.element.android.libraries.push.impl package io.element.android.appconfig
object NotificationConfig { object NotificationConfig {
// TODO EAx Implement and set to true at some point // TODO EAx Implement and set to true at some point

View file

@ -0,0 +1,24 @@
/*
* 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
}

1
changelog.d/2062.misc Normal file
View file

@ -0,0 +1 @@
Hide room list dropdown menu.

View file

@ -39,6 +39,7 @@ dependencies {
implementation(projects.libraries.uiStrings) implementation(projects.libraries.uiStrings)
api(projects.features.analytics.api) api(projects.features.analytics.api)
api(projects.services.analytics.api) api(projects.services.analytics.api)
implementation(projects.appconfig)
implementation(libs.androidx.datastore.preferences) implementation(libs.androidx.datastore.preferences)
implementation(libs.androidx.browser) implementation(libs.androidx.browser)
ksp(libs.showkase.processor) ksp(libs.showkase.processor)

View file

@ -17,7 +17,6 @@
package io.element.android.features.analytics.impl package io.element.android.features.analytics.impl
import android.app.Activity import android.app.Activity
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
@ -27,7 +26,8 @@ import com.bumble.appyx.core.plugin.Plugin
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import io.element.android.anvilannotations.ContributesNode import io.element.android.anvilannotations.ContributesNode
import io.element.android.features.analytics.api.Config import io.element.android.appconfig.AnalyticsConfig
import io.element.android.compound.theme.ElementTheme
import io.element.android.libraries.androidutils.browser.openUrlInChromeCustomTab import io.element.android.libraries.androidutils.browser.openUrlInChromeCustomTab
import io.element.android.libraries.di.AppScope import io.element.android.libraries.di.AppScope
@ -39,13 +39,13 @@ class AnalyticsOptInNode @AssistedInject constructor(
) : Node(buildContext, plugins = plugins) { ) : Node(buildContext, plugins = plugins) {
private fun onClickTerms(activity: Activity, darkTheme: Boolean) { private fun onClickTerms(activity: Activity, darkTheme: Boolean) {
activity.openUrlInChromeCustomTab(null, darkTheme, Config.POLICY_LINK) activity.openUrlInChromeCustomTab(null, darkTheme, AnalyticsConfig.POLICY_LINK)
} }
@Composable @Composable
override fun View(modifier: Modifier) { override fun View(modifier: Modifier) {
val activity = LocalContext.current as Activity val activity = LocalContext.current as Activity
val isDark = MaterialTheme.colors.isLight.not() val isDark = ElementTheme.isLightTheme.not()
val state = presenter.present() val state = presenter.present()
AnalyticsOptInView( AnalyticsOptInView(
state = state, state = state,

View file

@ -40,10 +40,10 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import io.element.android.appconfig.AnalyticsConfig
import io.element.android.compound.theme.ElementTheme import io.element.android.compound.theme.ElementTheme
import io.element.android.compound.tokens.generated.CompoundIcons import io.element.android.compound.tokens.generated.CompoundIcons
import io.element.android.features.analytics.api.AnalyticsOptInEvents import io.element.android.features.analytics.api.AnalyticsOptInEvents
import io.element.android.features.analytics.api.Config
import io.element.android.libraries.designsystem.atomic.molecules.ButtonColumnMolecule import io.element.android.libraries.designsystem.atomic.molecules.ButtonColumnMolecule
import io.element.android.libraries.designsystem.atomic.molecules.IconTitleSubtitleMolecule import io.element.android.libraries.designsystem.atomic.molecules.IconTitleSubtitleMolecule
import io.element.android.libraries.designsystem.atomic.organisms.InfoListItem import io.element.android.libraries.designsystem.atomic.organisms.InfoListItem
@ -119,7 +119,7 @@ private fun AnalyticsOptInHeader(
color = Color.Unspecified, color = Color.Unspecified,
underline = false, underline = false,
bold = true, bold = true,
tagAndLink = LINK_TAG to Config.POLICY_LINK, tagAndLink = LINK_TAG to AnalyticsConfig.POLICY_LINK,
) )
ClickableText( ClickableText(
text = text, text = text,

View file

@ -20,8 +20,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.rememberCoroutineScope
import com.squareup.anvil.annotations.ContributesBinding import com.squareup.anvil.annotations.ContributesBinding
import io.element.android.appconfig.AnalyticsConfig
import io.element.android.features.analytics.api.AnalyticsOptInEvents import io.element.android.features.analytics.api.AnalyticsOptInEvents
import io.element.android.features.analytics.api.Config
import io.element.android.features.analytics.api.preferences.AnalyticsPreferencesPresenter import io.element.android.features.analytics.api.preferences.AnalyticsPreferencesPresenter
import io.element.android.features.analytics.api.preferences.AnalyticsPreferencesState import io.element.android.features.analytics.api.preferences.AnalyticsPreferencesState
import io.element.android.libraries.core.meta.BuildMeta import io.element.android.libraries.core.meta.BuildMeta
@ -52,7 +52,7 @@ class DefaultAnalyticsPreferencesPresenter @Inject constructor(
return AnalyticsPreferencesState( return AnalyticsPreferencesState(
applicationName = buildMeta.applicationName, applicationName = buildMeta.applicationName,
isEnabled = isEnabled.value, isEnabled = isEnabled.value,
policyUrl = Config.POLICY_LINK, policyUrl = AnalyticsConfig.POLICY_LINK,
eventSink = ::handleEvents eventSink = ::handleEvents
) )
} }

View file

@ -38,6 +38,7 @@ anvil {
dependencies { dependencies {
implementation(projects.anvilannotations) implementation(projects.anvilannotations)
anvil(projects.anvilcodegen) anvil(projects.anvilcodegen)
implementation(projects.appconfig)
implementation(projects.libraries.core) implementation(projects.libraries.core)
implementation(projects.libraries.androidutils) implementation(projects.libraries.androidutils)
implementation(projects.libraries.architecture) implementation(projects.libraries.architecture)

View file

@ -46,6 +46,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.DpOffset import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import io.element.android.appconfig.RoomListConfig
import io.element.android.compound.theme.ElementTheme import io.element.android.compound.theme.ElementTheme
import io.element.android.compound.tokens.generated.CompoundIcons import io.element.android.compound.tokens.generated.CompoundIcons
import io.element.android.features.roomlist.impl.R import io.element.android.features.roomlist.impl.R
@ -128,8 +129,6 @@ private fun DefaultRoomListTopBar(
onMenuActionClicked: (RoomListMenuAction) -> Unit, onMenuActionClicked: (RoomListMenuAction) -> Unit,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
) { ) {
var showMenu by remember { mutableStateOf(false) }
// We need this to manually clip the top app bar in preview mode // We need this to manually clip the top app bar in preview mode
val previewAppBarHeight = if (LocalInspectionMode.current) { val previewAppBarHeight = if (LocalInspectionMode.current) {
112.dp.roundToPx() 112.dp.roundToPx()
@ -222,46 +221,53 @@ private fun DefaultRoomListTopBar(
contentDescription = stringResource(CommonStrings.action_search), contentDescription = stringResource(CommonStrings.action_search),
) )
} }
IconButton( if (RoomListConfig.hasDropdownMenu) {
onClick = { showMenu = !showMenu } var showMenu by remember { mutableStateOf(false) }
) { IconButton(
Icon( onClick = { showMenu = !showMenu }
imageVector = CompoundIcons.OverflowVertical, ) {
contentDescription = null, Icon(
) imageVector = CompoundIcons.OverflowVertical,
} contentDescription = null,
DropdownMenu( )
expanded = showMenu, }
onDismissRequest = { showMenu = false } DropdownMenu(
) { expanded = showMenu,
DropdownMenuItem( onDismissRequest = { showMenu = false }
onClick = { ) {
showMenu = false if (RoomListConfig.showInviteMenuItem) {
onMenuActionClicked(RoomListMenuAction.InviteFriends) DropdownMenuItem(
}, onClick = {
text = { Text(stringResource(id = CommonStrings.action_invite)) }, showMenu = false
leadingIcon = { onMenuActionClicked(RoomListMenuAction.InviteFriends)
Icon( },
imageVector = CompoundIcons.ShareAndroid, text = { Text(stringResource(id = CommonStrings.action_invite)) },
tint = ElementTheme.materialColors.secondary, leadingIcon = {
contentDescription = null, Icon(
imageVector = CompoundIcons.ShareAndroid,
tint = ElementTheme.materialColors.secondary,
contentDescription = null,
)
}
) )
} }
) if (RoomListConfig.showReportProblemMenuItem) {
DropdownMenuItem( DropdownMenuItem(
onClick = { onClick = {
showMenu = false showMenu = false
onMenuActionClicked(RoomListMenuAction.ReportBug) onMenuActionClicked(RoomListMenuAction.ReportBug)
}, },
text = { Text(stringResource(id = CommonStrings.common_report_a_problem)) }, text = { Text(stringResource(id = CommonStrings.common_report_a_problem)) },
leadingIcon = { leadingIcon = {
Icon( Icon(
imageVector = CompoundIcons.ChatProblem, imageVector = CompoundIcons.ChatProblem,
tint = ElementTheme.materialColors.secondary, tint = ElementTheme.materialColors.secondary,
contentDescription = null, contentDescription = null,
)
}
) )
} }
) }
} }
}, },
scrollBehavior = scrollBehavior, scrollBehavior = scrollBehavior,

View file

@ -20,9 +20,9 @@ import android.app.PendingIntent
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import io.element.android.appconfig.NotificationConfig
import io.element.android.libraries.androidutils.uri.createIgnoredUri import io.element.android.libraries.androidutils.uri.createIgnoredUri
import io.element.android.libraries.di.ApplicationContext import io.element.android.libraries.di.ApplicationContext
import io.element.android.libraries.push.impl.NotificationConfig
import io.element.android.libraries.push.impl.R import io.element.android.libraries.push.impl.R
import io.element.android.libraries.push.impl.notifications.NotificationActionIds import io.element.android.libraries.push.impl.notifications.NotificationActionIds
import io.element.android.libraries.push.impl.notifications.NotificationBroadcastReceiver import io.element.android.libraries.push.impl.notifications.NotificationBroadcastReceiver

View file

@ -22,12 +22,12 @@ import android.content.Intent
import android.os.Build import android.os.Build
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import androidx.core.app.RemoteInput import androidx.core.app.RemoteInput
import io.element.android.appconfig.NotificationConfig
import io.element.android.libraries.androidutils.uri.createIgnoredUri import io.element.android.libraries.androidutils.uri.createIgnoredUri
import io.element.android.libraries.di.ApplicationContext import io.element.android.libraries.di.ApplicationContext
import io.element.android.libraries.matrix.api.core.RoomId import io.element.android.libraries.matrix.api.core.RoomId
import io.element.android.libraries.matrix.api.core.SessionId import io.element.android.libraries.matrix.api.core.SessionId
import io.element.android.libraries.matrix.api.core.ThreadId import io.element.android.libraries.matrix.api.core.ThreadId
import io.element.android.libraries.push.impl.NotificationConfig
import io.element.android.libraries.push.impl.R import io.element.android.libraries.push.impl.R
import io.element.android.libraries.push.impl.notifications.NotificationActionIds import io.element.android.libraries.push.impl.notifications.NotificationActionIds
import io.element.android.libraries.push.impl.notifications.NotificationBroadcastReceiver import io.element.android.libraries.push.impl.notifications.NotificationBroadcastReceiver

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:4c4552bc00b305d4f0a114932bc34ce1e47a7e144d59fc73200554a4c41831c1 oid sha256:ce132903012c55bdca8fd9e081a4b92fbb9110b786bff2c15bed1f2bf81f6be7
size 37325 size 37003

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:2b9fbbaf2baa535bc8160e06f3451cf37344a1959bc7528fd7ebb60d1deba115 oid sha256:66756228647566a3985f80c6ab362713abb8b6a18fd6eb45b5def593c49ad26e
size 42668 size 42374

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:8683e41eaa1104e27cbd009df3ef5425387034217de552bd9a7452fe360aeab6 oid sha256:66a7de6dfd16f66a345ee092760f4e43db0099519584895bc5a73144001e6521
size 36879 size 36584

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:609af5a67bd82425771446f782d578ae0e65991a0dcd538622f2baccc2417280 oid sha256:e2f4761d2196058c740f051c457bb59cbbe000e06d2a0cf2c1b1c3db6e88a5c5
size 42300 size 42007

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:38633c4ad718d5b24d9f8bf950774945e10b980e179ed7ad3e2d6ada142d2a8c oid sha256:1e0ce69a05b0d5fc6f93379e3598f64de5907f4e58393cef6ac34db520e1a33d
size 65148 size 64861

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:27d44086e379f39dcfc0de3f57eaead0ee31e0eef17f9f57ac3acd27fec3410b oid sha256:77ded11b7e2bda0d6c32789c5f5fcc0e11cec268b9ca6759d395d6dd1a15d6ca
size 86637 size 86389

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:38633c4ad718d5b24d9f8bf950774945e10b980e179ed7ad3e2d6ada142d2a8c oid sha256:1e0ce69a05b0d5fc6f93379e3598f64de5907f4e58393cef6ac34db520e1a33d
size 65148 size 64861

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:15cb552fefe91c70a15d303d033f8cb20cbe9c6724db81a6af2401558d81f47e oid sha256:eb3738bad0fb2af6756b8b55f7534d221a928e747762bcd485af537721f80d15
size 65112 size 64800

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:d9e4bdb080c03ea0d64b66def5103f70d97c7ef493b4829f6be8962a87333336 oid sha256:e59a16fa5c62267598c19b10e669c2a3b29518b5d9442616a80e2a286d1d4dfe
size 66204 size 65893

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:2544d7bf96a1045ec0f4a0a6bffd893a1d5e5a3745a7acb2efceecc81b37922d oid sha256:775d4c475a1c3f31d27e5ccd550758b72073b4f1bd2c3ba80f6070d72633d514
size 66592 size 66277

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:341842b3aa4b16ce4881ac8c79017577a73322b82d0c6570f397d10bdcb31616 oid sha256:cb05834596fd1984b25b545a363cf44d5ce81675fa2953da7f98388fae04c6b2
size 89851 size 89571

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:f46ac96865c29a90c8e68d5c77ce04b922d56ff9072655b8f2d9c756e1e43d19 oid sha256:b4f2e2ca7a4192a7bac73d2f1285bf371048aeeb348fecb775630c9630c8e404
size 67360 size 67083

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:60cd171a7caf644493ac059595742d2a4a570672ef76e2039174d18851cfd041 oid sha256:379905d496dc1f7f38518252ecab1c7434d7bc43a0865f83c2ec3334e59787a9
size 88554 size 88311

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:f46ac96865c29a90c8e68d5c77ce04b922d56ff9072655b8f2d9c756e1e43d19 oid sha256:b4f2e2ca7a4192a7bac73d2f1285bf371048aeeb348fecb775630c9630c8e404
size 67360 size 67083

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:1474722e755a1be8d91db3a6f7ce60f591d23a52dcf8217abbaee844c2c55b60 oid sha256:3f0c14c6409b21d3f8aa4402bfc71cae6ef196b7ccf7ca45b9e7731dc3f2e29b
size 67154 size 66865

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:d8cc283fc4c71d0c0afa84d5b97643738b6552fb88dd2e242d7b4e0066a68166 oid sha256:597c721b783b7a5c92a87e554e49409b6e4fe22d8929bf234edddf8f2dc92bca
size 68953 size 68682

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:7c5775a0a578ddba1f279e5085d0e5687d5da0ab973fffa907263eed72aa5376 oid sha256:96bfd478d9ab46b53dc20f1867b5d5c56eddbbf9a9afc922520caa275961810a
size 69316 size 69039

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:aff70357e41e29d3dbbf8e805f38e35da274dba33809255c2ab0d3af0ca48706 oid sha256:b7a3271308ba07c7f75de9e597c477b4d1d25627be4c2732721b3c94ee79dd00
size 91446 size 91191