Tied in bandDeleteAll string

This commit is contained in:
Al Lansley 2024-08-12 14:17:04 +10:00
parent 93b8e74f2d
commit ea84aa1478
5 changed files with 13 additions and 18 deletions

View File

@ -40,6 +40,8 @@ class ConversationActionModeCallback(private val adapter: ConversationAdapter, p
val edKeyPair = MessagingModuleConfiguration.shared.getUserED25519KeyPair()!!
val blindedPublicKey = openGroup?.publicKey?.let { SodiumUtilities.blindedKeyPair(it, edKeyPair)?.publicKey?.asBytes }
?.let { AccountId(IdPrefix.BLINDED, it) }?.hexString
// Embedded function
fun userCanDeleteSelectedItems(): Boolean {
val allSentByCurrentUser = selectedItems.all { it.isOutgoing }
val allReceivedByCurrentUser = selectedItems.all { !it.isOutgoing }
@ -47,6 +49,8 @@ class ConversationActionModeCallback(private val adapter: ConversationAdapter, p
if (allSentByCurrentUser) { return true }
return OpenGroupManager.isUserModerator(context, openGroup.groupId, userPublicKey, blindedPublicKey)
}
// Embedded function
fun userCanBanSelectedUsers(): Boolean {
if (openGroup == null) { return false }
val anySentByCurrentUser = selectedItems.any { it.isOutgoing }
@ -55,6 +59,9 @@ class ConversationActionModeCallback(private val adapter: ConversationAdapter, p
if (selectedUsers.size > 1) { return false }
return OpenGroupManager.isUserModerator(context, openGroup.groupId, userPublicKey, blindedPublicKey)
}
// Delete message
menu.findItem(R.id.menu_context_delete_message).isVisible = userCanDeleteSelectedItems()
// Ban user

View File

@ -52,11 +52,11 @@ object ConversationMenuHelper {
) {
// Prepare
menu.clear()
val isOpenGroup = thread.isCommunityRecipient
val isCommunity = thread.isCommunityRecipient
// Base menu (options that should always be present)
inflater.inflate(R.menu.menu_conversation, menu)
// Expiring messages
if (!isOpenGroup && (thread.hasApprovedMe() || thread.isClosedGroupRecipient || thread.isLocalNumber)) {
if (!isCommunity && (thread.hasApprovedMe() || thread.isClosedGroupRecipient || thread.isLocalNumber)) {
inflater.inflate(R.menu.menu_conversation_expiration, menu)
}
// One-on-one chat menu allows copying the account id
@ -76,7 +76,7 @@ object ConversationMenuHelper {
inflater.inflate(R.menu.menu_conversation_closed_group, menu)
}
// Open group menu
if (isOpenGroup) {
if (isCommunity) {
inflater.inflate(R.menu.menu_conversation_open_group, menu)
}
// Muting

View File

@ -95,6 +95,7 @@ import kotlin.time.Duration.Companion.hours
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds
// Intent extra keys so we know where we came from
private const val NEW_ACCOUNT = "HomeActivity_NEW_ACCOUNT"
private const val FROM_ONBOARDING = "HomeActivity_FROM_ONBOARDING"
@ -105,11 +106,6 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
private val TAG = "HomeActivity"
// companion object {
// const val NEW_ACCOUNT = "HomeActivity_NEW_ACCOUNT"
// const val FROM_ONBOARDING = "HomeActivity_FROM_ONBOARDING"
// }
private lateinit var binding: ActivityHomeBinding
private lateinit var glide: RequestManager
@ -160,12 +156,6 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
private val isFromOnboarding: Boolean get() = intent.getBooleanExtra(FROM_ONBOARDING, false)
private val isNewAccount: Boolean get() = intent.getBooleanExtra(NEW_ACCOUNT, false)
// ACL REMOVE BLOCK START
fun getRelativeTimeLocalized(timestampMS: Long): String {

View File

@ -47,9 +47,8 @@
android:id="@+id/menu_context_ban_user"
app:showAsAction="never" />
<!-- ACL - we don't have a "Ban and delete all" string - ping Lucy -->
<item
android:title="Ban and delete all NEED STRING!"
android:title="@string/banDeleteAll"
android:id="@+id/menu_context_ban_and_delete_all"
app:showAsAction="never" />

View File

@ -679,8 +679,7 @@ object OpenGroupApi {
}
fun unban(publicKey: String, room: String, server: String): Promise<Unit, Exception> {
val request =
Request(verb = DELETE, room = room, server = server, endpoint = Endpoint.UserUnban(publicKey))
val request = Request(verb = DELETE, room = room, server = server, endpoint = Endpoint.UserUnban(publicKey))
return send(request).map {
Log.d("Loki", "Unbanned user: $publicKey from: $server.$room")
}