From 8d932724713395e6d535a4b8235d6d4d0add02e8 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sat, 7 Sep 2024 05:12:35 +0530 Subject: [PATCH] Remove AndroidX Browser, make scrollbars red --- app/build.gradle | 3 --- .../newpipe/ui/components/channel/AboutChannelSection.kt | 3 ++- .../ui/components/common/link/YouTubeLinkHandler.kt | 9 ++++++--- .../ui/components/video/StreamDescriptionSection.kt | 3 ++- app/src/main/java/org/schabi/newpipe/ui/theme/Theme.kt | 7 +++++++ 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index bfd87ba45d1..00e3ad65913 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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}" diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/channel/AboutChannelSection.kt b/app/src/main/java/org/schabi/newpipe/ui/components/channel/AboutChannelSection.kt index 381fa681cce..d3dc5fa7885 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/channel/AboutChannelSection.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/channel/AboutChannelSection.kt @@ -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 @@ -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) diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/common/link/YouTubeLinkHandler.kt b/app/src/main/java/org/schabi/newpipe/ui/components/common/link/YouTubeLinkHandler.kt index 33ae226032d..09445b206ff 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/common/link/YouTubeLinkHandler.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/common/link/YouTubeLinkHandler.kt @@ -1,7 +1,7 @@ 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 @@ -9,8 +9,11 @@ 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) { @@ -19,7 +22,7 @@ class YouTubeLinkHandler(private val context: Context) : LinkInteractionListener ) } else { // Open link in custom browser tab. - CustomTabsIntent.Builder().build().launchUrl(context, uri) + uriHandler.openUri(url) } } } diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/video/StreamDescriptionSection.kt b/app/src/main/java/org/schabi/newpipe/ui/components/video/StreamDescriptionSection.kt index 7805a3ada5e..f2b71bd34cb 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/video/StreamDescriptionSection.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/video/StreamDescriptionSection.kt @@ -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 @@ -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) diff --git a/app/src/main/java/org/schabi/newpipe/ui/theme/Theme.kt b/app/src/main/java/org/schabi/newpipe/ui/theme/Theme.kt index 846794d725c..609f096c087 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/theme/Theme.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/theme/Theme.kt @@ -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, @@ -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(