|
|
@ -5,11 +5,13 @@ import android.content.res.ColorStateList
|
|
|
|
import android.util.AttributeSet
|
|
|
|
import android.util.AttributeSet
|
|
|
|
import android.widget.LinearLayout
|
|
|
|
import android.widget.LinearLayout
|
|
|
|
import androidx.annotation.ColorInt
|
|
|
|
import androidx.annotation.ColorInt
|
|
|
|
|
|
|
|
import androidx.core.view.isVisible
|
|
|
|
import network.loki.messenger.databinding.ViewDocumentBinding
|
|
|
|
import network.loki.messenger.databinding.ViewDocumentBinding
|
|
|
|
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
|
|
|
|
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
|
|
|
|
|
|
|
|
|
|
|
|
class DocumentView : LinearLayout {
|
|
|
|
class DocumentView : LinearLayout {
|
|
|
|
private val binding: ViewDocumentBinding by lazy { ViewDocumentBinding.bind(this) }
|
|
|
|
private val binding: ViewDocumentBinding by lazy { ViewDocumentBinding.bind(this) }
|
|
|
|
|
|
|
|
|
|
|
|
// region Lifecycle
|
|
|
|
// region Lifecycle
|
|
|
|
constructor(context: Context) : super(context)
|
|
|
|
constructor(context: Context) : super(context)
|
|
|
|
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
|
|
|
|
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
|
|
|
@ -22,6 +24,12 @@ class DocumentView : LinearLayout {
|
|
|
|
binding.documentTitleTextView.text = document.fileName.or("Untitled File")
|
|
|
|
binding.documentTitleTextView.text = document.fileName.or("Untitled File")
|
|
|
|
binding.documentTitleTextView.setTextColor(textColor)
|
|
|
|
binding.documentTitleTextView.setTextColor(textColor)
|
|
|
|
binding.documentViewIconImageView.imageTintList = ColorStateList.valueOf(textColor)
|
|
|
|
binding.documentViewIconImageView.imageTintList = ColorStateList.valueOf(textColor)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Show the progress spinner if the attachment is downloading, otherwise show
|
|
|
|
|
|
|
|
// the document icon (and always remove the other, whichever one that is)
|
|
|
|
|
|
|
|
binding.documentViewProgress.isVisible = message.isMediaPending
|
|
|
|
|
|
|
|
binding.documentViewIconImageView.isVisible = !message.isMediaPending
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// endregion
|
|
|
|
// endregion
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|