use Tooltip instead of Toast for attachment description on long press
This commit is contained in:
parent
5eecf96d3b
commit
7e8ed0116e
|
@ -17,12 +17,12 @@ import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes;
|
import androidx.annotation.DrawableRes;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.PopupMenu;
|
import androidx.appcompat.widget.PopupMenu;
|
||||||
|
import androidx.appcompat.widget.TooltipCompat;
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.text.HtmlCompat;
|
import androidx.core.text.HtmlCompat;
|
||||||
|
@ -74,7 +74,6 @@ import java.text.NumberFormat;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import at.connyduck.sparkbutton.SparkButton;
|
import at.connyduck.sparkbutton.SparkButton;
|
||||||
import at.connyduck.sparkbutton.helpers.Utils;
|
import at.connyduck.sparkbutton.helpers.Utils;
|
||||||
|
@ -541,7 +540,8 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
||||||
imageView.setForeground(null);
|
imageView.setForeground(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
setAttachmentClickListener(imageView, listener, i, attachment, true);
|
final CharSequence formattedDescription = AttachmentHelper.getFormattedDescription(attachment, imageView.getContext());
|
||||||
|
setAttachmentClickListener(imageView, listener, i, formattedDescription, true);
|
||||||
|
|
||||||
if (sensitive) {
|
if (sensitive) {
|
||||||
sensitiveMediaWarning.setText(R.string.post_sensitive_media_title);
|
sensitiveMediaWarning.setText(R.string.post_sensitive_media_title);
|
||||||
|
@ -613,15 +613,15 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
||||||
int drawableId = getLabelIcon(attachments.get(0).getType());
|
int drawableId = getLabelIcon(attachments.get(0).getType());
|
||||||
mediaLabel.setCompoundDrawablesWithIntrinsicBounds(drawableId, 0, 0, 0);
|
mediaLabel.setCompoundDrawablesWithIntrinsicBounds(drawableId, 0, 0, 0);
|
||||||
|
|
||||||
setAttachmentClickListener(mediaLabel, listener, i, attachment, false);
|
setAttachmentClickListener(mediaLabel, listener, i, mediaDescriptions[i], false);
|
||||||
} else {
|
} else {
|
||||||
mediaLabel.setVisibility(View.GONE);
|
mediaLabel.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAttachmentClickListener(View view, @NonNull StatusActionListener listener,
|
private void setAttachmentClickListener(@NonNull View view, @NonNull StatusActionListener listener,
|
||||||
int index, Attachment attachment, boolean animateTransition) {
|
int index, CharSequence description, boolean animateTransition) {
|
||||||
view.setOnClickListener(v -> {
|
view.setOnClickListener(v -> {
|
||||||
int position = getBindingAdapterPosition();
|
int position = getBindingAdapterPosition();
|
||||||
if (position != RecyclerView.NO_POSITION) {
|
if (position != RecyclerView.NO_POSITION) {
|
||||||
|
@ -632,11 +632,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
view.setOnLongClickListener(v -> {
|
TooltipCompat.setTooltipText(view, description);
|
||||||
CharSequence description = AttachmentHelper.getFormattedDescription(attachment, view.getContext());
|
|
||||||
Toast.makeText(view.getContext(), description, Toast.LENGTH_LONG).show();
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void hideSensitiveMediaWarning() {
|
protected void hideSensitiveMediaWarning() {
|
||||||
|
|
|
@ -5,8 +5,8 @@ import android.graphics.Color
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.appcompat.content.res.AppCompatResources
|
import androidx.appcompat.content.res.AppCompatResources
|
||||||
|
import androidx.appcompat.widget.TooltipCompat
|
||||||
import androidx.core.view.setPadding
|
import androidx.core.view.setPadding
|
||||||
import androidx.paging.PagingDataAdapter
|
import androidx.paging.PagingDataAdapter
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
|
@ -141,11 +141,7 @@ class AccountMediaGridAdapter(
|
||||||
onAttachmentClickListener(item, imageView)
|
onAttachmentClickListener(item, imageView)
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.binding.root.setOnLongClickListener { view ->
|
TooltipCompat.setTooltipText(holder.binding.root, imageView.contentDescription)
|
||||||
val description = item.attachment.getFormattedDescription(view.context)
|
|
||||||
Toast.makeText(view.context, description, Toast.LENGTH_LONG).show()
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue