Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/strings updates #1659

Merged
merged 37 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f241328
Fixing styling issue in unread scroll to bottom button
ThomasSession Sep 2, 2024
32acd6e
Fixing up styling of Prominent buttons and "view_user" to work better…
ThomasSession Sep 2, 2024
28d59f9
Fixing strings
ThomasSession Sep 2, 2024
ea24ff6
Strings fixes
ThomasSession Sep 3, 2024
97db1fe
Reworked preferences
ThomasSession Sep 3, 2024
2704bc7
Updated the fake message in appearance
ThomasSession Sep 3, 2024
4aa68c9
Adding the ability to copy in message details
ThomasSession Sep 3, 2024
4d47354
Showing 'copy account id' in menu in 1to1 too
ThomasSession Sep 3, 2024
ffbb7d8
Updating files tab in "All media"
ThomasSession Sep 3, 2024
2f4c605
Strings updates
ThomasSession Sep 4, 2024
81f56de
Latest strings and handling bold
ThomasSession Sep 4, 2024
86f89f8
Updated constants file
ThomasSession Sep 4, 2024
d7bd0bf
Can save media in message details page now
ThomasSession Sep 4, 2024
bc067b6
Adding padding so that context menu doesn't hit the bottom of the screen
ThomasSession Sep 4, 2024
3db8b46
Strings update
ThomasSession Sep 4, 2024
7f8e9fd
Reverted changes on DMs
ThomasSession Sep 4, 2024
14207c7
Better ripple for home FAB
ThomasSession Sep 5, 2024
2c3e73b
Added a control message when the current user accepts a message request
ThomasSession Sep 5, 2024
a7843af
Updated QR screen to show dialog when permission is permanently denied
ThomasSession Sep 5, 2024
fa90b74
Using the Compose version of our QR scanning
ThomasSession Sep 5, 2024
4fd3961
Comments for future changes in JoinCommunityFragment
ThomasSession Sep 5, 2024
139f4ba
New strings + new camera permission handling
ThomasSession Sep 5, 2024
5795998
Making sure we do not crash when making/receiving a call without the …
ThomasSession Sep 2, 2024
4860adc
Added a new control message type to handle missed calls due to permis…
ThomasSession Sep 2, 2024
f44d066
Changed the missed call control message logic
ThomasSession Sep 2, 2024
2174976
Do not change the text color on emioji picker
ThomasSession Sep 6, 2024
aef0adb
[SES-2695] Incorrect message request approval on home screen
Sep 6, 2024
c38efc2
WIP for new avatar selection
ThomasSession Sep 6, 2024
c633338
Merge branch 'feature/strings-updates' of https://github.com/oxen-io/…
ThomasSession Sep 8, 2024
c0bf015
SES-2651 - New avatar picker
ThomasSession Sep 8, 2024
422b8b2
Fixing the remaining tasks
ThomasSession Sep 9, 2024
ae64189
Differentiating between voice notes and regular audio
ThomasSession Sep 9, 2024
4e2cef6
Fixing 'Leave group dialog' from inside the group settings
ThomasSession Sep 9, 2024
1761024
SES-2692 only save valid media in message details
ThomasSession Sep 9, 2024
87e3f93
SES-2675 - Standardisingdenied mic permission
ThomasSession Sep 9, 2024
85161ff
PR comment
ThomasSession Sep 9, 2024
83b08cc
Fixing Camera permissions
ThomasSession Sep 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.conversation.v2.messages

import android.content.Context
import android.util.AttributeSet
import android.util.Log
import android.view.LayoutInflater
import android.widget.LinearLayout
import androidx.core.content.res.ResourcesCompat
Expand All @@ -17,10 +18,12 @@ import network.loki.messenger.libsession_util.util.ExpiryMode
import org.session.libsession.messaging.MessagingModuleConfiguration
import org.session.libsession.messaging.messages.ExpirationConfiguration
import org.session.libsession.utilities.StringSubstitutionConstants.NAME_KEY
import org.session.libsession.utilities.TextSecurePreferences
import org.thoughtcrime.securesms.conversation.disappearingmessages.DisappearingMessages
import org.thoughtcrime.securesms.conversation.disappearingmessages.expiryMode
import org.thoughtcrime.securesms.database.model.MessageRecord
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
import org.thoughtcrime.securesms.ui.getSubbedCharSequence

