Skip to content

Unofficial YouTube Music / Spotify Premium client for Android, built in Liquid Glass. Audio effects, Spotify Connect, listening history, 8 languages. Rust core on librespot.

Add the option to use the phone's own font

Lelonio53307308c5e0
diff --git a/app/src/main/java/dev/lelonio/square/data/PreferencesStore.kt b/app/src/main/java/dev/lelonio/square/data/PreferencesStore.kt
index f5febea..65b7ec6 100644
--- a/app/src/main/java/dev/lelonio/square/data/PreferencesStore.kt
+++ b/app/src/main/java/dev/lelonio/square/data/PreferencesStore.kt
@@ -104,6 +104,21 @@ class PreferencesStore(context: Context) {
prefs.edit().putBoolean(KEY_CANVAS, value).apply()
}
+ private val _systemFont = MutableStateFlow(prefs.getBoolean(KEY_SYSTEM_FONT, false))
+
+ /**
+ * The phone's own typeface instead of Inter.
+ *
+ * Asked for by listeners whose phones set a face of their own (HyperOS,
+ * One UI), next to which the app's thinner type read as out of place.
+ */
+ val systemFont: StateFlow<Boolean> = _systemFont.asStateFlow()
+
+ fun setSystemFont(value: Boolean) {
+ _systemFont.value = value
+ prefs.edit().putBoolean(KEY_SYSTEM_FONT, value).apply()
+ }
+
/** Where the moving covers come from; see [animatedCoverSource]. */
enum class CoverSource { SPOTIFY, APPLE_MUSIC }
@@ -299,6 +314,7 @@ class PreferencesStore(context: Context) {
const val KEY_ONBOARDED = "onboarded"
const val KEY_CANVAS = "canvas_enabled"
const val KEY_COVER_SOURCE = "animated_cover_source"
+ const val KEY_SYSTEM_FONT = "system_font"
const val KEY_KEEP_PLAYING = "keep_playing_on_close"
const val KEY_SPONSOR_BLOCK = "sponsor_block"
const val KEY_AUTOPLAY_INFINITE = "autoplay_infinite"
diff --git a/app/src/main/java/dev/lelonio/square/ui/settings/SettingsScreen.kt b/app/src/main/java/dev/lelonio/square/ui/settings/SettingsScreen.kt
index 7714479..2af5174 100644
--- a/app/src/main/java/dev/lelonio/square/ui/settings/SettingsScreen.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/settings/SettingsScreen.kt
@@ -47,6 +47,7 @@ import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.ArrowLeft
import com.adamglin.phosphoricons.regular.Check
+import com.adamglin.phosphoricons.regular.TextAa
import com.adamglin.phosphoricons.regular.ArrowUpRight
import com.adamglin.phosphoricons.regular.CaretDown
import com.adamglin.phosphoricons.regular.CaretRight
@@ -581,6 +582,23 @@ fun SettingsScreen(
// The two settings that are Android's rather than the app's, and the
// two people are sent to when the music stops in the background or a
// notification never arrives.
+ // The face the app is set in: its own, or the phone's.
+ if (shown == SettingsPage.App) item("font") {
+ val store = remember(context) {
+ (context.applicationContext as dev.lelonio.square.SquareApplication).preferences
+ }
+ val systemFont by store.systemFont.collectAsStateWithLifecycle()
+ Section(stringResource(R.string.font_title)) {
+ DownloadSwitch(
+ label = stringResource(R.string.font_system),
+ checked = systemFont,
+ backdrop = backdrop,
+ icon = PhosphorIcons.Regular.TextAa,
+ onChange = store::setSystemFont,
+ )
+ }
+ }
+
if (shown == SettingsPage.App) item("system") {
Section(stringResource(R.string.page_app_system)) {
ActionRow(
diff --git a/app/src/main/java/dev/lelonio/square/ui/theme/Theme.kt b/app/src/main/java/dev/lelonio/square/ui/theme/Theme.kt
index 5bfaf4b..8b5626c 100644
--- a/app/src/main/java/dev/lelonio/square/ui/theme/Theme.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/theme/Theme.kt
@@ -5,6 +5,8 @@ import androidx.compose.animation.core.tween
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Typography
+import androidx.compose.runtime.collectAsState
+import androidx.compose.ui.text.font.FontFamily
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
@@ -142,7 +144,17 @@ fun SquareTheme(
}
CompositionLocalProvider(LocalLightTheme provides !darkTheme) {
- MaterialTheme(colorScheme = scheme, typography = SpotTypography, content = content)
+ // The listener's choice of face; see PreferencesStore.systemFont.
+ val context = androidx.compose.ui.platform.LocalContext.current
+ val systemFont by remember(context) {
+ (context.applicationContext as? dev.lelonio.square.SquareApplication)?.preferences?.systemFont
+ ?: kotlinx.coroutines.flow.MutableStateFlow(false)
+ }.collectAsState()
+ MaterialTheme(
+ colorScheme = scheme,
+ typography = if (systemFont) SystemTypography else SpotTypography,
+ content = content,
+ )
}
}
@@ -254,24 +266,33 @@ fun Modifier.softShadow(
* against small wide-tracked labels. The contrast between the two is what makes
* a screen read as designed instead of as a list of controls.
*/
-private val SpotTypography = Typography(
+private fun spotTypography(family: FontFamily, tracking: Float) = Typography(
displayLarge = TextStyle(
- fontFamily = Inter,
+ fontFamily = family,
fontSize = 34.sp,
lineHeight = 38.sp,
fontWeight = FontWeight.Bold,
- letterSpacing = (-1.2).sp,
+ letterSpacing = (-1.2 * tracking).sp,
),
headlineLarge = TextStyle(
- fontFamily = Inter,
+ fontFamily = family,
fontSize = 27.sp,
lineHeight = 31.sp,
fontWeight = FontWeight.Bold,
- letterSpacing = (-0.8).sp,
+ letterSpacing = (-0.8 * tracking).sp,
),
- titleLarge = TextStyle(fontFamily = Inter, fontSize = 19.sp, fontWeight = FontWeight.SemiBold, letterSpacing = (-0.3).sp),
- titleMedium = TextStyle(fontFamily = Inter, fontSize = 15.5.sp, fontWeight = FontWeight.Medium, letterSpacing = (-0.1).sp),
- bodyMedium = TextStyle(fontFamily = Inter, fontSize = 13.5.sp, fontWeight = FontWeight.Normal),
- bodySmall = TextStyle(fontFamily = Inter, fontSize = 12.sp, fontWeight = FontWeight.Normal),
- labelLarge = TextStyle(fontFamily = Inter, fontSize = 10.5.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.2.sp),
+ titleLarge = TextStyle(fontFamily = family, fontSize = 19.sp, fontWeight = FontWeight.SemiBold, letterSpacing = (-0.3 * tracking).sp),
+ titleMedium = TextStyle(fontFamily = family, fontSize = 15.5.sp, fontWeight = FontWeight.Medium, letterSpacing = (-0.1 * tracking).sp),
+ bodyMedium = TextStyle(fontFamily = family, fontSize = 13.5.sp, fontWeight = FontWeight.Normal),
+ bodySmall = TextStyle(fontFamily = family, fontSize = 12.sp, fontWeight = FontWeight.Normal),
+ labelLarge = TextStyle(fontFamily = family, fontSize = 10.5.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.2.sp),
)
+
+private val SpotTypography = spotTypography(Inter, tracking = 1f)
+
+/**
+ * The same scale in the phone's own face. Tracked half as tight: the negative
+ * spacing was set for Inter's shapes, and on a wider system face it crowded
+ * the letters of a large title together.
+ */
+private val SystemTypography = spotTypography(FontFamily.Default, tracking = 0.5f)
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index e889904..26ec67b 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -545,4 +545,6 @@
<string name="animated_cover_source">Quelle</string>
<string name="animated_cover_spotify">Spotify (Canvas)</string>
<string name="animated_cover_apple">Apple Music</string>
+ <string name="font_title">Schrift</string>
+ <string name="font_system">Schrift des Handys verwenden</string>
</resources>
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index 96b9142..73acf16 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -551,4 +551,6 @@
<string name="animated_cover_source">Fuente</string>
<string name="animated_cover_spotify">Spotify (Canvas)</string>
<string name="animated_cover_apple">Apple Music</string>
+ <string name="font_title">Fuente</string>
+ <string name="font_system">Usar la fuente del teléfono</string>
</resources>
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index 68b33ee..c8c6c1f 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -545,4 +545,6 @@
<string name="animated_cover_source">Source</string>
<string name="animated_cover_spotify">Spotify (Canvas)</string>
<string name="animated_cover_apple">Apple Music</string>
+ <string name="font_title">Police</string>
+ <string name="font_system">Utiliser la police du téléphone</string>
</resources>
diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml
index 3563c2b..1b3ed97 100644
--- a/app/src/main/res/values-hi/strings.xml
+++ b/app/src/main/res/values-hi/strings.xml
@@ -560,4 +560,6 @@
<string name="animated_cover_source">स्रोत</string>
<string name="animated_cover_spotify">Spotify (Canvas)</string>
<string name="animated_cover_apple">Apple Music</string>
+ <string name="font_title">फ़ॉन्ट</string>
+ <string name="font_system">फ़ोन का फ़ॉन्ट इस्तेमाल करें</string>
</resources>
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index 1c7b03d..c928776 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -582,4 +582,6 @@
<string name="animated_cover_source">Sorgente</string>
<string name="animated_cover_spotify">Spotify (Canvas)</string>
<string name="animated_cover_apple">Apple Music</string>
+ <string name="font_title">Carattere</string>
+ <string name="font_system">Usa il carattere del telefono</string>
</resources>
diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml
index f238718..19e3de5 100644
--- a/app/src/main/res/values-pt/strings.xml
+++ b/app/src/main/res/values-pt/strings.xml
@@ -545,4 +545,6 @@
<string name="animated_cover_source">Fonte</string>
<string name="animated_cover_spotify">Spotify (Canvas)</string>
<string name="animated_cover_apple">Apple Music</string>
+ <string name="font_title">Fonte</string>
+ <string name="font_system">Usar a fonte do telefone</string>
</resources>
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index 033d1f8..4f998c4 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -574,4 +574,6 @@
<string name="animated_cover_source">Источник</string>
<string name="animated_cover_spotify">Spotify (Canvas)</string>
<string name="animated_cover_apple">Apple Music</string>
+ <string name="font_title">Шрифт</string>
+ <string name="font_system">Использовать шрифт телефона</string>
</resources>
diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml
index bc0d05d..e4ff4a3 100644
--- a/app/src/main/res/values-tr/strings.xml
+++ b/app/src/main/res/values-tr/strings.xml
@@ -558,4 +558,6 @@
<string name="animated_cover_source">Kaynak</string>
<string name="animated_cover_spotify">Spotify (Canvas)</string>
<string name="animated_cover_apple">Apple Music</string>
+ <string name="font_title">Yazı tipi</string>
+ <string name="font_system">Telefonun yazı tipini kullan</string>
</resources>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index af06a0e..e6666c9 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -609,4 +609,6 @@
<string name="animated_cover_source">Source</string>
<string name="animated_cover_spotify">Spotify (Canvas)</string>
<string name="animated_cover_apple">Apple Music</string>
+ <string name="font_title">Font</string>
+ <string name="font_system">Use the phone’s font</string>
</resources>