|
|
|
@ -29,11 +29,11 @@ import com.keylesspalace.tusky.entity.Emoji; |
|
|
|
|
import com.keylesspalace.tusky.entity.Status; |
|
|
|
|
import com.keylesspalace.tusky.interfaces.StatusActionListener; |
|
|
|
|
import com.keylesspalace.tusky.util.CustomEmojiHelper; |
|
|
|
|
import com.keylesspalace.tusky.util.TimestampUtils; |
|
|
|
|
import com.keylesspalace.tusky.util.HtmlUtils; |
|
|
|
|
import com.keylesspalace.tusky.util.ImageLoadingHelper; |
|
|
|
|
import com.keylesspalace.tusky.util.LinkHelper; |
|
|
|
|
import com.keylesspalace.tusky.util.ThemeUtils; |
|
|
|
|
import com.keylesspalace.tusky.util.TimestampUtils; |
|
|
|
|
import com.keylesspalace.tusky.view.MediaPreviewImageView; |
|
|
|
|
import com.keylesspalace.tusky.viewdata.PollOptionViewData; |
|
|
|
|
import com.keylesspalace.tusky.viewdata.PollViewData; |
|
|
|
@ -92,6 +92,8 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
|
private int avatarRadius36dp; |
|
|
|
|
private int avatarRadius24dp; |
|
|
|
|
|
|
|
|
|
private final int mediaPreviewUnloadedId; |
|
|
|
|
|
|
|
|
|
protected StatusBaseViewHolder(View itemView, |
|
|
|
|
boolean useAbsoluteTime) { |
|
|
|
|
super(itemView); |
|
|
|
@ -145,6 +147,9 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
|
this.avatarRadius48dp = itemView.getContext().getResources().getDimensionPixelSize(R.dimen.avatar_radius_48dp); |
|
|
|
|
this.avatarRadius36dp = itemView.getContext().getResources().getDimensionPixelSize(R.dimen.avatar_radius_36dp); |
|
|
|
|
this.avatarRadius24dp = itemView.getContext().getResources().getDimensionPixelSize(R.dimen.avatar_radius_24dp); |
|
|
|
|
|
|
|
|
|
mediaPreviewUnloadedId = ThemeUtils.getDrawableId(itemView.getContext(), |
|
|
|
|
R.attr.media_preview_unloaded_drawable, android.R.color.black); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected abstract int getMediaPreviewHeight(Context context); |
|
|
|
@ -215,10 +220,10 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
|
boolean animateAvatar) { |
|
|
|
|
|
|
|
|
|
int avatarRadius; |
|
|
|
|
if(TextUtils.isEmpty(rebloggedUrl)) { |
|
|
|
|
if (TextUtils.isEmpty(rebloggedUrl)) { |
|
|
|
|
avatar.setPaddingRelative(0, 0, 0, 0); |
|
|
|
|
|
|
|
|
|
if(showBotOverlay && isBot) { |
|
|
|
|
if (showBotOverlay && isBot) { |
|
|
|
|
avatarInset.setVisibility(View.VISIBLE); |
|
|
|
|
avatarInset.setBackgroundColor(0x50ffffff); |
|
|
|
|
Glide.with(avatarInset) |
|
|
|
@ -329,66 +334,71 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
|
favouriteButton.setChecked(favourited); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void setMediaPreviews(final List<Attachment> attachments, boolean sensitive, |
|
|
|
|
final StatusActionListener listener, boolean showingContent) { |
|
|
|
|
|
|
|
|
|
Context context = itemView.getContext(); |
|
|
|
|
|
|
|
|
|
int mediaPreviewUnloadedId = |
|
|
|
|
ThemeUtils.getDrawableId(itemView.getContext(), R.attr.media_preview_unloaded_drawable, |
|
|
|
|
android.R.color.black); |
|
|
|
|
|
|
|
|
|
final int n = Math.min(attachments.size(), Status.MAX_MEDIA_ATTACHMENTS); |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < n; i++) { |
|
|
|
|
String previewUrl = attachments.get(i).getPreviewUrl(); |
|
|
|
|
String description = attachments.get(i).getDescription(); |
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(description)) { |
|
|
|
|
mediaPreviews[i].setContentDescription(context.getString(R.string.action_view_media)); |
|
|
|
|
} else { |
|
|
|
|
mediaPreviews[i].setContentDescription(description); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mediaPreviews[i].setVisibility(View.VISIBLE); |
|
|
|
|
|
|
|
|
|
private void loadImage(MediaPreviewImageView imageView, String previewUrl, String description, |
|
|
|
|
MetaData meta) { |
|
|
|
|
if (TextUtils.isEmpty(previewUrl)) { |
|
|
|
|
Glide.with(mediaPreviews[i]) |
|
|
|
|
Glide.with(imageView) |
|
|
|
|
.load(mediaPreviewUnloadedId) |
|
|
|
|
.centerInside() |
|
|
|
|
.into(mediaPreviews[i]); |
|
|
|
|
.into(imageView); |
|
|
|
|
} else { |
|
|
|
|
MetaData meta = attachments.get(i).getMeta(); |
|
|
|
|
Focus focus = meta != null ? meta.getFocus() : null; |
|
|
|
|
|
|
|
|
|
if (focus != null) { // If there is a focal point for this attachment:
|
|
|
|
|
mediaPreviews[i].setFocalPoint(focus); |
|
|
|
|
imageView.setFocalPoint(focus); |
|
|
|
|
|
|
|
|
|
Glide.with(mediaPreviews[i]) |
|
|
|
|
Glide.with(imageView) |
|
|
|
|
.load(previewUrl) |
|
|
|
|
.placeholder(mediaPreviewUnloadedId) |
|
|
|
|
.centerInside() |
|
|
|
|
.addListener(mediaPreviews[i]) |
|
|
|
|
.into(mediaPreviews[i]); |
|
|
|
|
.addListener(imageView) |
|
|
|
|
.into(imageView); |
|
|
|
|
} else { |
|
|
|
|
mediaPreviews[i].removeFocalPoint(); |
|
|
|
|
imageView.removeFocalPoint(); |
|
|
|
|
|
|
|
|
|
Glide.with(mediaPreviews[i]) |
|
|
|
|
Glide.with(imageView) |
|
|
|
|
.load(previewUrl) |
|
|
|
|
.placeholder(mediaPreviewUnloadedId) |
|
|
|
|
.centerInside() |
|
|
|
|
.into(mediaPreviews[i]); |
|
|
|
|
.into(imageView); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void setMediaPreviews(final List<Attachment> attachments, boolean sensitive, |
|
|
|
|
final StatusActionListener listener, boolean showingContent) { |
|
|
|
|
Context context = itemView.getContext(); |
|
|
|
|
final int n = Math.min(attachments.size(), Status.MAX_MEDIA_ATTACHMENTS); |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < n; i++) { |
|
|
|
|
String previewUrl = attachments.get(i).getPreviewUrl(); |
|
|
|
|
String description = attachments.get(i).getDescription(); |
|
|
|
|
MediaPreviewImageView imageView = mediaPreviews[i]; |
|
|
|
|
|
|
|
|
|
imageView.setVisibility(View.VISIBLE); |
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(description)) { |
|
|
|
|
imageView.setContentDescription(imageView.getContext() |
|
|
|
|
.getString(R.string.action_view_media)); |
|
|
|
|
} else { |
|
|
|
|
imageView.setContentDescription(description); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!sensitive || showingContent) { |
|
|
|
|
loadImage(imageView, previewUrl, description, attachments.get(i).getMeta()); |
|
|
|
|
} else { |
|
|
|
|
imageView.setImageResource(mediaPreviewUnloadedId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
final Attachment.Type type = attachments.get(i).getType(); |
|
|
|
|
if (type == Attachment.Type.VIDEO | type == Attachment.Type.GIFV) { |
|
|
|
|
if (type == Attachment.Type.VIDEO || type == Attachment.Type.GIFV) { |
|
|
|
|
mediaOverlays[i].setVisibility(View.VISIBLE); |
|
|
|
|
} else { |
|
|
|
|
mediaOverlays[i].setVisibility(View.GONE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setAttachmentClickListener(mediaPreviews[i], listener, i, attachments.get(i), true); |
|
|
|
|
setAttachmentClickListener(imageView, listener, i, attachments.get(i), true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
final int mediaPreviewHeight = getMediaPreviewHeight(context); |
|
|
|
|
|
|
|
|
@ -401,7 +411,6 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
|
mediaPreviews[2].getLayoutParams().height = mediaPreviewHeight; |
|
|
|
|
mediaPreviews[3].getLayoutParams().height = mediaPreviewHeight; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
final String hiddenContentText; |
|
|
|
|
if (sensitive) { |
|
|
|
@ -518,7 +527,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
|
listener.onReply(position); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
if(reblogButton != null) { |
|
|
|
|
if (reblogButton != null) { |
|
|
|
|
reblogButton.setEventListener(new SparkEventListener() { |
|
|
|
|
@Override |
|
|
|
|
public void onEvent(ImageView button, boolean buttonState) { |
|
|
|
@ -623,7 +632,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
|
|
|
|
|
|
setDescriptionForStatus(status); |
|
|
|
|
|
|
|
|
|
setupPoll(status.getPoll(),status.getStatusEmojis(), listener); |
|
|
|
|
setupPoll(status.getPoll(), status.getStatusEmojis(), listener); |
|
|
|
|
|
|
|
|
|
// Workaround for RecyclerView 1.0.0 / androidx.core 1.0.0
|
|
|
|
|
// RecyclerView tries to set AccessibilityDelegateCompat to null
|
|
|
|
@ -805,7 +814,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
|
|
|
|
|
|
List<Integer> pollResult = pollAdapter.getSelected(); |
|
|
|
|
|
|
|
|
|
if(!pollResult.isEmpty()) { |
|
|
|
|
if (!pollResult.isEmpty()) { |
|
|
|
|
listener.onVoteInPoll(position, pollResult); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|