From b52048a080ac5c9cf6217d5f519c79aa48c873b6 Mon Sep 17 00:00:00 2001 From: alansley Date: Tue, 27 Aug 2024 14:42:57 +1000 Subject: [PATCH] Addressed many aspects of PR feedback + misc. strings issues --- .../conversation/v2/ConversationActivityV2.kt | 6 +- .../conversation/v2/search/SearchBottomBar.kt | 38 --------- .../MultipleRecipientNotificationBuilder.java | 4 - .../securesms/onboarding/landing/Landing.kt | 24 +++--- .../MessageNotifications.kt | 80 ++++++++++++++----- .../preferences/HelpSettingsActivity.kt | 4 +- .../PrivacySettingsPreferenceFragment.kt | 4 +- app/src/main/res/xml/preferences_privacy.xml | 1 + .../utilities/UpdateMessageBuilder.kt | 9 +-- libsession/src/main/res/values/strings.xml | 30 +++---- 10 files changed, 91 insertions(+), 109 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index f6e37da6a3..1481d8ff12 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -2101,8 +2101,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe override fun banUser(messages: Set) { showSessionDialog { title(R.string.banUser) - // ACL TODO - We need a string for the below `text` element - have asked Lucy about this 2024/08/26 -AL - text("This will ban the selected user from this room. It won't ban them from other rooms.") + text(R.string.communityBanDescription) button(R.string.banUser) { viewModel.banUser(messages.first().individualRecipient); endActionMode() } cancelButton(::endActionMode) } @@ -2111,8 +2110,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe override fun banAndDeleteAll(messages: Set) { showSessionDialog { title(R.string.banUser) - // ACL TODO - We need a string for the below `text` element - have asked Lucy about this 2024/08/26 -AL - text("This will ban the selected user from this room and delete all messages sent by them. It won't ban them from other rooms or delete the messages they sent there.") + text(R.string.communityBanDeleteDescription) button(R.string.banUser) { viewModel.banAndDeleteAll(messages.first()); endActionMode() } cancelButton(::endActionMode) } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/search/SearchBottomBar.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/search/SearchBottomBar.kt index 81224b1282..a379a23445 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/search/SearchBottomBar.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/search/SearchBottomBar.kt @@ -45,44 +45,6 @@ class SearchBottomBar : LinearLayout { setViewEnabled(searchDown, position > 0) } - /* - fun setData(position: Int, count: Int, query: String?) = with(binding) { - searchProgressWheel.visibility = GONE - searchUp.setOnClickListener { v: View? -> - if (eventListener != null) { - eventListener!!.onSearchMoveUpPressed() - } - } - searchDown.setOnClickListener { v: View? -> - if (eventListener != null) { - eventListener!!.onSearchMoveDownPressed() - } - } - - // If we found search results list how many we found - if (count > 0) { - searchPosition.text = Phrase.from(context, R.string.searchMatches) - .put(COUNT_KEY, position + 1) - .put(TOTAL_COUNT_KEY, count) - .format() - } else { - // If there are no results we don't display anything if the query is - // empty, but we'll substitute "No results found for " otherwise. - var txt = "" - if (query != null) { - if (query.isNotEmpty()) { - txt = Phrase.from(context, R.string.searchMatchesNoneSpecific) - .put(QUERY_KEY, query) - .format().toString() - } - } - searchPosition.text = txt - } - setViewEnabled(searchUp, position < count - 1) - setViewEnabled(searchDown, position > 0) - } - */ - fun showLoading() { binding.searchProgressWheel.visibility = VISIBLE } diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/MultipleRecipientNotificationBuilder.java b/app/src/main/java/org/thoughtcrime/securesms/notifications/MultipleRecipientNotificationBuilder.java index 4898c9b840..2ee1fd2c17 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/MultipleRecipientNotificationBuilder.java +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/MultipleRecipientNotificationBuilder.java @@ -45,10 +45,6 @@ public class MultipleRecipientNotificationBuilder extends AbstractNotificationBu .put(CONVERSATION_COUNT_KEY, threadCount) .format().toString(); setSubText(txt); - - // Note: `setContentInfo` details are only visible in Android API 24 and below - as our minimum is now API 26 this can be skipped. - //setContentInfo(String.valueOf(messageCount)); - setNumber(messageCount); } diff --git a/app/src/main/java/org/thoughtcrime/securesms/onboarding/landing/Landing.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/landing/Landing.kt index 0ebd1752d8..0bd011a162 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/onboarding/landing/Landing.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/landing/Landing.kt @@ -131,21 +131,17 @@ internal fun LandingScreen( MESSAGES.take(count), key = { it.stringId } ) { item -> - // Perform string substitution in the bubbles that require it - if (item.stringId == R.string.onboardingBubbleWelcomeToSession || - item.stringId == R.string.onboardingBubbleSessionIsEngineered) { - AnimateMessageText( - Phrase.from(stringResource(item.stringId)) - .put(APP_NAME_KEY, stringResource(R.string.app_name)) - .format().toString(), - item.isOutgoing - ) - } else { // Non-substituted text bubbles - AnimateMessageText( - stringResource(item.stringId), - item.isOutgoing - ) + // Perform string substitution only in the bubbles that require it + val bubbleTxt = if (item.stringId == R.string.onboardingBubbleWelcomeToSession || + item.stringId == R.string.onboardingBubbleSessionIsEngineered) { + Phrase.from(stringResource(item.stringId)).put(APP_NAME_KEY, stringResource(R.string.app_name)).format().toString() + } else { + stringResource(item.stringId) } + AnimateMessageText( + bubbleTxt, + item.isOutgoing + ) } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/onboarding/messagenotifications/MessageNotifications.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/messagenotifications/MessageNotifications.kt index 1e093bd7e2..640f2be946 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/onboarding/messagenotifications/MessageNotifications.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/messagenotifications/MessageNotifications.kt @@ -80,12 +80,13 @@ internal fun MessageNotificationsScreen( // spacing between buttons is provided by ripple/downstate of NotificationRadioButton - val txt = Phrase.from(stringResource(R.string.onboardingMessageNotificationExplanation)) + val explanationTxt = Phrase.from(stringResource(R.string.notificationsSlowModeDescription)) .put(APP_NAME_KEY, stringResource(R.string.app_name)) .format().toString() + NotificationRadioButton( - R.string.notificationsSlowMode, - R.string.notificationsSlowModeDescription, + stringResource(R.string.notificationsSlowMode), + explanationTxt, modifier = Modifier.contentDescription(R.string.AccessibilityId_notificationsSlowMode), checked = state.pushDisabled, onClick = { setEnabled(false) } @@ -99,8 +100,8 @@ internal fun MessageNotificationsScreen( @Composable private fun NotificationRadioButton( - @StringRes title: Int, - @StringRes explanation: Int, + @StringRes titleId: Int, + @StringRes explanationId: Int, modifier: Modifier = Modifier, @StringRes tag: Int? = null, checked: Boolean = false, @@ -124,28 +125,65 @@ private fun NotificationRadioButton( Column( modifier = Modifier.padding(horizontal = LocalDimensions.current.smallSpacing, vertical = LocalDimensions.current.xsSpacing)) { Text( - stringResource(title), + stringResource(titleId), style = LocalType.current.h8 ) - // If this radio button is the one for slow mode notifications then substitute the app name.. - if (explanation == R.string.notificationsSlowModeDescription) { - val txt = Phrase.from(stringResource(explanation)) - .put(APP_NAME_KEY, stringResource(R.string.app_name)) - .format().toString() + Text( + stringResource(explanationId), + style = LocalType.current.small, + modifier = Modifier.padding(top = LocalDimensions.current.xxsSpacing) + ) + + tag?.let { Text( - txt, - style = LocalType.current.small, - modifier = Modifier.padding(top = LocalDimensions.current.xxsSpacing) - ) - } else { - // ..otherwise just pass through the text as it is. - Text( - stringResource(explanation), - style = LocalType.current.small, - modifier = Modifier.padding(top = LocalDimensions.current.xxsSpacing) + stringResource(it), + modifier = Modifier.padding(top = LocalDimensions.current.xxsSpacing), + color = LocalColors.current.primary, + style = LocalType.current.h9 ) } + } + } + } +} + +@Composable +private fun NotificationRadioButton( + titleTxt: String, + explanationTxt: String, + modifier: Modifier = Modifier, + @StringRes tag: Int? = null, + checked: Boolean = false, + onClick: () -> Unit = {} +) { + RadioButton( + onClick = onClick, + modifier = modifier, + selected = checked, + contentPadding = PaddingValues(horizontal = LocalDimensions.current.mediumSpacing, vertical = 7.dp) + ) { + Box( + modifier = Modifier + .weight(1f) + .border( + LocalDimensions.current.borderStroke, + LocalColors.current.borders, + RoundedCornerShape(8.dp) + ), + ) { + Column( + modifier = Modifier.padding(horizontal = LocalDimensions.current.smallSpacing, vertical = LocalDimensions.current.xsSpacing)) { + Text( + titleTxt, + style = LocalType.current.h8 + ) + + Text( + explanationTxt, + style = LocalType.current.small, + modifier = Modifier.padding(top = LocalDimensions.current.xxsSpacing) + ) tag?.let { Text( diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/HelpSettingsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/HelpSettingsActivity.kt index aa0a07ecb8..a63b8b391b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/HelpSettingsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/HelpSettingsActivity.kt @@ -46,13 +46,13 @@ class HelpSettingsFragment: CorrectedPreferenceFragment() { addPreferencesFromResource(R.xml.preferences_help) // String sub the summary text of the `export_logs` element in preferences_help.xml - var exportPref = preferenceScreen.findPreference(EXPORT_LOGS) + val exportPref = preferenceScreen.findPreference(EXPORT_LOGS) exportPref?.summary = Phrase.from(context, R.string.helpReportABugExportLogsDescription) .put(APP_NAME_KEY, getString(R.string.app_name)) .format() // String sub the summary text of the `translate_session` element in preferences_help.xml - var translatePref = preferenceScreen.findPreference(TRANSLATE) + val translatePref = preferenceScreen.findPreference(TRANSLATE) translatePref?.title = Phrase.from(context, R.string.helpHelpUsTranslateSession) .put(APP_NAME_KEY, getString(R.string.app_name)) .format() diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/PrivacySettingsPreferenceFragment.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/PrivacySettingsPreferenceFragment.kt index f8164626bd..361f7b5fd5 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/PrivacySettingsPreferenceFragment.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/PrivacySettingsPreferenceFragment.kt @@ -3,14 +3,13 @@ package org.thoughtcrime.securesms.preferences import android.app.KeyguardManager import android.content.Context import android.content.Intent -import android.net.Uri -import android.os.Build import android.os.Bundle import android.provider.Settings import androidx.preference.Preference import androidx.preference.PreferenceCategory import androidx.preference.PreferenceDataStore import dagger.hilt.android.AndroidEntryPoint +import javax.inject.Inject import network.loki.messenger.BuildConfig import network.loki.messenger.R import org.session.libsession.utilities.TextSecurePreferences @@ -24,7 +23,6 @@ import org.thoughtcrime.securesms.service.KeyCachingService import org.thoughtcrime.securesms.showSessionDialog import org.thoughtcrime.securesms.util.CallNotificationBuilder.Companion.areNotificationsEnabled import org.thoughtcrime.securesms.util.IntentUtils -import javax.inject.Inject @AndroidEntryPoint class PrivacySettingsPreferenceFragment : ListSummaryPreferenceFragment() { diff --git a/app/src/main/res/xml/preferences_privacy.xml b/app/src/main/res/xml/preferences_privacy.xml index 2491e8f88a..7bbe34deed 100644 --- a/app/src/main/res/xml/preferences_privacy.xml +++ b/app/src/main/res/xml/preferences_privacy.xml @@ -39,6 +39,7 @@ android:key="pref_typing_indicators" android:title="@string/typingIndicators" android:summary="@string/typingIndicatorsDescription" /> + 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 f20ba1ec16..9b9bbaa37c 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 @@ -35,7 +35,6 @@ object UpdateMessageBuilder { ?.displayName(Contact.ContactContext.REGULAR) ?: truncateIdForDisplay(senderId) - //@RequiresApi(Build.VERSION_CODES.P) fun buildGroupUpdateMessage(context: Context, updateMessageData: UpdateMessageData, senderId: String? = null, isOutgoing: Boolean = false): CharSequence { val updateData = updateMessageData.kind if (updateData == null || !isOutgoing && senderId == null) return "" @@ -71,7 +70,7 @@ object UpdateMessageBuilder { val newMemberCount = updateData.updatedMembers.size - // We previously differentiated between members added by us Vs. members added by someone + // Note: 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 -> { @@ -126,7 +125,7 @@ object UpdateMessageBuilder { .put(NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(0))) .put(OTHER_NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(1))) .format() - else -> Phrase.from(context, R.string.groupRemovedMore) + else -> Phrase.from(context, R.string.groupRemovedMultiple) .put(NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(0))) .put(COUNT_KEY, updateData.updatedMembers.size - 1) .format() @@ -150,7 +149,7 @@ object UpdateMessageBuilder { .put(NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(0))) .put(OTHER_NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(1))) .format() - else -> Phrase.from(context, R.string.groupRemovedMore) + else -> Phrase.from(context, R.string.groupRemovedMultiple) .put(NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(0))) .put(COUNT_KEY, updateData.updatedMembers.size - 1) .format() @@ -175,7 +174,7 @@ object UpdateMessageBuilder { .put(NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(0))) .put(OTHER_NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(1))) .format() - else -> Phrase.from(context, R.string.groupMemberLeftMore) + else -> Phrase.from(context, R.string.groupMemberLeftMultiple) .put(NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(0))) .put(COUNT_KEY, updateData.updatedMembers.size - 1) .format() diff --git a/libsession/src/main/res/values/strings.xml b/libsession/src/main/res/values/strings.xml index 037ad1aca1..524c808fb2 100644 --- a/libsession/src/main/res/values/strings.xml +++ b/libsession/src/main/res/values/strings.xml @@ -32,8 +32,8 @@ NOTE: Strings with blank lines have manually been replaced with '\n\n' - this wi {name} was promoted to Admin. Admin promotion failed Failed to promote {name} in {group_name} - Failed to promote {name} and {count} others in {group_name} - Failed to promote {name} and {other_name} in {group_name} + Failed to promote {name} and {count} others in {group_name} + Failed to promote {name} and {other_name} in {group_name} Admin promotion sent Remove Admins Remove as Admin @@ -198,6 +198,8 @@ NOTE: Strings with blank lines have manually been replaced with '\n\n' - this wi Are you sure you want to clear all Note to Self messages from your device? Close Close Window + This will ban the selected user from this Community. Are you sure you want to continue? + This will ban the selected user from this Community and delete all their messages. Are you sure you want to continue? Enter Community URL Invalid URL Please check the Community URL and try again. @@ -363,14 +365,6 @@ NOTE: Strings with blank lines have manually been replaced with '\n\n' - this wi And %1$d other has reacted %2$s to this message. And %1$d others have reacted %2$s to this message. - {name} reacted with - {name} and {other_name} reacted with - {name}, {other_name} and {count} others reacted with - {name}, {other_name} and 1 other reacted with - You reacted with - You and {name} reacted with - You, {name} and {count} others reacted with - You, {name} and 1 other reacted with Reacted to your message {emoji} Enable Please check your internet connection and try again. @@ -416,14 +410,14 @@ NOTE: Strings with blank lines have manually been replaced with '\n\n' - this wi Failed to leave {group_name} Groups have been upgraded, create a new group to upgrade. Old group functionality will be degraded from {date}. {name} left the group. - {name} and {count} others left the group. + {name} and {count} others left the group. {name} and {other_name} left the group. {name} and {count} others joined the group. - {name} was invited to join the group. + {name} joined the group. {name} was invited to join the group. Chat history was shared. {name} and {count} others were invited to join the group. Chat history was shared. {name} and {other_name} were invited to join the group. Chat history was shared. - {name} and {count} others were invited to join the group. + {name} and {count} others joined the group. {name} and {other_name} were invited to join the group. {name} was invited to join the group. Chat history was shared. You and {count} others were invited to join the group. Chat history was shared. @@ -449,14 +443,15 @@ NOTE: Strings with blank lines have manually been replaced with '\n\n' - this wi You and {count} others were promoted to Admin. You and {name} were promoted to Admin. Would you like to remove {name} from {group_name}? + Would you like to remove {name} and {other_name} from {group_name}? Remove user and their messages - Would you like to remove {name} and {count} others from {group_name}? + Would you like to remove {name} and {count} others from {group_name}? Would you like to remove {name} and {other_name} from {group_name}? Remove user Remove users and their messages Remove users {name} was removed from the group. - {name} and {count} others were removed from the group. + {name} and {count} others were removed from the group. {name} and {other_name} were removed from the group. You were removed from {group_name}. You and {count} others were removed from the group. @@ -501,7 +496,6 @@ NOTE: Strings with blank lines have manually been replaced with '\n\n' - this wi Loading... Lock App Require fingerprint, PIN, pattern or password to unlock {app_name}. - Require Touch ID, Face ID or your passcode to unlock {app_name}. You must enable a passcode in your iOS Settings in order to use Screen Lock. {app_name} is locked Quick response unavailable when {app_name} is locked! @@ -526,7 +520,7 @@ NOTE: Strings with blank lines have manually been replaced with '\n\n' - this wi Share message history Would you like to share group message history with {name} and {count} others? Share new messages only - Would you like to share group message history with {name} and {other_name}? + Would you like to share group message history with {name} and {other_name}? Invite Message This message is empty. @@ -592,7 +586,6 @@ NOTE: Strings with blank lines have manually been replaced with '\n\n' - this wi No Name or Content Fast Mode You\'ll be notified of new messages reliably and immediately using Google\'s notification Servers. - You\'ll be notified of new messages reliably and immediately using Apple\'s notification Servers. Go to device notification settings {name} to {conversation_name} You may have received messages while your {device} was restarting. @@ -759,6 +752,7 @@ NOTE: Strings with blank lines have manually been replaced with '\n\n' - this wi Help Invite a Friend Message Requests + {token_name_long} ({{token_name_short}) Notifications Permissions Privacy