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:
parent
257f3a5c1c
commit
c8fc2418b8
15 changed files with 530 additions and 284 deletions
|
|
@ -29,7 +29,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestBuilder;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||
import com.bumptech.glide.load.resource.bitmap.GranularRoundedCorners;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
|
|
@ -44,6 +43,7 @@ import com.keylesspalace.tusky.entity.HashTag;
|
|||
import com.keylesspalace.tusky.entity.Status;
|
||||
import com.keylesspalace.tusky.interfaces.StatusActionListener;
|
||||
import com.keylesspalace.tusky.util.AbsoluteTimeFormatter;
|
||||
import com.keylesspalace.tusky.util.AttachmentHelper;
|
||||
import com.keylesspalace.tusky.util.CardViewMode;
|
||||
import com.keylesspalace.tusky.util.CustomEmojiHelper;
|
||||
import com.keylesspalace.tusky.util.ImageLoadingHelper;
|
||||
|
|
@ -563,7 +563,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
|||
if (i < attachments.size()) {
|
||||
Attachment attachment = attachments.get(i);
|
||||
mediaLabel.setVisibility(View.VISIBLE);
|
||||
mediaDescriptions[i] = getAttachmentDescription(context, attachment);
|
||||
mediaDescriptions[i] = AttachmentHelper.getFormattedDescription(attachment, context);
|
||||
updateMediaLabel(i, sensitive, showingContent);
|
||||
|
||||
// Set the icon next to the label.
|
||||
|
|
@ -590,24 +590,12 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
|||
}
|
||||
});
|
||||
view.setOnLongClickListener(v -> {
|
||||
CharSequence description = getAttachmentDescription(view.getContext(), attachment);
|
||||
CharSequence description = AttachmentHelper.getFormattedDescription(attachment, view.getContext());
|
||||
Toast.makeText(view.getContext(), description, Toast.LENGTH_LONG).show();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private static CharSequence getAttachmentDescription(Context context, Attachment attachment) {
|
||||
String duration = "";
|
||||
if (attachment.getMeta() != null && attachment.getMeta().getDuration() != null && attachment.getMeta().getDuration() > 0) {
|
||||
duration = formatDuration(attachment.getMeta().getDuration()) + " ";
|
||||
}
|
||||
if (TextUtils.isEmpty(attachment.getDescription())) {
|
||||
return duration + context.getString(R.string.description_post_media_no_description_placeholder);
|
||||
} else {
|
||||
return duration + attachment.getDescription();
|
||||
}
|
||||
}
|
||||
|
||||
protected void hideSensitiveMediaWarning() {
|
||||
sensitiveMediaWarning.setVisibility(View.GONE);
|
||||
sensitiveMediaShow.setVisibility(View.GONE);
|
||||
|
|
@ -1168,13 +1156,4 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
|||
bookmarkButton.setVisibility(visibility);
|
||||
moreButton.setVisibility(visibility);
|
||||
}
|
||||
|
||||
private static String formatDuration(double durationInSeconds) {
|
||||
int seconds = (int) Math.round(durationInSeconds) % 60;
|
||||
int minutes = (int) durationInSeconds % 3600 / 60;
|
||||
int hours = (int) durationInSeconds / 3600;
|
||||
|
||||
return String.format("%d:%02d:%02d", hours, minutes, seconds);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue