Skip to content

Commit 7d07b0f

Browse files
Merge pull request #1124 from session-foundation/bring-1.23.0-to-dev
Bring release/1.23.0 to dev
2 parents b86c6b7 + 5c97a95 commit 7d07b0f

File tree

6 files changed

+43
-47
lines changed

6 files changed

+43
-47
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ configurations.configureEach {
1515
exclude module: "commons-logging"
1616
}
1717

18-
def canonicalVersionCode = 404
19-
def canonicalVersionName = "1.22.1"
18+
def canonicalVersionCode = 405
19+
def canonicalVersionName = "1.23.0"
2020

2121
def postFixSize = 10
2222
def abiPostFix = ['armeabi-v7a' : 1,

app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,7 +1916,7 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
19161916
private fun sendTextOnlyMessage(hasPermissionToSendSeed: Boolean = false): Pair<Address, Long>? {
19171917
val recipient = viewModel.recipient ?: return null
19181918
val sentTimestamp = SnodeAPI.nowWithOffset
1919-
viewModel.beforeSendingTextOnlyMessage()
1919+
val approvalSubmittingJob = viewModel.implicitlyApproveRecipient()
19201920
val text = getMessageBody()
19211921
val userPublicKey = textSecurePreferences.getLocalNumber()
19221922
val isNoteToSelf = (recipient.isContactRecipient && recipient.address.toString() == userPublicKey)
@@ -1955,6 +1955,8 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
19551955
null,
19561956
true
19571957
)
1958+
1959+
approvalSubmittingJob?.join()
19581960
MessageSender.send(message, recipient.address)
19591961
}
19601962
// Send a typing stopped message
@@ -1974,7 +1976,7 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
19741976
}
19751977
val recipient = viewModel.recipient!!
19761978
val sentTimestamp = SnodeAPI.nowWithOffset
1977-
viewModel.beforeSendingAttachments()
1979+
val approvalSubmittingJob = viewModel.implicitlyApproveRecipient()
19781980

19791981
// Create the message
19801982
val message = VisibleMessage().applyExpiryMode(viewModel.threadId)
@@ -2020,6 +2022,9 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
20202022
null,
20212023
runThreadUpdate = true
20222024
)
2025+
2026+
approvalSubmittingJob?.join()
2027+
20232028
MessageSender.send(message, recipient.address, attachments, quote, linkPreview)
20242029
}
20252030

app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationViewModel.kt

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import dagger.assisted.AssistedInject
1515
import dagger.hilt.android.qualifiers.ApplicationContext
1616
import kotlinx.coroutines.Dispatchers
1717
import kotlinx.coroutines.GlobalScope
18+
import kotlinx.coroutines.Job
1819
import kotlinx.coroutines.channels.consumeEach
1920
import kotlinx.coroutines.flow.Flow
2021
import kotlinx.coroutines.flow.MutableSharedFlow
@@ -893,7 +894,7 @@ class ConversationViewModel(
893894
}
894895
}
895896

896-
fun acceptMessageRequest() = viewModelScope.launch {
897+
fun acceptMessageRequest(): Job = viewModelScope.launch {
897898
val recipient = recipient ?: return@launch Log.w("Loki", "Recipient was null for accept message request action")
898899
val currentState = _uiState.value.messageRequestState as? MessageRequestUiState.Visible
899900
?: return@launch Log.w("Loki", "Current state was not visible for accept message request action")
@@ -973,23 +974,25 @@ class ConversationViewModel(
973974
attachmentDownloadHandler.retryFailedAttachments(attachments)
974975
}
975976

976-
fun beforeSendingTextOnlyMessage() {
977-
implicitlyApproveRecipient()
978-
}
979-
980-
fun beforeSendingAttachments() {
981-
implicitlyApproveRecipient()
982-
}
983-
984-
private fun implicitlyApproveRecipient() {
977+
/**
978+
* Implicitly approve the recipient.
979+
*
980+
* @return The (kotlin coroutine) job of sending job message request, if one should be sent. The job
981+
* instance is normally just for observing purpose. Note that the completion of this job
982+
* does not mean the message is sent, it only means the the successful submission to the message
983+
* send queue and they will be sent later. You will not be able to observe the completion
984+
* of message sending through this method.
985+
*/
986+
fun implicitlyApproveRecipient(): Job? {
985987
val recipient = recipient
986988

987989
if (uiState.value.messageRequestState is MessageRequestUiState.Visible) {
988-
acceptMessageRequest()
990+
return acceptMessageRequest()
989991
} else if (recipient?.isApproved == false) {
990992
// edge case for new outgoing thread on new recipient without sending approval messages
991993
repository.setApproved(recipient, true)
992994
}
995+
return null
993996
}
994997

995998
fun onCommand(command: Commands) {

app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import android.content.Intent
99
import android.os.Build
1010
import android.os.Bundle
1111
import android.view.ViewGroup.MarginLayoutParams
12-
import android.view.View
1312
import android.widget.Toast
1413
import androidx.activity.viewModels
1514
import androidx.core.os.bundleOf
@@ -246,7 +245,7 @@ class HomeActivity : ScreenLockActionBarActivity(),
246245
} else 0
247246
homeAdapter.data = data
248247
if(firstPos >= 0) { manager.scrollToPositionWithOffset(firstPos, offsetTop) }
249-
updateEmptyState()
248+
binding.emptyStateContainer.isVisible = homeAdapter.itemCount == 0
250249
}
251250
}
252251
}
@@ -421,30 +420,28 @@ class HomeActivity : ScreenLockActionBarActivity(),
421420
}
422421
}
423422

