From 6948d64fa88d75a5a8bf6de4c5b8ababfc1a8445 Mon Sep 17 00:00:00 2001 From: Al Lansley Date: Mon, 5 Aug 2024 10:45:05 +1000 Subject: [PATCH] WIP --- .../v2/utilities/AttachmentManager.java | 2 +- .../res/layout/fragment_enter_public_key.xml | 2 +- .../menu/menu_conversation_item_action.xml | 2 +- .../utilities/UpdateMessageBuilder.kt | 53 ++++++++++++------- .../recipients/RecipientProvider.java | 2 +- .../src/main/res/values-fr-rFR/strings.xml | 7 --- libsession/src/main/res/values-fr/strings.xml | 7 --- libsession/src/main/res/values/strings.xml | 10 ---- 8 files changed, 37 insertions(+), 48 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/AttachmentManager.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/AttachmentManager.java index eac00952df..7376c18222 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/AttachmentManager.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/AttachmentManager.java @@ -256,7 +256,7 @@ public class AttachmentManager { String needStoragePermissionTxt = Phrase.from(c, R.string.permissionsStorageSend) .put(APP_NAME_KEY, c.getString(R.string.sessionMessenger)) .format().toString(); - String storagePermissionDeniedTxt = Phrase.from(c, R.string.cameraGrantAccessStorageDenied) + String storagePermissionDeniedTxt = Phrase.from(c, R.string.permissionsStorageSaveDenied) .put(APP_NAME_KEY, c.getString(R.string.sessionMessenger)) .format().toString(); diff --git a/app/src/main/res/layout/fragment_enter_public_key.xml b/app/src/main/res/layout/fragment_enter_public_key.xml index cf66f65f2e..dd8f0f18c4 100644 --- a/app/src/main/res/layout/fragment_enter_public_key.xml +++ b/app/src/main/res/layout/fragment_enter_public_key.xml @@ -35,7 +35,7 @@ android:layout_marginTop="@dimen/large_spacing" android:contentDescription="@string/AccessibilityId_account_id_input" android:gravity="center_vertical" - android:hint="@string/accountIdEnterYourFriends" + android:hint="@string/accountIdOrOnsEnter" android:imeOptions="actionDone" android:inputType="textMultiLine" android:maxLines="3" diff --git a/app/src/main/res/menu/menu_conversation_item_action.xml b/app/src/main/res/menu/menu_conversation_item_action.xml index c3ad36f63e..d1758faddf 100644 --- a/app/src/main/res/menu/menu_conversation_item_action.xml +++ b/app/src/main/res/menu/menu_conversation_item_action.xml @@ -27,7 +27,7 @@ app:showAsAction="never" /> diff --git a/libsession/src/main/java/org/session/libsession/messaging/utilities/UpdateMessageBuilder.kt b/libsession/src/main/java/org/session/libsession/messaging/utilities/UpdateMessageBuilder.kt index 23dd0505df..61ae37e102 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/utilities/UpdateMessageBuilder.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/utilities/UpdateMessageBuilder.kt @@ -42,10 +42,8 @@ object UpdateMessageBuilder { return when (updateData) { // --- Group created or joined --- is UpdateMessageData.Kind.GroupCreation -> { - if (isOutgoing) context.getString(R.string.disappearingMessagesNewGroup) - else Phrase.from(context, R.string.disappearingMessagesAddedYou) - .put(NAME_KEY, senderName) - .format().toString() + if (!isOutgoing) context.getString(R.string.groupInviteYou) + else "" // We no longer add a string like `disappearingMessagesNewGroup` ("You created a new group") and leave the group with its default empty state } // --- Group name changed --- @@ -56,8 +54,7 @@ object UpdateMessageBuilder { .format().toString() } else { - Phrase.from(context, R.string.groupNameUpdatedBy) - .put(NAME_KEY, senderName) + Phrase.from(context, R.string.groupNameNew) .put(GROUP_NAME_KEY, updateData.name) .format().toString() } @@ -65,20 +62,36 @@ object UpdateMessageBuilder { // --- Group member(s) were added --- is UpdateMessageData.Kind.GroupMemberAdded -> { - val members = updateData.updatedMembers.joinToString(", ", transform = ::getSenderName) - // You added these members - if (isOutgoing) { - Phrase.from(context, R.string.groupYouAdded) - .put(MEMBERS_KEY, members) - .format().toString() - } - // Someone else added these members - else { - Phrase.from(context, R.string.groupNameAdded) - .put(NAME_KEY,senderName) - .put(MEMBERS_KEY, members) - .format().toString() + val newMemberCount = updateData.updatedMembers.size + + //val members = updateData.updatedMembers.joinToString(", ", transform = ::getSenderName) + + // We previously differentiated between members added by us Vs. members added by someone + // else via checking against `isOutgoing` - but now we use the same strings regardless. + when (newMemberCount) { + 0 -> { + Log.w(TAG, "Somehow asked to add zero new members to group - this should never happen.") + return "" + } + 1 -> { + Phrase.from(context, R.string.groupMemberNew) + .put(NAME_KEY, updateData.updatedMembers.elementAtOrNull(0)) + .format().toString() + } + 2 -> { + Phrase.from(context, R.string.groupMemberTwoNew) + .put(NAME_KEY, updateData.updatedMembers.elementAtOrNull(0)) + .put(OTHER_NAME_KEY, updateData.updatedMembers.elementAtOrNull(1)) + .format().toString() + } + else -> { + val newMemberCountMinusOne = newMemberCount - 1 + Phrase.from(context, R.string.groupMemberMoreNew) + .put(NAME_KEY, updateData.updatedMembers.elementAtOrNull(0)) + .put(COUNT_KEY, newMemberCountMinusOne) + .format().toString() + } } } @@ -217,7 +230,7 @@ object UpdateMessageBuilder { .format().toString() } else // 1-on-1 conversation { - Phrase.from(context, R.string.disappearingMessagesUpdatedYours) + Phrase.from(context, R.string.disappearingMessagesSetYou) .put(TIME_KEY, time) .put(DISAPPEARING_MESSAGES_TYPE_KEY, action) .format().toString() diff --git a/libsession/src/main/java/org/session/libsession/utilities/recipients/RecipientProvider.java b/libsession/src/main/java/org/session/libsession/utilities/recipients/RecipientProvider.java index 8f3ba4e7db..dc74c654ac 100644 --- a/libsession/src/main/java/org/session/libsession/utilities/recipients/RecipientProvider.java +++ b/libsession/src/main/java/org/session/libsession/utilities/recipients/RecipientProvider.java @@ -146,7 +146,7 @@ class RecipientProvider { return new RecipientDetails(title, avatarId, false, false, settings.orNull(), members); } - return new RecipientDetails(context.getString(R.string.groupUnnamed), null, false, false, settings.orNull(), null); + return new RecipientDetails(context.getString(R.string.groupUnknown), null, false, false, settings.orNull(), null); } static class RecipientDetails { diff --git a/libsession/src/main/res/values-fr-rFR/strings.xml b/libsession/src/main/res/values-fr-rFR/strings.xml index 796577d478..5401367554 100644 --- a/libsession/src/main/res/values-fr-rFR/strings.xml +++ b/libsession/src/main/res/values-fr-rFR/strings.xml @@ -1,16 +1,9 @@ - Vous avez créé un nouveau groupe. - %1$s vous a ajouté·e dans le groupe. - {name} a renommé le groupe en : {group_name} - Vous avez ajouté {members} au groupe. - %1$s a ajouté %2$s au groupe. Vous - Groupe sans nom - Oui Non Supprimer diff --git a/libsession/src/main/res/values-fr/strings.xml b/libsession/src/main/res/values-fr/strings.xml index fef47b52a2..b914ca09b8 100644 --- a/libsession/src/main/res/values-fr/strings.xml +++ b/libsession/src/main/res/values-fr/strings.xml @@ -1,16 +1,9 @@ - Vous avez créé un nouveau groupe. - %1$s vous a ajouté·e dans le groupe. - {name} a renommé le groupe en : {group_name} - Vous avez ajouté {members} au groupe. - %1$s a ajouté %2$s au groupe. Vous - Groupe sans nom - Oui Non Supprimer diff --git a/libsession/src/main/res/values/strings.xml b/libsession/src/main/res/values/strings.xml index 1232ee29cd..597235c77b 100644 --- a/libsession/src/main/res/values/strings.xml +++ b/libsession/src/main/res/values/strings.xml @@ -72,7 +72,6 @@ Accept Copy Account ID Enter Account ID - Enter your friend\'s Account ID or ONS This Account ID is invalid. Please check and try again. Enter Account ID or ONS Invite Account ID or ONS @@ -208,7 +207,6 @@ {app_name} needs camera access to take photos and videos, but it has been permanently denied. Please continue to app settings, select \"Permissions\", and enable \"Camera\". {app_name} needs camera access to take photos and videos, or scan QR codes. {app_name} needs camera access to scan QR codes - {app_name} needs storage access to send photos and videos, but it has been permanently denied. Please continue to app settings, select "Permissions", and enable "Storage". Cancel Clear Clear All @@ -307,7 +305,6 @@ Deleting Toggle Developer Tools Disappearing Messages - {name} added you to the group. Auto-deletes in {time_large} Auto-deletes in {time_large} {time_small} Delete Type @@ -322,7 +319,6 @@ Set your messages to disappear {time} after they have been {disappearing_messages_type}? Set your messages to disappear {time} after they have been {disappearing_messages_type}? {name} is using an outdated client. Disappearing messages may not work as expected. - You created a new group. Only group admins can change this setting. Sent {name} has set messages to disappear {time} after they have been {disappearing_messages_type}. @@ -334,7 +330,6 @@ sent {admin_name} updated disappearing message settings. You updated disappearing message settings. - You set your messages to disappear {time} after they have been {disappearing_messages_type}. Dismiss It can be your real name, an alias, or anything else you like — and you can change it at any time. Enter your display name @@ -412,13 +407,11 @@ Group Members There are no other members in this group. Group Name - {name} added {members} to the group. Enter a group name Please enter a group name. Please enter a shorter group name. Group name is now {group_name}. Group name updated. - {name} renamed the group to: {group_name} You have no messages from {group_name}. Send a message to start the conversation! You are the only admin in {group_name}.\nGroup members and settings cannot be changed without an admin. You were promoted to Admin. @@ -435,9 +428,7 @@ You were removed from {group_name}. Set Group Display Picture Unknown Group - Unnamed group Group updated - You added {members} to the group. FAQ Help us translate {app_name} Report a bug @@ -491,7 +482,6 @@ Would you like to share group message history with {name} and {other_name}? Invite Message - Copy message This message is empty. Message delivery failed Message limit reached