Skip to content

Commit

Permalink
Remove AndroidX Browser, make scrollbars red
Browse files Browse the repository at this point in the history
  • Loading branch information
Isira-Seneviratne committed Sep 6, 2024
1 parent 8f9faf3 commit 0d12cfc
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
3 changes: 0 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,6 @@ dependencies {
// Coroutines interop
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-rx3:1.8.1'

// Custom browser tab
implementation 'androidx.browser:browser:1.8.0'

/** Debugging **/
// Memory leak detection
debugImplementation "com.squareup.leakcanary:leakcanary-object-watcher-android:${leakCanaryVersion}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.schabi.newpipe.ui.components.metadata.MetadataItem
import org.schabi.newpipe.ui.components.metadata.TagsSection
import org.schabi.newpipe.ui.components.metadata.imageMetadataItem
import org.schabi.newpipe.ui.theme.AppTheme
import org.schabi.newpipe.ui.theme.NewPipeScrollbarSettings
import org.schabi.newpipe.util.Localization
import org.schabi.newpipe.util.NO_SERVICE_ID

Expand All @@ -32,7 +33,7 @@ fun AboutChannelSection(channelInfo: ParcelableChannelInfo) {
val (serviceId, description, count, avatars, banners, tags) = channelInfo
val lazyListState = rememberLazyListState()

LazyColumnScrollbar(state = lazyListState) {
LazyColumnScrollbar(state = lazyListState, settings = NewPipeScrollbarSettings) {
LazyColumn(
modifier = Modifier
.padding(12.dp)
Expand Down
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)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import org.schabi.newpipe.ui.components.metadata.MetadataItem
import org.schabi.newpipe.ui.components.metadata.TagsSection
import org.schabi.newpipe.ui.components.metadata.imageMetadataItem
import org.schabi.newpipe.ui.theme.AppTheme
import org.schabi.newpipe.ui.theme.NewPipeScrollbarSettings
import org.schabi.newpipe.util.Localization
import org.schabi.newpipe.util.NO_SERVICE_ID
import java.time.OffsetDateTime
Expand All @@ -66,7 +67,7 @@ fun StreamDescriptionSection(streamInfo: StreamInfo) {
val hasDescription = streamInfo.description != Description.EMPTY_DESCRIPTION
val lazyListState = rememberLazyListState()

LazyColumnScrollbar(state = lazyListState) {
LazyColumnScrollbar(state = lazyListState, settings = NewPipeScrollbarSettings) {
LazyColumn(
modifier = Modifier
.padding(start = 12.dp, end = 12.dp)
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/org/schabi/newpipe/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import my.nanihadesuka.compose.ScrollbarSettings

private val LightColors = lightColorScheme(
primary = md_theme_light_primary,
Expand Down Expand Up @@ -70,6 +72,11 @@ private val DarkColors = darkColorScheme(
scrim = md_theme_dark_scrim,
)

val NewPipeScrollbarSettings = ScrollbarSettings(
thumbSelectedColor = md_theme_dark_primary,
thumbUnselectedColor = Color.Red
)

@Composable
fun AppTheme(useDarkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
MaterialTheme(
Expand Down

0 comments on commit 0d12cfc

Please sign in to comment.