424-
private fun setSearchShown(isShown: Boolean) {
423+
private fun setSearchShown(isSearchShown: Boolean) {
425424
// Request focus immediately so the user can start typing
426-
if (isShown) {
425+
if (isSearchShown) {
427426
binding.globalSearchInputLayout.requestFocus()
428427
}
429428

430-
binding.searchToolbar.isVisible = isShown
431-
binding.sessionToolbar.isVisible = !isShown
432-
binding.conversationsRecyclerView.isVisible = !isShown
433-
binding.seedReminderView.isVisible = !TextSecurePreferences.getHasViewedSeed(this) && !isShown
434-
binding.globalSearchRecycler.isVisible = isShown
435-
binding.conversationListContainer.isVisible = !isShown
436-
if(isShown){
437-
binding.newConversationButton.animate().cancel()
438-
binding.newConversationButton.isVisible = false
439-
} else {
440-
updateEmptyState()
441-
binding.newConversationButton.apply {
442-
alpha = 0.0f
443-
visibility = View.VISIBLE
444-
animate().cancel()
445-
animate().setStartDelay(350).setDuration(250L).alpha(1.0f).setListener(null).start()
446-
}
429+
binding.searchToolbar.isVisible = isSearchShown
430+
binding.sessionToolbar.isVisible = !isSearchShown
431+
binding.seedReminderView.isVisible = !TextSecurePreferences.getHasViewedSeed(this) && !isSearchShown
432+
binding.globalSearchRecycler.isVisible = isSearchShown
433+
434+
435+
// Show a fade in animation for the conversation list upon re-appearing
436+
val shouldShowHomeAnimation = !isSearchShown && !binding.conversationListContainer.isVisible
437+
438+
binding.conversationListContainer.isVisible = !isSearchShown
439+
if (shouldShowHomeAnimation) {
440+
binding.conversationListContainer.animate().cancel()
441+
binding.conversationListContainer.alpha = 0f
442+
binding.conversationListContainer.animate().alpha(1f).start()
447443
}
444+
448445
}
449446

450447
private fun updateLegacyConfigView() {
@@ -482,11 +479,6 @@ class HomeActivity : ScreenLockActionBarActivity(),
482479
// endregion
483480

484481
// region Updating
485-
private fun updateEmptyState() {
486-
val threadCount = binding.conversationsRecyclerView.adapter?.itemCount ?: 0
487-
binding.emptyStateContainer.isVisible = threadCount == 0 && binding.conversationsRecyclerView.isVisible
488-
}
489-
490482
@Subscribe(threadMode = ThreadMode.MAIN)
491483
fun onUpdateProfileEvent(event: ProfilePictureModifiedEvent) {
492484
if (event.recipient.isLocalNumber) {

app/src/main/java/org/thoughtcrime/securesms/repository/ConversationRepository.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,8 @@ class DefaultConversationRepository @Inject constructor(
430430
)
431431
} else {
432432
val message = MessageRequestResponse(true)
433-
MessageSender.sendNonDurably(
434-
message = message,
435-
destination = Destination.from(recipient.address),
436-
isSyncMessage = recipient.isLocalNumber
437-
).await()
433+
434+
MessageSender.send(message = message, address = recipient.address)
438435

439436
// add a control message for our user
440437
storage.insertMessageRequestResponseFromYou(threadId)

app/src/main/res/layout/activity_home.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@
148148
</androidx.appcompat.widget.Toolbar>
149149

150150
<FrameLayout
151-
android:animateLayoutChanges="true"
152151
android:layout_width="match_parent"
153152
android:layout_height="match_parent">
154153

0 commit comments

Comments
 (0)