issue 2890: Add an "ALT" sticker to the media preview container (#2942)

* issue 2890: Add an "ALT" sticker to the media preview container if there are descriptions

* issue 2890: Use end and start for positioning

* issue 2890: Adapt to new media view group

* issue 2890: Use an indicator overlay for every (single) preview image

* issue 2890: Reduce radius to match that of the preview layout

* issue 2890: Remove (again) unused code

* issue 2890: Set visibility in any case

* issue 2890: Use a translatable text for ALT

* issue 2890: Show ALT flag only when showing media

* issue 2890: Call doOnLayout on the layout wrapper
This commit is contained in:
UlrichKu 2022-12-18 16:50:30 +01:00 committed by GitHub
commit 6aed1c6806
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 66 additions and 13 deletions

View file

@ -2,9 +2,11 @@ package com.keylesspalace.tusky.view
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import com.keylesspalace.tusky.R
import kotlin.math.roundToInt
@ -26,7 +28,9 @@ class MediaPreviewLayout(context: Context, attrs: AttributeSet? = null) :
attachImageViews()
}
private val imageViewCache = Array(4) { MediaPreviewImageView(context) }
private val imageViewCache = Array(4) {
LayoutInflater.from(context).inflate(R.layout.item_image_preview_overlay, this, false)
}
private var measuredOrientation = LinearLayout.VERTICAL
@ -180,9 +184,15 @@ class MediaPreviewLayout(context: Context, attrs: AttributeSet? = null) :
}
}
inline fun forEachIndexed(action: (Int, MediaPreviewImageView) -> Unit) {
inline fun forEachIndexed(action: (Int, View, MediaPreviewImageView, TextView) -> Unit) {
for (index in 0 until childCount) {
action(index, getChildAt(index) as MediaPreviewImageView)
val wrapper = getChildAt(index)
action(
index,
wrapper,
wrapper.findViewById(R.id.preview_image_view) as MediaPreviewImageView,
wrapper.findViewById(R.id.preview_media_description_indicator) as TextView
)
}
}
}