Started grid layout

This commit is contained in:
Sylvain Berfini 2023-11-02 15:42:47 +01:00
parent 7f739a4bc1
commit cafa301ea8
4 changed files with 41 additions and 12 deletions

View file

@ -77,11 +77,12 @@ dependencies {
implementation "androidx.core:core-ktx:1.12.0"
implementation "androidx.core:core-telecom:1.0.0-alpha02"
implementation "androidx.media:media:1.6.0"
implementation "androidx.fragment:fragment-ktx:1.6.2"
implementation "androidx.recyclerview:recyclerview:1.3.2"
implementation "androidx.slidingpanelayout:slidingpanelayout:1.2.0"
implementation "androidx.window:window:1.1.0"
def nav_version = "2.7.4"
def nav_version = "2.7.5"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"

View file

@ -65,7 +65,7 @@ class ChatMessageModel @WorkerThread constructor(
val text = MutableLiveData<Spannable>()
val bigImagePath = MutableLiveData<String>()
val imagesList = MutableLiveData<ArrayList<String>>()
val timestamp = chatMessage.time
@ -106,12 +106,16 @@ class ChatMessageModel @WorkerThread constructor(
updateReactionsList()
var displayableContentFound = false
var filesContentCount = 0
val imagesPath = arrayListOf<String>()
val contents = chatMessage.contents
for (content in contents) {
if (content.isText) {
computeTextContent(content)
displayableContentFound = true
} else {
filesContentCount += 1
if (content.isFile) {
val path = content.filePath ?: ""
if (path.isNotEmpty()) {
@ -120,7 +124,7 @@ class ChatMessageModel @WorkerThread constructor(
)
when (content.type) {
"image", "video" -> {
bigImagePath.postValue(path)
imagesPath.add(path)
displayableContentFound = true
}
"audio" -> {
@ -138,6 +142,8 @@ class ChatMessageModel @WorkerThread constructor(
}
}
imagesList.postValue(imagesPath)
if (!displayableContentFound) { // Temporary workaround to prevent empty bubbles
val describe = LinphoneUtils.getTextDescribingMessage(chatMessage)
val spannable = Spannable.Factory.getInstance().newSpannable(describe)

View file

@ -13,16 +13,16 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/big_image"
<GridLayout
android:id="@+id/grid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@drawable/smiley"
android:visibility="@{model.bigImagePath.length() > 0 ? View.VISIBLE : View.GONE}"
android:maxHeight="@dimen/chat_bubble_big_image_max_size"
coilBubble="@{model.bigImagePath}"/>
android:columnWidth="90dp"
android:numColumns="auto_fit"
android:stretchMode="none"
android:gravity="start"
entries="@{model.imagesList}"
layout="@{@layout/chat_bubble_content_grid_cell}"/>
<org.linphone.ui.main.chat.view.ChatBubbleTextView
style="@style/default_text_style"
@ -33,7 +33,7 @@
android:textSize="14sp"
android:textColor="@color/gray_main2_700"
android:gravity="center_vertical|start"
android:layout_below="@id/big_image"
android:layout_below="@id/grid"
android:visibility="@{model.text.length() > 0 ? View.VISIBLE : View.GONE}"/>
</RelativeLayout>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<import type="android.view.View" />
<variable
name="model"
type="String" />
</data>
<ImageView
android:id="@+id/big_image"
android:layout_width="88dp"
android:layout_height="88dp"
android:layout_margin="1dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/smiley"
coilBubble="@{model}"/>
</layout>