@AndroidEntryPoint
class ControlMessageView : LinearLayout {
Expand Down Expand Up @@ -77,7 +80,18 @@ class ControlMessageView : LinearLayout {
}
}
message.isMessageRequestResponse -> {
binding.textView.text = context.getString(R.string.messageRequestsAccepted)
val msgRecipient = message.recipient.address.serialize()
val me = TextSecurePreferences.getLocalNumber(context)
binding.textView.text = if(me == msgRecipient) { // you accepted the user's request
val threadRecipient = DatabaseComponent.get(context).threadDatabase().getRecipientForThreadId(message.threadId)
context.getSubbedCharSequence(
R.string.messageRequestYouHaveAccepted,
NAME_KEY to (threadRecipient?.name ?: "")
)
} else { // they accepted your request
context.getString(R.string.messageRequestsAccepted)
}

binding.root.contentDescription = context.getString(R.string.AccessibilityId_message_request_config_message)
}
message.isCallLog -> {
Expand Down
34 changes: 33 additions & 1 deletion app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.database

import android.content.Context
import android.net.Uri
import network.loki.messenger.R
import java.security.MessageDigest
import network.loki.messenger.libsession_util.ConfigBase
import network.loki.messenger.libsession_util.ConfigBase.Companion.PRIORITY_HIDDEN
Expand Down Expand Up @@ -1448,7 +1449,10 @@ open class Storage(
SSKEnvironment.shared.messageExpirationManager.maybeStartExpiration(sentTimestamp, senderPublicKey, expiryMode)
}

override fun insertMessageRequestResponse(response: MessageRequestResponse) {
/**
* This will create a control message used to indicate that a contact has accepted our message request
*/
override fun insertMessageRequestResponseFromContact(response: MessageRequestResponse) {
val userPublicKey = getUserPublicKey()
val senderPublicKey = response.sender!!
val recipientPublicKey = response.recipient!!
Expand Down Expand Up @@ -1542,6 +1546,34 @@ open class Storage(
}
}

/**
* This will create a control message used to indicate that you have accepted a message request
*/
override fun insertMessageRequestResponseFromYou(threadId: Long){
val userPublicKey = getUserPublicKey() ?: return

val mmsDb = DatabaseComponent.get(context).mmsDatabase()
val message = IncomingMediaMessage(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we converted IncomingMediaMessage to Kotlin we could have named arguments, because that constructor is absolutely grim and invites mistakes!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that is a nice update that we can work on post strings

fromSerialized(userPublicKey),
SnodeAPI.nowWithOffset,
-1,
0,
0,
false,
false,
true,
false,
Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.absent()
)
mmsDb.insertSecureDecryptedMessageInbox(message, threadId, runThreadUpdate = false)
}

override fun getRecipientApproved(address: Address): Boolean {
return DatabaseComponent.get(context).recipientDatabase().getApproved(address)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ class DefaultConversationRepository @Inject constructor(
MessageSender.send(message, Destination.from(recipient.address), isSyncMessage = recipient.isLocalNumber)
.success {
threadDb.setHasSent(threadId, true)
// add a control message for our user
storage.insertMessageRequestResponseFromYou(threadId)
continuation.resume(Result.success(Unit))
}.fail { error ->
continuation.resume(Result.failure(error))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ interface StorageProtocol {
fun getLastSeen(threadId: Long): Long
fun updateThread(threadId: Long, unarchive: Boolean)
fun insertDataExtractionNotificationMessage(senderPublicKey: String, message: DataExtractionNotificationInfoMessage, sentTimestamp: Long)
fun insertMessageRequestResponse(response: MessageRequestResponse)
fun insertMessageRequestResponseFromContact(response: MessageRequestResponse)
fun insertMessageRequestResponseFromYou(threadId: Long)
fun setRecipientApproved(recipient: Recipient, approved: Boolean)
fun getRecipientApproved(address: Address): Boolean
fun setRecipientApprovedMe(recipient: Recipient, approvedMe: Boolean)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.session.libsession.messaging.sending_receiving

import android.text.TextUtils
import network.loki.messenger.libsession_util.ConfigBase
import network.loki.messenger.libsession_util.util.ExpiryMode
import org.session.libsession.avatars.AvatarHelper
import org.session.libsession.messaging.MessagingModuleConfiguration
Expand Down Expand Up @@ -266,7 +265,7 @@ fun MessageReceiver.handleUnsendRequest(message: UnsendRequest): Long? {
}

fun handleMessageRequestResponse(message: MessageRequestResponse) {
MessagingModuleConfiguration.shared.storage.insertMessageRequestResponse(message)
MessagingModuleConfiguration.shared.storage.insertMessageRequestResponseFromContact(message)
}
//endregion

Expand Down