mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-25 07:42:15 +00:00
android: group preference to prohibit files and media (#2620)
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
2ad9d0ddbc
commit
534151f1bb
@@ -2930,7 +2930,8 @@ enum class GroupFeature: Feature {
|
||||
@SerialName("directMessages") DirectMessages,
|
||||
@SerialName("fullDelete") FullDelete,
|
||||
@SerialName("reactions") Reactions,
|
||||
@SerialName("voice") Voice;
|
||||
@SerialName("voice") Voice,
|
||||
@SerialName("files") Files;
|
||||
|
||||
override val hasParam: Boolean get() = when(this) {
|
||||
TimedMessages -> true
|
||||
@@ -2944,6 +2945,7 @@ enum class GroupFeature: Feature {
|
||||
FullDelete -> generalGetString(R.string.full_deletion)
|
||||
Reactions -> generalGetString(R.string.message_reactions)
|
||||
Voice -> generalGetString(R.string.voice_messages)
|
||||
Files -> generalGetString(R.string.files_and_media)
|
||||
}
|
||||
|
||||
val icon: Painter
|
||||
@@ -2953,6 +2955,7 @@ enum class GroupFeature: Feature {
|
||||
FullDelete -> painterResource(R.drawable.ic_delete_forever)
|
||||
Reactions -> painterResource(R.drawable.ic_add_reaction)
|
||||
Voice -> painterResource(R.drawable.ic_keyboard_voice)
|
||||
Files -> painterResource(R.drawable.ic_draft)
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -2962,6 +2965,7 @@ enum class GroupFeature: Feature {
|
||||
FullDelete -> painterResource(R.drawable.ic_delete_forever_filled)
|
||||
Reactions -> painterResource(R.drawable.ic_add_reaction_filled)
|
||||
Voice -> painterResource(R.drawable.ic_keyboard_voice_filled)
|
||||
Files -> painterResource(R.drawable.ic_draft_filled)
|
||||
}
|
||||
|
||||
fun enableDescription(enabled: GroupFeatureEnabled, canEdit: Boolean): String =
|
||||
@@ -2987,6 +2991,10 @@ enum class GroupFeature: Feature {
|
||||
GroupFeatureEnabled.ON -> generalGetString(R.string.allow_to_send_voice)
|
||||
GroupFeatureEnabled.OFF -> generalGetString(R.string.prohibit_sending_voice)
|
||||
}
|
||||
Files -> when(enabled) {
|
||||
GroupFeatureEnabled.ON -> generalGetString(R.string.allow_to_send_files)
|
||||
GroupFeatureEnabled.OFF -> generalGetString(R.string.prohibit_sending_files)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
when(this) {
|
||||
@@ -3010,6 +3018,10 @@ enum class GroupFeature: Feature {
|
||||
GroupFeatureEnabled.ON -> generalGetString(R.string.group_members_can_send_voice)
|
||||
GroupFeatureEnabled.OFF -> generalGetString(R.string.voice_messages_are_prohibited)
|
||||
}
|
||||
Files -> when(enabled) {
|
||||
GroupFeatureEnabled.ON -> generalGetString(R.string.group_members_can_send_files)
|
||||
GroupFeatureEnabled.OFF -> generalGetString(R.string.files_are_prohibited_in_group)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3122,7 +3134,8 @@ data class FullGroupPreferences(
|
||||
val directMessages: GroupPreference,
|
||||
val fullDelete: GroupPreference,
|
||||
val reactions: GroupPreference,
|
||||
val voice: GroupPreference
|
||||
val voice: GroupPreference,
|
||||
val files: GroupPreference,
|
||||
) {
|
||||
fun toGroupPreferences(): GroupPreferences =
|
||||
GroupPreferences(
|
||||
@@ -3130,7 +3143,8 @@ data class FullGroupPreferences(
|
||||
directMessages = directMessages,
|
||||
fullDelete = fullDelete,
|
||||
reactions = reactions,
|
||||
voice = voice
|
||||
voice = voice,
|
||||
files = files,
|
||||
)
|
||||
|
||||
companion object {
|
||||
@@ -3139,7 +3153,8 @@ data class FullGroupPreferences(
|
||||
directMessages = GroupPreference(GroupFeatureEnabled.OFF),
|
||||
fullDelete = GroupPreference(GroupFeatureEnabled.OFF),
|
||||
reactions = GroupPreference(GroupFeatureEnabled.ON),
|
||||
voice = GroupPreference(GroupFeatureEnabled.ON)
|
||||
voice = GroupPreference(GroupFeatureEnabled.ON),
|
||||
files = GroupPreference(GroupFeatureEnabled.ON),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -3150,7 +3165,8 @@ data class GroupPreferences(
|
||||
val directMessages: GroupPreference?,
|
||||
val fullDelete: GroupPreference?,
|
||||
val reactions: GroupPreference?,
|
||||
val voice: GroupPreference?
|
||||
val voice: GroupPreference?,
|
||||
val files: GroupPreference?,
|
||||
) {
|
||||
companion object {
|
||||
val sampleData = GroupPreferences(
|
||||
@@ -3158,7 +3174,8 @@ data class GroupPreferences(
|
||||
directMessages = GroupPreference(GroupFeatureEnabled.OFF),
|
||||
fullDelete = GroupPreference(GroupFeatureEnabled.OFF),
|
||||
reactions = GroupPreference(GroupFeatureEnabled.ON),
|
||||
voice = GroupPreference(GroupFeatureEnabled.ON)
|
||||
voice = GroupPreference(GroupFeatureEnabled.ON),
|
||||
files = GroupPreference(GroupFeatureEnabled.ON),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import android.webkit.MimeTypeMap
|
||||
import android.widget.Toast
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContract
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.*
|
||||
@@ -713,11 +714,22 @@ fun ComposeView(
|
||||
modifier = Modifier.padding(end = 8.dp),
|
||||
verticalAlignment = Alignment.Bottom,
|
||||
) {
|
||||
IconButton(showChooseAttachment, enabled = !composeState.value.attachmentDisabled && rememberUpdatedState(chat.userCanSend).value) {
|
||||
val isGroupAndProhibitedFiles = chat.chatInfo is ChatInfo.Group && !chat.chatInfo.groupInfo.fullGroupPreferences.files.on
|
||||
val attachmentClicked = if (isGroupAndProhibitedFiles) {
|
||||
{
|
||||
AlertManager.shared.showAlertMsg(
|
||||
title = generalGetString(R.string.files_and_media_prohibited),
|
||||
text = generalGetString(R.string.only_owners_can_enable_files_and_media)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
showChooseAttachment
|
||||
}
|
||||
IconButton(attachmentClicked, enabled = !composeState.value.attachmentDisabled && rememberUpdatedState(chat.userCanSend).value) {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_attach_file_filled_500),
|
||||
contentDescription = stringResource(R.string.attach),
|
||||
tint = if (!composeState.value.attachmentDisabled && userCanSend.value) MaterialTheme.colors.primary else MaterialTheme.colors.secondary,
|
||||
tint = if (!composeState.value.attachmentDisabled && userCanSend.value && !isGroupAndProhibitedFiles) MaterialTheme.colors.primary else MaterialTheme.colors.secondary,
|
||||
modifier = Modifier
|
||||
.size(28.dp)
|
||||
.clip(CircleShape)
|
||||
|
||||
@@ -103,6 +103,12 @@ private fun GroupPreferencesLayout(
|
||||
FeatureSection(GroupFeature.Voice, allowVoice, groupInfo, preferences, onTTLUpdated) {
|
||||
applyPrefs(preferences.copy(voice = GroupPreference(enable = it)))
|
||||
}
|
||||
// TODO uncomment in 5.3
|
||||
// SectionDividerSpaced(true, maxBottomPadding = false)
|
||||
// val allowFiles = remember(preferences) { mutableStateOf(preferences.files.enable) }
|
||||
// FeatureSection(GroupFeature.Files, allowFiles, groupInfo, preferences, onTTLUpdated) {
|
||||
// applyPrefs(preferences.copy(files = GroupPreference(enable = it)))
|
||||
// }
|
||||
if (groupInfo.canEdit) {
|
||||
SectionDividerSpaced(maxTopPadding = true, maxBottomPadding = false)
|
||||
ResetSaveButtons(
|
||||
|
||||
@@ -281,6 +281,8 @@
|
||||
<string name="you_are_observer">you are observer</string>
|
||||
<string name="observer_cant_send_message_title">You can\'t send messages!</string>
|
||||
<string name="observer_cant_send_message_desc">Please contact group admin.</string>
|
||||
<string name="files_and_media_prohibited">Files and media prohibited!</string>
|
||||
<string name="only_owners_can_enable_files_and_media">Only group owners can enable files and media.</string>
|
||||
|
||||
<!-- Images - chat.simplex.app.views.chat.item.CIImageView.kt -->
|
||||
<string name="image_descr">Image</string>
|
||||
@@ -1290,6 +1292,7 @@
|
||||
<string name="full_deletion">Delete for everyone</string>
|
||||
<string name="message_reactions">Message reactions</string>
|
||||
<string name="voice_messages">Voice messages</string>
|
||||
<string name="files_and_media">Files and media</string>
|
||||
<string name="audio_video_calls">Audio/video calls</string>
|
||||
<string name="available_in_v51">\nAvailable in v5.1</string>
|
||||
<string name="feature_enabled">enabled</string>
|
||||
@@ -1344,6 +1347,8 @@
|
||||
<string name="prohibit_sending_voice">Prohibit sending voice messages.</string>
|
||||
<string name="allow_message_reactions">Allow message reactions.</string>
|
||||
<string name="prohibit_message_reactions_group">Prohibit messages reactions.</string>
|
||||
<string name="allow_to_send_files">Allow to send files and media.</string>
|
||||
<string name="prohibit_sending_files">Prohibit sending files and media.</string>
|
||||
<string name="group_members_can_send_disappearing">Group members can send disappearing messages.</string>
|
||||
<string name="disappearing_messages_are_prohibited">Disappearing messages are prohibited in this group.</string>
|
||||
<string name="group_members_can_send_dms">Group members can send direct messages.</string>
|
||||
@@ -1354,6 +1359,8 @@
|
||||
<string name="voice_messages_are_prohibited">Voice messages are prohibited in this group.</string>
|
||||
<string name="group_members_can_add_message_reactions">Group members can add message reactions.</string>
|
||||
<string name="message_reactions_are_prohibited">Message reactions are prohibited in this group.</string>
|
||||
<string name="group_members_can_send_files">Group members can send files and media.</string>
|
||||
<string name="files_are_prohibited_in_group">Files and media are prohibited in this group.</string>
|
||||
<string name="delete_after">Delete after</string>
|
||||
<string name="ttl_sec">%d sec</string>
|
||||
<string name="ttl_s">%ds</string>
|
||||
|
||||
Reference in New Issue
Block a user