session-android/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/MessageDetailActivity.kt

160 lines
5.8 KiB
Kotlin
Raw Normal View History

2021-07-13 08:22:10 +02:00
package org.thoughtcrime.securesms.conversation.v2
import android.os.Bundle
import android.view.View
2023-06-29 04:07:55 +02:00
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
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.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Divider
2023-06-29 11:44:47 +02:00
import androidx.compose.material.LocalTextStyle
2023-06-29 04:07:55 +02:00
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
2023-06-29 11:44:47 +02:00
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
2023-06-29 04:07:55 +02:00
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import dagger.hilt.android.AndroidEntryPoint
2021-07-13 08:22:10 +02:00
import network.loki.messenger.R
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
import org.thoughtcrime.securesms.database.Storage
2021-07-13 08:22:10 +02:00
import org.thoughtcrime.securesms.database.model.MessageRecord
2023-06-29 09:41:11 +02:00
import org.thoughtcrime.securesms.ui.AppTheme
import org.thoughtcrime.securesms.ui.Cell
import org.thoughtcrime.securesms.ui.CellWithPadding
import org.thoughtcrime.securesms.ui.ItemButton
import org.thoughtcrime.securesms.ui.LocalExtraColors
import org.thoughtcrime.securesms.ui.destructiveButtonColors
Paged conversation recycler, update compile sdk version 31 (#1049) * Update build tools * Update appcompat version * Update dependencies * feat: add paging into conversation recycler and queries to fetch data off-thread * refactor: wip for updating paged results and bucketing messages / fetching enough to display * fix: currently works for scrolling and possibly refreshing? need scroll to message and auto scroll down on insert (at bottom) * fix: search and scrolling to X message works now * build: increase version code and name * fix: re-add refresh, remove the outdated comment * refactor: lets see if 25 size pages increases performance :eyes: * feat: add in some equals overrides for mms records to refresh if media has finished DLing * feat: add scroll to bottom for new messages if we are at the end of the chat * build: update build numbers * fix: update AGP and fix compile errors for sdk version 31 * feat: add log for loki-avatar and loki-fs on upload types and responses * feat: increase build number to match latest installed version * feat: changing props and permission checks for call service * fix: possible service exception when no call ID remote foreground service not terminated * revert: google services version * fix: re-add paging dependency * feat: adding new last seen function and figuring out the last seen for recycler adapter * build: update version names and codes for deploy * refactor: undo the new adapter and query changes to use previous cursor logic. revert this commit to enable new paged adapter * fix: use author's address in typist equality and hashcode for set inclusion * refactor: refactor the select contacts activity * refactor: refactor the select contacts activity * build: update version code * fix: hide all other bound views if deleted * refactor: change voice message tint, upgrade build number * fix: message detail showing up properly * revert: realise copy public key is actually not allowed if open group participant * fix: copy session ID, message detail activity support re-enabled * build: update build version code * build: remove version name * build: update build code * feat: google services version minimum compatible * fix: selection for re-created objects not properly highlighting * fix: foreground CENTER_INSIDE instead of just CENTER for scaletype * build: update version code * fix: don't show error if no error * build: update version code * fix: clear error messages if any on successful send Co-authored-by: charles <charles@oxen.io>
2022-12-19 01:29:05 +01:00
import java.util.*
import javax.inject.Inject
2021-07-13 08:22:10 +02:00
2023-06-29 09:41:11 +02:00
@AndroidEntryPoint
2021-07-13 08:22:10 +02:00
class MessageDetailActivity: PassphraseRequiredActionBarActivity() {
var messageRecord: MessageRecord? = null
@Inject
lateinit var storage: Storage
2021-07-13 08:22:10 +02:00
// region Settings
companion object {
// Extras
const val MESSAGE_TIMESTAMP = "message_timestamp"
}
// endregion
override fun onCreate(savedInstanceState: Bundle?, ready: Boolean) {
super.onCreate(savedInstanceState, ready)
2023-06-29 04:07:55 +02:00
2021-07-13 08:22:10 +02:00
val timestamp = intent.getLongExtra(MESSAGE_TIMESTAMP, -1L)
2023-06-29 04:07:55 +02:00
title = resources.getString(R.string.conversation_context__menu_message_details)
setContentView(createComposeView())
}
private fun createComposeView(): ComposeView = ComposeView(this).apply {
id = View.generateViewId()
setContent {
MessageDetails()
}
2023-06-29 04:07:55 +02:00
}
data class TitledText(val title: String, val value: String)
@OptIn(ExperimentalLayoutApi::class)
@Preview
@Composable
fun MessageDetails() {
val fileDetails = listOf(
TitledText("File Id:", "1237896548514214124235985214"),
TitledText("File Type:", ".PNG"),
TitledText("File Size:", "6mb"),
TitledText("Resolution:", "550x550"),
TitledText("Duration:", "N/A"),
)
2023-06-29 11:44:47 +02:00
val sent = TitledText("Sent:", "6:12 AM Tue, 09/08/2022")
val received = TitledText("Received:", "6:12 AM Tue, 09/08/2022")
2023-06-29 04:07:55 +02:00
val user = TitledText("Connor", "d4f1g54sdf5g1d5f4g65ds4564df65f4g65d54gdfsg")
2023-06-29 09:41:11 +02:00
AppTheme {
2023-06-29 04:07:55 +02:00
Column(
modifier = Modifier.verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.spacedBy(16.dp)) {
2023-06-29 09:41:11 +02:00
CellWithPadding {
2023-06-29 04:07:55 +02:00
FlowRow(
verticalArrangement = Arrangement.spacedBy(16.dp),
maxItemsInEachRow = 2
) {
fileDetails.forEach {
titledText(it, Modifier.weight(1f))
}
}
}
2023-06-29 09:41:11 +02:00
CellWithPadding {
2023-06-29 04:07:55 +02:00
Column(verticalArrangement = Arrangement.spacedBy(16.dp)) {
titledText(sent)
titledText(received)
titledView("From:") {
Row {
2023-06-29 09:41:11 +02:00
Box(modifier = Modifier
.width(60.dp)
.height(60.dp))
2023-06-29 04:07:55 +02:00
Column {
2023-06-29 11:44:47 +02:00
titledText(user, valueStyle = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace))
2023-06-29 04:07:55 +02:00
}
}
}
}
}
2023-06-29 09:41:11 +02:00
Cell {
2023-06-29 04:07:55 +02:00
Column {
ItemButton("Reply", R.drawable.ic_reply)
Divider()
ItemButton("Resend", R.drawable.ic_reply)
Divider()
2023-06-29 09:41:11 +02:00
ItemButton("Delete", R.drawable.ic_delete_24 , colors = destructiveButtonColors())
2023-06-29 04:07:55 +02:00
}
}
}
2021-07-13 08:22:10 +02:00
}
}
2023-06-29 04:07:55 +02:00
@Composable
fun Divider() {
2023-06-29 09:41:11 +02:00
Divider(modifier = Modifier.padding(horizontal = 16.dp), thickness = 1.dp, color = LocalExtraColors.current.divider)
2023-06-29 04:07:55 +02:00
}
@Composable
2023-06-29 11:44:47 +02:00
fun titledText(titledText: TitledText, modifier: Modifier = Modifier, valueStyle: TextStyle = LocalTextStyle.current) {
2023-06-29 04:07:55 +02:00
Column(modifier = modifier, verticalArrangement = Arrangement.spacedBy(4.dp)) {
Title(titledText.title)
2023-06-29 11:44:47 +02:00
Text(titledText.value, style = valueStyle)
2023-06-29 04:07:55 +02:00
}
}
2023-06-29 09:41:11 +02:00
2023-06-29 04:07:55 +02:00
@Composable
fun titledView(title: String, modifier: Modifier = Modifier, content: @Composable () -> Unit) {
Column(modifier = modifier, verticalArrangement = Arrangement.spacedBy(4.dp)) {
Title(title)
content()
2021-07-13 08:22:10 +02:00
}
}
2023-06-29 04:07:55 +02:00
@Composable
fun Title(text: String) {
Text(text, fontWeight = FontWeight.Bold)
}
2023-06-29 09:41:11 +02:00
}