-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add long press action on hashtags and web links in descriptions #7725
Add long press action on hashtags and web links in descriptions #7725
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note:
- The videos are unplayable (can't view them in Firefox or Chromium-based browsers)
- There are some Sonar warnings
I had to compress them, unfortunately, but it seems Video Transcoder converted them in an unplayable format for browsers (you can play them in VLC I think) |
@litetex You may download the video with Video Download Helper. I eventually had to download, the video is still loading on my browser. @TiA4f8R I included some suggestions in #7097. I think, it'll be more suitable for copying links. |
This comment has been minimized.
This comment has been minimized.
So what's the best way to proceed when long pressing links and hashtags?
I am not all a UX designer so feedback is appreciated. |
@TiA4f8R The usual behaviour for Android apps is to take the specific action when directly tapping, and to copy to clipboard (or something else) when long-pressing. |
Ok, I will do this. Edit: done |
0c16ea7
to
770d9c8
Compare
Kudos, SonarCloud Quality Gate passed! |
@TiA4f8R Can you please add this functionality to timestamps in the description? (Example video with timestamps: https://www.youtube.com/watch?v=mOSirVeP5lo) Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks almost good to me ;-)
app/src/main/java/org/schabi/newpipe/util/external_communication/TextLinkifier.java
Outdated
Show resolved
Hide resolved
Note: even if it seems I forgot this pull request, I didn't forget it and I will continue to work on this, maybe once my work is done on other features/bug fixes I have on NewPipe projects. |
770d9c8
to
cb703bd
Compare
@ktprograms Done (in the app side) on services on which timestamps supported (otherwise, a fallback to copy timestamp raw text is made). |
Note that the Sonar bug is a false positive, as nullity is checked by |
cb703bd
to
aaae49a
Compare
SonarCloud Quality Gate failed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point you should probably create a library for clipboard & sharing handling 😂
I tested on API 33 emulated, API 22 emulated and my API 29 phone and everything works well. Comments with links now behave correctly :-D
The few comments I left are really small things: once you solve them, you can merge this PR yourself. Code looks good. I rebased and solved conflicts, otherwise it wouldn't build, because of the missing extractor commit build on Jitpack.
app/src/main/java/org/schabi/newpipe/util/external_communication/TextLinkifier.java
Outdated
Show resolved
Hide resolved
app/src/main/java/org/schabi/newpipe/util/CommentTextOnTouchListener.java
Outdated
Show resolved
Hide resolved
app/src/main/java/org/schabi/newpipe/views/LongPressLinkMovementMethod.java
Outdated
Show resolved
Hide resolved
…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.
aaae49a
to
22c201b
Compare
SonarCloud Quality Gate failed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! The bug reported by Sonar is wrong: it says content
might be null but actually we check for isBlank
ness above.
kinda strange that yeah, it doesn't play on desktop browser ( Vivaldi | 5.5.2805.48 (Stable channel) (64-bit) ; Chrome/106.0.0.0), but is working fine on android browser (Vivaldi 5.6.2868.29) |
but i still don't understand the premise of this PR. like, selecting tags and links was available before this pr as well:
This pr shows that press and holding them automatically copies them - one tap saved. But what happens in this pr when u single tap on links/tags? Did this problem was an effort to solve this single tap problem? Following is a screenrecord from Newpipe v0.23.3 i.e. back from 2022.08' v0.23.3-newpipe.mp4 |
I don't understand what you are referring to.
What do you mean by "single tap problem"? For me single taps work normally. Also, this PR was also needed because soon we will have comments with copiable links and hashtags. |
sorry, have updated with link. : #7725 (review)
this is shown in the screen recording - i meant that on single tapping, the links were opening. i was asking that was that considered the problem?
yeah, that is understandable. the thing that confused me was the following quoted part: "reopening as we are not able to copy full links" which we definitely were.
|
Oh ok, I see what you meant. Yeah, in the description you were already able to copy YouTube links, since those are always shown in full. I am not sure about Peertube though, where Markdown is employed, and |
ohw ohkayh, yeah, makes sense then 👍 |
What is it?
Description of the changes in your PR
This PR adds a long press action on web links and hashtags which copy them to clipboard.
To do so:
Some changes in our
TextView
class have been required and metadata items are now using aNewPipeTextView
instead of a standardTextView
.Three new classes have been added: a custom
LinkMovementMethod
class (adapted from a StackOverflow answer), a customClickableSpan
class have been added in order to set a long press event and a class to avoid code duplication inCommentTextOnTouchListener
,TouchUtils
.Before/After Screenshots/Screen Record
Long.press.links.and.hashtags.before.mp4
Long.press.links.and.hashtags.after.mp4
Fixes the following issue(s)
APK testing
The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.
Due diligence