Add ability to copy hashtags, URLs and timestamps in descriptions on long-press

This commit adds the ability to copy to clipboard hashtags, URLs and timestamps
when long-pressing them.

Some changes in our TextView class related to text setting have been required
and metadata items are now using a NewPipeTextView instead of a standard
TextView.

Six new classes have been added:

- a custom LinkMovementMethod class;
- a custom ClickableSpan class, LongPressClickableSpan, in order to set a long
  press event;
- a class to avoid code duplication in CommentTextOnTouchListener, TouchUtils;
- three implementations of LongPressClickableSpan used when linkifying text:
  - HashtagLongPressClickableSpan for hashtags;
  - TimestampLongPressClickableSpan for timestamps;
  - UrlLongPressClickableSpan for URLs.
This commit is contained in:
AudricV 2022-07-16 13:33:25 +02:00 committed by Stypox
parent b5faaa7f75
commit 6de5a8cf04
16 changed files with 524 additions and 226 deletions

View file

@ -6,7 +6,7 @@
android:layout_height="wrap_content"
android:paddingVertical="6dp">
<TextView
<org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/metadata_type_view"
android:layout_width="96dp"
android:layout_height="wrap_content"
@ -19,7 +19,7 @@
app:layout_constraintTop_toTopOf="parent"
tools:text="Licence" />
<TextView
<org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/metadata_content_view"
android:layout_width="0dp"
android:layout_height="wrap_content"