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"

View file

@ -741,4 +741,5 @@
<string name="import_subscriptions_hint">Importer ou exporter des abonnements à partir du menu</string>
<string name="app_update_unavailable_toast">Vous utilisez la dernière version de NewPipe</string>
<string name="app_update_available_notification_text">Appuyez pour télécharger %s</string>
<string name="msg_failed_to_copy">Échec de la copie dans le presse-papiers</string>
</resources>

View file

@ -327,6 +327,7 @@
<string name="msg_calculating_hash">Calculating hash</string>
<string name="msg_wait">Please wait…</string>
<string name="msg_copied">Copied to clipboard</string>
<string name="msg_failed_to_copy">Failed to copy to clipboard</string>
<string name="no_available_dir">Please define a download folder later in settings</string>
<string name="no_dir_yet">No download folder set yet, choose the default download folder now</string>
<string name="msg_popup_permission">This permission is needed to\nopen in popup mode</string>