mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-04-20 09:58:28 +00:00
Started grid layout
This commit is contained in:
parent
7f739a4bc1
commit
cafa301ea8
4 changed files with 41 additions and 12 deletions
|
|
@ -77,11 +77,12 @@ dependencies {
|
||||||
implementation "androidx.core:core-ktx:1.12.0"
|
implementation "androidx.core:core-ktx:1.12.0"
|
||||||
implementation "androidx.core:core-telecom:1.0.0-alpha02"
|
implementation "androidx.core:core-telecom:1.0.0-alpha02"
|
||||||
implementation "androidx.media:media:1.6.0"
|
implementation "androidx.media:media:1.6.0"
|
||||||
|
implementation "androidx.fragment:fragment-ktx:1.6.2"
|
||||||
implementation "androidx.recyclerview:recyclerview:1.3.2"
|
implementation "androidx.recyclerview:recyclerview:1.3.2"
|
||||||
implementation "androidx.slidingpanelayout:slidingpanelayout:1.2.0"
|
implementation "androidx.slidingpanelayout:slidingpanelayout:1.2.0"
|
||||||
implementation "androidx.window:window:1.1.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-fragment-ktx:$nav_version"
|
||||||
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
|
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ class ChatMessageModel @WorkerThread constructor(
|
||||||
|
|
||||||
val text = MutableLiveData<Spannable>()
|
val text = MutableLiveData<Spannable>()
|
||||||
|
|
||||||
val bigImagePath = MutableLiveData<String>()
|
val imagesList = MutableLiveData<ArrayList<String>>()
|
||||||
|
|
||||||
val timestamp = chatMessage.time
|
val timestamp = chatMessage.time
|
||||||
|
|
||||||
|
|
@ -106,12 +106,16 @@ class ChatMessageModel @WorkerThread constructor(
|
||||||
updateReactionsList()
|
updateReactionsList()
|
||||||
|
|
||||||
var displayableContentFound = false
|
var displayableContentFound = false
|
||||||
|
var filesContentCount = 0
|
||||||
|
val imagesPath = arrayListOf<String>()
|
||||||
|
|
||||||
val contents = chatMessage.contents
|
val contents = chatMessage.contents
|
||||||
for (content in contents) {
|
for (content in contents) {
|
||||||
if (content.isText) {
|
if (content.isText) {
|
||||||
computeTextContent(content)
|
computeTextContent(content)
|
||||||
displayableContentFound = true
|
displayableContentFound = true
|
||||||
} else {
|
} else {
|
||||||
|
filesContentCount += 1
|
||||||
if (content.isFile) {
|
if (content.isFile) {
|
||||||
val path = content.filePath ?: ""
|
val path = content.filePath ?: ""
|
||||||
if (path.isNotEmpty()) {
|
if (path.isNotEmpty()) {
|
||||||
|
|
@ -120,7 +124,7 @@ class ChatMessageModel @WorkerThread constructor(
|
||||||
)
|
)
|
||||||
when (content.type) {
|
when (content.type) {
|
||||||
"image", "video" -> {
|
"image", "video" -> {
|
||||||
bigImagePath.postValue(path)
|
imagesPath.add(path)
|
||||||
displayableContentFound = true
|
displayableContentFound = true
|
||||||
}
|
}
|
||||||
"audio" -> {
|
"audio" -> {
|
||||||
|
|
@ -138,6 +142,8 @@ class ChatMessageModel @WorkerThread constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
imagesList.postValue(imagesPath)
|
||||||
|
|
||||||
if (!displayableContentFound) { // Temporary workaround to prevent empty bubbles
|
if (!displayableContentFound) { // Temporary workaround to prevent empty bubbles
|
||||||
val describe = LinphoneUtils.getTextDescribingMessage(chatMessage)
|
val describe = LinphoneUtils.getTextDescribingMessage(chatMessage)
|
||||||
val spannable = Spannable.Factory.getInstance().newSpannable(describe)
|
val spannable = Spannable.Factory.getInstance().newSpannable(describe)
|
||||||
|
|
|
||||||
|
|
@ -13,16 +13,16 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<ImageView
|
<GridLayout
|
||||||
android:id="@+id/big_image"
|
android:id="@+id/grid"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:adjustViewBounds="true"
|
android:columnWidth="90dp"
|
||||||
android:scaleType="fitCenter"
|
android:numColumns="auto_fit"
|
||||||
android:src="@drawable/smiley"
|
android:stretchMode="none"
|
||||||
android:visibility="@{model.bigImagePath.length() > 0 ? View.VISIBLE : View.GONE}"
|
android:gravity="start"
|
||||||
android:maxHeight="@dimen/chat_bubble_big_image_max_size"
|
entries="@{model.imagesList}"
|
||||||
coilBubble="@{model.bigImagePath}"/>
|
layout="@{@layout/chat_bubble_content_grid_cell}"/>
|
||||||
|
|
||||||
<org.linphone.ui.main.chat.view.ChatBubbleTextView
|
<org.linphone.ui.main.chat.view.ChatBubbleTextView
|
||||||
style="@style/default_text_style"
|
style="@style/default_text_style"
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textColor="@color/gray_main2_700"
|
android:textColor="@color/gray_main2_700"
|
||||||
android:gravity="center_vertical|start"
|
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}"/>
|
android:visibility="@{model.text.length() > 0 ? View.VISIBLE : View.GONE}"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
|
||||||
22
app/src/main/res/layout/chat_bubble_content_grid_cell.xml
Normal file
22
app/src/main/res/layout/chat_bubble_content_grid_cell.xml
Normal 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>
|
||||||
Loading…
Add table
Reference in a new issue