mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-02 08:23:00 +01:00
Inline the send member labels feature flag.
This commit is contained in:
committed by
Michelle Tang
parent
dba5252be6
commit
a5e00c4319
@@ -860,20 +860,18 @@ class ConversationSettingsFragment :
|
||||
}
|
||||
)
|
||||
|
||||
if (RemoteConfig.sendMemberLabels) {
|
||||
clickPref(
|
||||
title = DSLSettingsText.from(R.string.ConversationSettingsFragment__group_member_label),
|
||||
icon = DSLSettingsIcon.from(R.drawable.symbol_tag_24),
|
||||
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()
|
||||
}
|
||||
)
|
||||
}
|
||||
clickPref(
|
||||
title = DSLSettingsText.from(R.string.ConversationSettingsFragment__group_member_label),
|
||||
icon = DSLSettingsIcon.from(R.drawable.symbol_tag_24),
|
||||
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()
|
||||
}
|
||||
)
|
||||
|
||||
clickPref(
|
||||
title = DSLSettingsText.from(R.string.ConversationSettingsFragment__requests_and_invites),
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.thoughtcrime.securesms.components.settings.DSLSettingsText
|
||||
import org.thoughtcrime.securesms.components.settings.configure
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.groups.ui.GroupErrors
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig
|
||||
import org.thoughtcrime.securesms.util.adapter.mapping.MappingAdapter
|
||||
|
||||
class PermissionsSettingsFragment : DSLSettingsFragment(
|
||||
@@ -87,21 +86,19 @@ class PermissionsSettingsFragment : DSLSettingsFragment(
|
||||
}
|
||||
)
|
||||
|
||||
if (RemoteConfig.sendMemberLabels) {
|
||||
radioListPref(
|
||||
title = DSLSettingsText.from(R.string.PermissionsSettingsFragment__add_member_labels),
|
||||
isEnabled = state.selfCanEditSettings,
|
||||
listItems = permissionsOptions,
|
||||
dialogTitle = DSLSettingsText.from(R.string.PermissionsSettingsFragment__who_can_add_member_labels),
|
||||
selected = getSelected(state.nonAdminCanSetMemberLabel),
|
||||
confirmAction = true,
|
||||
onSelected = { selectedIndex ->
|
||||
if (selectedIndex >= 0) {
|
||||
viewModel.onMemberLabelPermissionChangeRequested(nonAdminCanSetMemberLabel = selectedIndex == 1)
|
||||
}
|
||||
radioListPref(
|
||||
title = DSLSettingsText.from(R.string.PermissionsSettingsFragment__add_member_labels),
|
||||
isEnabled = state.selfCanEditSettings,
|
||||
listItems = permissionsOptions,
|
||||
dialogTitle = DSLSettingsText.from(R.string.PermissionsSettingsFragment__who_can_add_member_labels),
|
||||
selected = getSelected(state.nonAdminCanSetMemberLabel),
|
||||
confirmAction = true,
|
||||
onSelected = { selectedIndex ->
|
||||
if (selectedIndex >= 0) {
|
||||
viewModel.onMemberLabelPermissionChangeRequested(nonAdminCanSetMemberLabel = selectedIndex == 1)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.keyvalue.UiHintValues
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig
|
||||
import org.whispersystems.signalservice.api.NetworkResult
|
||||
|
||||
/**
|
||||
@@ -97,7 +96,6 @@ class MemberLabelRepository private constructor(
|
||||
* 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
|
||||
|
||||
val memberLevel = groupRecord.memberLevel(recipient)
|
||||
@@ -147,10 +145,6 @@ class MemberLabelRepository private constructor(
|
||||
* Sets the group member label for the current user.
|
||||
*/
|
||||
suspend fun setLabel(groupId: GroupId.V2, label: MemberLabel): NetworkResult<Unit> = withContext(Dispatchers.IO) {
|
||||
if (!RemoteConfig.sendMemberLabels) {
|
||||
throw IllegalStateException("Set member label not allowed due to remote config.")
|
||||
}
|
||||
|
||||
val sanitizedLabel = label.sanitized()
|
||||
NetworkResult.fromFetch {
|
||||
GroupManager.updateMemberLabel(context, groupId, sanitizedLabel.text, sanitizedLabel.emoji.orEmpty())
|
||||
|
||||
@@ -19,7 +19,6 @@ import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.groups.memberlabel.MemberLabel
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig
|
||||
|
||||
class AboutSheetViewModel(
|
||||
recipientId: RecipientId,
|
||||
@@ -56,7 +55,7 @@ class AboutSheetViewModel(
|
||||
init {
|
||||
disposables.addAll(recipientDisposable, groupsInCommonDisposable, verifiedDisposable)
|
||||
|
||||
if (groupId != null && RemoteConfig.sendMemberLabels) {
|
||||
if (groupId != null) {
|
||||
observeMemberLabel(groupId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.signal.core.util.gibiBytes
|
||||
import org.signal.core.util.kibiBytes
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.core.util.mebiBytes
|
||||
import org.thoughtcrime.securesms.BuildConfig
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.groups.SelectionLimits
|
||||
import org.thoughtcrime.securesms.jobs.RemoteConfigRefreshJob
|
||||
@@ -522,24 +521,6 @@ object RemoteConfig {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* A config that evaluates to true when the app's version is >= the semantic version string (e.g. "8.2.0") stored in the remote config value.
|
||||
*
|
||||
* Returns false if the remote value is absent, empty, or unparseable.
|
||||
*/
|
||||
@Suppress("SameParameterValue")
|
||||
private fun remoteMinVersion(
|
||||
key: String
|
||||
): Config<Boolean> = remoteValue(
|
||||
key = key,
|
||||
hotSwappable = true,
|
||||
transformer = { value ->
|
||||
val minVersion = SemanticVersion.parse(value.asString(null))
|
||||
val appVersion = SemanticVersion.parse(BuildConfig.VERSION_NAME.substringBefore("-"))
|
||||
minVersion != null && appVersion != null && appVersion >= minVersion
|
||||
}
|
||||
)
|
||||
|
||||
private fun <T> remoteValue(
|
||||
key: String,
|
||||
hotSwappable: Boolean,
|
||||
@@ -1278,15 +1259,6 @@ object RemoteConfig {
|
||||
hotSwappable = true
|
||||
)
|
||||
|
||||
/**
|
||||
* Whether to enable modifying group member labels.
|
||||
*/
|
||||
@JvmStatic
|
||||
@get:JvmName("sendMemberLabels")
|
||||
val sendMemberLabels: Boolean by remoteMinVersion(
|
||||
key = "android.sendMemberLabels.4"
|
||||
)
|
||||
|
||||
/**
|
||||
* Whether or not to receive admin delete messages.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user