mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 13:08:46 +00:00
Fix spoiler reveal in full screen media viewer.
This commit is contained in:
@@ -108,6 +108,11 @@ public class EmojiTextView extends AppCompatTextView {
|
||||
setEmojiCompatEnabled(useSystemEmoji());
|
||||
}
|
||||
|
||||
public void setMaxLength(int maxLength) {
|
||||
this.maxLength = maxLength;
|
||||
setText(getText());
|
||||
}
|
||||
|
||||
public void enableSpoilerFiltering() {
|
||||
spoilerFilteringSpannableFactory = new SpoilerFilteringSpannableFactory(() -> isInOnDraw);
|
||||
setSpannableFactory(spoilerFilteringSpannableFactory);
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package org.thoughtcrime.securesms.mediapreview.caption
|
||||
|
||||
import android.content.Context
|
||||
import android.text.method.ScrollingMovementMethod
|
||||
import android.graphics.Typeface
|
||||
import android.text.SpannableString
|
||||
import android.text.Spanned
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.text.style.StyleSpan
|
||||
import android.util.AttributeSet
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.updateLayoutParams
|
||||
@@ -26,7 +30,10 @@ class ExpandingCaptionView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
init {
|
||||
setOnClickListener { toggleExpansion() }
|
||||
movementMethod = LinkMovementMethod.getInstance()
|
||||
val overflow = SpannableString(context.getString(R.string.MediaPreviewFragment_read_more_overflow_text))
|
||||
overflow.setSpan(StyleSpan(Typeface.BOLD), 0, overflow.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
setOverflowText(overflow)
|
||||
}
|
||||
|
||||
private fun toggleExpansion() {
|
||||
@@ -40,19 +47,16 @@ class ExpandingCaptionView @JvmOverloads constructor(
|
||||
|
||||
private fun updateExpansionState(expand: Boolean) {
|
||||
if (expand) {
|
||||
setMaxLength(-1)
|
||||
text = fullCaptionText
|
||||
movementMethod = ScrollingMovementMethod()
|
||||
scrollTo(0, 0)
|
||||
updateLayoutParams { height = expandedHeight }
|
||||
} else {
|
||||
text = if (isExpandable()) {
|
||||
context.getString(R.string.MediaPreviewFragment_see_more, fullCaptionText.substring(0, CHAR_LIMIT_MESSAGE_PREVIEW))
|
||||
} else {
|
||||
fullCaptionText
|
||||
}
|
||||
movementMethod = null
|
||||
setMaxLength(CHAR_LIMIT_MESSAGE_PREVIEW)
|
||||
text = fullCaptionText
|
||||
updateLayoutParams { height = ViewGroup.LayoutParams.WRAP_CONTENT }
|
||||
}
|
||||
|
||||
if (isExpandable()) {
|
||||
setOnClickListener { toggleExpansion() }
|
||||
} else {
|
||||
|
||||
@@ -2153,7 +2153,7 @@
|
||||
<!-- This is displayed as a toast notification when we encounter an error deleting a message, including potentially on other people\'s devices -->
|
||||
<string name="MediaPreviewFragment_media_delete_error">Error Deleting Message, Message May Still Exist</string>
|
||||
<!-- A suffix to be attached to truncated captions that the user may tap onto to view the entire text caption -->
|
||||
<string name="MediaPreviewFragment_see_more">%1$s… <b>Read More</b></string>
|
||||
<string name="MediaPreviewFragment_read_more_overflow_text">Read More</string>
|
||||
|
||||
<!-- MessageNotifier -->
|
||||
<string name="MessageNotifier_d_new_messages_in_d_conversations">%1$d new messages in %2$d conversations</string>
|
||||
|
||||
Reference in New Issue
Block a user