mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-21 13:48:11 +00:00
Display audio files duration as well
This commit is contained in:
parent
4fe0487eaf
commit
bb844739c1
6 changed files with 52 additions and 38 deletions
|
|
@ -61,7 +61,7 @@ class FileModel @AnyThread constructor(
|
|||
|
||||
val isVideoPreview: Boolean
|
||||
|
||||
val videoDuration = MutableLiveData<String>()
|
||||
val audioVideoDuration = MutableLiveData<String>()
|
||||
|
||||
val isPdf: Boolean
|
||||
|
||||
|
|
@ -91,10 +91,10 @@ class FileModel @AnyThread constructor(
|
|||
mimeType = FileUtils.getMimeType(mime)
|
||||
isImage = mimeType == FileUtils.MimeType.Image
|
||||
isVideoPreview = mimeType == FileUtils.MimeType.Video
|
||||
if (isVideoPreview) {
|
||||
isAudio = mimeType == FileUtils.MimeType.Audio
|
||||
if (isVideoPreview || isAudio) {
|
||||
getDuration()
|
||||
}
|
||||
isAudio = mimeType == FileUtils.MimeType.Audio
|
||||
Log.d(
|
||||
"$TAG File has already been downloaded, extension is [$extension], MIME is [$mime]"
|
||||
)
|
||||
|
|
@ -139,7 +139,7 @@ class FileModel @AnyThread constructor(
|
|||
val seconds = durationInMs / 1000
|
||||
val duration = TimestampUtils.durationToString(seconds)
|
||||
Log.d("$TAG Duration for file [$file] is $duration")
|
||||
videoDuration.postValue(duration)
|
||||
audioVideoDuration.postValue(duration)
|
||||
retriever.release()
|
||||
} catch (e: Exception) {
|
||||
Log.e("$TAG Failed to get duration for file [$file]: $e")
|
||||
|
|
|
|||
|
|
@ -81,8 +81,7 @@ class ConversationDocumentsListViewModel @UiThread constructor() : AbstractConve
|
|||
}
|
||||
}
|
||||
Log.i("$TAG [${documents.size}] documents have been processed")
|
||||
|
||||
documentsList.postValue(list.reversed()) // To have most recent documents at the top
|
||||
documentsList.postValue(list)
|
||||
operationInProgress.postValue(false)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,9 @@ class ConversationMediaListViewModel @UiThread constructor() : AbstractConversat
|
|||
val media = chatRoom.mediaContents
|
||||
Log.i("$TAG [${media.size}] media have been fetched")
|
||||
for (mediaContent in media) {
|
||||
// Do not display voice recordings here, even if they are media file
|
||||
if (mediaContent.isVoiceRecording) continue
|
||||
|
||||
val isEncrypted = mediaContent.isFileEncrypted
|
||||
val path = if (isEncrypted) {
|
||||
Log.i(
|
||||
|
|
@ -85,8 +88,7 @@ class ConversationMediaListViewModel @UiThread constructor() : AbstractConversat
|
|||
}
|
||||
}
|
||||
Log.i("$TAG [${media.size}] media have been processed")
|
||||
|
||||
mediaList.postValue(list.reversed()) // To have most recent files at the top
|
||||
mediaList.postValue(list)
|
||||
operationInProgress.postValue(false)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,10 +46,10 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:text="@{model.videoDuration, default=`00:42`}"
|
||||
android:text="@{model.audioVideoDuration, default=`00:42`}"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp"
|
||||
android:visibility="@{model.isVideoPreview && model.videoDuration.length() > 0 ? View.VISIBLE : View.GONE, default=gone}"
|
||||
android:visibility="@{model.isVideoPreview && model.audioVideoDuration.length() > 0 ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintBottom_toBottomOf="@id/image"
|
||||
app:layout_constraintStart_toStartOf="@id/image"/>
|
||||
|
||||
|
|
@ -84,6 +84,19 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:tint="?attr/color_main2_600" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_600"
|
||||
android:id="@+id/audio_duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:text="@{model.audioVideoDuration, default=`00:42`}"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp"
|
||||
android:visibility="@{model.isAudio && model.audioVideoDuration.length() > 0 ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintBottom_toBottomOf="@id/file_icon"
|
||||
app:layout_constraintStart_toStartOf="@id/file_icon"/>
|
||||
|
||||
<com.google.android.material.progressindicator.CircularProgressIndicator
|
||||
android:id="@+id/transfer_progress"
|
||||
android:layout_width="@dimen/chat_bubble_grid_image_size"
|
||||
|
|
|
|||
|
|
@ -43,10 +43,10 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:text="@{model.videoDuration, default=`00:42`}"
|
||||
android:text="@{model.audioVideoDuration, default=`00:42`}"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp"
|
||||
android:visibility="@{model.isVideoPreview && model.videoDuration.length() > 0 ? View.VISIBLE : View.GONE, default=gone}"
|
||||
android:visibility="@{model.isVideoPreview && model.audioVideoDuration.length() > 0 ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintBottom_toBottomOf="@id/image"
|
||||
app:layout_constraintStart_toStartOf="@id/image"/>
|
||||
|
||||
|
|
|
|||
|
|
@ -28,32 +28,6 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_600"
|
||||
android:id="@+id/video_duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:text="@{model.videoDuration, default=`00:42`}"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp"
|
||||
android:visibility="@{model.isVideoPreview && model.videoDuration.length() > 0 ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintBottom_toBottomOf="@id/image"
|
||||
app:layout_constraintStart_toStartOf="@id/image"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/video_preview"
|
||||
android:layout_width="@dimen/icon_size"
|
||||
android:layout_height="@dimen/icon_size"
|
||||
android:src="@drawable/play_fill"
|
||||
android:contentDescription="@null"
|
||||
android:visibility="@{model.isVideoPreview ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintTop_toTopOf="@id/image"
|
||||
app:layout_constraintBottom_toBottomOf="@id/image"
|
||||
app:layout_constraintStart_toStartOf="@id/image"
|
||||
app:layout_constraintEnd_toEndOf="@id/image"
|
||||
app:tint="@color/white" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/audio_file"
|
||||
android:layout_width="0dp"
|
||||
|
|
@ -70,6 +44,32 @@
|
|||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:tint="?attr/color_main2_600" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_600"
|
||||
android:id="@+id/audio_video_duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:text="@{model.audioVideoDuration, default=`00:42`}"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp"
|
||||
android:visibility="@{(model.isVideoPreview || model.isAudio) && model.audioVideoDuration.length() > 0 ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/video_preview"
|
||||
android:layout_width="@dimen/icon_size"
|
||||
android:layout_height="@dimen/icon_size"
|
||||
android:src="@drawable/play_fill"
|
||||
android:contentDescription="@null"
|
||||
android:visibility="@{model.isVideoPreview ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintTop_toTopOf="@id/image"
|
||||
app:layout_constraintBottom_toBottomOf="@id/image"
|
||||
app:layout_constraintStart_toStartOf="@id/image"
|
||||
app:layout_constraintEnd_toEndOf="@id/image"
|
||||
app:tint="@color/white" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
Loading…
Add table
Reference in a new issue