Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,6 @@ public static TimestampMatchDTO getTimestampFromMatcher(
return new TimestampMatchDTO(timestampStart, timestampEnd, seconds);
}

public static class TimestampMatchDTO {
private final int timestampStart;
private final int timestampEnd;
private final int seconds;

public TimestampMatchDTO(
final int timestampStart,
final int timestampEnd,
final int seconds) {
this.timestampStart = timestampStart;
this.timestampEnd = timestampEnd;
this.seconds = seconds;
}

public int timestampStart() {
return timestampStart;
}

public int timestampEnd() {
return timestampEnd;
}

public int seconds() {
return seconds;
}
public record TimestampMatchDTO(int timestampStart, int timestampEnd, int seconds) {
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package org.schabi.newpipe.util.text

import android.content.Context
import android.view.View
import io.reactivex.rxjava3.disposables.CompositeDisposable
import org.schabi.newpipe.extractor.ServiceList
import org.schabi.newpipe.extractor.StreamingService
import org.schabi.newpipe.util.external_communication.ShareUtils
import org.schabi.newpipe.util.text.TimestampExtractor.TimestampMatchDTO

class TimestampLongPressClickableSpan(
private val context: Context,
private val descriptionText: String,
private val disposables: CompositeDisposable,
private val relatedInfoService: StreamingService,
private val relatedStreamUrl: String,
private val timestampMatchDTO: TimestampMatchDTO
) : LongPressClickableSpan() {
override fun onClick(view: View) {
InternalUrlsHandler.playOnPopup(
context, relatedStreamUrl, relatedInfoService,
timestampMatchDTO.seconds()
Comment on lines +21 to +22
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put all on single line or separate if its over 100 char.

)
}

override fun onLongClick(view: View) {
ShareUtils.copyToClipboard(
context,
getTimestampTextToCopy(
relatedInfoService, relatedStreamUrl, descriptionText, timestampMatchDTO
)
)
}

companion object {
private fun getTimestampTextToCopy(
relatedInfoService: StreamingService,
relatedStreamUrl: String,
descriptionText: String,
timestampMatchDTO: TimestampMatchDTO
): String {
// TODO: use extractor methods to get timestamps when this feature will be implemented in it
when (relatedInfoService) {
ServiceList.YouTube ->
return relatedStreamUrl + "&t=" + timestampMatchDTO.seconds()
ServiceList.SoundCloud, ServiceList.MediaCCC ->
return relatedStreamUrl + "#t=" + timestampMatchDTO.seconds()
ServiceList.PeerTube ->
return relatedStreamUrl + "?start=" + timestampMatchDTO.seconds()
}

// Return timestamp text for other services
return descriptionText.subSequence(
timestampMatchDTO.timestampStart(),
timestampMatchDTO.timestampEnd()
).toString()
Comment on lines +43 to +56
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be possible to concat string and also lift the return statement out of the when block with an else logic.

Copy link
Copy Markdown
Author

@ghost ghost Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am dumb. Could you explain (about else)? And thanks for reviews

}
}
}