mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-28 02:37:46 +00:00
Wire up buttons
This commit is contained in:
parent
351b259449
commit
d44dbe089f
@ -18,6 +18,8 @@ import android.view.*
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.ActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.activity.viewModels
|
||||
import androidx.annotation.DimenRes
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
@ -78,6 +80,10 @@ import org.thoughtcrime.securesms.contacts.SelectContactsActivity.Companion.sele
|
||||
import org.thoughtcrime.securesms.contactshare.SimpleTextWatcher
|
||||
import org.thoughtcrime.securesms.conversation.v2.ConversationReactionOverlay.OnActionSelectedListener
|
||||
import org.thoughtcrime.securesms.conversation.v2.ConversationReactionOverlay.OnReactionSelectedListener
|
||||
import org.thoughtcrime.securesms.conversation.v2.MessageDetailActivity.Companion.MESSAGE_TIMESTAMP
|
||||
import org.thoughtcrime.securesms.conversation.v2.MessageDetailActivity.Companion.ON_REPLY
|
||||
import org.thoughtcrime.securesms.conversation.v2.MessageDetailActivity.Companion.ON_RESEND
|
||||
import org.thoughtcrime.securesms.conversation.v2.MessageDetailActivity.Companion.ON_DELETE
|
||||
import org.thoughtcrime.securesms.conversation.v2.dialogs.BlockedDialog
|
||||
import org.thoughtcrime.securesms.conversation.v2.dialogs.LinkPreviewDialog
|
||||
import org.thoughtcrime.securesms.conversation.v2.dialogs.SendSeedDialog
|
||||
@ -1771,10 +1777,23 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
endActionMode()
|
||||
}
|
||||
|
||||
private val handleMessageDetail = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult ->
|
||||
val message = result.data?.extras?.getLong(MESSAGE_TIMESTAMP)
|
||||
?.let(mmsSmsDb::getMessageForTimestamp)
|
||||
|
||||
val set = setOfNotNull(message)
|
||||
|
||||
when (result.resultCode) {
|
||||
ON_REPLY -> reply(set)
|
||||
ON_RESEND -> resendMessage(set)
|
||||
ON_DELETE -> deleteMessages(set)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showMessageDetail(messages: Set<MessageRecord>) {
|
||||
Intent(this, MessageDetailActivity::class.java)
|
||||
.apply { putExtra(MessageDetailActivity.MESSAGE_TIMESTAMP, messages.first().timestamp) }
|
||||
.let(::push)
|
||||
.apply { putExtra(MESSAGE_TIMESTAMP, messages.first().timestamp) }
|
||||
.let { handleMessageDetail.launch(it) }
|
||||
|
||||
endActionMode()
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.conversation.v2
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@ -11,6 +12,7 @@ import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.pager.HorizontalPager
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.Divider
|
||||
@ -38,6 +40,7 @@ import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||
import org.thoughtcrime.securesms.components.ProfilePictureView
|
||||
import org.thoughtcrime.securesms.database.Storage
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
|
||||
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
||||
import org.thoughtcrime.securesms.ui.AppTheme
|
||||
import org.thoughtcrime.securesms.ui.Cell
|
||||
@ -74,6 +77,10 @@ class MessageDetailActivity: PassphraseRequiredActionBarActivity() {
|
||||
class MessageDetailsViewModel: ViewModel() {
|
||||
|
||||
fun setMessageRecord(value: MessageRecord?, error: String?) {
|
||||
val mmsRecord = value as? MmsMessageRecord
|
||||
|
||||
val slides = mmsRecord?.slideDeck?.thumbnailSlides
|
||||
|
||||
_details.value = value?.run {
|
||||
MessageDetails(
|
||||
sent = dateSent.let(::Date).toString().let { TitledText("Sent:", it) },
|
||||
@ -124,11 +131,9 @@ class MessageDetailActivity: PassphraseRequiredActionBarActivity() {
|
||||
}
|
||||
|
||||
private fun setResultAndFinish(code: Int) {
|
||||
setResult(code)
|
||||
|
||||
Bundle().apply { putLong(MESSAGE_TIMESTAMP, timestamp) }
|
||||
.let(Intent()::putExtras)
|
||||
.let { setResult(RESULT_OK, it) }
|
||||
.let { setResult(code, it) }
|
||||
|
||||
finish()
|
||||
}
|
||||
@ -164,7 +169,7 @@ class MessageDetailActivity: PassphraseRequiredActionBarActivity() {
|
||||
)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
@OptIn(ExperimentalLayoutApi::class, ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun MessageDetails(
|
||||
messageDetails: MessageDetails,
|
||||
@ -178,6 +183,10 @@ class MessageDetailActivity: PassphraseRequiredActionBarActivity() {
|
||||
modifier = Modifier.verticalScroll(rememberScrollState()),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
HorizontalPager(pageCount = 1) {
|
||||
|
||||
}
|
||||
|
||||
fileDetails?.takeIf { it.isNotEmpty() }?.let {
|
||||
CellWithPadding {
|
||||
FlowRow(
|
||||
@ -199,7 +208,9 @@ class MessageDetailActivity: PassphraseRequiredActionBarActivity() {
|
||||
titledView("From:") {
|
||||
Row {
|
||||
sender?.let {
|
||||
Box(modifier = Modifier.width(60.dp).align(Alignment.CenterVertically)) {
|
||||
Box(modifier = Modifier
|
||||
.width(60.dp)
|
||||
.align(Alignment.CenterVertically)) {
|
||||
AndroidView(
|
||||
factory = { ProfilePictureView(it).apply { update(sender) } },
|
||||
modifier = Modifier
|
||||
|
Loading…
x
Reference in New Issue
Block a user