mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-02 08:23:00 +01:00
Allow any group member to set member labels.
This commit is contained in:
committed by
Greyson Parrelli
parent
a6c8b940c9
commit
16e63a061d
@@ -861,17 +861,13 @@ class ConversationSettingsFragment :
|
||||
)
|
||||
|
||||
if (RemoteConfig.sendMemberLabels) {
|
||||
val canSetMemberLabel = groupState.canSetOwnMemberLabel && !state.isDeprecatedOrUnregistered
|
||||
clickPref(
|
||||
title = DSLSettingsText.from(R.string.ConversationSettingsFragment__group_member_label),
|
||||
icon = DSLSettingsIcon.from(R.drawable.symbol_tag_24),
|
||||
isEnabled = canSetMemberLabel,
|
||||
isEnabled = groupState.canSetOwnMemberLabel && !state.isDeprecatedOrUnregistered,
|
||||
onClick = {
|
||||
val action = ConversationSettingsFragmentDirections.actionConversationSettingsFragmentToMemberLabelFragment(groupState.groupId)
|
||||
navController.safeNavigate(action)
|
||||
},
|
||||
onDisabledClicked = {
|
||||
Snackbar.make(requireView(), R.string.GroupMemberLabel__error_no_edit_permission, Snackbar.LENGTH_SHORT).show()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -522,8 +522,8 @@ sealed class ConversationSettingsViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadCanSetMemberLabel(v2GroupId: GroupId.V2) = viewModelScope.launch(SignalDispatchers.IO) {
|
||||
val canSetLabel = MemberLabelRepository.instance.canSetLabel(v2GroupId, Recipient.self())
|
||||
private fun loadCanSetMemberLabel(groupId: GroupId.V2) = viewModelScope.launch(SignalDispatchers.IO) {
|
||||
val canSetLabel = MemberLabelRepository.instance.canSetLabel(groupId, Recipient.self())
|
||||
store.update {
|
||||
it.copy(
|
||||
specificSettingsState = it.requireGroupSettingsState().copy(
|
||||
|
||||
@@ -142,10 +142,10 @@ import org.thoughtcrime.securesms.revealable.ViewOnceUtil
|
||||
import org.thoughtcrime.securesms.sms.GroupV2UpdateMessageUtil
|
||||
import org.thoughtcrime.securesms.stories.Stories.isFeatureEnabled
|
||||
import org.thoughtcrime.securesms.util.JsonUtils
|
||||
import org.thoughtcrime.securesms.util.SignalTrace
|
||||
import org.thoughtcrime.securesms.util.MediaUtil
|
||||
import org.thoughtcrime.securesms.util.MessageConstraintsUtil
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig
|
||||
import org.thoughtcrime.securesms.util.SignalTrace
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.thoughtcrime.securesms.util.isStory
|
||||
import org.whispersystems.signalservice.internal.push.SyncMessage
|
||||
|
||||
@@ -68,9 +68,9 @@ import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.recipients.RecipientUtil
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
import org.thoughtcrime.securesms.util.ConversationUtil
|
||||
import org.thoughtcrime.securesms.util.SignalTrace
|
||||
import org.thoughtcrime.securesms.util.JsonUtils
|
||||
import org.thoughtcrime.securesms.util.JsonUtils.SaneJSONObject
|
||||
import org.thoughtcrime.securesms.util.SignalTrace
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.thoughtcrime.securesms.util.isPoll
|
||||
import org.thoughtcrime.securesms.util.isScheduled
|
||||
|
||||
@@ -107,7 +107,6 @@ class MemberLabelFragment : ComposeFragment(), ReactWithAnyEmojiBottomSheetDialo
|
||||
}
|
||||
|
||||
val networkErrorMessage = stringResource(R.string.GroupMemberLabel__error_cant_save_no_network)
|
||||
val noPermissionErrorMessage = stringResource(R.string.GroupMemberLabel__error_no_edit_permission)
|
||||
|
||||
LaunchedEffect(uiState.saveState) {
|
||||
when (uiState.saveState) {
|
||||
@@ -121,10 +120,7 @@ class MemberLabelFragment : ComposeFragment(), ReactWithAnyEmojiBottomSheetDialo
|
||||
viewModel.onSaveStateConsumed()
|
||||
}
|
||||
|
||||
is SaveState.InsufficientRights -> {
|
||||
snackbarHostState.showSnackbar(noPermissionErrorMessage)
|
||||
viewModel.onSaveStateConsumed()
|
||||
}
|
||||
is SaveState.InsufficientRights -> throw IllegalStateException("User does not have permission to set member label.")
|
||||
|
||||
is SaveState.InProgress, null -> Unit
|
||||
}
|
||||
|
||||
@@ -94,12 +94,12 @@ class MemberLabelRepository private constructor(
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the [Recipient] has permission to set their member label in the given group.
|
||||
* Checks whether [recipient] has permission to set their member label in the given group.
|
||||
*/
|
||||
suspend fun canSetLabel(groupId: GroupId.V2, recipient: Recipient): Boolean = withContext(Dispatchers.IO) {
|
||||
if (!RemoteConfig.sendMemberLabels) return@withContext false
|
||||
val groupRecord = groupsTable.getGroup(groupId).orNull() ?: return@withContext false
|
||||
groupRecord.attributesAccessControl.allows(groupRecord.memberLevel(recipient))
|
||||
groupRecord.memberLevel(recipient).isInGroup
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1252,7 +1252,7 @@ object RemoteConfig {
|
||||
@JvmStatic
|
||||
@get:JvmName("sendMemberLabels")
|
||||
val sendMemberLabels: Boolean by remoteBoolean(
|
||||
key = "android.sendMemberLabels.2",
|
||||
key = "android.sendMemberLabels.3",
|
||||
defaultValue = false,
|
||||
hotSwappable = true
|
||||
)
|
||||
|
||||
@@ -179,7 +179,7 @@
|
||||
<color name="quote_view_bar_outgoing_normal">@color/signal_colorOnCustom</color>
|
||||
<color name="quote_view_foreground_outgoing_normal">@color/signal_colorOnSurface</color>
|
||||
<color name="quote_view_label_background_incoming_normal">@color/signal_colorOnSurface_8</color>
|
||||
<color name="quote_view_label_background_incoming_wallpaper">@color/transparent_white_80</color>
|
||||
<color name="quote_view_label_background_incoming_wallpaper">@color/signal_colorOnSurface_8</color>
|
||||
<color name="quote_view_label_background_outgoing_normal">@color/transparent_white_36</color>
|
||||
<color name="quote_view_label_background_outgoing_wallpaper">@color/transparent_white_36</color>
|
||||
|
||||
|
||||
@@ -9471,8 +9471,6 @@
|
||||
<string name="GroupMemberLabel__description">Add a member label to describe yourself or your role in this group. Labels are only visible within this group.</string>
|
||||
<!-- Error message shown when the group member label fails to save due to a network error. -->
|
||||
<string name="GroupMemberLabel__error_cant_save_no_network">Couldn\'t save label. Check your network and try again.</string>
|
||||
<!-- Error message shown when trying to edit a member label without adequate permission. -->
|
||||
<string name="GroupMemberLabel__error_no_edit_permission">Only admins can add member labels in this group.</string>
|
||||
<!-- Accessibility label for the button to open the group member label emoji picker. -->
|
||||
<string name="GroupMemberLabel__accessibility_select_emoji">Select emoji</string>
|
||||
<!-- Accessibility label for the group member label close screen button. -->
|
||||
|
||||
Reference in New Issue
Block a user