Compare commits
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -87,34 +87,15 @@ export default function AppLayout() {
|
||||
<Stack.Screen
|
||||
name="settings"
|
||||
options={{
|
||||
// iOS gets a native header with a close button; Android
|
||||
// draws its own title bar in the screen.
|
||||
headerShown: Platform.OS === "ios",
|
||||
headerShown: Platform.OS === "android",
|
||||
title: "Settings",
|
||||
headerLargeTitle: false,
|
||||
headerTransparent: false,
|
||||
headerShadowVisible: false,
|
||||
headerStyle: { backgroundColor: "#000" },
|
||||
// Matches the inline title size of Apple Music's settings.
|
||||
headerTitleStyle: { fontSize: 20, fontWeight: "700" },
|
||||
presentation:
|
||||
Platform.OS === "ios" ? "modal" : "fullScreenModal",
|
||||
animation: "slide_from_bottom",
|
||||
gestureEnabled: true,
|
||||
gestureDirection: "vertical",
|
||||
}}
|
||||
>
|
||||
{/* Stack.Toolbar forces the header on, so keep it iOS-only. */}
|
||||
{Platform.OS === "ios" ? (
|
||||
<Stack.Toolbar placement="right">
|
||||
<Stack.Toolbar.Button
|
||||
icon="xmark"
|
||||
accessibilityLabel="Close settings"
|
||||
onPress={() => router.back()}
|
||||
/>
|
||||
</Stack.Toolbar>
|
||||
) : null}
|
||||
</Stack.Screen>
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="create-account"
|
||||
options={{
|
||||
|
||||
@@ -1 +1,16 @@
|
||||
export { default } from "./(tabs)/home/settings"
|
||||
import { Platform } from "react-native"
|
||||
import { SafeAreaView } from "react-native-safe-area-context"
|
||||
|
||||
import SettingsScreen from "./(tabs)/home/settings"
|
||||
|
||||
export default function Settings() {
|
||||
if (Platform.OS !== "android") return <SettingsScreen />
|
||||
return (
|
||||
<SafeAreaView
|
||||
edges={["bottom", "left", "right"]}
|
||||
style={{ flex: 1, backgroundColor: "#000" }}
|
||||
>
|
||||
<SettingsScreen />
|
||||
</SafeAreaView>
|
||||
)
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import { Button, Host } from "@expo/ui/swift-ui"
|
||||
import {
|
||||
buttonBorderShape,
|
||||
buttonStyle,
|
||||
controlSize,
|
||||
labelStyle,
|
||||
} from "@expo/ui/swift-ui/modifiers"
|
||||
|
||||
/** A native SwiftUI glass "+" button, matching the iOS header close button. */
|
||||
export function AddButton({
|
||||
label,
|
||||
onPress,
|
||||
}: {
|
||||
label: string
|
||||
onPress: () => void
|
||||
}) {
|
||||
return (
|
||||
<Host matchContents>
|
||||
<Button
|
||||
label={label}
|
||||
systemImage="plus"
|
||||
onPress={onPress}
|
||||
modifiers={[
|
||||
labelStyle("iconOnly"),
|
||||
buttonStyle("glass"),
|
||||
buttonBorderShape("circle"),
|
||||
controlSize("large"),
|
||||
]}
|
||||
/>
|
||||
</Host>
|
||||
)
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import { Ionicons } from "@expo/vector-icons"
|
||||
import { Pressable } from "react-native"
|
||||
|
||||
import { useThemeColors } from "@/lib/theme"
|
||||
|
||||
/** A plain "+" icon button. iOS uses a native SwiftUI button instead. */
|
||||
export function AddButton({
|
||||
label,
|
||||
onPress,
|
||||
}: {
|
||||
label: string
|
||||
onPress: () => void
|
||||
}) {
|
||||
const colors = useThemeColors()
|
||||
return (
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={label}
|
||||
hitSlop={8}
|
||||
onPress={onPress}
|
||||
style={({ pressed }) => ({ opacity: pressed ? 0.6 : 1 })}
|
||||
>
|
||||
<Ionicons name="add" size={32} color={colors.foreground} />
|
||||
</Pressable>
|
||||
)
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
useAndroidTabPalette,
|
||||
useAndroidTabHasArtworkPalette,
|
||||
} from "@/contexts/android-tab-theme"
|
||||
import { useAndroidTabPalette } from "@/contexts/android-tab-theme"
|
||||
import { Ionicons } from "@expo/vector-icons"
|
||||
import { NativeTabs } from "expo-router/native-tabs"
|
||||
import { useRouter } from "expo-router"
|
||||
@@ -166,20 +163,10 @@ function MiniPlayerContent({
|
||||
|
||||
function MiniPlayerChrome({ children }: { children: React.ReactNode }) {
|
||||
const palette = useAndroidTabPalette()
|
||||
const hasArtworkPalette = useAndroidTabHasArtworkPalette()
|
||||
|
||||
return (
|
||||
<View style={[styles.androidBar, { backgroundColor: palette.background }]}>
|
||||
{children}
|
||||
{hasArtworkPalette ? (
|
||||
<View
|
||||
style={[
|
||||
styles.separator,
|
||||
styles.topBorder,
|
||||
{ backgroundColor: palette.secondaryForeground },
|
||||
]}
|
||||
/>
|
||||
) : null}
|
||||
<View
|
||||
style={[
|
||||
styles.separator,
|
||||
@@ -267,7 +254,6 @@ const styles = StyleSheet.create({
|
||||
height: 1,
|
||||
zIndex: 1,
|
||||
},
|
||||
topBorder: { top: 0 },
|
||||
bottomBorder: { bottom: 0 },
|
||||
content: {
|
||||
flexDirection: "row",
|
||||
|
||||
@@ -34,6 +34,7 @@ import {
|
||||
writeRememberedDownloadQuality,
|
||||
} from "@/lib/downloads"
|
||||
import { loadPlaybackSongs } from "@/lib/playback-files"
|
||||
import { downloadQualitySupported } from "@/lib/playback-capabilities"
|
||||
import type { ServerConfig } from "@/lib/server-config"
|
||||
import { showError } from "@/lib/toast"
|
||||
import { useThemeColors } from "@/lib/theme"
|
||||
@@ -238,36 +239,44 @@ function DownloadQualityPopup({
|
||||
>
|
||||
{pending?.target.title}
|
||||
</Text>
|
||||
{pending?.response.options.map((option) => (
|
||||
<Pressable
|
||||
key={option.quality}
|
||||
accessibilityRole="button"
|
||||
style={[styles.row, { borderBottomColor: colors.border }]}
|
||||
onPress={() => onPick(option.quality, remember)}
|
||||
>
|
||||
<View style={styles.rowText}>
|
||||
{option.quality === "lossless" ||
|
||||
option.quality === "atmos" ? (
|
||||
<AudioFormatBadge
|
||||
format={option.quality}
|
||||
color={colors.foreground}
|
||||
backgroundColor={colors.card}
|
||||
/>
|
||||
) : (
|
||||
<Text style={[styles.label, { color: colors.foreground }]}>
|
||||
{DOWNLOAD_QUALITY_LABELS[option.quality]}
|
||||
{pending?.response.options
|
||||
.filter((option) => downloadQualitySupported(option.quality))
|
||||
.map((option) => (
|
||||
<Pressable
|
||||
key={option.quality}
|
||||
accessibilityRole="button"
|
||||
style={[styles.row, { borderBottomColor: colors.border }]}
|
||||
onPress={() => onPick(option.quality, remember)}
|
||||
>
|
||||
<View style={styles.rowText}>
|
||||
{option.quality === "lossless" ||
|
||||
option.quality === "atmos" ? (
|
||||
<AudioFormatBadge
|
||||
format={option.quality}
|
||||
color={colors.foreground}
|
||||
backgroundColor={colors.card}
|
||||
/>
|
||||
) : (
|
||||
<Text
|
||||
style={[styles.label, { color: colors.foreground }]}
|
||||
>
|
||||
{DOWNLOAD_QUALITY_LABELS[option.quality]}
|
||||
</Text>
|
||||
)}
|
||||
<Text
|
||||
style={{ color: colors.mutedForeground, fontSize: 12 }}
|
||||
>
|
||||
{optionDetail(option, songCount)}
|
||||
</Text>
|
||||
)}
|
||||
<Text style={{ color: colors.mutedForeground, fontSize: 12 }}>
|
||||
{optionDetail(option, songCount)}
|
||||
</View>
|
||||
<Text
|
||||
style={[styles.size, { color: colors.mutedForeground }]}
|
||||
>
|
||||
{option.estimated ? "~" : ""}
|
||||
{formatBytes(option.bytes)}
|
||||
</Text>
|
||||
</View>
|
||||
<Text style={[styles.size, { color: colors.mutedForeground }]}>
|
||||
{option.estimated ? "~" : ""}
|
||||
{formatBytes(option.bytes)}
|
||||
</Text>
|
||||
</Pressable>
|
||||
))}
|
||||
</Pressable>
|
||||
))}
|
||||
<View style={styles.rememberRow}>
|
||||
<Text style={{ color: colors.foreground, fontSize: 15 }}>
|
||||
Remember my choice
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
type DownloadQuality,
|
||||
} from "@otunes/convex/download-quality"
|
||||
import { getAuthCookieHeader } from "@/lib/auth-cookies"
|
||||
import { downloadQualitySupported } from "@/lib/playback-capabilities"
|
||||
import type { ServerConfig } from "@/lib/server-config"
|
||||
|
||||
const REMEMBERED_QUALITY_KEY = "otunes.download-quality"
|
||||
@@ -298,9 +299,10 @@ export function downloadedCoverUri(url: string) {
|
||||
|
||||
export async function readRememberedDownloadQuality() {
|
||||
try {
|
||||
return parseDownloadQuality(
|
||||
const quality = parseDownloadQuality(
|
||||
await AsyncStorage.getItem(REMEMBERED_QUALITY_KEY)
|
||||
)
|
||||
return quality && downloadQualitySupported(quality) ? quality : undefined
|
||||
} catch {
|
||||
return undefined
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { Platform } from "react-native"
|
||||
|
||||
import {
|
||||
DOWNLOAD_QUALITIES,
|
||||
type DownloadQuality,
|
||||
} from "@otunes/convex/download-quality"
|
||||
|
||||
// Android Dolby decoder reports do not reliably indicate working Atmos playback.
|
||||
export const dolbyAtmosSupported = Platform.OS === "ios"
|
||||
|
||||
@@ -7,3 +12,13 @@ export const dolbyAtmosSupported = Platform.OS === "ios"
|
||||
export function atmosEnabled(user: { preferAtmos?: boolean }) {
|
||||
return dolbyAtmosSupported && (user.preferAtmos ?? false)
|
||||
}
|
||||
|
||||
/** Whether this device may download in a quality. Android cannot download Atmos. */
|
||||
export function downloadQualitySupported(quality: DownloadQuality) {
|
||||
return quality !== "atmos" || dolbyAtmosSupported
|
||||
}
|
||||
|
||||
/** Download qualities this device offers, lowest first. */
|
||||
export const deviceDownloadQualities = DOWNLOAD_QUALITIES.filter(
|
||||
downloadQualitySupported
|
||||
)
|
||||
@@ -39,9 +39,10 @@ const ASK_EVERY_TIME = "ask"
|
||||
|
||||
/** Shades of the text color, darkest for the smallest files. */
|
||||
const QUALITY_OPACITY: Record<DownloadQuality, number> = {
|
||||
medium: 0.25,
|
||||
high: 0.45,
|
||||
lossless: 0.7,
|
||||
low: 0.2,
|
||||
medium: 0.35,
|
||||
high: 0.5,
|
||||
lossless: 0.75,
|
||||
atmos: 1,
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { PlaybackSource, PlaybackStreamPlan } from "./playback-stream"
|
||||
|
||||
/** Qualities a listener can pick when downloading, lowest first. */
|
||||
export const DOWNLOAD_QUALITIES = [
|
||||
"low",
|
||||
"medium",
|
||||
"high",
|
||||
"lossless",
|
||||
@@ -11,6 +12,7 @@ export const DOWNLOAD_QUALITIES = [
|
||||
export type DownloadQuality = (typeof DOWNLOAD_QUALITIES)[number]
|
||||
|
||||
export const DOWNLOAD_QUALITY_LABELS: Record<DownloadQuality, string> = {
|
||||
low: "Low",
|
||||
medium: "Medium",
|
||||
high: "High",
|
||||
lossless: "Lossless",
|
||||
@@ -18,12 +20,14 @@ export const DOWNLOAD_QUALITY_LABELS: Record<DownloadQuality, string> = {
|
||||
}
|
||||
|
||||
export const DOWNLOAD_QUALITY_DETAILS: Record<DownloadQuality, string> = {
|
||||
low: "AAC 64 kbps",
|
||||
medium: "AAC 128 kbps",
|
||||
high: "AAC 256 kbps",
|
||||
lossless: "ALAC or FLAC",
|
||||
atmos: "Spatial audio",
|
||||
}
|
||||
|
||||
const LOW_KBPS = 64
|
||||
const MEDIUM_KBPS = 128
|
||||
const HIGH_KBPS = 256
|
||||
|
||||
@@ -54,13 +58,14 @@ function highPlan(files: Record<string, unknown>): DownloadPlan {
|
||||
|
||||
/**
|
||||
* Picks the file for one song. Lossless and Dolby Atmos fall back to High when
|
||||
* the song lacks them, and Medium is always transcoded.
|
||||
* the song lacks them, and Low and Medium are always transcoded.
|
||||
*/
|
||||
export function downloadPlan(
|
||||
files: Record<string, unknown>,
|
||||
quality: DownloadQuality
|
||||
): DownloadPlan {
|
||||
switch (quality) {
|
||||
case "low":
|
||||
case "medium":
|
||||
return {
|
||||
quality,
|
||||
@@ -70,7 +75,7 @@ export function downloadPlan(
|
||||
: "normal" in files
|
||||
? "normal"
|
||||
: "atmos",
|
||||
kbps: MEDIUM_KBPS,
|
||||
kbps: quality === "low" ? LOW_KBPS : MEDIUM_KBPS,
|
||||
}
|
||||
case "high":
|
||||
return highPlan(files)
|
||||
@@ -84,7 +89,7 @@ export function downloadPlan(
|
||||
|
||||
/**
|
||||
* The download quality holding the same audio a stream plan plays, so a
|
||||
* download can stand in for streaming. Low has no download equivalent.
|
||||
* download can stand in for streaming.
|
||||
*/
|
||||
export function streamDownloadQuality(
|
||||
plan: PlaybackStreamPlan
|
||||
@@ -95,6 +100,7 @@ export function streamDownloadQuality(
|
||||
}
|
||||
if (plan.kbps === HIGH_KBPS) return "high"
|
||||
if (plan.kbps === MEDIUM_KBPS) return "medium"
|
||||
if (plan.kbps === LOW_KBPS) return "low"
|
||||
return undefined
|
||||
}
|
||||
|
||||
@@ -129,6 +135,7 @@ export function downloadOptions(
|
||||
).length
|
||||
if (
|
||||
fallbackCount === songs.length &&
|
||||
quality !== "low" &&
|
||||
quality !== "medium" &&
|
||||
quality !== "high"
|
||||
) {
|
||||
|
||||
Reference in new issue
Block a user