AccountMediaFragment improvements (#2684)

* initial setup

* add spacing between images

* use blurhash

* handle hidden state and show video indicator

* handle item clicks

* small cleanup

* move SquareImageView into account.media package

* fix build

* improve AccountMediaGridAdapter

* handle loadstate, errors and refreshing

* remove commented out code

* log error

* show audio attachments with icon

* fix glitchy transition animation

* set image Description on imageview

* show toast with media description on long press
This commit is contained in:
Konrad Pozniak 2022-09-02 16:52:47 +02:00 committed by GitHub
commit c8fc2418b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 530 additions and 284 deletions

View file

@ -0,0 +1,26 @@
@file:JvmName("AttachmentHelper")
package com.keylesspalace.tusky.util
import android.content.Context
import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.entity.Attachment
import kotlin.math.roundToInt
fun Attachment.getFormattedDescription(context: Context): CharSequence {
var duration = ""
if (meta?.duration != null && meta.duration > 0) {
duration = formatDuration(meta.duration.toDouble()) + " "
}
return if (description.isNullOrEmpty()) {
duration + context.getString(R.string.description_post_media_no_description_placeholder)
} else {
duration + description
}
}
private fun formatDuration(durationInSeconds: Double): String {
val seconds = durationInSeconds.roundToInt() % 60
val minutes = durationInSeconds.toInt() % 3600 / 60
val hours = durationInSeconds.toInt() / 3600
return "%d:%02d:%02d".format(hours, minutes, seconds)
}