-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove AndroidX Browser, make scrollbars red
- Loading branch information
1 parent
8f9faf3
commit 0d12cfc
Showing
5 changed files
with
17 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10
app/src/main/java/org/schabi/newpipe/ui/components/common/link/YouTubeLinkHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
package org.schabi.newpipe.ui.components.common.link | ||
|
||
import android.content.Context | ||
import androidx.browser.customtabs.CustomTabsIntent | ||
import androidx.compose.ui.platform.AndroidUriHandler | ||
import androidx.compose.ui.text.LinkAnnotation | ||
import androidx.compose.ui.text.LinkInteractionListener | ||
import androidx.core.net.toUri | ||
import org.schabi.newpipe.extractor.ServiceList | ||
import org.schabi.newpipe.util.NavigationHelper | ||
|
||
class YouTubeLinkHandler(private val context: Context) : LinkInteractionListener { | ||
private val uriHandler = AndroidUriHandler(context) | ||
|
||
override fun onClick(link: LinkAnnotation) { | ||
val uri = (link as LinkAnnotation.Url).url.toUri() | ||
val url = (link as LinkAnnotation.Url).url | ||
val uri = url.toUri() | ||
|
||
// TODO: Handle other links in NewPipe as well. | ||
if ("hashtag" in uri.pathSegments) { | ||
NavigationHelper.openSearch( | ||
context, ServiceList.YouTube.serviceId, "#${uri.lastPathSegment}" | ||
) | ||
} else { | ||
// Open link in custom browser tab. | ||
CustomTabsIntent.Builder().build().launchUrl(context, uri) | ||
uriHandler.openUri(url) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters