Compare commits

..
12 changed files with 207 additions and 50 deletions

No files matched your search

+4
View File
@@ -36,6 +36,10 @@ export default ({ config }: ConfigContext): ExpoConfig => {
...config.ios,
bundleIdentifier: `${config.ios!.bundleIdentifier}${suffix}`,
icon: `./assets/${composer}.icon`,
infoPlist: {
...config.ios?.infoPlist,
NSUserActivityTypes: [`com.abunchofknowitalls.otunes${suffix}.media`],
},
},
android: {
...config.android,
+5 -2
View File
@@ -1,6 +1,9 @@
import { loadServerConfig, parseServerHostname } from "@/lib/server-config"
import { secureGetItem } from "@/lib/auth-storage"
import { rememberIncomingMediaLink } from "@/lib/incoming-media-link"
import {
isMediaRoute,
rememberIncomingMediaLink,
} from "@/lib/incoming-media-link"
import { showError } from "@/lib/toast"
export async function redirectSystemPath({
@@ -28,7 +31,7 @@ export async function redirectSystemPath({
target.username ||
target.password ||
new URL(server.serverUrl).origin !== target.origin ||
!/^\/(album|artist|playlist)\/[a-zA-Z0-9_-]+$/.test(target.pathname)
!isMediaRoute(target.pathname)
) {
return "/"
}
+3
View File
@@ -9,6 +9,8 @@ import { Toaster } from "@/components/ui/toaster"
import { ConvexAppProvider } from "@/contexts/convex-app"
import { ServerConfigProvider, useServerConfig } from "@/contexts/server-config"
import { HandoffBridge } from "@/components/handoff-bridge"
const navigationTheme = {
...DarkTheme,
colors: { ...DarkTheme.colors, background: "#000", card: "#000" },
@@ -56,6 +58,7 @@ export default function RootLayout() {
<ConvexAppProvider>
<StatusBar style={isDark ? "light" : "dark"} />
<ThemeProvider value={navigationTheme}>
<HandoffBridge />
<RootNavigator />
</ThemeProvider>
<Toaster />
+81
View File
@@ -0,0 +1,81 @@
import { useConvexAuth } from "@convex-dev/auth/react"
import { requireOptionalNativeModule, type NativeModule } from "expo"
import { usePathname } from "expo-router"
import { useEffect } from "react"
import { Platform } from "react-native"
import { useServerConfig } from "@/contexts/server-config"
import {
isMediaRoute,
rememberIncomingMediaLink,
} from "@/lib/incoming-media-link"
import { showError } from "@/lib/toast"
type Activity = { server: string; route: string }
declare class HandoffModule extends NativeModule<{ onActivity: () => void }> {
takeActivity(): Promise<Activity | null>
publish(server: string | null, route: string | null): Promise<void>
}
const handoff =
Platform.OS === "ios"
? requireOptionalNativeModule<HandoffModule>("Handoff")
: null
export function HandoffBridge() {
const { config, isLoading } = useServerConfig()
const auth = useConvexAuth()
const pathname = usePathname()
useEffect(() => {
if (!handoff || isLoading) return
let active = true
async function receive() {
const activity = await handoff!.takeActivity()
if (!active || !activity) return
try {
const source = new URL(activity.server)
if (!config || source.origin !== new URL(config.serverUrl).origin) {
showError("This activity belongs to a different oTunes server.")
return
}
if (
!["http:", "https:"].includes(source.protocol) ||
source.username ||
source.password ||
!isMediaRoute(activity.route)
)
return
rememberIncomingMediaLink(
`/(app)/(tabs)/home${activity.route}`,
source.origin
)
} catch {
// Ignore malformed activities without navigating or changing servers.
}
}
const subscription = handoff.addListener("onActivity", () => {
void receive()
})
void receive()
return () => {
active = false
subscription.remove()
}
}, [config, isLoading])
useEffect(() => {
if (!handoff) return
const route = pathname.replace(/^\/(home|search|library)/, "")
const canPublish = config && auth?.isAuthenticated && isMediaRoute(route)
void handoff.publish(
canPublish ? config.serverUrl : null,
canPublish ? route : null
)
return () => {
void handoff.publish(null, null)
}
}, [config, auth?.isAuthenticated, pathname])
return null
}
+5
View File
@@ -28,3 +28,8 @@ export function rememberIncomingMediaLink(path: string, serverOrigin: string) {
pendingLink = { path, serverOrigin }
for (const listener of listeners) listener()
}
// Shared by native links and Handoff. Only concrete media screens are routable.
export function isMediaRoute(path: string) {
return /^\/(album|artist|playlist)\/[a-zA-Z0-9_-]+$/.test(path)
}
@@ -0,0 +1,7 @@
{
"platforms": ["apple"],
"apple": {
"modules": ["HandoffModule"],
"appDelegateSubscribers": ["HandoffAppDelegateSubscriber"]
}
}
@@ -0,0 +1,16 @@
Pod::Spec.new do |s|
s.name = 'Handoff'
s.version = '1.0.0'
s.summary = 'Native media screen Handoff for oTunes'
s.description = s.summary
s.license = { :type => 'MIT' }
s.author = 'oTunes'
s.homepage = 'https://otunes.abunchofknowitalls.com'
s.platforms = { :ios => '16.4' }
s.swift_version = '5.9'
s.source = { :git => '' }
s.static_framework = true
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
s.dependency 'ExpoModulesCore'
s.source_files = '**/*.swift'
end
@@ -0,0 +1,70 @@
import ExpoModulesCore
import UIKit
// Retain the latest continuation until JS is mounted, including cold launches.
private enum HandoffState {
static var activity: NSUserActivity?
static var pending: [String: String]?
static var notify: (() -> Void)?
static var activityType: String {
"\(Bundle.main.bundleIdentifier!).media"
}
}
public final class HandoffAppDelegateSubscriber: ExpoAppDelegateSubscriber {
public func application(
_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
) -> Bool {
guard userActivity.activityType == HandoffState.activityType,
let server = userActivity.userInfo?["server"] as? String,
let route = userActivity.userInfo?["route"] as? String
else { return false }
HandoffState.pending = ["server": server, "route": route]
HandoffState.notify?()
return true
}
}
public final class HandoffModule: Module {
public func definition() -> ModuleDefinition {
Name("Handoff")
Events("onActivity")
OnStartObserving {
HandoffState.notify = { [weak self] in self?.sendEvent("onActivity") }
if HandoffState.pending != nil { HandoffState.notify?() }
}
OnStopObserving { HandoffState.notify = nil }
AsyncFunction("takeActivity") { () -> [String: String]? in
defer { HandoffState.pending = nil }
return HandoffState.pending
}.runOnQueue(.main)
AsyncFunction("publish") { (server: String?, route: String?) in
HandoffState.activity?.invalidate()
HandoffState.activity = nil
guard let server, let route else { return }
let activity = NSUserActivity(activityType: HandoffState.activityType)
activity.title = "oTunes"
activity.userInfo = ["server": server, "route": route]
activity.requiredUserInfoKeys = ["server", "route"]
activity.isEligibleForHandoff = true
activity.isEligibleForSearch = false
activity.isEligibleForPublicIndexing = false
HandoffState.activity = activity
activity.becomeCurrent()
}.runOnQueue(.main)
OnDestroy {
DispatchQueue.main.async {
HandoffState.activity?.invalidate()
HandoffState.activity = nil
HandoffState.notify = nil
}
}
}
}
+5
View File
@@ -0,0 +1,5 @@
{
"name": "otunes-handoff",
"version": "1.0.0",
"private": true
}
+1 -2
View File
@@ -21,8 +21,7 @@
"packageManager": "pnpm@10.1.0",
"pnpm": {
"patchedDependencies": {
"expo-audio@58.0.10": "patches/expo-audio@58.0.10.patch",
"react-native-screens@4.30.0": "patches/react-native-screens@4.30.0.patch"
"expo-audio@58.0.10": "patches/expo-audio@58.0.10.patch"
}
}
}
-33
View File
@@ -1,33 +0,0 @@
diff --git a/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/appearance/TabsAppearanceApplicator.kt b/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/appearance/TabsAppearanceApplicator.kt
index cbe9b978ced6972a51bc5235b47a58dd55836351..b7063502332a7d1da5cb58ea8738670a9d3f5e87 100644
--- a/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/appearance/TabsAppearanceApplicator.kt
+++ b/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/appearance/TabsAppearanceApplicator.kt
@@ -186,16 +186,24 @@ internal class TabsAppearanceApplicator(
val rippleColor =
tabBarAppearance?.tabBarItemRippleColor
?: resolveColorAttr(context, R.attr.itemRippleColor)
- bottomNavigationView.itemRippleColor = ColorStateList.valueOf(rippleColor)
+ // Material recreates the ripple drawable on these setters, even when
+ // values are unchanged. Preserve an in-flight press across tab updates.
+ if (bottomNavigationView.itemRippleColor?.defaultColor != rippleColor) {
+ bottomNavigationView.itemRippleColor = ColorStateList.valueOf(rippleColor)
+ }
// Active Indicator
val activeIndicatorColor =
tabBarAppearance?.tabBarItemActiveIndicatorColor
?: resolveColorAttr(context, R.attr.colorSecondaryContainer)
- bottomNavigationView.isItemActiveIndicatorEnabled =
- tabBarAppearance?.tabBarItemActiveIndicatorEnabled ?: true
- bottomNavigationView.itemActiveIndicatorColor = ColorStateList.valueOf(activeIndicatorColor)
+ val activeIndicatorEnabled = tabBarAppearance?.tabBarItemActiveIndicatorEnabled ?: true
+ if (bottomNavigationView.isItemActiveIndicatorEnabled != activeIndicatorEnabled) {
+ bottomNavigationView.isItemActiveIndicatorEnabled = activeIndicatorEnabled
+ }
+ if (bottomNavigationView.itemActiveIndicatorColor?.defaultColor != activeIndicatorColor) {
+ bottomNavigationView.itemActiveIndicatorColor = ColorStateList.valueOf(activeIndicatorColor)
+ }
}
fun updateFontStyles(
+10 -13
View File
@@ -8,9 +8,6 @@ patchedDependencies:
expo-audio@58.0.10:
hash: f7f102c0f17b28e763d828acd4f138d62809f5be576e316a13008c27e84968c5
path: patches/expo-audio@58.0.10.patch
react-native-screens@4.30.0:
hash: 4c993bb49116c59c1df018c02687484d61964af674b5ea2d5b68c051e434423a
path: patches/react-native-screens@4.30.0.patch
importers:
@@ -96,7 +93,7 @@ importers:
version: 58.0.4(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
expo-router:
specifier: ~58.0.25
version: 58.0.25(5c865dc62adb071be8c7946ff2c6115b)
version: 58.0.25(114ad080e17b889d99a70734d72d1fb4)
expo-secure-store:
specifier: ~58.0.2
version: 58.0.2(expo@58.0.17)
@@ -138,7 +135,7 @@ importers:
version: 5.10.1(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
react-native-screens:
specifier: 4.30.0
version: 4.30.0(patch_hash=4c993bb49116c59c1df018c02687484d61964af674b5ea2d5b68c051e434423a)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
version: 4.30.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
react-native-svg:
specifier: 15.16.0
version: 15.16.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
@@ -147,7 +144,7 @@ importers:
version: 0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
sonner-native:
specifier: ^0.26.2
version: 0.26.4(ee6658a01f0566316b5a28dccc2b8480)
version: 0.26.4(6b7420e058a3b6d4e4d2699d79ac8702)
devDependencies:
'@types/node':
specifier: ^20
@@ -7531,7 +7528,7 @@ snapshots:
ws: 8.21.0
zod: 3.25.76
optionalDependencies:
expo-router: 58.0.25(5c865dc62adb071be8c7946ff2c6115b)
expo-router: 58.0.25(114ad080e17b889d99a70734d72d1fb4)
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)
transitivePeerDependencies:
- '@expo/dom-webview'
@@ -7832,7 +7829,7 @@ snapshots:
react: 19.3.0
optionalDependencies:
'@expo/metro-runtime': 58.0.15(@expo/log-box@58.0.13)(expo@58.0.17)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
expo-router: 58.0.25(5c865dc62adb071be8c7946ff2c6115b)
expo-router: 58.0.25(114ad080e17b889d99a70734d72d1fb4)
react-dom: 19.3.0(react@19.3.0)
transitivePeerDependencies:
- supports-color
@@ -11233,7 +11230,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
expo-router@58.0.25(5c865dc62adb071be8c7946ff2c6115b):
expo-router@58.0.25(114ad080e17b889d99a70734d72d1fb4):
dependencies:
'@expo/log-box': 58.0.13(@expo/dom-webview@58.0.2)(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
'@expo/metro-runtime': 58.0.15(@expo/log-box@58.0.13)(expo@58.0.17)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
@@ -11255,7 +11252,7 @@ snapshots:
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)
react-native-drawer-layout: 4.2.12(react-native-gesture-handler@3.3.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native-reanimated@4.7.1(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
react-native-safe-area-context: 5.10.1(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
react-native-screens: 4.30.0(patch_hash=4c993bb49116c59c1df018c02687484d61964af674b5ea2d5b68c051e434423a)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
react-native-screens: 4.30.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
server-only: 0.0.1
sf-symbols-typescript: 2.2.0
standard-navigation: 0.0.5
@@ -12957,7 +12954,7 @@ snapshots:
react: 19.3.0
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)
react-native-screens@4.30.0(patch_hash=4c993bb49116c59c1df018c02687484d61964af674b5ea2d5b68c051e434423a)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0):
react-native-screens@4.30.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0):
dependencies:
react: 19.3.0
react-freeze: 1.0.4(react@19.3.0)
@@ -13506,14 +13503,14 @@ snapshots:
slugify@1.6.9: {}
sonner-native@0.26.4(ee6658a01f0566316b5a28dccc2b8480):
sonner-native@0.26.4(6b7420e058a3b6d4e4d2699d79ac8702):
dependencies:
react: 19.3.0
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)
react-native-gesture-handler: 3.3.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
react-native-reanimated: 4.7.1(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
react-native-safe-area-context: 5.10.1(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
react-native-screens: 4.30.0(patch_hash=4c993bb49116c59c1df018c02687484d61964af674b5ea2d5b68c051e434423a)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
react-native-screens: 4.30.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
react-native-svg: 15.16.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
react-native-worklets: 0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)